jerosoler / Drawflow

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

Rendering content inside a node #350

Closed mcesaro closed 2 years ago

mcesaro commented 2 years ago

Hi Jero, I was wondering if it would be possible to controlling render the content of a div or another kind of control inside a Drawflow node. In my example, I'd like to store inside the df- data a JSON object that is derived from the content of one ore more input fields. I actually can do that with updateNodeDataFromId. However, if the input field is, for example, a text area it would be good to represent the content with a text that it's not necessarily the JSON.stringify of the object, but something else (like "JSON blob"). Do you think it would be possible to do that with Drawflow?

Thanks, Massimo

jerosoler commented 2 years ago

If it would be possible. Using an extra field in the node.

You can use the nodecreated or import events to transform the df attribute and render-it.

And as you comment update with updateNodeDataFromId.

mcesaro commented 2 years ago

Hi, so I created a -meta data attribute and stored the SON array with the node data using updateNodeDataFromId.

Then I leave the rendering of the content to a functions that returns the value of the input field. Works for me! Thank you Jero