fix visual editor block closing

This commit is contained in:
Shawn Erquhart 2017-10-04 18:53:56 -04:00 committed by Benaiah Mischenko
parent be4609e54d
commit 1cf7b74eb9

View File

@ -9,14 +9,15 @@ const SoftBreak = (options = {}) => ({
if (options.shift && e.shiftKey == false) return;
const { onlyIn, ignoreIn, defaultBlock = 'paragraph' } = options;
const { type, nodes } = change.state.startBlock;
const { type, text } = change.state.startBlock;
if (onlyIn && !onlyIn.includes(type)) return;
if (ignoreIn && ignoreIn.includes(type)) return;
const shouldClose = nodes.last().characters.last() === '\n';
const shouldClose = text.endsWith('\n');
if (shouldClose) {
const trimmed = change.deleteBackward(1);
return trimmed.insertBlock(defaultBlock);
return change
.deleteBackward(1)
.insertBlock(defaultBlock);
}
const textNode = Text.create('\n');