Save and Apply/Reuse History

I was wondering what is the best way to go about saving the history?

Is there a way to serialise the history from https://prosemirror.net/docs/ref/#history and then reuse it ?

The idea is that I could save the doc someone is working on and all of it’s history with it to the database (JSON and/or HTML) and reinstate it when needed. Call it as a “snapshot” of the document at the time.

Although I am not sure how useful this would be in real life just playing with the idea.

Any thoughts ?

The history plugin could define an external format for history data and expose a toJSON method that serializes it and a fromJSON method that deserializes. You could then use State.toJSON to save a state including its history data.

But this hasn’t been a convincing enough use case so far for anybody to work on it.

Yes. Having thought about it I am not convinced it wouldn’t be all that useful for me either. At first it seemed like a good idea but I can just store the state or the html in my case and this is good enough for now.

I guess if I was using PM collab features than in scenario when two people work on the same document it could be a nice way of seeing what the other person has done / edited out. Perhaps highlighting the bit of document they worked on. If that is even possible …

We need this function.

We hope that users can use the history function at any time when editing their articles, including the historical version.

So we will save this state and restore it to a suitable state at any time.

@marijn