Correct way to implement Version History like google doc

We use y-websocket and y-leveldb to implement a collaborative documentation tool, now we are trying to implement the Version History like google doc which groups the changes by the user.

I think we should use the ydoc.on('update') callback in the backend to record every update and implement logic to generate the Version History.

Just want to know what is the best way to do this in the backend.

1 Like

Yjs currently has an experimental feature: Y.PermanentUserData, which can be used to meet the above requirements.

However, since it is currently in the experimental stage and the author said that it will provide a better implementation in the future, it is recommended to refer to its implementation and introduce it carefully in production.

Reference resources:

2 Likes

Thanks @jarone, actually I was saying to build the Google doc Version History.

But as you mentioned PermanentUserData, I checked the prosemirror-versions demo, I have a question about it, seems PermanentUserData uses the clientID to map the user name, if the clientID is changed for the same user, as PermanentUserData doesn’t persist the old clientID/Name mapping to somewhere, then PermanentUserData will lose the clientID/Name mapping on the old changes(if server or client all flush/reboot), when you check old snapshot and see who did the changes, it will show Unknown user.

I think we should persist the Client/Name mapping data that for PermanentUserData? ideally, also make sure each user has a unique clientID and never change?

I think clientID refers to a specific instance of Y.js rather than the user. So it’s expected to randomly change. The naming is confusing because it doesn’t refer to the user, but one particular session.

See here: