From b649d8d4bbb849c3ac0f34a296a9a97f670094fd Mon Sep 17 00:00:00 2001 From: umaranis Date: Fri, 22 Dec 2023 16:37:41 +0500 Subject: [PATCH] bug: insert link through toolbar or shortcut doesn't open floating editor in edit mode --- .../plugins/link/FloatingLinkEditor.svelte | 18 +++++++++--------- .../link/FloatingLinkEditorPlugin.svelte | 14 +++++++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/svelte-lexical/src/core/plugins/link/FloatingLinkEditor.svelte b/packages/svelte-lexical/src/core/plugins/link/FloatingLinkEditor.svelte index b73754b..a3914a0 100644 --- a/packages/svelte-lexical/src/core/plugins/link/FloatingLinkEditor.svelte +++ b/packages/svelte-lexical/src/core/plugins/link/FloatingLinkEditor.svelte @@ -29,11 +29,11 @@ let inputRef: HTMLInputElement; let linkUrl = ''; let editedLinkUrl = ''; - let isEditMode = false; + export let isEditMode: Writable; let lastSelection: RangeSelection | GridSelection | NodeSelection | null = null; - $: if (isEditMode && inputRef) { + $: if ($isEditMode && inputRef) { inputRef.focus(); } @@ -107,7 +107,7 @@ linkUrl = ''; } } - if (isEditMode) { + if ($isEditMode) { editedLinkUrl = linkUrl; } const editorElem = editorRef; @@ -139,7 +139,7 @@ setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem); } lastSelection = null; - isEditMode = false; + $isEditMode = false; linkUrl = ''; } @@ -154,7 +154,7 @@ handleLinkSubmission(); } else if (event.key === 'Escape') { event.preventDefault(); - isEditMode = false; + $isEditMode = false; } } @@ -163,7 +163,7 @@ if (linkUrl !== '') { editor.dispatchCommand(TOGGLE_LINK_COMMAND, sanitizeUrl(editedLinkUrl)); } - isEditMode = false; + $isEditMode = false; } } @@ -172,7 +172,7 @@