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
There probably are a couple workarounds for this issue but it seems odd that deleting text would result in a retain signaling a change to content that didn't actually change. Is there any reason to structure the YEvents this way?
From debugging the issue it seems when we're creating the YTextEvent, when we process the first deleted ContentFormat, we set the attribute to null in attributes but we don't remove it when processing the second deleted ContentFormat. This is around
@dmonad I put up a potential fix in #530 and interested in your thoughts. If I understand correctly embedded types aren't subject to formatting so it makes sense to entirely skip setting retain attributes if the retain describes an embedded type. The one downside I see is that this fix will increase the number of retains in certain circumstances. Let me know if you think there are any alternatives worth considering
If I understand correctly embedded types aren't subject to formatting so it makes sense to entirely skip setting retain attributes
This was not a good assumption! Embedded types (like XmlText as a child of XmlText) are subject to formatting and that formatting is separate from attributes directly on the XmlText (XmlText#setAttributes).
I was in fact running into a Slate Yjs issue where
Describe the bug
Deleting text can lead to a YEvent which includes an extra attribute update
To Reproduce
Steps to reproduce the behavior:
Or in code:
Expected behavior
Expect to observe an event with a delta that has one delete with a length equal to however long the text was.
Actual behavior
For some reason the event includes a retain that tries to null out the formatting attribute on the embedded XmlText
Environment Information
Additional context
Ran into this problem while using Slate Yjs, which turns the retain into set_node Slate operation over here: https://github.com/BitPhinix/slate-yjs/blob/966b9325ff312058023d017f857fbb6ac9a7a8a4/packages/core/src/applyToSlate/textEvent.ts#L88. This then tries to update the representation of the paragraph in Slate based on formatting attributes that the text had, which doesn't really make sense and leads to an invalid state.
There probably are a couple workarounds for this issue but it seems odd that deleting text would result in a retain signaling a change to content that didn't actually change. Is there any reason to structure the YEvents this way?
From debugging the issue it seems when we're creating the YTextEvent, when we process the first deleted ContentFormat, we set the attribute to null in
attributes
but we don't remove it when processing the second deleted ContentFormat. This is aroundyjs/src/types/YText.js
Lines 718 to 727 in e0a2f11
The text was updated successfully, but these errors were encountered: