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

Commit bc96a25

Browse files
authored
Merge pull request #26 from iansinnott/rc1-compat
Use the editor state passed directly from draftjs
2 parents c057ba2 + c210026 commit bc96a25

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ demo/public
4141
.deploy
4242
test-results.xml
4343

44+
yarn.lock

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"css-loader": "^0.26.0",
6262
"css-modules-require-hook": "^4.0.5",
6363
"dirty-chai": "^1.2.2",
64-
"draft-js-plugins-editor": "2.0.0-beta10",
64+
"draft-js-plugins-editor": "2.0.0-rc2",
6565
"draft-js-prism": "ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb",
6666
"enzyme": "^2.6.0",
6767
"eslint": "^3.11.1",
@@ -99,7 +99,7 @@
9999
"webpack-hot-middleware": "^2.13.2"
100100
},
101101
"peerDependencies": {
102-
"draft-js-plugins-editor": "~2.0.0-beta.10 || 2.0.0-beta11 || 2.0.0-beta10",
102+
"draft-js-plugins-editor": "~2.0.0-rc.1 || 2.0.0-rc2 || 2.0.0-rc1 || 2.0.0-beta12",
103103
"react": "^15.0.0",
104104
"react-dom": "^15.0.0"
105105
},
@@ -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.5",
113113
"immutable": "~3.7.4"
114114
}

src/__test__/plugin-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('draft-js-markdown-shortcuts-plugin', () => {
9999
});
100100
describe('handleReturn', () => {
101101
beforeEach(() => {
102-
subject = () => plugin.handleReturn(event, store);
102+
subject = () => plugin.handleReturn(event, store.getEditorState(), store);
103103
});
104104
it('does not handle', () => {
105105
currentRawContentState = {
@@ -298,7 +298,7 @@ describe('draft-js-markdown-shortcuts-plugin', () => {
298298
let character;
299299
beforeEach(() => {
300300
character = ' ';
301-
subject = () => plugin.handleBeforeInput(character, store);
301+
subject = () => plugin.handleBeforeInput(character, store.getEditorState(), store);
302302
});
303303
[
304304
'handleBlockType',
@@ -337,7 +337,7 @@ describe('draft-js-markdown-shortcuts-plugin', () => {
337337
pastedText = `_hello world_
338338
Hello`;
339339
html = undefined;
340-
subject = () => plugin.handlePastedText(pastedText, html, store);
340+
subject = () => plugin.handlePastedText(pastedText, html, store.getEditorState(), store);
341341
});
342342
[
343343
'replaceText',

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 }) {
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, { 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, { 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)