Open PhilGarb opened 9 months ago
If the main use case of XML shared types is in rich text editors that interface directly with YJS, then I don't see much value creating a separate valtio API. Just expose the YJS shared type as-is.
However, if there is a need to subscribe to XML changes outside the editor then we can design around that use case.
For us the main issue steams from the xml type being part of a larger doc and therefore deeply nested. I agree that it is possible to work with the yDoc directly, but that means no types and a different way to access things. A situation where you might want to subscribe to the xmlfragment could be something like a markdown editor with a preview.
I think a good first step then is to add the ability to:
store.parent.child.fragment
Subtree subscriptions can be considered separately.
Yes. The access and subscription are the important ones. I haven't even thought about nested subscriptions. Do you want me to submit a PR with a proposal? I have a naive prototype running.
I don't actually use XmlFragment in my app, so I'll leave that up to you and @dai-shi. I'm just interested in this integration and in the YJS ecosystem in general.
Problem
One of the main values of valtio-yjs is the ability to have a more natural way to interact with the underlying yjs doc. Currently this only extends to array and map. It would be great to have support for other yjs types as well. Currently these are converted to strings, because that is what the internal
anyXmlFragment.toJSON()
does.Proposal
All the xml types should not be converted internally and be just exposed as they are, because the string is useless for their intended purpose: rich-text-editors. I have a prototype of this working, but the questions are: