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

Commit 23e8a54

Browse files
authored
Merge pull request #90 from withspectrum/fix-code-insert
insert plain text if in code block
2 parents fb3efad + 8f3c496 commit 23e8a54

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,19 @@ const createMarkdownPlugin = (_config = {}) => {
416416
}
417417
},
418418
handlePastedText(text, html, editorState, { setEditorState }) {
419+
let newEditorState = editorState;
420+
let buffer = [];
421+
419422
if (html) {
420423
return "not-handled";
421424
}
425+
422426
// If we're in a code block don't add markdown to it
423-
if (inCodeBlock(editorState)) return "not-handled";
424-
let newEditorState = editorState;
425-
let buffer = [];
427+
if (inCodeBlock(editorState)) {
428+
setEditorState(insertText(editorState, text));
429+
return "handled";
430+
}
431+
426432
for (let i = 0; i < text.length; i++) {
427433
// eslint-disable-line no-plusplus
428434
if (INLINE_STYLE_CHARACTERS.indexOf(text[i]) >= 0) {
@@ -464,6 +470,7 @@ const createMarkdownPlugin = (_config = {}) => {
464470
setEditorState(newEditorState);
465471
return "handled";
466472
}
473+
467474
return "not-handled";
468475
},
469476
};

0 commit comments

Comments
 (0)