-import {HeadingNode, QuoteNode} from '@lexical/rich-text';
import {CalloutNode} from './callout';
import {
ElementNode,
LexicalNodeReplacement, NodeMutation,
ParagraphNode
} from "lexical";
-import {CustomParagraphNode} from "./custom-paragraph";
import {LinkNode} from "@lexical/link";
import {ImageNode} from "./image";
import {DetailsNode, SummaryNode} from "./details";
import {EditorUiContext} from "../ui/framework/core";
import {MediaNode} from "./media";
import {CustomListItemNode} from "./custom-list-item";
+import {CustomTableCellNode} from "./custom-table-cell";
+import {CustomTableRowNode} from "./custom-table-row";
+import {CustomListNode} from "./custom-list";
+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
- CustomListItemNode,
+ CalloutNode,
+ HeadingNode,
+ QuoteNode,
+ CustomListNode,
+ CustomListItemNode, // TODO - Alignment?
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: ListNode,
+ with: (node: ListNode) => {
+ return new CustomListNode(node.getListType(), node.getStart());
+ }
+ },
+ {
+ replace: ListItemNode,
+ with: (node: ListItemNode) => {
+ return new CustomListItemNode(node.__value, node.__checked);
}
},
{
}
},
{
- replace: ListItemNode,
- with: (node: ListItemNode) => {
- return new CustomListItemNode(node.__value, node.__checked);
+ 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;
+ }
+ },
];
}