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

Commit 58cfe64

Browse files
authored
Merge pull request #54 from withspectrum/fix-modifier-interaction
fix modifier interaction
2 parents 1ac6db0 + 137483c commit 58cfe64

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/__test__/plugin.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ describe("draft-js-markdown-plugin", () => {
333333
event = new window.KeyboardEvent("keydown", props);
334334
});
335335
it("inserts new empty block", () => {
336-
createMarkdownPlugin.__Rewire__("insertEmptyBlock", modifierSpy); // eslint-disable-line no-underscore-dangle
337336
const text = "Hello";
338337
currentRawContentState = {
339338
entityMap: {},
@@ -349,9 +348,8 @@ describe("draft-js-markdown-plugin", () => {
349348
},
350349
],
351350
};
352-
expect(subject()).toBe("handled");
353-
expect(modifierSpy).toHaveBeenCalledTimes(1);
354-
expect(store.setEditorState).toHaveBeenCalledWith(newEditorState);
351+
expect(subject()).toBe("not-handled");
352+
expect(store.setEditorState).not.toHaveBeenCalled();
355353
});
356354
});
357355
});

src/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,14 @@ function checkReturnForState(config, editorState, ev) {
137137

138138
const isHeader = /^header-/.test(type);
139139
const isBlockQuote = type === "blockquote";
140-
141-
const modifierKeyPressed =
142-
ev.ctrlKey || ev.shiftKey || ev.metaKey || ev.altKey;
143140
const isAtEndOfLine = endOffset === blockLength;
144141
const atEndOfHeader = isHeader && isAtEndOfLine;
145142
const atEndOfBlockQuote = isBlockQuote && isAtEndOfLine;
146143

147144
if (
148145
newEditorState === editorState &&
149146
isCollapsed &&
150-
(modifierKeyPressed || atEndOfHeader || atEndOfBlockQuote)
147+
(atEndOfHeader || atEndOfBlockQuote)
151148
) {
152149
// transform markdown (if we aren't in a codeblock that is)
153150
if (!inCodeBlock(editorState)) {

0 commit comments

Comments
 (0)