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

Commit 4cf0b3b

Browse files
committed
Disable markdown in code blocks
Fixes #5
1 parent 3a39746 commit 4cf0b3b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ const createMarkdownPlugin = (config = {}) => {
152152
if (character !== " ") {
153153
return "not-handled";
154154
}
155+
// If we're in a code block don't add markdown to it
156+
const startKey = editorState.getSelection().getStartKey();
157+
if (startKey) {
158+
const currentBlockType = editorState
159+
.getCurrentContent()
160+
.getBlockForKey(startKey)
161+
.getType();
162+
if (currentBlockType === "code-block") return "not-handled";
163+
}
164+
155165
const newEditorState = checkCharacterForState(editorState, character);
156166
if (editorState !== newEditorState) {
157167
setEditorState(newEditorState);

0 commit comments

Comments
 (0)