ycs icon indicating copy to clipboard operation
ycs copied to clipboard

Yjs subdocuments guids do not match after applying an update from Ycs document

Open yarkoe opened this issue 3 years ago • 1 comments

Describe the bug Applying update from Ycs documents with subdocuments on Yjs documents generate new subdocuments guids.

To Reproduce Steps to reproduce the behavior:

  1. With Ycs create a new root document.
  2. With Ycs create some subdocuments and add them to the root document.
  3. Apply update from Ycs root document to Yjs document.

For example:

// C# code

var document = new YDoc();
var subDoc1 = new YDoc(new YDocOptions(){Guid = "subdoc1"});
var subDoc2 = new YDoc(new YDocOptions(){Guid = "subdoc2"});
document.GetMap("subdocs").Set("subdoc1", subDoc1);
document.GetMap("subdocs").Set("subdoc2", subDoc2);
byte[] update = document.EncodeStateAsUpdateV2();

// send this update to Node.js (e. g. with Convert.FromBase64String())
// JavaScript code

const document = new Y.Doc()
Y.applyUpdateV2(document, updateFromYcs)

Expected behavior Ycs subdocuments guids the same as Yjs subdocuments guids.

Screenshots Yjs document state after applying: image

Environment Information

  • Node.js (v14.16.0)
  • yjs (v13.4.14)

Additional context Applying an update from a Yjs document with subdocuments to a Ycs document keeps guids as expected. Applying an update from a Ycs document with subdocuments to the new Ycs document keeps guids as expected too.

yarkoe avatar Mar 31 '21 12:03 yarkoe

Working on the fix.

aleksk avatar Apr 12 '21 21:04 aleksk