excalidraw / mermaid-to-excalidraw

Generate Excalidraw diagrams from Mermaid
https://mermaid-to-excalidraw.vercel.app
MIT License
265 stars 46 forks source link

fix: trigger mermaid.render only once for each diagram in playground #41

Closed ad1992 closed 10 months ago

ad1992 commented 10 months ago

In mermaid version 10.3.1 an optimisation to mermaid parser was added which makes sure mermaid parses the diagram just once instead of multiple times for each render and that breaks the playground since we pre-render all the mermaid diagrams' parsed json and using that to render diagrams in Excalidraw. More info here. In other words, memaid.render was being called twice for each diagram -> first for rendering mermaid svg and second for getting parsed json via parseMermaid API and the 2nd call was failing and resulting in empty / outdated json due the optimisation and thus breaking the playground.

Hence I am removing that and when the "Render to Excalidraw" button is clicked that time only we parse it and render the active mermaid diagram in excalidraw

I am removing rendering the parsed json as well as that's not needed right now and isn't very useful in playground, user can always console.log if needed for a particular diagram. We can reintroduce later if needed.

Additionally this will make the playground better as well since now we are parsing the active diagram when rendering which makes debugging easier as well for individual testcases(as the parsed json isn't pre-rendered anymore due to which always custom test case had to be used so that its easy to visualize the code flow)

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
mermaid-to-excalidraw ✅ Ready (Inspect) Visit Preview Nov 28, 2023 11:53am