projectstorm / react-diagrams

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

how do I add extra field to DefaultNodeModel #768

Closed bewithme closed 3 years ago

bewithme commented 3 years ago

how do I add extra field to DefaultNodeModel and make it can be serialized and deserialized ?

sinanyaman95 commented 3 years ago

Option 1: You can override the DefaultNodeModel and add the extra fields you want, in the serialize() and deserialize() methods Option 2: You can use the extras:{} field that is default on DefaultNodeModel and store your extra fields in that as a json object

rzfzr commented 2 years ago

For whatever reason I'm having issues accessing the extra prop after deserialize, are there any examples? I'm using the DefaultNodeModel, tried to add extras as is ports but no success

sinanyaman95 commented 2 years ago

@rzfzr How are you trying to access the extras field?