Skip to content

nodeClick doesn't work #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lianghuilin opened this issue Jul 11, 2019 · 5 comments
Open

nodeClick doesn't work #3

lianghuilin opened this issue Jul 11, 2019 · 5 comments

Comments

@lianghuilin
Copy link

template code

<div style="width: auto; height: 300px;margin: 200px auto;width: 500px;">
        <vue-mermaid :nodes="data" type="graph LR" @nodeClick="editNode"></vue-mermaid>
</div>

javascript code

import Vue from "vue";
import VueMermaid from "vue-mermaid";

export default {
  name: "FlowPage",
  data() {
    return {
      data: [
        {
          id: "1",
          text: "A",
          link: "---",
          next: ["2"],
          editable: true,
          style: "fill:#f9f,stroke:#333,stroke-width:4px"
        },
        { id: "2", text: "B", edgeType: "circle", next: ["3"] },
        { id: "3", text: "C", next: ["4", "6"] },
        { id: "4", text: "D", link: "-- This is the text ---", next: ["5"] },
        { id: "5", text: "E" },
        { id: "6", text: "F" }
      ]
    };
  },
  methods: {
    editNode(node) {
     // even if i'm bind the edit event,it doesn't work
      console.log("come in", node);
      alert(node);
    }
  }
};
@robin1liu
Copy link
Owner

only the node with 'editable: true' support click event, so make sure it, thx

@Haelenia
Copy link

Hi,
I have the same probleme even with my node having editable: true.
I think it is linked to the security update on mermaid preventing clic action with securityLevel: strict => https://mermaidjs.github.io/#/README
If I switch back to a previous version of mermaid (like 8.0.0) it is working just fine.

@gioppoluca
Copy link

Also for me is not working.
The node is editable, but no event get fired any hint?

@gioppoluca
Copy link

Fixed by adding the config option like this:
merconf: { theme: "default", startOnLoad: false, securityLevel: 'loose' },

Add this to the template:

@via4e
Copy link

via4e commented Oct 25, 2019

Fixed by adding the config option like this:
merconf: { theme: "default", startOnLoad: false, securityLevel: 'loose' },

Thank you, i fix it before with manually edit vue-mermaid.js.
See you comment, andI try again with mermaid config, and see trouble in my syntax. Syntax was fixed and all working now.
Few words to people with same problem. How to fix clicks on nodes.

  1. Generate node object with "editable: true" property

  2. initialize vue-mermaid with binded config defenition
    <vue-mermaid v-bind:nodes="data" type="graph TB" @nodeClick="editNode" v-bind:config="mermaid">

  3. Define config in Data section in your template. Check your config defenition contains securityLevel: 'loose' string
    data: function() {
    return {
    mermaid : {
    theme: "default",
    startOnLoad: !1,
    securityLevel: 'loose'
    }}},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants