mirror of
https://github.com/zadam/trilium.git
synced 2025-10-06 13:39:51 +08:00
chore(popup_editor): switch keyboard combo to Ctrl+right click
This commit is contained in:
parent
bce2094fb2
commit
c7f49f0e21
2 changed files with 17 additions and 15 deletions
|
@ -309,13 +309,14 @@ function goToLinkExt(evt: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent
|
||||||
const shiftKey = evt?.shiftKey;
|
const shiftKey = evt?.shiftKey;
|
||||||
const isLeftClick = !evt || ("which" in evt && evt.which === 1);
|
const isLeftClick = !evt || ("which" in evt && evt.which === 1);
|
||||||
const isMiddleClick = evt && "which" in evt && evt.which === 2;
|
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 targetIsBlank = ($link?.attr("target") === "_blank");
|
||||||
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
|
const openInNewTab = (isLeftClick && ctrlKey) || isMiddleClick || targetIsBlank;
|
||||||
const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
|
const activate = (isLeftClick && ctrlKey && shiftKey) || (isMiddleClick && shiftKey);
|
||||||
const openInNewWindow = isLeftClick && evt?.shiftKey && !ctrlKey;
|
const openInNewWindow = isLeftClick && evt?.shiftKey && !ctrlKey;
|
||||||
|
|
||||||
if (notePath) {
|
if (notePath) {
|
||||||
if (openInPopup || (ctrlKey && isMiddleClick)) {
|
if (openInPopup || (ctrlKey && isRightClick)) {
|
||||||
appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath });
|
appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath });
|
||||||
} else if (openInNewWindow) {
|
} else if (openInNewWindow) {
|
||||||
appContext.triggerCommand("openInWindow", { notePath, viewScope });
|
appContext.triggerCommand("openInWindow", { notePath, viewScope });
|
||||||
|
@ -387,6 +388,11 @@ function linkContextMenu(e: PointerEvent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.button === 2) {
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { notePath, viewScope } = parseNavigationStateFromUrl(url);
|
const { notePath, viewScope } = parseNavigationStateFromUrl(url);
|
||||||
|
|
||||||
if (!notePath) {
|
if (!notePath) {
|
||||||
|
|
|
@ -240,20 +240,15 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||||
this.$tree.on("mousedown", ".fancytree-title", (e) => {
|
this.$tree.on("mousedown", ".fancytree-title", (e) => {
|
||||||
if (e.which === 2) {
|
if (e.which === 2) {
|
||||||
const node = $.ui.fancytree.getNode(e as unknown as Event);
|
const node = $.ui.fancytree.getNode(e as unknown as Event);
|
||||||
|
|
||||||
const notePath = treeService.getNotePath(node);
|
const notePath = treeService.getNotePath(node);
|
||||||
|
|
||||||
if (notePath) {
|
if (notePath) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (e.ctrlKey) {
|
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
|
||||||
appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath });
|
activate: e.shiftKey ? true : false
|
||||||
} else {
|
});
|
||||||
appContext.tabManager.openTabWithNoteWithHoisting(notePath, {
|
|
||||||
activate: e.shiftKey ? true : false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -264,11 +259,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||||
e.preventDefault();
|
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.$treeSettingsPopup = this.$widget.find(".tree-settings-popup");
|
||||||
this.$hideArchivedNotesCheckbox = this.$treeSettingsPopup.find(".hide-archived-notes");
|
this.$hideArchivedNotesCheckbox = this.$treeSettingsPopup.find(".hide-archived-notes");
|
||||||
|
@ -723,7 +713,13 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.$tree.on("contextmenu", ".fancytree-node", (e) => {
|
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
|
return false; // blocks default browser right click menu
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue