Ticket #5931: 5931_5.patch
File 5931_5.patch, 2.8 KB (added by , 13 years ago) |
---|
-
_source/plugins/styles/plugin.js
483 483 // Get the element that holds the entire range. 484 484 var parent = styleRange.getCommonAncestor(); 485 485 486 var removeList = { 487 styles : {}, 488 attrs : {}, 489 // Styles cannot be removed. 490 blockedStyles : {}, 491 // Attrs cannot be removed. 492 blockedAttrs : {} 493 }; 494 495 var attName, styleName, value; 496 486 497 // Loop through the parents, removing the redundant attributes 487 498 // from the element to be applied. 488 499 while ( styleNode && parent ) 489 500 { 490 501 if ( parent.getName() == elementName ) 491 502 { 492 for ( varattName in def.attributes )503 for ( attName in def.attributes ) 493 504 { 494 if ( styleNode.getAttribute( attName ) == parent.getAttribute( attName ) ) 495 styleNode.removeAttribute( attName ); 496 } 505 if ( removeList.blockedAttrs[ attName ] || !( value = parent.getAttribute( styleName ) ) ) 506 continue; 497 507 498 for ( var styleName in def.styles)499 {500 if ( styleNode.getStyle( styleName ) == parent.getStyle( styleName ) )501 styleNode.removeStyle( styleName );508 if ( styleNode.getAttribute( attName ) == value ) 509 removeList.attrs[ attName ] = 1; 510 else 511 removeList.blockedAttrs[ attName ] = 1; 502 512 } 503 513 504 if ( !styleNode.hasAttributes())514 for ( styleName in def.styles ) 505 515 { 506 styleNode = null; 507 break; 516 if ( removeList.blockedStyles[ styleName ] || !( value = parent.getStyle( styleName ) ) ) 517 continue; 518 519 if ( styleNode.getStyle( styleName ) == value ) 520 removeList.styles[ styleName ] = 1; 521 else 522 removeList.blockedStyles[ styleName ] = 1; 508 523 } 509 524 } 510 525 511 526 parent = parent.getParent(); 512 527 } 513 528 529 for ( attName in removeList.attrs ) 530 styleNode.removeAttribute( attName ); 531 532 for ( styleName in removeList.styles ) 533 styleNode.removeStyle( styleName ); 534 535 if ( !styleNode.hasAttributes() ) 536 styleNode = null; 537 514 538 if ( styleNode ) 515 539 { 516 540 // Move the contents of the range to the style element. … … 536 560 if ( !CKEDITOR.env.ie ) 537 561 styleNode.$.normalize(); 538 562 } 563 // Style already inherit from parents, left just to clear up any internal overrides. (#5931) 564 else 565 { 566 styleNode = new CKEDITOR.dom.element( 'span' ); 567 styleRange.extractContents().appendTo( styleNode ); 568 styleRange.insertNode( styleNode ); 569 removeFromInsideElement( this, styleNode ); 570 styleNode.remove( true ); 571 } 539 572 540 573 // Style applied, let's release the range, so it gets 541 574 // re-initialization in the next loop.