jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.65k stars 722 forks source link

Limit drag and drop useage #591

Closed mithunsidd closed 1 year ago

mithunsidd commented 1 year ago

Hi, I have a drag and drop issue, I want to set the to limit number of time able to drag and drop facebook to once

jerosoler commented 1 year ago

Hi! @mithunsidd

Following the example of the demo. The addNodeToDrawflow function, we can modify it like this: Link code demo: https://github.com/jerosoler/Drawflow/blob/master/docs/index.html

  function addNodeToDrawFlow(name, pos_x, pos_y) {
      const drawflowModule = editor.module;
      const nodes = editor.drawflow.drawflow[drawflowModule].data;
      let nodeExist = false;
      for (var key in nodes) {
        if(editor.drawflow.drawflow[drawflowModule].data[key].name === name) {
            nodeExist = true;
        }
      };

      alert(nodeExist);
      ....
}

We can see if there is any module with the same name in the module. Depending on whether or not it exists, you can decide what to do.