You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mermaid.js currently supports clickable links in flowcharts using the click directive:
graph TD
A[Start] --> B[Go to Google]
B --> C[End]
click B "https://google.com" "Visit Google"
However, state diagrams do not support clickable links in the same way.
It would be very useful to have a similar feature for state diagrams, allowing nodes to link to external URLs or trigger JavaScript functions.
Use Case
Making state transition diagrams interactive for documentation, tutorials, and apps.
Example:
stateDiagram
[*] --> Idle
Idle --> Google
Google --> [*]
click Google "https://google.com" "Visit Google"
I looked into how the click directive is implemented in flowcharts and whether we can extend this functionality to state diagrams. Based on the findings, I fully support adding this feature, as it would enhance the interactivity of state diagrams in the same way it does for flowcharts.
Current click Functionality in Flowcharts
In flowcharts, click directives allow nodes to:
Trigger a JavaScript callback function
Open a URL in a new tab (_blank)
Display an optional tooltip
Verified Implementation Details from the Codebase:
1. flowDb.ts
The setClickEvent() function registers clickable nodes, while setClickFun() processes arguments and attaches event listeners.
Proposal
Feature Request
Mermaid.js currently supports clickable links in flowcharts using the
click
directive:However, state diagrams do not support clickable links in the same way.
It would be very useful to have a similar feature for state diagrams, allowing nodes to link to external URLs or trigger JavaScript functions.
Use Case
Making state transition diagrams interactive for documentation, tutorials, and apps.
Example:
This should allow clicking Google to open https://google.com.
Proposed Solution
click
directive support for state diagrams, just like flowcharts.Related Discussions
#6304
Would love to hear thoughts on feasibility!
Example
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: