]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/nodes/index.ts
Lexical: Started build of image node and decoration UI
[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
8 /**
9  * Load the nodes for lexical.
10  */
11 export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
12     return [
13         CalloutNode, // Todo - Create custom
14         HeadingNode, // Todo - Create custom
15         QuoteNode, // Todo - Create custom
16         ImageNode,
17         CustomParagraphNode,
18         {
19             replace: ParagraphNode,
20             with: (node: ParagraphNode) => {
21                 return new CustomParagraphNode();
22             }
23         },
24         LinkNode,
25     ];
26 }
27
28 export type LexicalNodeMatcher = (node: LexicalNode|null|undefined) => boolean;
29 export type LexicalElementNodeCreator = () => ElementNode;