robin1liu / vue-mermaid

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

Empty text in node has mermaid crashing #27

Open lc-thomas opened 3 years ago

lc-thomas commented 3 years ago

My application allows users to create nodes, links them together, edit them, etc.

But when the text of a node is empty, then mermaid crashes. So to avoid that, I edited the buildNode(item) method as such (see end of the method) :

    buildNode(item) {
      let edge = !item.edgeType
        ? this.edges.find(e => {
            return e.type === "default";
          })
        : this.edges.find(e => {
            return e.type === item.edgeType;
          });
      let text = item.text != '' ? item.text : ' - '
      return `${item.id}${edge.open}${text}${edge.close}`;
    },

Maybe it could be nice to add something like that in your library to prevent crashes ?