From d3a6079d9b0547456b38b301034e559d5eb8cf90 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sun, 4 May 2025 17:02:57 +0800 Subject: [PATCH] Open in a new tab and activate notes when ctrl+click in tree --- apps/client/src/widgets/note_tree.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts index cbc3ec055..6f5f09585 100644 --- a/apps/client/src/widgets/note_tree.ts +++ b/apps/client/src/widgets/note_tree.ts @@ -230,7 +230,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { const notePath = treeService.getNotePath(node); if (notePath) { - appContext.tabManager.openTabWithNoteWithHoisting(notePath); + appContext.tabManager.openTabWithNoteWithHoisting(notePath, { + activate: e.shiftKey ? true : false + }); } e.stopPropagation(); @@ -343,11 +345,12 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { }, scrollParent: this.$tree, minExpandLevel: 2, // root can't be collapsed - click: (event, data): boolean => { + click: (event: MouseEvent | JQuery.ClickEvent | JQuery.MouseDownEvent | React.PointerEvent, data): boolean => { this.activityDetected(); const targetType = data.targetType; const node = data.node; + const ctrlKey = utils.isCtrlKey(event); if (node.isSelected() && targetType === "icon") { this.triggerCommand("openBulkActionsDialog", { @@ -356,7 +359,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { return false; } else if (targetType === "title" || targetType === "icon") { - if (event.shiftKey) { + if (event.shiftKey && !ctrlKey) { const activeNode = this.getActiveNode(); if (activeNode.getParent() !== node.getParent()) { @@ -381,9 +384,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } node.setFocus(true); - } else if ((!utils.isMac() && event.ctrlKey) || (utils.isMac() && event.metaKey)) { + } else if (ctrlKey) { const notePath = treeService.getNotePath(node); - appContext.tabManager.openTabWithNoteWithHoisting(notePath); + appContext.tabManager.openTabWithNoteWithHoisting(notePath, { + activate: event.shiftKey ? true : false + }); } else if (event.altKey) { node.setSelected(!node.isSelected()); node.setFocus(true);