Merging changes from one document into another

You can’t move nodes around in Yjs. Not even within Yjs documents. This feature is not planned for a long time and is tracked in the Yjs discussion board: Moving elements in lists

The best method is to copy a node from one place to another. This can be nicely expressed using events and doesn’t have the drawbacks discussed in the above thread. However, even in this case, you need to implement the copy semantic manually.

Subdocuments might be an interesting solution to your case, because it would allow you to use the same “template” in many different documents and also allow you to basically move a node to a different place.

But you are right, slate doesn’t know how to handle subdocuments.

I think you could implement the approach you described manually. It might be helpful to give every node a unique GUID that maps from template to customized document. But this is not something where Yjs can help.

1 Like