@@ -254,39 +254,46 @@ export const QuillEditor = defineComponent({
254254 or use v-on:ready="onReady(quill)" event instead.`
255255 }
256256
257- const getContents = ( ) => {
257+ const getContents = (
258+ index ?: number | undefined ,
259+ length ?: number | undefined
260+ ) => {
258261 if ( props . contentType === 'html' ) {
259262 return getHTML ( )
260263 } else if ( props . contentType === 'text' ) {
261- return getText ( )
264+ return getText ( index , length )
262265 }
263- return quill ?. getContents ( )
266+ return quill ?. getContents ( index , length )
264267 }
265268
266- const setContents = ( content : string | Delta ) => {
269+ const setContents = ( content : string | Delta , source : Sources = 'api' ) => {
267270 if ( props . contentType === 'html' ) {
268- setHTML ( content as string )
271+ setHTML ( content as string , source )
269272 } else if ( props . contentType === 'text' ) {
270- setText ( content as string )
273+ setText ( content as string , source )
271274 } else {
272- quill ?. setContents ( content as Delta )
275+ quill ?. setContents ( content as Delta , source )
273276 }
274277 }
275278
276- const getText = ( ) : string => {
277- return quill ?. getText ( ) ?? ''
279+ const getText = (
280+ index ?: number | undefined ,
281+ length ?: number | undefined
282+ ) : string => {
283+ return quill ?. getText ( index , length ) ?? ''
278284 }
279285
280- const setText = ( text : string ) => {
281- quill ?. setText ( text )
286+ const setText = ( text : string , source : Sources = 'api' ) => {
287+ quill ?. setText ( text , source )
282288 }
283289
284290 const getHTML = ( ) : string => {
285291 return quill ?. root . innerHTML ?? ''
286292 }
287293
288- const setHTML = ( html : string ) => {
289- quill ?. clipboard . dangerouslyPasteHTML ( html )
294+ const setHTML = ( html : string , source : Sources = 'api' ) => {
295+ const delta = quill ?. clipboard . convert ( html as { } )
296+ if ( delta ) quill ?. setContents ( delta , source )
290297 }
291298
292299 const reinit = ( ) => {
0 commit comments