yTextToSlateElement strips properties from empty text nodes#415
yTextToSlateElement strips properties from empty text nodes#415BrentFarese wants to merge 1 commit intoBitPhinix:mainfrom
Conversation
|
|
@BitPhinix it seems that Maybe we should use something like zero-width space to encode empty text nodes and, then on the way out of YJS, turn them into Is there some way to do empty text nodes in YJS correctly? |
|
I made this trade-off when deciding to "flatten" the slate tree in the yjs representation for better merging characteristics. Since [{text: "a", bold" true}, {text: "b"}, {text:"c", italic: true}] -> Y.XmlText with content "ab Since slate merges empty text nodes by default and treats them as disposable, storing data that isn't for local use on the current selection is an anti-pattern in my eye. In most cases, that state should be handled on the parent element, but I might be overlooking a use case. (Or if that's not possible, it can also be enforced via normalization) |
Here is an example use case we need empty text nodes for This is a simple example there are others where the information loss is more severe/causes weirder bugs. In our case, empty text nodes w/ comment information are being stripped out and it causes a bug in our comments implementation. I think it's completely fine to merge/flatten text nodes w/ the same properties, but not fine to remove all empty text nodes (which is what I am seeing). |
It seems
yTextToSlateElementstrips properties/marks from empty text nodes. This causes issues b/c, when editor.connect is called it sets the output ofyTextToSlateElementtoeditor.childrenhere.Stripping properties from empty text nodes results in information loss and bugs (we are experiencing a bug at Aline).