]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/nodes/index.ts
Lexical: Added id support for all main block types
[bookstack] / resources / js / wysiwyg / nodes / index.ts
index 81a0c1a0d8e8e1dbd19f9312b8f9e4f40402539e..8cbec20dad21f58460fc638ee72b78c311c32068 100644 (file)
@@ -22,16 +22,19 @@ 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
+        CalloutNode,
+        CustomHeadingNode,
+        CustomQuoteNode,
+        CustomListNode,
         CustomListItemNode,
         CustomTableNode,
         CustomTableRowNode,
@@ -42,7 +45,7 @@ export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> |
         CodeBlockNode,
         DiagramNode,
         MediaNode,
-        CustomParagraphNode,
+        CustomParagraphNode, // TODO - ID
         LinkNode,
         {
             replace: ParagraphNode,
@@ -50,6 +53,24 @@ export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> |
                 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());
+            }
+        },
         {
             replace: ListItemNode,
             with: (node: ListItemNode) => {