Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 9765f2f

Browse files
committed
Use Ctrl + Shift + Click on the launcher pane to open and activate in a new tab.
1 parent d3a6079 commit 9765f2f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

apps/client/src/components/tab_manager.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,18 @@ export default class TabManager extends Component {
277277
return noteContext;
278278
}
279279

280-
async openInNewTab(targetNoteId: string, hoistedNoteId: string | null = null) {
280+
async openInNewTab(targetNoteId: string, hoistedNoteId: string | null = null, activate: boolean = false) {
281281
const noteContext = await this.openEmptyTab(null, hoistedNoteId || this.getActiveContext()?.hoistedNoteId);
282282

283283
await noteContext.setNote(targetNoteId);
284+
285+
if (activate && noteContext.notePath) {
286+
this.activateNoteContext(noteContext.ntxId, false);
287+
await this.triggerEvent("noteSwitchedAndActivated", {
288+
noteContext,
289+
notePath: noteContext.notePath
290+
});
291+
}
284292
}
285293

286294
async openInSameTab(targetNoteId: string, hoistedNoteId: string | null = null) {

apps/client/src/widgets/buttons/launcher/note_launcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ export default class NoteLauncher extends AbstractLauncher {
5353
await appContext.tabManager.openInSameTab(targetNoteId, hoistedNoteId);
5454
} else {
5555
const ctrlKey = utils.isCtrlKey(evt);
56+
const activate = evt.shiftKey ? true : false;
5657

5758
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
5859
// TODO: Fix once tabManager is ported.
5960
//@ts-ignore
60-
await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId);
61+
await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId, activate);
6162
} else {
6263
// TODO: Fix once tabManager is ported.
6364
//@ts-ignore

apps/client/src/widgets/buttons/open_note_button_widget.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,21 @@ export default class OpenNoteButtonWidget extends OnClickButtonWidget {
2828
if (evt.which === 3) {
2929
return;
3030
}
31+
const hoistedNoteId = this.getHoistedNoteId();
3132
const ctrlKey = utils.isCtrlKey(evt);
3233

3334
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
34-
await appContext.tabManager.openInNewTab(this.noteToOpen.noteId);
35+
const activate = evt.shiftKey ? true : false;
36+
await appContext.tabManager.openInNewTab(this.noteToOpen.noteId, hoistedNoteId, activate);
3537
} else {
3638
await appContext.tabManager.openInSameTab(this.noteToOpen.noteId);
3739
}
3840
}
3941

42+
getHoistedNoteId() {
43+
return this.noteToOpen.getRelationValue("hoistedNote") || appContext.tabManager.getActiveContext()?.hoistedNoteId;
44+
}
45+
4046
initialRenderCompleteEvent() {
4147
// we trigger refresh above
4248
}

0 commit comments

Comments
 (0)