1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Lexical: Added custom id-supporting paragraph blocks

This commit is contained in:
Dan Brown
2024-05-28 15:09:50 +01:00
parent 49546cd627
commit 0f8bd869d8
6 changed files with 122 additions and 20 deletions

View File

@ -1,14 +1,22 @@
import {HeadingNode, QuoteNode} from '@lexical/rich-text';
import {Callout} from './callout';
import {KlassConstructor, LexicalNode} from "lexical";
import {CalloutNode} from './callout';
import {KlassConstructor, LexicalNode, LexicalNodeReplacement, ParagraphNode} from "lexical";
import {CustomParagraphNode} from "./custom-paragraph";
/**
* Load the nodes for lexical.
*/
export function getNodesForPageEditor(): KlassConstructor<typeof LexicalNode>[] {
export function getNodesForPageEditor(): (KlassConstructor<typeof LexicalNode> | LexicalNodeReplacement)[] {
return [
Callout,
HeadingNode,
QuoteNode,
CalloutNode, // Todo - Create custom
HeadingNode, // Todo - Create custom
QuoteNode, // Todo - Create custom
CustomParagraphNode,
{
replace: ParagraphNode,
with: (node: ParagraphNode) => {
return new CustomParagraphNode();
}
}
];
}