Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Yjs-folks!
First of all thanks for this awesome piece of software ❤️ I'm currently working on the integration of a
slate
-based editor into my app, usingslate-yjs
to allow collaborative editing. During testing of the editor I came across an issue, where using falsy attribute values lead to problems within slate-yjs. I found the reason of the problems within slate-yjs however to be caused by this LOC within yjs.To better understand this problem, please picture the following scenario:
I got a document with a YXmlText that looks like the following after calling
.toJSON()
.The YXmlText therefore has the attributes
fontface
andfontsize
, however in this case both are set to an empty string (''
), resulting in the above representation. When I insert any character within that text, passing the same attributes ({fontface: '', fontsize: ''}
),YText#insertAttributes
will drop the falsy attributes, resulting in different attributes for the inserted character, despite me passing in the same attributes as the surrounding text. This then leads to slate-yjs having trouble mapping a slate document node to a YXmlText node, because for one document node there suddenly are multpile YXmlText nodes with differing attributes.This MR fixes this issue, by replacing the logical or operation in the above linked LOC with the nullish coalescing operator. However, I'm unsure if your implementation using the logical or operation is by design. Maybe this operation was chosen to minimize YDoc storage consumption?