Home Reference Source

application/components/common/rich-editor2/util/ensure-empty-graf.js

import {Block} from 'slate';

export function ensureEmptyGraf(editor) {
    // ensures that an empty paragraph exists at the end of the editor
    // this keeps non-text blocks from consuming the cursor at the end
    // of the editor
    const parent = editor.value.document;
    const newLine = Block.create({
        'type': 'paragraph'
    });
    editor.insertNodeByKey(parent.key, parent.nodes.size, newLine);
    return;
}