Skip to content

Instantly share code, notes, and snippets.

@dragosbulugean
Created March 19, 2019 20:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragosbulugean/8d50bc3766ccc6aca121e445272b8b8b to your computer and use it in GitHub Desktop.
Save dragosbulugean/8d50bc3766ccc6aca121e445272b8b8b to your computer and use it in GitHub Desktop.
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