right context menu on note map

This commit is contained in:
zadam
2021-09-24 21:40:02 +02:00
parent 3d9260c974
commit fdb7b7721d
4 changed files with 37 additions and 25 deletions

View File

@@ -0,0 +1,32 @@
import contextMenu from "./context_menu.js";
import appContext from "./app_context.js";
function openContextMenu(notePath, e) {
contextMenu.show({
x: e.pageX,
y: e.pageY,
items: [
{title: "Open note in a new tab", command: "openNoteInNewTab", uiIcon: "empty"},
{title: "Open note in a new split", command: "openNoteInNewSplit", uiIcon: "dock-right"},
{title: "Open note in a new window", command: "openNoteInNewWindow", uiIcon: "window-open"}
],
selectMenuItemHandler: ({command}) => {
if (command === 'openNoteInNewTab') {
appContext.tabManager.openTabWithNoteWithHoisting(notePath);
}
else if (command === 'openNoteInNewSplit') {
const subContexts = appContext.tabManager.getActiveContext().getSubContexts();
const {ntxId} = subContexts[subContexts.length - 1];
appContext.triggerCommand("openNewNoteSplit", {ntxId, notePath});
}
else if (command === 'openNoteInNewWindow') {
appContext.triggerCommand('openInWindow', {notePath, hoistedNoteId: 'root'});
}
}
});
}
export default {
openContextMenu
}