@@ -3,9 +3,11 @@ import {
33 SelectionChangeHandler ,
44 EditorChangeHandler ,
55 QuillOptionsStatic ,
6+ RangeStatic ,
7+ Sources ,
68} from "quill" ;
79import { Quill } from "../main"
8- import { Delta } from "types- quill-delta" ;
10+ import Delta from "quill-delta" ;
911import {
1012 defineComponent ,
1113 onBeforeUnmount ,
@@ -140,26 +142,46 @@ export default defineComponent({
140142 ) ;
141143 }
142144
143- const handleTextChange : TextChangeHandler = ( ... args ) => {
145+ const handleTextChange : TextChangeHandler = ( delta : Delta , oldContents : Delta , source : Sources ) => {
144146 // Update v-model:content when text changes
145147 ctx . emit ( "update:content" , quill ?. getContents ( ) ) ;
146- ctx . emit ( "textChange" , { ... args } ) ;
148+ ctx . emit ( "textChange" , { delta , oldContents , source } ) ;
147149 } ;
148150
149151 const isEditorFocus = ref < boolean > ( )
150- const handleSelectionChange : SelectionChangeHandler = ( ... args ) => {
152+ const handleSelectionChange : SelectionChangeHandler = ( range : RangeStatic , oldRange : RangeStatic , source : Sources ) => {
151153 // Mark model as touched if editor lost focus
152154 isEditorFocus . value = quill ?. hasFocus ( ) ? true : false
153- ctx . emit ( "selectionChange" , { ... args } ) ;
155+ ctx . emit ( "selectionChange" , { range , oldRange , source } ) ;
154156 } ;
155157
156158 watch ( isEditorFocus , ( focus ) => {
157159 if ( focus ) ctx . emit ( "focus" , editor )
158160 else ctx . emit ( "blur" , editor ) ;
159161 } )
160162
161- const handleEditorChange : EditorChangeHandler = ( ...args ) => {
162- ctx . emit ( "editorChange" , { ...args } ) ;
163+ const handleEditorChange : EditorChangeHandler = ( name : "text-change" | "selection-change" , ...args ) => {
164+ if ( name === "text-change" ) {
165+ ctx . emit (
166+ "editorChange" ,
167+ {
168+ name,
169+ delta : args [ 0 ] as Delta ,
170+ oldContents : args [ 1 ] as Delta ,
171+ source : args [ 2 ] as Sources
172+ }
173+ ) ;
174+ } else if ( name === "selection-change" ) {
175+ ctx . emit (
176+ "editorChange" ,
177+ {
178+ name,
179+ range : args [ 0 ] as RangeStatic ,
180+ oldRange : args [ 1 ] as RangeStatic ,
181+ source : args [ 2 ] as Sources
182+ }
183+ ) ;
184+ }
163185 } ;
164186
165187 const getQuill = ( ) : Quill => {
0 commit comments