X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b35b62d59ff057ce5cfbc5fb463431b086f5c830..2e718c12e120f5d39efc23eef995275fc6fb80a4:/resources/js/wysiwyg/lexical/core/LexicalNode.ts diff --git a/resources/js/wysiwyg/lexical/core/LexicalNode.ts b/resources/js/wysiwyg/lexical/core/LexicalNode.ts index c6bc2e642..7306e6bca 100644 --- a/resources/js/wysiwyg/lexical/core/LexicalNode.ts +++ b/resources/js/wysiwyg/lexical/core/LexicalNode.ts @@ -142,10 +142,21 @@ export type DOMConversionMap = Record< >; type NodeName = string; +/** + * Output for a DOM conversion. + * Node can be set to 'ignore' to ignore the conversion and handling of the DOMNode + * including all its children. + * + * You can specify a function to run for each converted child (forChild) or on all + * the child nodes after the conversion is complete (after). + * The key difference here is that forChild runs for every deeply nested child node + * of the current node, whereas after will run only once after the + * transformation of the node and all its children is complete. + */ export type DOMConversionOutput = { after?: (childLexicalNodes: Array) => Array; forChild?: DOMChildConversion; - node: null | LexicalNode | Array; + node: null | LexicalNode | Array | 'ignore'; }; export type DOMExportOutputMap = Map< @@ -1160,6 +1171,16 @@ export class LexicalNode { markDirty(): void { this.getWritable(); } + + /** + * Insert the DOM of this node into that of the parent. + * Allows this node to implement custom DOM attachment logic. + * Boolean result indicates if the insertion was handled by the function. + * A true return value prevents default insertion logic from taking place. + */ + insertDOMIntoParent(nodeDOM: HTMLElement, parentDOM: HTMLElement): boolean { + return false; + } } function errorOnTypeKlassMismatch(