@@ -3,9 +3,11 @@ import {
3
3
SelectionChangeHandler ,
4
4
EditorChangeHandler ,
5
5
QuillOptionsStatic ,
6
+ RangeStatic ,
7
+ Sources ,
6
8
} from "quill" ;
7
9
import { Quill } from "../main"
8
- import { Delta } from "types- quill-delta" ;
10
+ import Delta from "quill-delta" ;
9
11
import {
10
12
defineComponent ,
11
13
onBeforeUnmount ,
@@ -140,26 +142,46 @@ export default defineComponent({
140
142
) ;
141
143
}
142
144
143
- const handleTextChange : TextChangeHandler = ( ... args ) => {
145
+ const handleTextChange : TextChangeHandler = ( delta : Delta , oldContents : Delta , source : Sources ) => {
144
146
// Update v-model:content when text changes
145
147
ctx . emit ( "update:content" , quill ?. getContents ( ) ) ;
146
- ctx . emit ( "textChange" , { ... args } ) ;
148
+ ctx . emit ( "textChange" , { delta , oldContents , source } ) ;
147
149
} ;
148
150
149
151
const isEditorFocus = ref < boolean > ( )
150
- const handleSelectionChange : SelectionChangeHandler = ( ... args ) => {
152
+ const handleSelectionChange : SelectionChangeHandler = ( range : RangeStatic , oldRange : RangeStatic , source : Sources ) => {
151
153
// Mark model as touched if editor lost focus
152
154
isEditorFocus . value = quill ?. hasFocus ( ) ? true : false
153
- ctx . emit ( "selectionChange" , { ... args } ) ;
155
+ ctx . emit ( "selectionChange" , { range , oldRange , source } ) ;
154
156
} ;
155
157
156
158
watch ( isEditorFocus , ( focus ) => {
157
159
if ( focus ) ctx . emit ( "focus" , editor )
158
160
else ctx . emit ( "blur" , editor ) ;
159
161
} )
160
162
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
+ }
163
185
} ;
164
186
165
187
const getQuill = ( ) : Quill => {
0 commit comments