Yes, you can position a note to point to an arrow or be beside an arrow in Mermaid. To achieve this, you need to give the arrow (or the connection between nodes) an ID, and then reference that ID in your note. Here's how you can do it:
Pointing to an Arrow
To point a note to an arrow, you can use the note keyword followed by the direction and then reference the connection ID. Here's an example:
graph LR
A[Start] -->|id1|> B{Decision}
note "Note about id1" below id1
In this example, id1 is the ID given to the connection between A and B, and the note is placed below this connection.
Beside an Arrow
To place a note beside an arrow, you can use a similar approach but specify the direction relative to the connection ID. For example:
graph LR
A[Start] -->|id1|> B{Decision}
note "Note beside id1" right of id1
This will place the note to the right of the connection id1.
Pointing to a Specific Part of the Arrow
If you want the note to point to a specific part of the arrow (like the middle), you can use the note keyword without specifying a node or connection ID, and Mermaid will automatically place the note near the last defined element (which could be an arrow). However, for precise control over the note's position relative to an arrow, using connection IDs as shown above is more reliable.
Example with Multiple Notes
Here's an example with multiple notes positioned around an arrow:
graph LR
A[Start] -->|id1|> B{Decision}
note "Above" above id1
note "Below" below id1
note "Left" left of id1
note "Right" right of id1
This will place notes above, below, to the left, and to the right of the connection id1, giving you flexibility in how you annotate your diagrams.