mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-12 20:02:28 +08:00
Use Ctrl + Shift + Click on the launcher pane to open and activate in a new tab.
This commit is contained in:
parent
d3a6079d9b
commit
9765f2f6d7
@ -277,10 +277,18 @@ export default class TabManager extends Component {
|
|||||||
return noteContext;
|
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);
|
const noteContext = await this.openEmptyTab(null, hoistedNoteId || this.getActiveContext()?.hoistedNoteId);
|
||||||
|
|
||||||
await noteContext.setNote(targetNoteId);
|
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) {
|
async openInSameTab(targetNoteId: string, hoistedNoteId: string | null = null) {
|
||||||
|
@ -53,11 +53,12 @@ export default class NoteLauncher extends AbstractLauncher {
|
|||||||
await appContext.tabManager.openInSameTab(targetNoteId, hoistedNoteId);
|
await appContext.tabManager.openInSameTab(targetNoteId, hoistedNoteId);
|
||||||
} else {
|
} else {
|
||||||
const ctrlKey = utils.isCtrlKey(evt);
|
const ctrlKey = utils.isCtrlKey(evt);
|
||||||
|
const activate = evt.shiftKey ? true : false;
|
||||||
|
|
||||||
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
|
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
|
||||||
// TODO: Fix once tabManager is ported.
|
// TODO: Fix once tabManager is ported.
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId);
|
await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId, activate);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Fix once tabManager is ported.
|
// TODO: Fix once tabManager is ported.
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
@ -28,15 +28,21 @@ export default class OpenNoteButtonWidget extends OnClickButtonWidget {
|
|||||||
if (evt.which === 3) {
|
if (evt.which === 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const hoistedNoteId = this.getHoistedNoteId();
|
||||||
const ctrlKey = utils.isCtrlKey(evt);
|
const ctrlKey = utils.isCtrlKey(evt);
|
||||||
|
|
||||||
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
|
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 {
|
} else {
|
||||||
await appContext.tabManager.openInSameTab(this.noteToOpen.noteId);
|
await appContext.tabManager.openInSameTab(this.noteToOpen.noteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHoistedNoteId() {
|
||||||
|
return this.noteToOpen.getRelationValue("hoistedNote") || appContext.tabManager.getActiveContext()?.hoistedNoteId;
|
||||||
|
}
|
||||||
|
|
||||||
initialRenderCompleteEvent() {
|
initialRenderCompleteEvent() {
|
||||||
// we trigger refresh above
|
// we trigger refresh above
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user