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
The issue is that during upcast we use data.modelRange which holds the range over the just-inserted elements so the converter knows where to operate. In attribute upcast though, the range that is set there is incorrectly used/interpreted.
function_setAttributeOn(modelRange,modelAttribute,conversionApi){letresult=false;// Set attribute on each item in range according to Schema.for(constnodeofArray.from(modelRange.getItems())){if(conversionApi.schema.checkAttribute(node,modelAttribute.key)){conversionApi.writer.setAttribute(modelAttribute.key,modelAttribute.value,node);result=true;}}returnresult;}
This function sets attributes on passed modelRange. The thing is that for elements, the range is like this: [<div>...</div>] not like this: [<div>]...</div>. So, in the given example, the range to set attribute border on is [0] - [1] instead of [0] - [0,0]. This means that all elements inside will also have that attribute set.
There are two solutions here: either we change _setAttributeOn function to work correctly for such ranges (changing in the loop to .getItems( { shallow: true } ) should be enough). Or we change what data.modelRange is generated for elements during conversion. I think that the first fix is probably safer.
BTW. we didn't notice that bug before because we don't have any element that can contain itself. So, whenever we set an attribute on an element it was not allowed on any of its children, so it worked.
The text was updated successfully, but these errors were encountered:
Originally reported on SO: https://stackoverflow.com/questions/50992491/ckeditor5-prevent-nested-same-type-elements-from-automatically-inheriting-paren
The issue is that during upcast we use
data.modelRange
which holds the range over the just-inserted elements so the converter knows where to operate. In attribute upcast though, the range that is set there is incorrectly used/interpreted.This function sets attributes on passed
modelRange
. The thing is that for elements, the range is like this:[<div>...</div>]
not like this:[<div>]...</div>
. So, in the given example, the range to set attributeborder
on is[0] - [1]
instead of[0] - [0,0]
. This means that all elements inside will also have that attribute set.There are two solutions here: either we change
_setAttributeOn
function to work correctly for such ranges (changing in the loop to.getItems( { shallow: true } )
should be enough). Or we change whatdata.modelRange
is generated for elements during conversion. I think that the first fix is probably safer.BTW. we didn't notice that bug before because we don't have any element that can contain itself. So, whenever we set an attribute on an element it was not allowed on any of its children, so it worked.
The text was updated successfully, but these errors were encountered: