X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/111a313d5125bd890d7df46929802f4621388c95..refs/pull/5313/head:/resources/js/wysiwyg/nodes/callout.ts diff --git a/resources/js/wysiwyg/nodes/callout.ts b/resources/js/wysiwyg/nodes/callout.ts index 8018190c8..cfe32ec85 100644 --- a/resources/js/wysiwyg/nodes/callout.ts +++ b/resources/js/wysiwyg/nodes/callout.ts @@ -10,7 +10,7 @@ import { import type {EditorConfig} from "lexical/LexicalEditor"; import type {RangeSelection} from "lexical/LexicalSelection"; import { - CommonBlockAlignment, commonPropertiesDifferent, + CommonBlockAlignment, commonPropertiesDifferent, deserializeCommonBlockNode, SerializedCommonBlockNode, setCommonBlockPropsFromElement, updateElementWithCommonBlockProps @@ -26,6 +26,7 @@ export class CalloutNode extends ElementNode { __id: string = ''; __category: CalloutCategory = 'info'; __alignment: CommonBlockAlignment = ''; + __inset: number = 0; static getType() { return 'callout'; @@ -34,6 +35,8 @@ export class CalloutNode extends ElementNode { static clone(node: CalloutNode) { const newNode = new CalloutNode(node.__category, node.__key); newNode.__id = node.__id; + newNode.__alignment = node.__alignment; + newNode.__inset = node.__inset; return newNode; } @@ -72,6 +75,16 @@ export class CalloutNode extends ElementNode { return self.__alignment; } + setInset(size: number) { + const self = this.getWritable(); + self.__inset = size; + } + + getInset(): number { + const self = this.getLatest(); + return self.__inset; + } + createDOM(_config: EditorConfig, _editor: LexicalEditor) { const element = document.createElement('p'); element.classList.add('callout', this.__category || ''); @@ -140,13 +153,13 @@ export class CalloutNode extends ElementNode { category: this.__category, id: this.__id, alignment: this.__alignment, + inset: this.__inset, }; } static importJSON(serializedNode: SerializedCalloutNode): CalloutNode { const node = $createCalloutNode(serializedNode.category); - node.setId(serializedNode.id); - node.setAlignment(serializedNode.alignment); + deserializeCommonBlockNode(serializedNode, node); return node; }