robin1liu / vue-mermaid

flowchart of mermaid with vue component
MIT License
126 stars 25 forks source link

mermaid stops updating after parsing error #5

Closed Udik closed 4 years ago

Udik commented 5 years ago

I'm building a small Vue app that dynamically updates a mermaid graph on user input.

vue-mermaid gets stuck whenever the node input cannot be parsed correctly (for example because a node contains unescaped double quotes). The current graph disappears- which is fine- but the whole component stops updating, whatever the next inputs are.

The only way I've found to solve the issue is to surround in a try-catch block the call to mermaid.init in the load method of vue-mermaid:

load(code) {
        .....
            try {
              mermaid.init(code, container);
            }
            catch(e) {
              console.log("parsing error", e)
            }

I'm failry inexperienced with Vue so I'm not sure if there is an obvious better way to solve this; or, if there isn't, maybe you want to integrate this in your source?

Thanks for the good work!

robin1liu commented 4 years ago

fix it at v0.0.10