You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
<XmlFragmenta="a">
<XmlTextb="b">
Shallow
<XmlTextc="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 YDocs 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.
The text was updated successfully, but these errors were encountered:
Maybe the question to begin with should be why are you using nested text elements?
If you want to apply formatting, there're a format/insert_with_attributes methods. If you need to insert non-text contents like images or other Y-types, you can use insert_embed - see the docs for the details. If you need to read the formatted content you can use diff method which returns chunks of formatted text/embeds.
The short answer is that this isn't our data pattern--this is the format that lexical uses to encode its documents (code here). I would much rather use a simpler/more standard pattern if possible but for now I was trying to work with what lexical produces.
If you think that this is not a valid use case for YJS it would be helpful to understand that better and then I suppose I could go to the lexical team to see if we can change things there, although that seems tough.
Between the fact that the JS library permits this pattern and that the lexical team is using it, I figured it was valid.
Problem
Hey all! I'm wondering if we're missing something about a good way to read nested
XmlText
. In essence we have aYDoc
that looks something likeAlthough 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
onXmlText
(literally onXmlTextRef
) so that we can iterate through these children. For this implementation it seems like we need to iterate over everyXmlText
branch node that may containMap
and one or moreSplittableString
entities following it for every child node.Two questions here:
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.The text was updated successfully, but these errors were encountered: