Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 12c8dc9

Browse files
committed
Use the editor state passed directly from draftjs
As of Draft 0.10.1 editor state is passed in directly.
1 parent 8b44850 commit 12c8dc9

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
],
109109
"dependencies": {
110110
"decorate-component-with-props": "^1.0.2",
111-
"draft-js": "~0.10.0",
111+
"draft-js": "~0.10.1",
112112
"draft-js-checkable-list-item": "^2.0.4",
113113
"immutable": "~3.7.4"
114114
}

src/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,32 +119,29 @@ const createMarkdownShortcutsPlugin = (config = {}) => {
119119
}
120120
return 'not-handled';
121121
},
122-
handleReturn(ev, { setEditorState, getEditorState }) {
123-
const editorState = getEditorState();
122+
handleReturn(ev, editorState, { setEditorState, getEditorState }) {
124123
const newEditorState = checkReturnForState(editorState, ev);
125124
if (editorState !== newEditorState) {
126125
setEditorState(newEditorState);
127126
return 'handled';
128127
}
129128
return 'not-handled';
130129
},
131-
handleBeforeInput(character, { getEditorState, setEditorState }) {
130+
handleBeforeInput(character, editorState, { getEditorState, setEditorState }) {
132131
if (character !== ' ') {
133132
return 'not-handled';
134133
}
135-
const editorState = getEditorState();
136134
const newEditorState = checkCharacterForState(editorState, character);
137135
if (editorState !== newEditorState) {
138136
setEditorState(newEditorState);
139137
return 'handled';
140138
}
141139
return 'not-handled';
142140
},
143-
handlePastedText(text, html, { getEditorState, setEditorState }) {
141+
handlePastedText(text, html, editorState, { getEditorState, setEditorState }) {
144142
if (html) {
145143
return 'not-handled';
146144
}
147-
const editorState = getEditorState();
148145
let newEditorState = editorState;
149146
let buffer = [];
150147
for (let i = 0; i < text.length; i++) { // eslint-disable-line no-plusplus

0 commit comments

Comments
 (0)