How to use the quill/blots/block.create function in quill

To help you get started, we’ve selected a few quill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vanilla / vanilla / plugins / rich-editor / src / scripts / quill / utility.ts View on Github external
export function insertNewLineAfterBlotAndTrim(quill, range: RangeStatic, deleteAmount = 1) {
    const [line, offset] = quill.getLine(range.index);

    const newBlot = new BlockBlot(BlockBlot.create(""));
    const thisBlot = line;

    const nextBlot = thisBlot.next;
    newBlot.insertInto(quill.scroll, nextBlot);

    // Now we need to clean up that extra newline.
    const positionUpToPreviousNewline = range.index + line.length() - offset;
    const deleteDelta = new Delta().retain(positionUpToPreviousNewline - deleteAmount).delete(deleteAmount);
    quill.updateContents(deleteDelta, Emitter.sources.USER);
    quill.setSelection(positionUpToPreviousNewline - deleteAmount, Emitter.sources.USER);
}
github vanilla / vanilla / plugins / rich-editor / src / scripts / quill / NewLineClickInsertionModule.ts View on Github external
// Check that we don't have an embed blot at the end.
        const lastBlot = this.quill.scroll.children.tail;
        if (!(lastBlot instanceof ExternalEmbedBlot)) {
            return;
        }

        // Filter out click events that aren't below the last item in the document.
        const blotRect = (lastBlot.domNode as HTMLElement).getBoundingClientRect();
        const bottomOfBlot = blotRect.bottom;

        if (event.y <= bottomOfBlot) {
            // The click not on the bottom section of the document.
            return;
        }

        const newline = new BlockBlot(BlockBlot.create("\n"));
        newline.insertInto(this.quill.scroll);
        this.quill.update(Quill.sources.USER);
        this.quill.setSelection(this.quill.scroll.length(), 0, Quill.sources.USER);
    };
}
github vanilla / vanilla / plugins / rich-editor / src / scripts / quill / utility.ts View on Github external
export function insertNewLineAtEndOfScroll(quill: Quill) {
    const newLineBlot = new BlockBlot(BlockBlot.create(""));
    quill.scroll.appendChild(newLineBlot);
    quill.update(Quill.sources.USER);
    quill.setSelection(quill.scroll.length(), 0);
}
github vanilla / vanilla / plugins / rich-editor / src / scripts / quill / utility.ts View on Github external
export function insertNewLineAtStartOfScroll(quill: Quill) {
    const newLineBlot = new BlockBlot(BlockBlot.create(""));
    quill.scroll.insertBefore(newLineBlot, quill.scroll.children.head!);
    quill.update(Quill.sources.USER);
    quill.setSelection(0, 0);
}