Skip to content

Commit 6f36f92

Browse files
committed
Only create new line after header on EOL return
1 parent bfe6546 commit 6f36f92

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ function checkReturnForState(editorState, ev) {
4646
if (/-list-item$/.test(type) && text === '') {
4747
newEditorState = leaveList(editorState);
4848
}
49-
if (newEditorState === editorState &&
50-
(ev.ctrlKey || ev.shiftKey || ev.metaKey || ev.altKey || /^header-/.test(type))) {
49+
if (newEditorState === editorState
50+
&& (ev.ctrlKey || ev.shiftKey || ev.metaKey || ev.altKey
51+
|| (/^header-/.test(type) && selection.isCollapsed() && selection.getEndOffset() === text.length))) {
5152
newEditorState = insertEmptyBlock(editorState);
5253
}
5354
if (newEditorState === editorState && type !== 'code-block' && /^```([\w-]+)?$/.test(text)) {

0 commit comments

Comments
 (0)