@@ -8,14 +8,9 @@ import React, {
8
8
import SimpleMDE , { Options } from "easymde" ;
9
9
10
10
import type {
11
- Doc ,
12
11
Editor ,
13
- EditorChange ,
14
- EditorChangeCancellable ,
15
- EditorChangeLinkedList ,
16
- EditorSelectionChange ,
12
+ EditorEventMap ,
17
13
KeyMap ,
18
- LineHandle ,
19
14
Position ,
20
15
} from "codemirror" ;
21
16
@@ -67,46 +62,7 @@ export type IndexEventsSignature = {
67
62
export interface SimpleMdeToCodemirrorEvents
68
63
extends CopyEvents ,
69
64
GlobalEvents ,
70
- IndexEventsSignature {
71
- change ?: ( instance : Editor , changeObj : EditorChangeLinkedList ) => void ;
72
- changes ?: ( instance : Editor , changes : EditorChangeLinkedList [ ] ) => void ;
73
- beforeChange ?: ( instance : Editor , changeObj : EditorChangeCancellable ) => void ;
74
- cursorActivity ?: ( instance : Editor ) => void ;
75
- keyHandled ?: ( instance : Editor , name : string , event : KeyboardEvent ) => void ;
76
- inputRead ?: ( instance : Editor , changeObj : EditorChange ) => void ;
77
- electricInput ?: ( instance : Editor , line : number ) => void ;
78
- beforeSelectionChange ?: (
79
- instance : Editor ,
80
- obj : EditorSelectionChange
81
- ) => void ;
82
- viewportChange ?: ( instance : Editor , from : number , to : number ) => void ;
83
- swapDoc ?: ( instance : Editor , oldDoc : Doc ) => void ;
84
- gutterClick ?: (
85
- instance : Editor ,
86
- line : number ,
87
- gutter : string ,
88
- clickEvent : MouseEvent
89
- ) => void ;
90
- gutterContextMenu ?: (
91
- instance : Editor ,
92
- line : number ,
93
- gutter : string ,
94
- contextMenu : MouseEvent
95
- ) => void ;
96
- focus ?: ( instance : Editor , event : FocusEvent ) => void ;
97
- blur ?: ( instance : Editor , event : FocusEvent ) => void ;
98
- scroll ?: ( instance : Editor ) => void ;
99
- refresh ?: ( instance : Editor ) => void ;
100
- optionChange ?: ( instance : Editor , option : string ) => void ;
101
- scrollCursorIntoView ?: ( instance : Editor , event : Event ) => void ;
102
- update ?: ( instance : Editor ) => void ;
103
- renderLine ?: (
104
- instance : Editor ,
105
- line : LineHandle ,
106
- element : HTMLElement
107
- ) => void ;
108
- overwriteToggle ?: ( instance : Editor , overwrite : boolean ) => void ;
109
- }
65
+ IndexEventsSignature , Partial < EditorEventMap > { }
110
66
111
67
export type GetMdeInstance = ( instance : SimpleMDE ) => void ;
112
68
export type GetCodemirrorInstance = ( instance : Editor ) => void ;
@@ -305,18 +261,18 @@ export const SimpleMdeReact = React.forwardRef<
305
261
isNotFirstEffectRun &&
306
262
prevEvents . current &&
307
263
Object . entries ( prevEvents . current ) . forEach ( ( [ event , handler ] ) => {
308
- handler && codemirror ?. off ( event , handler ) ;
264
+ handler && codemirror ?. off ( event as keyof EditorEventMap , handler ) ;
309
265
} ) ;
310
266
311
267
events &&
312
268
Object . entries ( events ) . forEach ( ( [ event , handler ] ) => {
313
- handler && codemirror ?. on ( event , handler ) ;
269
+ handler && codemirror ?. on ( event as keyof EditorEventMap , handler ) ;
314
270
} ) ;
315
271
prevEvents . current = events ;
316
272
return ( ) => {
317
273
events &&
318
274
Object . entries ( events ) . forEach ( ( [ event , handler ] ) => {
319
- handler && codemirror ?. off ( event , handler ) ;
275
+ handler && codemirror ?. off ( event as keyof EditorEventMap , handler ) ;
320
276
} ) ;
321
277
} ;
322
278
} , [ codemirror , events ] ) ;
0 commit comments