]> BookStack Code Mirror - bookstack/blob - resources/js/wysiwyg/nodes/index.ts
Lexical: Added base table support and started resize handling
[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 import {ListItemNode, ListNode} from "@lexical/list";
9 import {TableCellNode, TableNode, TableRowNode} from "@lexical/table";
10
11 /**
12  * Load the nodes for lexical.
13  */
14 export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
15     return [
16         CalloutNode, // Todo - Create custom
17         HeadingNode, // Todo - Create custom
18         QuoteNode, // Todo - Create custom
19         ListNode, // Todo - Create custom
20         ListItemNode,
21         TableNode, // Todo - Create custom,
22         TableRowNode,
23         TableCellNode,
24         ImageNode,
25         DetailsNode, SummaryNode,
26         CustomParagraphNode,
27         {
28             replace: ParagraphNode,
29             with: (node: ParagraphNode) => {
30                 return new CustomParagraphNode();
31             }
32         },
33         LinkNode,
34     ];
35 }
36
37 export type LexicalNodeMatcher = (node: LexicalNode|null|undefined) => boolean;
38 export type LexicalElementNodeCreator = () => ElementNode;