X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ea4c50c2c22be9a8920d5dfe7f1162c3454f2d53..refs/pull/5313/head:/resources/js/wysiwyg/nodes/index.ts diff --git a/resources/js/wysiwyg/nodes/index.ts b/resources/js/wysiwyg/nodes/index.ts index a2c739576..b5483c500 100644 --- a/resources/js/wysiwyg/nodes/index.ts +++ b/resources/js/wysiwyg/nodes/index.ts @@ -1,10 +1,8 @@ import {HeadingNode, QuoteNode} from '@lexical/rich-text'; import {CalloutNode} from './callout'; import { - $getNodeByKey, ElementNode, KlassConstructor, - LexicalEditor, LexicalNode, LexicalNodeReplacement, NodeMutation, ParagraphNode @@ -19,27 +17,34 @@ import {CustomTableNode} from "./custom-table"; import {HorizontalRuleNode} from "./horizontal-rule"; import {CodeBlockNode} from "./code-block"; import {DiagramNode} from "./diagram"; -import {EditorUIManager} from "../ui/framework/manager"; 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 {CustomHeadingNode} from "./custom-heading"; +import {CustomQuoteNode} from "./custom-quote"; +import {CustomListNode} from "./custom-list"; /** * Load the nodes for lexical. */ export function getNodesForPageEditor(): (KlassConstructor | LexicalNodeReplacement)[] { return [ - CalloutNode, // Todo - Create custom - HeadingNode, // Todo - Create custom - QuoteNode, // Todo - Create custom - ListNode, // Todo - Create custom - ListItemNode, + CalloutNode, + CustomHeadingNode, + CustomQuoteNode, + CustomListNode, + CustomListItemNode, // TODO - Alignment? CustomTableNode, - TableRowNode, - TableCellNode, - ImageNode, + CustomTableRowNode, + CustomTableCellNode, + ImageNode, // TODO - Alignment HorizontalRuleNode, DetailsNode, SummaryNode, CodeBlockNode, DiagramNode, + MediaNode, // TODO - Alignment CustomParagraphNode, LinkNode, { @@ -48,12 +53,54 @@ export function getNodesForPageEditor(): (KlassConstructor | 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) => { + return new CustomListItemNode(node.__value, node.__checked); + } + }, { 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; + } + }, ]; }