jupyter_ydoc icon indicating copy to clipboard operation
jupyter_ydoc copied to clipboard

Y bridge between YDocs

Open davidbrochart opened this issue 2 years ago • 1 comments

Problem

One document may have different YDoc structures, e.g. a Jupyter notebook can be opened in JupyterLab as a notebook (and it will be shown nicely with cells etc.) or as a plain text document. While the text document has a relatively simple YDoc, with only a YText for the whole content, the notebook has a YArray for cells, a YMap for metadata, etc. This finer-grained structure allows to observe changes to e.g. a cell source only, and react accordingly. While a YDoc can be synced with another YDoc of the same structure, for instance between two browsers showing the same notebook, the same document cannot be synced when opened as two different YDocs (e.g. in text/as a notebook) in the same JupyterLab.

Proposed Solution

We could create a "Y bridge", that would make syncing the two "incompatible" YDocs possible. Something that observes changes to a YDoc and translates them to the other. It will require some interpretation, e.g. when changing the cell source in a text document, we need to do the update in the appropriate cell structure in a notebook.

cc @dmonad @hbcarlos

Additional context

See https://github.com/jupyterlab/jupyterlab/pull/12360#discussion_r869224163.

davidbrochart avatar May 10 '22 14:05 davidbrochart