chore(popup_editor): switch keyboard combo to Ctrl+right click

This commit is contained in:
Elian Doran 2025-07-11 16:42:37 +03:00
parent bce2094fb2
commit c7f49f0e21
No known key found for this signature in database
2 changed files with 17 additions and 15 deletions

View file

@ -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) {

View file

@ -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
});