-
-
Save dragosbulugean/8d50bc3766ccc6aca121e445272b8b8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { focusBlock } = editor.value | |
if ( | |
focusBlock.type === BlockTypes.h1 || | |
focusBlock.type === BlockTypes.h2 | |
) { | |
const selection = editor.value.selection | |
if ( | |
selection.isCollapsed && | |
selection.focus.offset === focusBlock.text.length | |
) { | |
editor.splitBlock(1).setBlocks(BlockTypes.paragraph) | |
return | |
} else { | |
return editor.insertText('\n') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment