|
|
@@ -735,30 +735,20 @@ export default class Schema {
|
|
|
for ( const node of nodes ) {
|
|
|
// When node is a `Text` it has no children, so just filter it out.
|
|
|
if ( node.is( 'text' ) ) {
|
|
|
- removeDisallowedAttributeFromNode( this, node );
|
|
|
-
|
|
|
- continue;
|
|
|
+ removeDisallowedAttributeFromNode( this, node, writer );
|
|
|
}
|
|
|
-
|
|
|
// In a case of `Element` iterates through positions between nodes inside this element
|
|
|
// and filter out node before the current position, or position parent when position
|
|
|
// is at start of an element. Using positions prevent from omitting merged nodes
|
|
|
// see https://github.com/ckeditor/ckeditor5-engine/issues/1789.
|
|
|
+ else {
|
|
|
+ const rangeInNode = Range._createIn( node );
|
|
|
+ const positionsInRange = rangeInNode.getPositions();
|
|
|
|
|
|
- const rangeInNode = Range._createIn( node );
|
|
|
- const positionsInRange = rangeInNode.getPositions();
|
|
|
-
|
|
|
- for ( const position of positionsInRange ) {
|
|
|
- const item = position.nodeBefore || position.parent;
|
|
|
-
|
|
|
- removeDisallowedAttributeFromNode( this, item );
|
|
|
- }
|
|
|
- }
|
|
|
+ for ( const position of positionsInRange ) {
|
|
|
+ const item = position.nodeBefore || position.parent;
|
|
|
|
|
|
- function removeDisallowedAttributeFromNode( schema, node ) {
|
|
|
- for ( const attribute of node.getAttributeKeys() ) {
|
|
|
- if ( !schema.checkAttribute( node, attribute ) ) {
|
|
|
- writer.removeAttribute( attribute, node );
|
|
|
+ removeDisallowedAttributeFromNode( this, item, writer );
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1611,3 +1601,11 @@ function* convertToMinimalFlatRanges( ranges ) {
|
|
|
yield* range.getMinimalFlatRanges();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+function removeDisallowedAttributeFromNode( schema, node, writer ) {
|
|
|
+ for ( const attribute of node.getAttributeKeys() ) {
|
|
|
+ if ( !schema.checkAttribute( node, attribute ) ) {
|
|
|
+ writer.removeAttribute( attribute, node );
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|