fix: use document GUID as prosemirror reference to avoid updating deleted documents #564
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Store the current prosemirror document in the YDoc under
prosemirror-${guid}instead of the previousprosemirrorkey. A new prosemirror document gets a new GUID, even if it was stored in the same location as where a previous document used to live. This means that if there was an old editor open somewhere, that is editing a document that has since been deleted, these edits are then ignored.The property prosemirror-guids contains an array of GUIDs with timestamps. Only the newest timestamp is active, any older guids on that array are not active any more. This array is often scrubbed, so deleted documents on the same location generally don't appear in the prosemirror-guids at all any more.
When creating a fresh new document in the editor, it creates a new GUID for it, using
crypto.randomUUID()When editing an existing document, the GUID of that document is returned from the HEAD request in the x-da-id header. So we can set that to the prosemirror-${guid} in that case.
Requires adobe/da-collab#88
Requires existing open browser DA editors to be refreshed.
Related Issue
#378
How Has This Been Tested?
Types of changes
Checklist: