right click on external link should not open the link, fixes #3971

This commit is contained in:
zadam 2023-05-26 11:13:49 +02:00
parent 6878877acd
commit ad4631018a

View file

@ -105,11 +105,14 @@ function goToLink(evt) {
const ctrlKey = utils.isCtrlKey(evt); const ctrlKey = utils.isCtrlKey(evt);
const leftClick = evt.which === 1;
const middleClick = evt.which === 2;
if (notePath) { if (notePath) {
if ((evt.which === 1 && ctrlKey) || evt.which === 2) { if ((leftClick && ctrlKey) || middleClick) {
appContext.tabManager.openTabWithNoteWithHoisting(notePath); 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 ntxId = $(evt.target).closest("[data-ntx-id]").attr("data-ntx-id");
const noteContext = ntxId const noteContext = ntxId
@ -124,9 +127,12 @@ function goToLink(evt) {
} }
} }
else { else {
if ((evt.which === 1 && ctrlKey) || evt.which === 2 const withinEditLink = $link.hasClass("ck-link-actions__preview");
|| $link.hasClass("ck-link-actions__preview") // within edit link dialog single click suffices const outsideOfCKEditor = $link.closest("[contenteditable]").length === 0;
|| $link.closest("[contenteditable]").length === 0 // outside of CKEditor single click suffices
if ((leftClick && ctrlKey) || middleClick
|| (withinEditLink && (leftClick || middleClick))
|| (outsideOfCKEditor && (leftClick || middleClick))
) { ) {
if (address) { if (address) {
if (address.toLowerCase().startsWith('http')) { if (address.toLowerCase().startsWith('http')) {