[Quill][Bug] - Delta merging happens when not desired.
Closed this issue · 1 comments
We're seeing some cases where serializing separate DocumentNode
s to deltas results in multiple nodes being merged into single deltas when they should be separate deltas.
The merging action happens at the delta level - the originating DocumentNode
s are irrelevant.
Reproduction deltas
Start with a serialized delta:
{
"insert": "This paragraph is above the styled one:\n"
}
Then add another delta by executing TextBlockDeltaSerializer.serialize(node, deltas)
, which produces an intermediate delta like the following:
{
"insert": "This is a block styled paragraph.",
"attributes": {
"banner-color": "red"
}
}
Due to the delta merge decision within TextBlockDeltaSerializer
we end up with a final single delta:
{
"insert": "This paragraph is above the styled one:\nThis is a block styled paragraph.",
"attributes": {
"banner-color": "red"
}
}
What we want to end up with is:
{
"insert": "This paragraph is above the styled one:\n"
},
{
"insert": "This is a block styled paragraph.",
"attributes": {
"banner-color": "red"
}
}
I think this issue was wrong.
In the original description I said that the following was a bad merge:
{
"insert": "This paragraph is above the styled one:\nThis is a block styled paragraph.",
"attributes": {
"banner-color": "red"
}
}
I think this is actually a correct merge. If I remember correctly, Quill Deltas don't blindly apply attributes to all text in the insert
. Instead, every newline creates a barrier, even when the newline is in the same Delta. Therefore, when this Delta is processed, the first line gets a paragraph, and no attributes are applied. Then, the second line gets a paragraph, and the attributes are applied to that second paragraph. This results in the desired output.
Closing the issue.