Exploring parent and child document with same text content but different marks?

Hello!

For our use case, we are interested in the ability of having a parent document set the text and marks content of a child document, while also allowing the child document to have independent marks that do not get sent to its parent.

For example:

  1. We have the parent document with a substring bolded that is pushed to its child such that both documents are completely identical.
  2. The child document then italicizes any other substring in that document, without making any changes to the parent document.

Parent Document:
This is my parent document with this section bolded.

Child Document:
This is my parent document with this section bolded.

The difference between these two documents is the fact that the substring section bolded is italicized on the child document, but not the parent. However, any additional changes to the parent document are still reflected in the child, including content. \

For example:

(Starting State)
Parent Document:
This is my parent document with this section bolded.

Child Document:
This is my parent document with this section bolded.

(After editing Parent)
Parent Document:
This is my parent document with this section bolded. Here is some newly added text from the parent.

Child Document:
This is my parent document with this section bolded. Here is some newly added text from the parent.


My team is still in the discovery phase, but we are interested in using Tiptap as a resource to provide an AST representation of both documents, and attempt some tree diffing and manipulation to keep these documents in sync in some form.

One thing we have already uncovered is the fact that inline styling changes (such as bolding a substring) changes the amount of nodes represented in each document. As a result, we would need some mechanism to ensure both documents have the most complex node structure.

Any guidance on how to achieve this functionality would be extremely useful, including libraries that would simplify this problem. If anyone has an example that has already accomplished something similar that we can look into would be fantastic!

If the child always has the same text as the parent, and cannot be edited directly, it seems more straightforward to model the child as a list of decorations.