diff --git a/apps/client/src/services/link.ts b/apps/client/src/services/link.ts index cc6d6f66f..c87332464 100644 --- a/apps/client/src/services/link.ts +++ b/apps/client/src/services/link.ts @@ -309,13 +309,14 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent const shiftKey = evt?.shiftKey; const isLeftClick = !evt || ("which" in evt && evt.which === 1); const isMiddleClick = evt && "which" in evt && evt.which === 2; + const isRightClick = evt && "button" in evt && evt.button === 2; const targetIsBlank = ($link?.attr("target") === "_blank"); const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank; const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey); const openInNewWindow = isLeftClick && evt?.shiftKey && !ctrlKey; if (notePath) { - if (openInPopup || (ctrlKey && isMiddleClick)) { + if (openInPopup || (ctrlKey && isRightClick)) { appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath }); } else if (openInNewWindow) { appContext.triggerCommand("openInWindow", { notePath, viewScope }); @@ -387,6 +388,11 @@ function linkContextMenu(e: PointerEvent) { return; } + if (e.button === 2) { + e.preventDefault(); + return; + } + const { notePath, viewScope } = parseNavigationStateFromUrl(url); if (!notePath) { diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts index fbd788ad7..e77337aa7 100644 --- a/apps/client/src/widgets/note_tree.ts +++ b/apps/client/src/widgets/note_tree.ts @@ -240,20 +240,15 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { this.$tree.on("mousedown", ".fancytree-title", (e) => { if (e.which === 2) { const node = $.ui.fancytree.getNode(e as unknown as Event); - const notePath = treeService.getNotePath(node); if (notePath) { e.stopPropagation(); e.preventDefault(); - if (e.ctrlKey) { - appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath }); - } else { - appContext.tabManager.openTabWithNoteWithHoisting(notePath, { - activate: e.shiftKey ? true : false - }); - } + appContext.tabManager.openTabWithNoteWithHoisting(notePath, { + activate: e.shiftKey ? true : false + }); } } }); @@ -264,11 +259,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { e.preventDefault(); } }); - this.$tree.on("auxclick", (e) => { - // Prevent middle click from pasting in the editor. - e.stopPropagation(); - e.preventDefault(); - }); this.$treeSettingsPopup = this.$widget.find(".tree-settings-popup"); this.$hideArchivedNotesCheckbox = this.$treeSettingsPopup.find(".hide-archived-notes"); @@ -723,7 +713,13 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { }); } else { this.$tree.on("contextmenu", ".fancytree-node", (e) => { - this.showContextMenu(e); + if (!e.ctrlKey) { + this.showContextMenu(e); + } else { + const node = $.ui.fancytree.getNode(e as unknown as Event); + const notePath = treeService.getNotePath(node); + appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath }); + } return false; // blocks default browser right click menu });