]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/nodes/index.ts
f47575bc5f615bb25ed84c57e8978910768ecc11
[bookstack] / resources / js / wysiwyg / nodes / index.ts
1 import {HeadingNode, QuoteNode} from '@lexical/rich-text';
2 import {CalloutNode} from './callout';
3 import {ElementNode, KlassConstructor, LexicalNode, LexicalNodeReplacement, ParagraphNode} from "lexical";
4 import {CustomParagraphNode} from "./custom-paragraph";
5 import {LinkNode} from "@lexical/link";
6 import {ImageNode} from "./image";
7 import {DetailsNode, SummaryNode} from "./details";
8
9 /**
10  * Load the nodes for lexical.
11  */
12 export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
13     return [
14         CalloutNode, // Todo - Create custom
15         HeadingNode, // Todo - Create custom
16         QuoteNode, // Todo - Create custom
17         ImageNode,
18         DetailsNode, SummaryNode,
19         CustomParagraphNode,
20         {
21             replace: ParagraphNode,
22             with: (node: ParagraphNode) => {
23                 return new CustomParagraphNode();
24             }
25         },
26         LinkNode,
27     ];
28 }
29
30 export type LexicalNodeMatcher = (node: LexicalNode|null|undefined) => boolean;
31 export type LexicalElementNodeCreator = () => ElementNode;