projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.58k stars 1.17k forks source link

How to store custom data inside a Node ? #789

Closed maxtsh closed 3 years ago

maxtsh commented 3 years ago

hello everyone. I have a problem with storing custom data inside a node JSON object which I want to use after serialization.

I added a Modal popup to my node and want to ask my user to give me some information about the flow so I added a state to my node-widget component but How can I pass that data to output serialized data?

renato-bohler commented 3 years ago

I've done this on my project: check PortModel.

Basically, react-diagrams will call yourNodeInstance.serialize() whenever it needs to serialize your node model, and it will call yourNodeInstance.deserialize(event, engine) whenever it needs to deserialize your node model, where event.data is what you returned in serialize.

maxtsh commented 3 years ago

Oh, man thanks. @renato-bohler. I got the point. very cool.