UNPKG

lexical-vue

Version:

An extensible Vue 3 web text-editor based on Lexical.

42 lines (41 loc) 1.04 kB
import { DecoratorNode } from "lexical"; class DecoratorBlockNode extends DecoratorNode { __format; constructor(format, key){ super(key); this.__format = format || ''; } canIndent() { return false; } isInline() { return false; } exportJSON() { return { ...super.exportJSON(), format: this.__format || '' }; } updateFromJSON(serializedNode) { return super.updateFromJSON(serializedNode).setFormat(serializedNode.format || ''); } setFormat(format) { const self = this.getWritable(); self.__format = format; return self; } createDOM() { return document.createElement('div'); } updateDOM() { return false; } } function $createDecoratorBlockNode() { return new DecoratorBlockNode(); } function $isDecoratorBlockNode(node) { return node instanceof DecoratorBlockNode; } export { $createDecoratorBlockNode, $isDecoratorBlockNode, DecoratorBlockNode };