From c8787467e0dca229ff877e6c3b47bdab2b5e9f03 Mon Sep 17 00:00:00 2001 From: reffat Date: Thu, 20 Feb 2025 22:47:07 +0300 Subject: [PATCH 1/3] fix(link): fixed link cursor focus --- .../markdown/Link/plugins/LinkTooltipPlugin/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx b/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx index bcf76a77f..affbe114b 100644 --- a/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx +++ b/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx @@ -239,6 +239,8 @@ class SelectionTooltip implements PluginView { view.state.tr.addMark(from, to, linkType(view.state.schema).create({href: url})), ); + view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, to))); + setTimeout(this.cancelPopup.bind(this)); } } From e44315277381bb9e099a691dff5c1193545767ee Mon Sep 17 00:00:00 2001 From: reffat Date: Sun, 23 Feb 2025 20:51:48 +0300 Subject: [PATCH 2/3] fix(link): fixed cursor position --- .../Link/plugins/LinkTooltipPlugin/index.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx b/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx index affbe114b..8d37d284e 100644 --- a/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx +++ b/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx @@ -111,14 +111,12 @@ class SelectionTooltip implements PluginView { if (prevState && prevState.doc.eq(state.doc) && prevState.selection.eq(state.selection)) return; - const prevTextNode = this.textNode; this.textNode = getTextNode(view.state); const prevRef = this.textNodeRef; this.updateTextNodeRef(); if (!this.textNode || !this.textNodeRef) { - this.removePlaceholderLink(prevTextNode); this.hideTooltip(); return; } @@ -235,13 +233,11 @@ class SelectionTooltip implements PluginView { if (normalizeResult) { const {url} = normalizeResult; const {from, to} = textNode; - view.dispatch( - view.state.tr.addMark(from, to, linkType(view.state.schema).create({href: url})), - ); - view.dispatch(view.state.tr.setSelection(TextSelection.create(view.state.doc, to))); - - setTimeout(this.cancelPopup.bind(this)); + const tr = view.state.tr; + tr.setSelection(TextSelection.create(tr.doc, tr.mapping.map(to))); + tr.addMark(from, to, linkType(view.state.schema).create({href: url})); + view.dispatch(tr); } } From 93e435d4b2d7989a2adccfd49b6cbb20e39daa03 Mon Sep 17 00:00:00 2001 From: reffat Date: Sun, 9 Mar 2025 23:35:45 +0300 Subject: [PATCH 3/3] fix(link): fixed outside link --- .../markdown/Link/plugins/LinkTooltipPlugin/index.tsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx b/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx index 8d37d284e..0627ae368 100644 --- a/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx +++ b/src/extensions/markdown/Link/plugins/LinkTooltipPlugin/index.tsx @@ -189,14 +189,9 @@ class SelectionTooltip implements PluginView { }; private onOutisdeClick = () => { - // after all updates of the editor state - setTimeout(() => { - if (!this.view.hasFocus()) { - this.removePlaceholderLink(this.textNode); - this.hideTooltip(); - this.manualHidden = false; - } - }); + this.removePlaceholderLink(this.textNode); + this.hideTooltip(); + this.manualHidden = true; }; private cancelPopup() {