Introduce Mermaid on_node_click
using a no-markdown solution
#4871
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This PR introduces another alternative way of adding node click events to Mermaid diagrams without use of the global
emitEvent
.The method was first raised in #4845 and demonstrated in #4862. This implementation differs to the previous working demonstration by ensuring the rendering queue is included as per #4852 and #4853.
Implementation
This approach bypasses Mermaid's own
click
event methods - the adding ofclick <nodeName> call <func(params)>
to the markdown - by attaching a handler directing to the node DOM elements. The method utilizesquerySelectorAll
to identify the nodes within each diagram based on html tag and class names.Progress
The Pros, Cons, and Inbetweens
Pros
Cons
Inbetweens
The Extra Functionality
Mermaid click events still work
Because no changes are made to the markdown or the Mermaid click definitions, they still work with existing methods and as per the Mermaid documentation.
You can reference the nodes in the DOM directly
Because we have the node html id (and not just the node name) we can reference it directly and make changes.