zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.22k stars 1.91k forks source link

(Feature request) Better support for linking notes from Mermaid diagrams #2363

Open agentydragon opened 2 years ago

agentydragon commented 2 years ago

Preflight Checklist

Describe feature

It would be useful to be able to insert a link to another page into Mermaid diagrams.

I found https://stackoverflow.com/questions/41960529/how-to-add-a-link-in-a-mermaid-node-description which shows how to do this for a known URL.

When I put in a link like <a class="reference-link" href="#root/e8FRQGiaShTV/tOx3SD2xhSIK/uiw7MoVcd06W" data-note-path="root/e8FRQGiaShTV/tOx3SD2xhSIK/uiw7MoVcd06W">Rust</a>, it renders correctly:

image

Code:

graph TD; 
A[hello]
B[a <a class='reference-link' href='#root/e8FRQGiaShTV/tOx3SD2xhSIK/uiw7MoVcd06W' data-note-path='root/e8FRQGiaShTV/tOx3SD2xhSIK/uiw7MoVcd06W'>Rust</a>]
A-->B

You just have to replace quotes with apostrophes for some reason. Also I had to copy that link from a HTML note, and I'm not sure if it needs to get updated if the linked page gets moved.

It would be nice to have a button (or some other user-friendly tool) to create these links in Mermaid diagrams. (And to double-check they work well in the presence of pages getting moved.)

(I used to use links in diagrams in Roam Research a bunch.)

Additional Information

No response

Lightirius commented 1 year ago

That link can be easily created from Note ID on "Note Info" tab, but support for drag-and-drop into mermaid editor will be great <a class='reference-link' href='root/**Note ID**' data-note-path='root/**Note ID**'></a> Links like that work at least on desktop Trilium 0.57.5

Ivan-Igorevich commented 1 year ago

probably, not a d'n'd behavior, but common linking behavior by typing @

meichthys commented 1 year ago

Manually adding the NoteID works, but remember, you need to use the full note id as described here if your note is nested.

kkzhang commented 10 months ago

a simple way to add note on mermaid node, and can dynamic reflect note change would be very awesome