1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Lexical: Added single node enter handling

Also updated media to be an inline element to align with old editor
behaviour.
This commit is contained in:
Dan Brown
2024-09-10 12:14:26 +01:00
parent ced66f1671
commit 2036438203
5 changed files with 79 additions and 18 deletions

View File

@ -16,7 +16,7 @@ import {$findMatchingParent, $getNearestBlockElementAncestorOrThrow} from "@lexi
import {LexicalElementNodeCreator, LexicalNodeMatcher} from "../nodes";
import {$setBlocksType} from "@lexical/selection";
import {$getParentOfType, nodeHasAlignment} from "./nodes";
import {$getNearestNodeBlockParent, $getParentOfType, nodeHasAlignment} from "./nodes";
import {$createCustomParagraphNode} from "../nodes/custom-paragraph";
import {CommonBlockAlignment} from "../nodes/_common";
@ -155,11 +155,8 @@ export function $getBlockElementNodesInSelection(selection: BaseSelection | null
const blockNodes: Map<string, ElementNode> = new Map();
for (const node of selection.getNodes()) {
const blockElement = $findMatchingParent(node, (node) => {
return $isElementNode(node) && !node.isInline();
}) as ElementNode | null;
if (blockElement) {
const blockElement = $getNearestNodeBlockParent(node);
if ($isElementNode(blockElement)) {
blockNodes.set(blockElement.getKey(), blockElement);
}
}