jerosoler / Drawflow

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

Re-render after Import #729

Closed rogereyes86 closed 1 year ago

rogereyes86 commented 1 year ago

Hi, following other questions I was able to implement 2 changes that are working fine:

1- Adjust the connection to be used horizontally. 2- Add and remove a class to the input dot when a connection is successfully made.

So far so good, the problem is when I save the JSON code and then imported it, the following issues occur:

1- The curvature line is a little off the Dots:

image

Moving the Node it fixes it:

image

Is there any way to re-render all curvatures after editor.import(dataToImport)?

Maybe calling this function but not sure how to call it from the edit.drawflow:

image

2- When importing, the class I applied to the input dots is rolled back, any idea how can I reapply this class to each input dot that has a valid connection?:

Before the Import:

image

After the Import (rolled back to his default class):

image

jerosoler commented 1 year ago
  1. Try this comment: https://github.com/jerosoler/Drawflow/issues/371#issuecomment-1061686102
  2. You have to add the class again. You can parse the json file you import to add them back.
rogereyes86 commented 1 year ago

-1 Worked using that comment.

Thanks for your help. Amazing~!

rogereyes86 commented 1 year ago

-2 Working like a charm after Import:

setTimeout(function(){

editor.import(dataToImport);

for (var i = 1, b = Object.keys(dataToImport["drawflow"]["Home"]["data"]).length; i <= b; i++) { for (var x = 1, c = Object.keys(dataToImport["drawflow"]["Home"]["data"][i]["inputs"]).length; x <= c; x++) {
if ( Object.keys(dataToImport["drawflow"]["Home"]["data"][i]["inputs"]["input"+x]["connections"]).length > 0 ) {
document.querySelector('#node-'+i+' .input
'+x).classList.add("filled");
}
} }

}, 1000);

image