projectstorm / react-diagrams

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

How can i prevent remove nodes and links ? #705

Closed ppnwt closed 4 years ago

ppnwt commented 4 years ago

I want to prevent remove only nodes and links, except point which i created

example -> i have 2 node and 1 link and i added more 2 points how can i disable each node and this link, but allow remove these points

Anyone can help, Thanks a lot Screenshot from 2020-08-24 14-53-54

renato-bohler commented 4 years ago

You can customize the delete action following this example (link to storybook).

Here, you have access to a list of all selected entities (nodes, links, points). You can implement a filter to call model.remove only on those you want, instead of asking for confirmation.

https://github.com/projectstorm/react-diagrams/blob/655462087f1f54eccb5e75f024be00efda674eab/packages/diagrams-demo-gallery/demos/demo-custom-action/index.tsx#L24-L38