Ticket #5462: 5462_2.patch

File 5462_2.patch, 2.2 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/plugins/styles/plugin.js

     
    141141                },
    142142
    143143                // Removes any conflicting styles from within the specified range..
    144                 removeConflictsFromRange : function ( range )
     144                removeConflictsFromRange : function ( range, nodeToPreserve )
    145145                {
    146146                        var style = this,
    147                                         overrides = getOverrides( style ),
    148                                         styleCandidates = [],
    149                                         overrideCandidates = [];
     147                                overrides = getOverrides( style ),
     148                                styleCandidates = [],
     149                                overrideCandidates = [];
    150150
    151151                        var walker = new CKEDITOR.dom.walker( range );
    152152                        walker.evaluator = function( node )
    153153                        {
    154                                 if ( node.type == CKEDITOR.NODE_ELEMENT )
     154                                if ( node.type == CKEDITOR.NODE_ELEMENT && ( !nodeToPreserve || !node.equals( nodeToPreserve ) ) )
    155155                                {
    156156                                        if ( node.is( style.element ) )
    157157                                                styleCandidates.push( node );
     158
    158159                                        if ( node.getName() in overrides )
    159160                                                overrideCandidates.push( node );
    160161                                }
     
    408409                range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
    409410                range.trim();
    410411
    411                 // Remove all style conflictions within the range,
    412                 // e.g. style="color:red" is conflicting with style="color:blue".
    413                 var enlargedBookmark = range.createBookmark();
    414                 this.removeConflictsFromRange( range );
    415                 range.moveToBookmark( enlargedBookmark );
    416 
    417412                // Get the first node to be processed and the last, which concludes the
    418413                // processing.
    419414                var boundaryNodes = range.getBoundaryNodes();
     
    579574                                        styleRange.extractContents().appendTo( styleNode );
    580575
    581576                                        // Insert it into the range position (it is collapsed after
    582                                         // extractContents.
     577                                        // extractContents).
    583578                                        styleRange.insertNode( styleNode );
    584579
     580                                        // Remove all style conflicts within the range, including
     581                                        // parents boundaries touched by styleNode.
     582                                        styleRange.enlarge( CKEDITOR.ENLARGE_ELEMENT );
     583                                        this.removeConflictsFromRange( styleRange, styleNode );
     584
    585585                                        // Let's merge our new style with its neighbors, if possible.
    586586                                        mergeSiblings( styleNode );
    587587
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy