jerosoler / Drawflow

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

Dynamic output_classes/nodes #778

Open Krintox opened 8 months ago

Krintox commented 8 months ago

Hi @jerosoler , I want to add the output nodes dynamically using a variable which will increase and at the same time the nodes will be added as well, something like this : editor.addNode(nodeId, 1, inputCount, pos_x, pos_y, name, { "channel": 'channel_3', "input-tb[]": [] }, telegrambot);

So when I am trying to fetch the inputCount it is not adding into it. I am using vanilla JS for this. inputCount will change dynamically but still the ouput nodes are not getting updated.

Please suggest some way to do it.

Krintox commented 8 months ago

@jerosoler can you please tell me how to alter the output nodes.

jerosoler commented 8 months ago

Hi!

It has two functions available. AddNodeOutput and removeNodeOutput.

When you detect that your variable is modified, you have to add or remove according to your variable.

View in: https://github.com/jerosoler/Drawflow/tree/master#methods

Krintox commented 8 months ago

Ok, will look into it, thank you so much. Also, when I am adding elements before then its getting updated in the export data fine but when I am adding elements dynamically, it is not exporting that part. Like I have a button clicking on which input elements will be added, but these buttons are not getting exported in the export data JSON. How to add dynamic elements which gets loaded in the DOM later into the library? @jerosoler

jerosoler commented 8 months ago

View for add DOM later:

Krintox commented 8 months ago

When I am importing the flows, it is importing everything but not the connections. The connections are in the exportData but the they are not shown. Only the cards are being shown.Why is it ? THere is no error message also. @jerosoler

jerosoler commented 7 months ago

Review: