diff --git a/apps/client/package.json b/apps/client/package.json index 6b5a9807f..7195b28ab 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -60,7 +60,7 @@ "@types/react": "19.1.3", "@types/react-dom": "19.1.3", "copy-webpack-plugin": "13.0.0", - "happy-dom": "17.4.6", + "happy-dom": "17.4.7", "script-loader": "0.7.2" }, "nx": { diff --git a/apps/client/src/components/tab_manager.ts b/apps/client/src/components/tab_manager.ts index 937bd8982..cf2876a5a 100644 --- a/apps/client/src/components/tab_manager.ts +++ b/apps/client/src/components/tab_manager.ts @@ -277,10 +277,18 @@ export default class TabManager extends Component { return noteContext; } - async openInNewTab(targetNoteId: string, hoistedNoteId: string | null = null) { + async openInNewTab(targetNoteId: string, hoistedNoteId: string | null = null, activate: boolean = false) { const noteContext = await this.openEmptyTab(null, hoistedNoteId || this.getActiveContext()?.hoistedNoteId); await noteContext.setNote(targetNoteId); + + if (activate && noteContext.notePath) { + this.activateNoteContext(noteContext.ntxId, false); + await this.triggerEvent("noteSwitchedAndActivated", { + noteContext, + notePath: noteContext.notePath + }); + } } async openInSameTab(targetNoteId: string, hoistedNoteId: string | null = null) { diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 6bd1657f5..ebef11e05 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -126,7 +126,8 @@ "collapseWholeTree": "collapse whole note tree", "collapseSubTree": "collapse sub-tree", "tabShortcuts": "Tab shortcuts", - "newTabNoteLink": "CTRL+click - (or middle mouse click) on note link opens note in a new tab", + "newTabNoteLink": "Ctrl+click - (or middle mouse click) on note link opens note in a new tab", + "newTabWithActivationNoteLink": "Ctrl+Shift+click - (or Shift+middle mouse click) on note link opens and activates the note in a new tab", "onlyInDesktop": "Only in desktop (Electron build)", "openEmptyTab": "open empty tab", "closeActiveTab": "close active tab", diff --git a/apps/client/src/widgets/buttons/launcher/note_launcher.ts b/apps/client/src/widgets/buttons/launcher/note_launcher.ts index 7622df401..00ba956a1 100644 --- a/apps/client/src/widgets/buttons/launcher/note_launcher.ts +++ b/apps/client/src/widgets/buttons/launcher/note_launcher.ts @@ -53,11 +53,12 @@ export default class NoteLauncher extends AbstractLauncher { await appContext.tabManager.openInSameTab(targetNoteId, hoistedNoteId); } else { const ctrlKey = utils.isCtrlKey(evt); + const activate = evt.shiftKey ? true : false; if ((evt.which === 1 && ctrlKey) || evt.which === 2) { // TODO: Fix once tabManager is ported. //@ts-ignore - await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId); + await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId, activate); } else { // TODO: Fix once tabManager is ported. //@ts-ignore diff --git a/apps/client/src/widgets/buttons/open_note_button_widget.ts b/apps/client/src/widgets/buttons/open_note_button_widget.ts index 950ded0a6..c0a4c6334 100644 --- a/apps/client/src/widgets/buttons/open_note_button_widget.ts +++ b/apps/client/src/widgets/buttons/open_note_button_widget.ts @@ -28,15 +28,21 @@ export default class OpenNoteButtonWidget extends OnClickButtonWidget { if (evt.which === 3) { return; } + const hoistedNoteId = this.getHoistedNoteId(); const ctrlKey = utils.isCtrlKey(evt); if ((evt.which === 1 && ctrlKey) || evt.which === 2) { - await appContext.tabManager.openInNewTab(this.noteToOpen.noteId); + const activate = evt.shiftKey ? true : false; + await appContext.tabManager.openInNewTab(this.noteToOpen.noteId, hoistedNoteId, activate); } else { await appContext.tabManager.openInSameTab(this.noteToOpen.noteId); } } + getHoistedNoteId() { + return this.noteToOpen.getRelationValue("hoistedNote") || appContext.tabManager.getActiveContext()?.hoistedNoteId; + } + initialRenderCompleteEvent() { // we trigger refresh above } diff --git a/apps/client/src/widgets/dialogs/help.ts b/apps/client/src/widgets/dialogs/help.ts index 0d2e77d7b..747d01b02 100644 --- a/apps/client/src/widgets/dialogs/help.ts +++ b/apps/client/src/widgets/dialogs/help.ts @@ -38,6 +38,7 @@ const TPL = /*html*/`

${t("help.onlyInDesktop")}: