I’m trying to add a menu item to the context menu that shows when a user right-clicks on a Canvas edge and one when the user right-clicks on a Canvas node (that’s not a file node). The Obsidian.d.ts file shows the list of available events my plugin can subscribe to. None of these options are dispatched when the user right-clicks on an edge or a non-file node.
Is it possible to add menu items to the canvas menu?
Example use case:
I’m working on the Semantic Canvas plugin and would like to make the following possible:
Right click on an edge & have a menu option to delete the corresponding property from notes that link to the edge.
Right click on a node & have a menu option to pull properties from that node to the canvas
The Advanced Canvas plugin is editing the pop-up menu to include options there, which is similar, but doesn’t use Obsidian’s events API, instead using its own custom event handling logic that’s way more involved (and impressive, admittedly).
I may be looking in the wrong place, but I’m not seeing mention of “Canvas” anywhere in the link you sent. The snippet of code referencing canvas:edge-menu doesn’t work for me, unfortunately. There just isn’t a “canvas:edge-menu” option - or any “canvas” options for that matter.
HOLY CATS! That’s perfect! I have no idea how you knew to use “canvas:edge-menu”, as that’s not in the d.ts file that I’m seeing, but it works! Thank you The_Tree!
Adding a menu item in editor is to use workspace.on("editor-menu"), so I guess adding a menu item of canvas edge is similar. Then I tried to search edge-menu in app.js (obsidian’s source code in devtools)