Posted 23 August 2024, 7:12 am EST
Hi team,
Is there any way to allow us to remove just some actions in undoStack? In documentation, there is only method clear() to clear undo & redo stack.
Thank you!
Forums Home / Spread / SpreadJS
Posted by: trankhanhngan00 on 23 August 2024, 7:12 am EST
Posted 23 August 2024, 7:12 am EST
Hi team,
Is there any way to allow us to remove just some actions in undoStack? In documentation, there is only method clear() to clear undo & redo stack.
Thank you!
Posted 26 August 2024, 4:56 am EST
Hi,
As per my understanding, you want to remove an operation from the undo stack.
Currently, this isn’t directly supported. However, you can prevent an operation from being added to the undo stack by setting the canUndo property to false. Here’s an example where I made the setting cell value and drag-and-drop operations non-undoable: https://jscodemine.mescius.io/share/Hkc_BKm0tE2PKcKtlK-KyA/?defaultOpen={“OpenedFileName”%3A[“%2Findex.html”]%2C"ActiveFile"%3A"%2Findex.html"}
If you’re performing operations through the API, like using the setValue method, you don’t need to worry about the undo stack, as API operations aren’t added to it. However, if you’re using commands via the execute method of the command manager, those operations will be added to the undo stack. But you can use the command in a different way to prevent it from being added to the undo stack. For more details, you can check out this forum discussion: https://developer.mescius.com/forums/spreadjs/pause-not-disable-undo-history
Regards,
Priyam
Posted 26 August 2024, 5:54 am EST
Hi Priyam,
Thanks for this solution, that helps us to disable undoing some actions!
However, we have another problem that we can’t find the command for addSheet action
spread.addSheet(index, newSheet)
Posted 27 August 2024, 8:14 am EST
Hi,
I understand that you want the insert sheet operation to support undo/redo functionality.
This behavior is by design and is consistent with how Excel operates. Unfortunately, there is no effective workaround available to meet this requirement at the moment.
Regards,
Priyam
Posted 27 August 2024, 10:44 pm EST
Hi Priyam, I got it. Thanks for your reply.