Description
Problem
Hey all! I'm wondering if we're missing something about a good way to read nested XmlText
. In essence we have a YDoc
that looks something like
<XmlFragment a="a">
<XmlText b="b">
Shallow
<XmlText c="c">
Deep
</XmlText>
</XmlText>
</XmlFragment>
Although in the general case the data can be nested arbitrarily deeply with multiple children at each level. A third party lib we are using is making these docs so we can't change or simplify the format.
It is possible to create a doc like this using the JS library. Our only goal is to be able to read/write from this sort of format using yrs. Right now it is not possible to read/write this format as far as we can tell because XmlText
does not have children.
Proposed solution
We are working on a PR that implements first_child
on XmlText
(literally on XmlTextRef
) so that we can iterate through these children. For this implementation it seems like we need to iterate over every XmlText
branch node that may contain Map
and one or more SplittableString
entities following it for every child node.
Two questions here:
- Is there a preexisting solution that we're missing?
- Does this seem like the right solution? Will it be mergeable when we finish?
Additional Context
At Dart we use lexical for text editing; lexical comes with existing YJS bindings. Our backend is in Python and we need to manipulate the YDoc
s on the backend so our goal is to be able to parse and create docs following the lexical format. The lexical code is not so well-documented yet but the operating code on their end is here.
For more info check out this post in the ypy lib that has more context including a full example with the YDoc
update bytes, expected data, and code example for JS that demonstrates how to parse docs in this format using the JS lib.