Global document undo manager

The structure of the Y.Doc is static and well defined, I just want a mechanism to reset the document to a previous state, which is agnostic to the document. To give some context, I’m working on this suggestion system, where a fork of a document is created. If the suggestions are not merged back to the root document, I want to reset the document to its pre-fork state.
Thanks for the solution, I’ll try that. I’m wondering if that will work with nested shared types? Also, do shared types support multiple undo managers at the same time?