asokolov
May 19, 2021Brass Contributor
Status:
New
Implement some kind of UndoRecord class in office-js for Office Word
I have a Word add-in that needs to do some manipulation on the document and be able to undo them with one click on the undo button. In the VSTO add-in version, I am using the https://docs.microsoft.c...
ErnstScheithauer
Dec 13, 2022Brass Contributor
Hello Yun,
maybe I can jump in here. We also use the UndoRecord class in our VSTO Add-In - quite a lot actually. There are two main things we achived with that:
- Group several manipulations in the COM object model to a single undo line, to prevent the user to go to an intermediate state halfway through that is not valid (e.g. content control is inserted but properties and tag metadata is not set yet)
As I understood our previous Teams conversation this can be achieved differently in JS API because all manipulations in a single Word.run are part of one undo record anyway
The question is now, if there is or should be a possibility to specify a name this undo entry - I think it should - We also used UndoRecords for performance optimizations (really!)
We did a log of changes on content controls in large documents, and if every single change of a title, color or appearance is a separate undo step, then this got very slow. By using an UndoRecord we stopped Word storing a restorable version of the document after every step of the process, which made it extremely slow.
I hope that is not really necessary in JS API 😉
That's what we did with it, does this help you?
Ernst