@@ -254,39 +254,46 @@ export const QuillEditor = defineComponent({
254
254
or use v-on:ready="onReady(quill)" event instead.`
255
255
}
256
256
257
- const getContents = ( ) => {
257
+ const getContents = (
258
+ index ?: number | undefined ,
259
+ length ?: number | undefined
260
+ ) => {
258
261
if ( props . contentType === 'html' ) {
259
262
return getHTML ( )
260
263
} else if ( props . contentType === 'text' ) {
261
- return getText ( )
264
+ return getText ( index , length )
262
265
}
263
- return quill ?. getContents ( )
266
+ return quill ?. getContents ( index , length )
264
267
}
265
268
266
- const setContents = ( content : string | Delta ) => {
269
+ const setContents = ( content : string | Delta , source : Sources = 'api' ) => {
267
270
if ( props . contentType === 'html' ) {
268
- setHTML ( content as string )
271
+ setHTML ( content as string , source )
269
272
} else if ( props . contentType === 'text' ) {
270
- setText ( content as string )
273
+ setText ( content as string , source )
271
274
} else {
272
- quill ?. setContents ( content as Delta )
275
+ quill ?. setContents ( content as Delta , source )
273
276
}
274
277
}
275
278
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 ) ?? ''
278
284
}
279
285
280
- const setText = ( text : string ) => {
281
- quill ?. setText ( text )
286
+ const setText = ( text : string , source : Sources = 'api' ) => {
287
+ quill ?. setText ( text , source )
282
288
}
283
289
284
290
const getHTML = ( ) : string => {
285
291
return quill ?. root . innerHTML ?? ''
286
292
}
287
293
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 )
290
297
}
291
298
292
299
const reinit = ( ) => {
0 commit comments