jerosoler / Drawflow

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

how to store the created connection label text #678

Closed Gsmraaj closed 1 year ago

Gsmraaj commented 1 year ago
hi sir, thank you so much for you to creating this wonderful library which is very useful to do my college project
, i found a way to use the connection label text , 
but i dont know how to store it like below , 

      outputs: {
        output_1: {
          connections: [
            {
              node: "2",
              output: "input_1",
              conLabelTxt: "something"
            },
            {
              node: "3",
              output: "input_1",
              conLabelTxt: "something"
            },
          ],
        },
      },

      for (let nodeId in dataToImport.drawflow.Home.data) {
     let node = dataToImport.drawflow.Home.data[nodeId];
     let outputKeys = Object.keys(node.outputs);
       for (let i = 0; i < outputKeys.length; i++) {
        let outputKey = outputKeys[i];
       let connections = node.outputs[outputKey].connections;
       for (let j = 0; j < connections.length; j++) {
        let connection = connections[j];

  let conLabel = document.querySelector(
    `.connection.node_in_node-${connection.node}.node_out_node-${node.id}.output_1.input_1`
  );

  if (connection.conLabelTxt !== undefined) {
    addLabelText(conLabel, `${connection.conLabelTxt}`);
  }
}

} }

jerosoler commented 1 year ago

You can save to the drawflow's JSON by following the example below

Gsmraaj commented 1 year ago

editor.drawflow.drawflow.Home.data[ conOpId ].outputs.output_1.connections.find( (connection) => connection.node === conIpId ).conLabelTxt = "${successMsg.value}";

thanks sir it worked