From d3e74968e7a091f59897fd0e0352d940bb369210 Mon Sep 17 00:00:00 2001 From: umaranis Date: Tue, 7 May 2024 18:23:26 +1000 Subject: [PATCH] bug: wrong logic for FloatingLinkEditorPlugin bad node --- .../link/FloatingLinkEditorPlugin.svelte | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/svelte-lexical/src/lib/core/plugins/link/FloatingLinkEditorPlugin.svelte b/packages/svelte-lexical/src/lib/core/plugins/link/FloatingLinkEditorPlugin.svelte index ef51607..d7dc9ed 100644 --- a/packages/svelte-lexical/src/lib/core/plugins/link/FloatingLinkEditorPlugin.svelte +++ b/packages/svelte-lexical/src/lib/core/plugins/link/FloatingLinkEditorPlugin.svelte @@ -40,19 +40,19 @@ $isLink = false; return; } - const badNode = selection.getNodes().find((node) => { - const linkNode = findMatchingParent(node, isLinkNode); - const autoLinkNode = findMatchingParent(node, isAutoLinkNode); - if ( - !linkNode?.is(focusLinkNode) && - !autoLinkNode?.is(focusAutoLinkNode) && - !linkNode && - !autoLinkNode && - !isLineBreakNode(node) - ) { - return node; - } - }); + const badNode = selection + .getNodes() + .filter((node) => !isLineBreakNode(node)) + .find((node) => { + const linkNode = findMatchingParent(node, isLinkNode); + const autoLinkNode = findMatchingParent(node, isAutoLinkNode); + return ( + (focusLinkNode && !focusLinkNode.is(linkNode)) || + (linkNode && !linkNode.is(focusLinkNode)) || + (focusAutoLinkNode && !focusAutoLinkNode.is(autoLinkNode)) || + (autoLinkNode && !autoLinkNode.is(focusAutoLinkNode)) + ); + }); if (!badNode) { $isLink = true; } else {