]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/nodes/index.ts
Lexical: Merged custom paragraph node, removed old format/indent refs
[bookstack] / resources / js / wysiwyg / nodes / index.ts
index 81a0c1a0d8e8e1dbd19f9312b8f9e4f40402539e..062394a9887db2a4454f3b480590b1630ade766c 100644 (file)
@@ -7,7 +7,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";
@@ -22,32 +21,47 @@ import {MediaNode} from "./media";
 import {CustomListItemNode} from "./custom-list-item";
 import {CustomTableCellNode} from "./custom-table-cell";
 import {CustomTableRowNode} from "./custom-table-row";
+import {CustomHeadingNode} from "./custom-heading";
+import {CustomQuoteNode} from "./custom-quote";
+import {CustomListNode} from "./custom-list";
 
 /**
  * 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
-        CustomListItemNode,
+        CalloutNode,
+        CustomHeadingNode,
+        CustomQuoteNode,
+        CustomListNode,
+        CustomListItemNode, // TODO - Alignment?
         CustomTableNode,
         CustomTableRowNode,
         CustomTableCellNode,
-        ImageNode,
+        ImageNode, // TODO - Alignment
         HorizontalRuleNode,
         DetailsNode, SummaryNode,
         CodeBlockNode,
         DiagramNode,
-        MediaNode,
-        CustomParagraphNode,
+        MediaNode, // TODO - Alignment
+        ParagraphNode,
         LinkNode,
         {
-            replace: ParagraphNode,
-            with: (node: ParagraphNode) => {
-                return new CustomParagraphNode();
+            replace: HeadingNode,
+            with: (node: HeadingNode) => {
+                return new CustomHeadingNode(node.__tag);
+            }
+        },
+        {
+            replace: QuoteNode,
+            with: (node: QuoteNode) => {
+                return new CustomQuoteNode();
+            }
+        },
+        {
+            replace: ListNode,
+            with: (node: ListNode) => {
+                return new CustomListNode(node.getListType(), node.getStart());
             }
         },
         {