Notes/src/public/app/menus/link_context_menu.js

33 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-09-24 21:40:02 +02:00
import contextMenu from "./context_menu.js";
2022-12-01 13:07:23 +01:00
import appContext from "../components/app_context.js";
2021-09-24 21:40:02 +02:00
function openContextMenu(notePath, e) {
contextMenu.show({
x: e.pageX,
y: e.pageY,
items: [
2022-05-31 22:45:57 +02:00
{title: "Open note in a new tab", command: "openNoteInNewTab", uiIcon: "bx bx-empty"},
{title: "Open note in a new split", command: "openNoteInNewSplit", uiIcon: "bx bx-dock-right"},
{title: "Open note in a new window", command: "openNoteInNewWindow", uiIcon: "bx bx-window-open"}
2021-09-24 21:40:02 +02:00
],
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
}