1 import {CalloutNode} from './callout';
6 LexicalNodeReplacement, NodeMutation,
9 import {LinkNode} from "@lexical/link";
10 import {ImageNode} from "./image";
11 import {DetailsNode, SummaryNode} from "./details";
12 import {ListItemNode, ListNode} from "@lexical/list";
13 import {TableCellNode, TableNode, TableRowNode} from "@lexical/table";
14 import {HorizontalRuleNode} from "./horizontal-rule";
15 import {CodeBlockNode} from "./code-block";
16 import {DiagramNode} from "./diagram";
17 import {EditorUiContext} from "../ui/framework/core";
18 import {MediaNode} from "./media";
19 import {HeadingNode} from "@lexical/rich-text/LexicalHeadingNode";
20 import {QuoteNode} from "@lexical/rich-text/LexicalQuoteNode";
23 * Load the nodes for lexical.
25 export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
35 ImageNode, // TODO - Alignment
37 DetailsNode, SummaryNode,
40 MediaNode, // TODO - Alignment
46 export function registerCommonNodeMutationListeners(context: EditorUiContext): void {
47 const decorated = [ImageNode, CodeBlockNode, DiagramNode];
49 const decorationDestroyListener = (mutations: Map<string, NodeMutation>): void => {
50 for (let [nodeKey, mutation] of mutations) {
51 if (mutation === "destroyed") {
52 const decorator = context.manager.getDecoratorByNodeKey(nodeKey);
54 decorator.destroy(context);
60 for (let decoratedNode of decorated) {
61 // Have to pass a unique function here since they are stored by lexical keyed on listener function.
62 context.editor.registerMutationListener(decoratedNode, (mutations) => decorationDestroyListener(mutations));
66 export type LexicalNodeMatcher = (node: LexicalNode|null|undefined) => boolean;
67 export type LexicalElementNodeCreator = () => ElementNode;