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

Commit e4557b2

Browse files
committed
convert markdown in other block types
1 parent 8b36fe2 commit e4557b2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,15 @@ function checkReturnForState(editorState, ev) {
8181
/^header-/.test(type) ||
8282
type === "blockquote")
8383
) {
84-
newEditorState = insertEmptyBlock(editorState);
84+
// transform markdown (if we aren't in a codeblock that is)
85+
if (!inCodeBlock(editorState)) {
86+
newEditorState = checkCharacterForState(newEditorState, "\n");
87+
}
88+
if (newEditorState === editorState) {
89+
newEditorState = insertEmptyBlock(newEditorState);
90+
} else {
91+
newEditorState = RichUtils.toggleBlockType(newEditorState, type);
92+
}
8593
}
8694
if (
8795
newEditorState === editorState &&
@@ -165,6 +173,7 @@ const createMarkdownPlugin = (config = {}) => {
165173
let newEditorState = checkReturnForState(editorState, ev);
166174
let selection = newEditorState.getSelection();
167175

176+
// exit code blocks
168177
if (
169178
inCodeBlock(editorState) &&
170179
!is(editorState.getImmutable(), newEditorState.getImmutable())

0 commit comments

Comments
 (0)