bookmark buttons should behave similarly as other launcher buttons in respect to context menu, ctrl-click, left click

This commit is contained in:
zadam
2022-12-19 23:19:47 +01:00
parent db5e76fe8c
commit 8c4dda45ef
5 changed files with 36 additions and 46 deletions

View File

@@ -42,30 +42,18 @@ export default class NoteLauncher extends AbstractLauncher {
if (!evt) {
// keyboard shortcut
await this.openInSameTab(targetNoteId, hoistedNoteId);
await appContext.tabManager.openInSameTab(targetNoteId, hoistedNoteId);
} else {
const ctrlKey = utils.isCtrlKey(evt);
if ((evt.which === 1 && ctrlKey) || evt.which === 2) {
await this.openInNewTab(targetNoteId, hoistedNoteId);
await appContext.tabManager.openInNewTab(targetNoteId, hoistedNoteId);
} else {
await this.openInSameTab(targetNoteId, hoistedNoteId);
await appContext.tabManager.openInSameTab(targetNoteId, hoistedNoteId);
}
}
}
async openInNewTab(targetNoteId, hoistedNoteId) {
const noteContext = await appContext.tabManager.openEmptyTab(null, hoistedNoteId);
await noteContext.setNote(targetNoteId);
}
async openInSameTab(targetNoteId, hoistedNoteId) {
const activeContext = appContext.tabManager.getActiveContext();
await activeContext.setHoistedNoteId(hoistedNoteId);
await activeContext.setNote(targetNoteId);
}
getTargetNoteId() {
const targetNoteId = this.launcherNote.getRelationValue('targetNote');