]> BookStack Code Mirror - bookstack/blobdiff - resources/js/wysiwyg/utils/selection.ts
Lexical: Added single node enter handling
[bookstack] / resources / js / wysiwyg / utils / selection.ts
index 4f565fa10db2dd207a91306bb969bce89dd5b39c..4aa21045f3013641ac115c8ba336cf431de66729 100644 (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);
         }
     }