Block filler recognition is incorrect when converting from DOM to view #9345
Labels
package:engine
squad:collaboration
Issue to be handled by the Collaboration team.
type:bug
This issue reports a buggy (incorrect) behavior.
Milestone
📝 Provide detailed reproduction steps (if any)
Filler element
is not correctly removed when it was placed after<br />
and the data is loaded.editor.setData( '<p>A<br></p>' )
or prepare such content in the editor.editor.getData()
->'<p>A<br> </p>'
-> this is fine, filler is needed.editor.setData( '<p>A<br> </p>' )
✔️ Expected result
There is no space in the editor (in the model).
❌ Actual result
The filler
has not been removed and has been added as a space to the model.What is wrong
Block filler element is not recognised properly. We have a mechanism that should remove this
when it was converted from DOM to view but the mechanism didn't work.We should start from looking at the method that adds the filler. For a container element it is:
As you can see, there is some logic here, but tl;dr - the filler is added at the end of the element if there are no or only UI elements in the container or if there is
<br>
at the end of the container.Actually, different types of elements have different rules for that. And AFAIK, it is possible to set a custom behavior.
The logic presented above is not reflected in the function that tries to recognise and remove fillers. It looks like this:
As you can see, the logic here is simpler, it just checks if this is an
in an empty element. It is not compatible withgetFillerOffset()
for container elements and it would get outdated again ifgetFillerOffset()
changes.Solutions
Quick solution - simply fixisNbspBlockFiller()
to be more compatible with current implementation ofgetFillerOffset(
). Since UI elements are most of the time (always?) not rendered in the data pipeline, we could just expand the check inisNbspBlockFiller()
to also include a scenario when
is after<br>
. This should cover most of the cases and is very small effort.Unfortunately, marker elements are UI elements, so
s are inserted into elements that have only a marker (suggestions).Good solution - change the flow of block fillers removing. Instead of skipping them when traversing converted DOM tree, convert them to view. Then usegetFillerOffset()
of the view elements and remove fillers from the view layer. This requires more effort and may result in some bugs.And in this case we cannot do that because during upcast we don't have "semantic" view elements (attribute element, container element, etc.) so we cannot check
getFillerOffset()
.The text was updated successfully, but these errors were encountered: