Undo/redo independent between different layer

I have a trouble to make undo/redo manager happened only in the scope of each layer. For example, I have two layers A and B. They are mutual for each other, which is to say, only one of them is visible. When undoing, I want to make the scope to be in layer A only if layer A is currently visible but not impact whatever in layer B. Is there any guidance on how to achieve this? Thanks.

-Chuan

Sounds as if you want to use two separate models (each with its own UndoManager), switching between models when switching layers. Or maybe even two separate diagrams.

Yes, I also think that before. Is that that only way I can achieve this goal? It is a little bit hard to refactor my structure now. And also, does copy/paste support between different model/diagram?

-Chuan

Yes, you can copy-and-paste between two diagrams in the same page: Two Diagrams

I don’t know exactly what constraints you have in your app, but another possibility is that you replace the Model.undoManager each time you change layers. One UndoManager per “layer”.

Just know UndoManager is settable. I thought it is read only. Thanks for that. We can refactor our code to use multiple models but it impacts so much. The easiest way is to host a seperated undo manager for each layer. Thanks.

-Chuan