note launchers by default open in the active note context but follow the same logic with ctrl/middle click as links

This commit is contained in:
zadam
2022-12-09 16:48:00 +01:00
parent dfb462cf35
commit 5ac332960e
6 changed files with 80 additions and 19 deletions

View File

@@ -90,27 +90,27 @@ function getNotePathFromLink($link) {
return url ? getNotePathFromUrl(url) : null;
}
function goToLink(e) {
const $link = $(e.target).closest("a,.block-link");
function goToLink(evt) {
const $link = $(evt.target).closest("a,.block-link");
const address = $link.attr('href');
if (address?.startsWith("data:")) {
return true;
}
e.preventDefault();
e.stopPropagation();
evt.preventDefault();
evt.stopPropagation();
const notePath = getNotePathFromLink($link);
const ctrlKey = (!utils.isMac() && e.ctrlKey) || (utils.isMac() && e.metaKey);
const ctrlKey = utils.isCtrlKey(evt);
if (notePath) {
if ((e.which === 1 && ctrlKey) || e.which === 2) {
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
appContext.tabManager.openTabWithNoteWithHoisting(notePath);
}
else if (e.which === 1) {
const ntxId = $(e.target).closest("[data-ntx-id]").attr("data-ntx-id");
else if (evt.which === 1) {
const ntxId = $(evt.target).closest("[data-ntx-id]").attr("data-ntx-id");
const noteContext = ntxId
? appContext.tabManager.getNoteContextById(ntxId)
@@ -124,7 +124,7 @@ function goToLink(e) {
}
}
else {
if ((e.which === 1 && ctrlKey) || e.which === 2
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
) {