Skip to content

Commit 61bcbd7

Browse files
authored
Update @types/codemirror to match the one in latest easymde (#186)
1 parent 2c675d5 commit 61bcbd7

File tree

3 files changed

+14
-51
lines changed

3 files changed

+14
-51
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"src"
2121
],
2222
"dependencies": {
23-
"@types/codemirror": "0.0.109"
23+
"@types/codemirror": "^5.60.5"
2424
},
2525
"peerDependencies": {
2626
"easymde": ">= 2.0.0 < 3.0.0",
@@ -34,7 +34,7 @@
3434
"@testing-library/jest-dom": "^5.12.0",
3535
"@testing-library/react": "^11.2.6",
3636
"@testing-library/user-event": "^13.1.8",
37-
"@types/codemirror": "0.0.109",
37+
"@types/codemirror": "^5.60.5",
3838
"@types/jest": "^26.0.23",
3939
"@types/node": "^12.20.11",
4040
"@types/react": "^17.0.4",

src/SimpleMdeReact.tsx

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ import React, {
88
import SimpleMDE, { Options } from "easymde";
99

1010
import type {
11-
Doc,
1211
Editor,
13-
EditorChange,
14-
EditorChangeCancellable,
15-
EditorChangeLinkedList,
16-
EditorSelectionChange,
12+
EditorEventMap,
1713
KeyMap,
18-
LineHandle,
1914
Position,
2015
} from "codemirror";
2116

@@ -67,46 +62,7 @@ export type IndexEventsSignature = {
6762
export interface SimpleMdeToCodemirrorEvents
6863
extends CopyEvents,
6964
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> {}
11066

11167
export type GetMdeInstance = (instance: SimpleMDE) => void;
11268
export type GetCodemirrorInstance = (instance: Editor) => void;
@@ -305,18 +261,18 @@ export const SimpleMdeReact = React.forwardRef<
305261
isNotFirstEffectRun &&
306262
prevEvents.current &&
307263
Object.entries(prevEvents.current).forEach(([event, handler]) => {
308-
handler && codemirror?.off(event, handler);
264+
handler && codemirror?.off(event as keyof EditorEventMap, handler);
309265
});
310266

311267
events &&
312268
Object.entries(events).forEach(([event, handler]) => {
313-
handler && codemirror?.on(event, handler);
269+
handler && codemirror?.on(event as keyof EditorEventMap, handler);
314270
});
315271
prevEvents.current = events;
316272
return () => {
317273
events &&
318274
Object.entries(events).forEach(([event, handler]) => {
319-
handler && codemirror?.off(event, handler);
275+
handler && codemirror?.off(event as keyof EditorEventMap, handler);
320276
});
321277
};
322278
}, [codemirror, events]);

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,13 @@
17811781
dependencies:
17821782
"@types/tern" "*"
17831783

1784+
"@types/codemirror@^5.60.5":
1785+
version "5.60.5"
1786+
resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-5.60.5.tgz#5b989a3b4bbe657458cf372c92b6bfda6061a2b7"
1787+
integrity sha512-TiECZmm8St5YxjFUp64LK0c8WU5bxMDt9YaAek1UqUb9swrSCoJhh92fWu1p3mTEqlHjhB5sY7OFBhWroJXZVg==
1788+
dependencies:
1789+
"@types/tern" "*"
1790+
17841791
"@types/eslint@^7.2.6":
17851792
version "7.2.10"
17861793
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-7.2.10.tgz#4b7a9368d46c0f8cd5408c23288a59aa2394d917"

0 commit comments

Comments
 (0)