mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-12-23 23:02:08 +03:00
Lexical: Merged custom paragraph node, removed old format/indent refs
Start of work to merge custom nodes into lexical, removing old unused format/indent core logic while extending common block elements where possible.
This commit is contained in:
@@ -7,17 +7,15 @@ import {
|
||||
$isTextNode,
|
||||
$setSelection,
|
||||
BaseSelection, DecoratorNode,
|
||||
ElementFormatType,
|
||||
ElementNode, LexicalEditor,
|
||||
LexicalNode,
|
||||
TextFormatType, TextNode
|
||||
} from "lexical";
|
||||
import {$findMatchingParent, $getNearestBlockElementAncestorOrThrow} from "@lexical/utils";
|
||||
import {$getNearestBlockElementAncestorOrThrow} from "@lexical/utils";
|
||||
import {LexicalElementNodeCreator, LexicalNodeMatcher} from "../nodes";
|
||||
import {$setBlocksType} from "@lexical/selection";
|
||||
|
||||
import {$getNearestNodeBlockParent, $getParentOfType, nodeHasAlignment} from "./nodes";
|
||||
import {$createCustomParagraphNode} from "../nodes/custom-paragraph";
|
||||
import {CommonBlockAlignment} from "../nodes/_common";
|
||||
|
||||
const lastSelectionByEditor = new WeakMap<LexicalEditor, BaseSelection|null>;
|
||||
@@ -71,7 +69,7 @@ export function $toggleSelectionBlockNodeType(matcher: LexicalNodeMatcher, creat
|
||||
const selection = $getSelection();
|
||||
const blockElement = selection ? $getNearestBlockElementAncestorOrThrow(selection.getNodes()[0]) : null;
|
||||
if (selection && matcher(blockElement)) {
|
||||
$setBlocksType(selection, $createCustomParagraphNode);
|
||||
$setBlocksType(selection, $createParagraphNode);
|
||||
} else {
|
||||
$setBlocksType(selection, creator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user