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
|
|
|
|
2023-04-03 23:47:24 +02:00
|
|
|
function openContextMenu(notePath, e, viewScope = {}, hoistedNoteId = null) {
|
2021-09-24 21:40:02 +02:00
|
|
|
contextMenu.show({
|
|
|
|
x: e.pageX,
|
|
|
|
y: e.pageY,
|
|
|
|
items: [
|
2024-11-20 01:45:36 +02:00
|
|
|
{title: "Open note in a new tab", command: "openNoteInNewTab", uiIcon: "bx bx-link-external"},
|
2022-05-31 22:45:57 +02:00
|
|
|
{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}) => {
|
2022-12-18 22:05:06 +01:00
|
|
|
if (!hoistedNoteId) {
|
|
|
|
hoistedNoteId = appContext.tabManager.getActiveContext().hoistedNoteId;
|
|
|
|
}
|
|
|
|
|
2021-09-24 21:40:02 +02:00
|
|
|
if (command === 'openNoteInNewTab') {
|
2023-04-03 23:47:24 +02:00
|
|
|
appContext.tabManager.openContextWithNote(notePath, { hoistedNoteId, viewScope });
|
2021-09-24 21:40:02 +02:00
|
|
|
}
|
|
|
|
else if (command === 'openNoteInNewSplit') {
|
|
|
|
const subContexts = appContext.tabManager.getActiveContext().getSubContexts();
|
|
|
|
const {ntxId} = subContexts[subContexts.length - 1];
|
|
|
|
|
2023-04-03 23:47:24 +02:00
|
|
|
appContext.triggerCommand("openNewNoteSplit", {ntxId, notePath, hoistedNoteId, viewScope});
|
2021-09-24 21:40:02 +02:00
|
|
|
}
|
|
|
|
else if (command === 'openNoteInNewWindow') {
|
2023-04-03 23:47:24 +02:00
|
|
|
appContext.triggerCommand('openInWindow', {notePath, hoistedNoteId, viewScope});
|
2021-09-24 21:40:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
openContextMenu
|
|
|
|
}
|