mermaid icon indicating copy to clipboard operation
mermaid copied to clipboard

Programmatically interacting with Mermaid diagrams

Open abelardolg opened this issue 2 years ago • 5 comments

Hi there. I wonder if there is any way to interact with Mermaid diagrams by clicking over them. My goal is clear: I would like to programmatically generate a state diagram according to states stored inside my database. Each time I click on a state, I would like to send a post request to my Symfony controller to act according to that click and show an appropriate web page and dinamically stylize that state with a CSS style. Thanks.

abelardolg avatar Jul 18 '22 14:07 abelardolg

State diagram doesn't support interaction right now.

https://mermaid-js.github.io/mermaid/#/classDiagram?id=interaction

PRs are welcome to add support.

sidharthv96 avatar Oct 08 '22 11:10 sidharthv96

Hi @sidharthv96 :wave: I would be happy to try but first wanna know why it's not supported. Is there some super difficult parsing problem or you just didn't have time for it yet?

yurtsiv avatar Oct 08 '22 21:10 yurtsiv

@yurtsiv The state diagram was added a while back, I wasn't involved during that time.

But I think interaction support was simply not added. It should be relatively straightforward to refer flowchart/classdiagram code to add support.

You'll mainly have to make changes in the jison file, db and renderer. (I think)

sidharthv96 avatar Oct 09 '22 02:10 sidharthv96

Related https://github.com/mermaid-js/mermaid/issues/1139

sidharthv96 avatar Oct 09 '22 12:10 sidharthv96

I'll try to tackle this

yurtsiv avatar Oct 09 '22 18:10 yurtsiv

Closing as Duplicate of #1139

jgreywolf avatar Jan 26 '23 18:01 jgreywolf