jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
5.32k stars 602 forks source link

How to realize redo and undo? #471

Open cpa0701 opened 2 weeks ago

cpa0701 commented 2 weeks ago

like title ,How to realize redo and undo?do we have to save schemas in every changing?

atlasan commented 1 week ago

Yes, that's correct, seems expensive but actually it's quick (not sure if you how would do with thousands nodes ^_^) The alternative would try to revert a single action but that's complex and some node would need to implement themself to rollback. I had tried an internal implementation that works that way, probably needs some refactoring and fixing but that's the concept, https://github.com/atlasan/litegraph.js/blob/2ebb3fde22e7e7e367eecab11a7a45b38c8f6f70/src/litegraph.js#L154