Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
right context menu on note map
zadamfdb7b7721d74
diff --git a/bin/better-sqlite3/win-better_sqlite3.node b/bin/better-sqlite3/win-better_sqlite3.nodeindex 2af4650dc8..1cb25caa38 100644Binary files a/bin/better-sqlite3/win-better_sqlite3.node and b/bin/better-sqlite3/win-better_sqlite3.node differdiff --git a/src/public/app/services/link.js b/src/public/app/services/link.jsindex 207c1a7e1c..688fe79d5a 100644--- a/src/public/app/services/link.js+++ b/src/public/app/services/link.js@@ -1,5 +1,5 @@import treeService from './tree.js';-import contextMenu from "./context_menu.js";+import linkContextMenuService from "./link_context_menu.js";import appContext from "./app_context.js";import froca from "./froca.js";import utils from "./utils.js";@@ -128,29 +128,7 @@ function linkContextMenu(e) {e.preventDefault();- 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'});- }- }- });+ linkContextMenuService.openContextMenu(notePath, e);}async function loadReferenceLinkTitle(noteId, $el) {diff --git a/src/public/app/services/link_context_menu.js b/src/public/app/services/link_context_menu.jsnew file mode 100644index 0000000000..6c1e972cc7--- /dev/null+++ b/src/public/app/services/link_context_menu.js@@ -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+}diff --git a/src/public/app/widgets/note_map.js b/src/public/app/widgets/note_map.jsindex 8fc03283be..f147e2bfaa 100644--- a/src/public/app/widgets/note_map.js+++ b/src/public/app/widgets/note_map.js@@ -4,6 +4,7 @@ import attributeService from "../services/attributes.js";import hoistedNoteService from "../services/hoisted_note.js";import appContext from "../services/app_context.js";import NoteContextAwareWidget from "./note_context_aware_widget.js";+import linkContextMenuService from "../services/link_context_menu.js";const TPL = `<div class="note-map-widget" style="position: relative;"><style>@@ -106,7 +107,8 @@ export default class NoteMapWidget extends NoteContextAwareWidget {.linkDirectionalArrowRelPos(1).linkWidth(1).linkColor(() => this.css.mutedTextColor)- .onNodeClick(node => appContext.tabManager.getActiveContext().setNote(node.id));+ .onNodeClick(node => appContext.tabManager.getActiveContext().setNote(node.id))+ .onNodeRightClick((node, e) => linkContextMenuService.openContextMenu(node.id, e));if (this.mapType === 'link') {this.graph