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 support #151

Closed
iliatimofeev opened this issue Aug 16, 2024 · 3 comments · Fixed by #184
Closed

xml support #151

iliatimofeev opened this issue Aug 16, 2024 · 3 comments · Fixed by #184
Labels
enhancement New feature or request

Comments

@iliatimofeev
Copy link

Problem

I'm working on a Python agent, that needs to edit state of richtext. On js side, I can use y-prosemirror but the document schema is based on YXmlFragment which is not supported by pycrdt.

Proposed Solution

Any plans to support the full range of Yjs types?

export const YXmlElementRefID = 3
export const YXmlFragmentRefID = 4
export const YXmlHookRefID = 5
export const YXmlTextRefID = 6

Additional context

From jupyter-server/team-compass#55 I know that the XML part is not used internally.

Unfortunately, I'm new to Yjs and have zero experience with Rust. I can give it a try under some guidance, but I'm not sure that would be the best solution for the mantainer :)

Maybe someone already did it, and I can use a fork?

@iliatimofeev iliatimofeev added the enhancement New feature or request label Aug 16, 2024
@davidbrochart
Copy link
Collaborator

That would be good to have in pycrdt, but I'm not sure when I can find time to do it. A PR would indeed make it happen sooner.

ColonelThirtyTwo added a commit to ColonelThirtyTwo/pycrdt that referenced this issue Sep 30, 2024
Add bindings to XMLFragment, XMLElement, XMLText, and XMLEvent. Allows
reading and writing of XML fragments from the document, which rich text
editors use heavily.

Closes jupyter-server#151
ColonelThirtyTwo added a commit to ColonelThirtyTwo/pycrdt that referenced this issue Oct 1, 2024
Add bindings to XMLFragment, XMLElement, XMLText, and XMLEvent. Allows
reading and writing of XML fragments from the document, which rich text
editors use heavily.

Closes jupyter-server#151
ColonelThirtyTwo added a commit to ColonelThirtyTwo/pycrdt that referenced this issue Oct 11, 2024
Add bindings to XMLFragment, XMLElement, XMLText, and XMLEvent. Allows
reading and writing of XML fragments from the document, which rich text
editors use heavily.

Closes jupyter-server#151
@joshua-lawrence
Copy link

I'm working on something very similar, also happy to contribute here.

@davidbrochart
Copy link
Collaborator

It looks like we have a PR 🚀

davidbrochart pushed a commit that referenced this issue Oct 19, 2024
* Add support for XML.

Add bindings to XMLFragment, XMLElement, XMLText, and XMLEvent. Allows
reading and writing of XML fragments from the document, which rich text
editors use heavily.

Closes #151

* Add support for formatting and embeds in Text

Rich text editors often store their markup in attributes and embeds.

* Allow apply_update in a transaction

Currently trying to use apply_update in a transaction causes a deadlock,
as apply_update tries to make its own new transaction but is locked out.
This reuses the existing transaction, which also allows applying
multiple updates in a single transaction.

* Add __eq__ and __hash__ to XML types

Allows comparing whether objects refer to the same element in a doc.
Important since every access generates a new, unique Python wrapper
instance.

__eq__ is based directly from the underlying rust objects' `Eq`
implementation. __hash__ is based off of the `Hash` implementation of
the `BranchID` of the rust objects.

* Add XmlText.diff

Like Text, XmlText can contain embedded formatting, so make that
available.

* Mypy and ruff fixes and formatting

* Document XML types

* More lint fixes

* Add XML related tests and fixes for found bugs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants