2024-05-28 03:23:45 +08:00
|
|
|
import {HeadingNode, QuoteNode} from '@lexical/rich-text';
|
2024-05-28 22:09:50 +08:00
|
|
|
import {CalloutNode} from './callout';
|
2024-05-29 01:04:48 +08:00
|
|
|
import {ElementNode, KlassConstructor, LexicalNode, LexicalNodeReplacement, ParagraphNode} from "lexical";
|
2024-05-28 22:09:50 +08:00
|
|
|
import {CustomParagraphNode} from "./custom-paragraph";
|
2024-05-30 03:38:31 +08:00
|
|
|
import {LinkNode} from "@lexical/link";
|
2024-06-03 23:56:31 +08:00
|
|
|
import {ImageNode} from "./image";
|
2024-06-06 21:43:50 +08:00
|
|
|
import {DetailsNode, SummaryNode} from "./details";
|
2024-05-28 03:23:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the nodes for lexical.
|
|
|
|
*/
|
2024-05-28 22:09:50 +08:00
|
|
|
export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
|
2024-05-28 03:23:45 +08:00
|
|
|
return [
|
2024-05-28 22:09:50 +08:00
|
|
|
CalloutNode, // Todo - Create custom
|
|
|
|
HeadingNode, // Todo - Create custom
|
|
|
|
QuoteNode, // Todo - Create custom
|
2024-06-03 23:56:31 +08:00
|
|
|
ImageNode,
|
2024-06-06 21:43:50 +08:00
|
|
|
DetailsNode, SummaryNode,
|
2024-05-28 22:09:50 +08:00
|
|
|
CustomParagraphNode,
|
|
|
|
{
|
|
|
|
replace: ParagraphNode,
|
|
|
|
with: (node: ParagraphNode) => {
|
|
|
|
return new CustomParagraphNode();
|
|
|
|
}
|
2024-05-30 03:38:31 +08:00
|
|
|
},
|
|
|
|
LinkNode,
|
2024-05-28 03:23:45 +08:00
|
|
|
];
|
|
|
|
}
|
2024-05-29 01:04:48 +08:00
|
|
|
|
|
|
|
export type LexicalNodeMatcher = (node: LexicalNode|null|undefined) => boolean;
|
|
|
|
export type LexicalElementNodeCreator = () => ElementNode;
|