Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML and Text Support #4

Open
luishdz1010 opened this issue Aug 17, 2022 · 2 comments
Open

XML and Text Support #4

luishdz1010 opened this issue Aug 17, 2022 · 2 comments

Comments

@luishdz1010
Copy link

In my use case I only need to pass through the XML Fragments to different rich text editors, not mutate or read the rendered contents directly. I have many, and they are nested.

Even after customizing applyPatch to pass-trhough the XML and text YJS objects, immer-yjs calls toJSON on the doc instance, which makes the XMLFragment transform into a string.

Furthermore, this string never gets updated because the text events are never listened to.

The other suggested option is keeping the XML fragment objects outside immer. In this case, do you have any suggestions to make these reactive?

SyncedStore does implement all of this, but the mutable/FRP API is not for everyone.

@sep2
Copy link
Owner

sep2 commented Aug 17, 2022

This is a tricky one:

  1. immer itself is not very good at supporting custom classes docs . Which basically means for the writing side of the API, we should not expose XMLFragment class directly, instead, we should map XMLFragments to plain json.

  2. Therefore, we have to find a way to identify which part of the "writing side"(inside immer produce) is a standard json and which part isn't (a fragment). This can be done by the applyPatch option. The same goes for "reading side" (get()/subscribe() to return snapshot) but currently there is no way to configure it.

  3. We should probably add an option for that. But this means we need to give up YMap/YArray.toJSON() and implement it by ourself.

  4. We also need an option to customize the applyYEvents() function to handle events come from yjs side and update snapshot accordingly.

  5. In summary, two more options need to be implemented for supporting embeded XMLFragments.

@sep2
Copy link
Owner

sep2 commented Aug 17, 2022

As for Y.Text, I don't think there is a point to map Y.Text to plain string. If you really want it, you should use the original yjs api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants