File-menu: Can I get link subpath?

The file-menu event is triggered when a file (or folder) is right-clicked in the file navigation menu, but also when right-clicking a link in a note. Imagine I’d have the following link:


Is there a way to get the subpath of the link, i.e. #Heading? If there is not, could it be added to the API?

I’m not certain if it’s possible to do. Looking at the event’s API, the callback get’s the following arguments: menu: Menu, file: TAbstractFile, source: string, leaf?: WorkspaceLeaf

  • menu: The menu object where to add a custom item.
  • file: Contains the linked file’s name and path, but not the subpath of the link.
  • source: Tells where the event happened, i.e. in file navigation, note pane or maybe somewhere else? I don’t know all the places this menu event can occur for sure. Anyway, this doesn’t reveal any details of the actual link.
  • leaf: I guess this is the pane where the right-clicked link is located in. I tried to go through the methods of this object, but didn’t notice anything that could lead me to a currently focused/clicked link.

Thank you for your help! :slightly_smiling_face:

For background information, here’s a related feature request for my Shell commands plugin: file menu new link variable · Discussion #221 · Taitava/obsidian-shellcommands · GitHub . I’d like to be able to develop this feature.

1 Like

+1 for this

1 Like