Create son/brother from graph view

Imagine this:

  • When you right-click on any note in the graph view, you can choose to create a child or a sibling for the selected note.

  • There are also two hot-keys that allow you to create a child or a sibling for the current note you are working on in the workspace.

This plugin would be very useful for building linked clusters easily. You just need to set a template for the child and a template for the sibling

The Breadcrumbs plugin enables relationships like those but I don’t think it has this graph feature. You might post this as a feature request on the Breadcrumbs GitHub — altho as I understand it the graph isn’t very open to modification (but maybe context menus for the graph are a different matter).

1 Like

I am new to the world of Obsidan in general and new to the world of Obsidan plugins development, for a week now I have been messing around with the Obsidan plugin API , I’m now working on my plugin there is little left to publish it, but so far I have no information about modifying context menus.

@lorens

idea

Since it is “graph” view, not sure what does “son” or “brother” means, which is concept for “tree”, anyway, based on my understanding, implement below, hope it helps for reference, enjoy coding :slight_smile:

  1. create context menu as selecting file in the graph view
  2. add new file linked with the selected file

code

based sample plugin in onload of plugin, add follow code

		this.registerEvent(
			this.app.workspace.on("file-menu", (menu, file) => {
			  menu.addItem((item) => {
				item
					.setTitle("Add sibling")
					.setIcon("document")
					.onClick(async () => {
						this.app.vault.create(file.parent?.path + "/" + file.name+ ".sibling.md", "[["+file.name+"]]");
						new Notice("Add sibling "+ file.name+ ".sibling.md" +" for "+ file.path);
					});
			  });
			})
		  );

video

Screen Recording 2024-01-07 at 17.31.15.zip (3.3 MB)

Reference

WOW, Your code snippet is absolutely fantastic! It’s exactly what I was looking for, I especially appreciate the video and taking the time to help me out, especially with such a clear and concise explanation. It saved me a lot of time and frustration!.

Thank you again for your help!