From ad4631018a1779abe303831fdc8c9f3904099737 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 26 May 2023 11:13:49 +0200 Subject: [PATCH] right click on external link should not open the link, fixes #3971 --- src/public/app/services/link.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index c7d75c132..a7c2cfaf3 100644 --- a/src/public/app/services/link.js +++ b/src/public/app/services/link.js @@ -105,11 +105,14 @@ function goToLink(evt) { const ctrlKey = utils.isCtrlKey(evt); + const leftClick = evt.which === 1; + const middleClick = evt.which === 2; + if (notePath) { - if ((evt.which === 1 && ctrlKey) || evt.which === 2) { + if ((leftClick && ctrlKey) || middleClick) { appContext.tabManager.openTabWithNoteWithHoisting(notePath); } - else if (evt.which === 1) { + else if (leftClick) { const ntxId = $(evt.target).closest("[data-ntx-id]").attr("data-ntx-id"); const noteContext = ntxId @@ -124,9 +127,12 @@ function goToLink(evt) { } } else { - if ((evt.which === 1 && ctrlKey) || evt.which === 2 - || $link.hasClass("ck-link-actions__preview") // within edit link dialog single click suffices - || $link.closest("[contenteditable]").length === 0 // outside of CKEditor single click suffices + const withinEditLink = $link.hasClass("ck-link-actions__preview"); + const outsideOfCKEditor = $link.closest("[contenteditable]").length === 0; + + if ((leftClick && ctrlKey) || middleClick + || (withinEditLink && (leftClick || middleClick)) + || (outsideOfCKEditor && (leftClick || middleClick)) ) { if (address) { if (address.toLowerCase().startsWith('http')) {