@@ -229,7 +229,7 @@ class Insertion {
229229 // If the node is a text and bare text is allowed in current position it means that the node
230230 // contains disallowed attributes and we have to remove them.
231231 else if ( this . schema . check ( { name : '$text' , inside : this . position } ) ) {
232- removeDisallowedAttributes ( [ node ] , this . position , this . schema ) ;
232+ this . schema . removeDisallowedAttributes ( [ node ] , this . position ) ;
233233 this . _handleNode ( node , context ) ;
234234 }
235235 // If text is not allowed, try autoparagraphing.
@@ -291,7 +291,7 @@ class Insertion {
291291 // We need to check and strip disallowed attributes in all nested nodes because after merge
292292 // some attributes could end up in a path where are disallowed.
293293 const parent = position . nodeBefore ;
294- removeDisallowedAttributes ( parent . getChildren ( ) , Position . createAt ( parent ) , this . schema , this . batch ) ;
294+ this . schema . removeDisallowedAttributes ( parent . getChildren ( ) , Position . createAt ( parent ) , this . batch ) ;
295295
296296 this . position = Position . createFromPosition ( position ) ;
297297 position . detach ( ) ;
@@ -318,7 +318,7 @@ class Insertion {
318318
319319 // We need to check and strip disallowed attributes in all nested nodes because after merge
320320 // some attributes could end up in a place where are disallowed.
321- removeDisallowedAttributes ( position . parent . getChildren ( ) , position , this . schema , this . batch ) ;
321+ this . schema . removeDisallowedAttributes ( position . parent . getChildren ( ) , position , this . batch ) ;
322322
323323 this . position = Position . createFromPosition ( position ) ;
324324 position . detach ( ) ;
@@ -330,7 +330,7 @@ class Insertion {
330330 // When there was no merge we need to check and strip disallowed attributes in all nested nodes of
331331 // just inserted node because some attributes could end up in a place where are disallowed.
332332 if ( ! mergeLeft && ! mergeRight ) {
333- removeDisallowedAttributes ( node . getChildren ( ) , Position . createAt ( node ) , this . schema , this . batch ) ;
333+ this . schema . removeDisallowedAttributes ( node . getChildren ( ) , Position . createAt ( node ) , this . batch ) ;
334334 }
335335 }
336336
@@ -350,7 +350,7 @@ class Insertion {
350350 // When node is a text and is disallowed by schema it means that contains disallowed attributes
351351 // and we need to remove them.
352352 if ( node . is ( 'text' ) && ! this . _checkIsAllowed ( node , [ paragraph ] ) ) {
353- removeDisallowedAttributes ( [ node ] , [ paragraph ] , this . schema ) ;
353+ this . schema . removeDisallowedAttributes ( [ node ] , [ paragraph ] ) ;
354354 }
355355
356356 if ( this . _checkIsAllowed ( node , [ paragraph ] ) ) {
@@ -453,36 +453,3 @@ class Insertion {
453453function getNodeSchemaName ( node ) {
454454 return node . is ( 'text' ) ? '$text' : node . name ;
455455}
456-
457- // Removes disallowed by schema attributes from given nodes. When batch parameter is provided then
458- // attributes will be removed by creating AttributeDeltas otherwise attributes will be removed
459- // directly from provided nodes.
460- //
461- // @param {Array<module:engine/model/node~Node> } nodes Nodes that will be filtered.
462- // @param {module:engine/model/schema~SchemaPath } inside Path inside which schema will be checked.
463- // @param {module:engine/model/schema~Schema } schema Schema instance uses for element validation.
464- // @param {module:engine/model/batch~Batch } [batch] Batch to which the deltas will be added.
465- function removeDisallowedAttributes ( nodes , inside , schema , batch ) {
466- for ( const node of nodes ) {
467- const name = getNodeSchemaName ( node ) ;
468-
469- // When node with attributes is not allowed in current position.
470- if ( ! schema . check ( { name, inside, attributes : Array . from ( node . getAttributeKeys ( ) ) } ) ) {
471- // Let's remove attributes one by one.
472- // This should be improved to check all combination of attributes.
473- for ( const attribute of node . getAttributeKeys ( ) ) {
474- if ( ! schema . check ( { name, inside, attributes : attribute } ) ) {
475- if ( batch ) {
476- batch . removeAttribute ( node , attribute ) ;
477- } else {
478- node . removeAttribute ( attribute ) ;
479- }
480- }
481- }
482- }
483-
484- if ( node . is ( 'element' ) ) {
485- removeDisallowedAttributes ( node . getChildren ( ) , Position . createAt ( node ) , schema , batch ) ;
486- }
487- }
488- }
0 commit comments