]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/nodes/index.ts
Lexical: Merged list nodes
[bookstack] / resources / js / wysiwyg / nodes / index.ts
index 669ffe6ddc9eb29863f4358733007dea76999c5b..7e0ce9daf2bf437fe44019a8f335077825b7350d 100644 (file)
@@ -1,4 +1,3 @@
-import {HeadingNode, QuoteNode} from '@lexical/rich-text';
 import {CalloutNode} from './callout';
 import {
     ElementNode,
@@ -7,7 +6,6 @@ import {
     LexicalNodeReplacement, NodeMutation,
     ParagraphNode
 } from "lexical";
-import {CustomParagraphNode} from "./custom-paragraph";
 import {LinkNode} from "@lexical/link";
 import {ImageNode} from "./image";
 import {DetailsNode, SummaryNode} from "./details";
@@ -19,40 +17,56 @@ import {CodeBlockNode} from "./code-block";
 import {DiagramNode} from "./diagram";
 import {EditorUiContext} from "../ui/framework/core";
 import {MediaNode} from "./media";
+import {CustomTableCellNode} from "./custom-table-cell";
+import {CustomTableRowNode} from "./custom-table-row";
+import {HeadingNode} from "@lexical/rich-text/LexicalHeadingNode";
+import {QuoteNode} from "@lexical/rich-text/LexicalQuoteNode";
 
 /**
  * Load the nodes for lexical.
  */
 export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
     return [
-        CalloutNode, // Todo - Create custom
-        HeadingNode, // Todo - Create custom
-        QuoteNode, // Todo - Create custom
-        ListNode, // Todo - Create custom
+        CalloutNode,
+        HeadingNode,
+        QuoteNode,
+        ListNode,
         ListItemNode,
         CustomTableNode,
-        TableRowNode,
-        TableCellNode,
-        ImageNode,
+        CustomTableRowNode,
+        CustomTableCellNode,
+        ImageNode, // TODO - Alignment
         HorizontalRuleNode,
         DetailsNode, SummaryNode,
         CodeBlockNode,
         DiagramNode,
-        MediaNode,
-        CustomParagraphNode,
+        MediaNode, // TODO - Alignment
+        ParagraphNode,
         LinkNode,
-        {
-            replace: ParagraphNode,
-            with: (node: ParagraphNode) => {
-                return new CustomParagraphNode();
-            }
-        },
         {
             replace: TableNode,
             with(node: TableNode) {
                 return new CustomTableNode();
             }
         },
+        {
+            replace: TableRowNode,
+            with(node: TableRowNode) {
+                return new CustomTableRowNode();
+            }
+        },
+        {
+            replace: TableCellNode,
+            with: (node: TableCellNode) => {
+                const cell = new CustomTableCellNode(
+                    node.__headerState,
+                    node.__colSpan,
+                    node.__width,
+                );
+                cell.__rowSpan = node.__rowSpan;
+                return cell;
+            }
+        },
     ];
 }