Ticket #4886: 4886.patch

File 4886.patch, 2.2 KB (added by garry.yao, 2 years ago)
  • _source/plugins/styles/plugin.js

     
    278278                return ( styleDefinition._ST = stylesText ); 
    279279        }; 
    280280 
     281 
     282        var notLineContent = CKEDITOR.dom.walker.lineContent( true, true ); 
     283 
    281284        function applyInlineStyle( range ) 
    282285        { 
    283286                var document = range.document; 
     
    436439                        // Apply the style if we have something to which apply it. 
    437440                        if ( applyStyle && hasContents && styleRange && !styleRange.collapsed ) 
    438441                        { 
     442                                // Tails BRs in the range are never selected by the user, 
     443                                // we shouldn't include them in the range which are either line-breaks 
     444                                // or just block filler in non-IE. (#4886) 
     445                                var walker = new CKEDITOR.dom.walker( styleRange ); 
     446                                walker.guard = notLineContent; 
     447                                walker.evaluator = function( node ) 
     448                                { 
     449                                        if( node.type == CKEDITOR.NODE_ELEMENT && node.is( 'br' ) ) 
     450                                                styleRange.setEndBefore( node ); 
     451                                }; 
     452                                walker.checkBackward(); 
     453 
    439454                                // Build the style element, based on the style object definition. 
    440455                                var styleNode = getElement( this, document ); 
    441456 
  • _source/core/dom/walker.js

     
    410410        }; 
    411411 
    412412        /** 
     413         * Whether it's a non-empty text node or non-empty inline element. 
     414         * @param {Boolean} ignoreBr Br should not be considered as line content. 
     415         * @param {Boolean} isReject 
     416         */ 
     417        CKEDITOR.dom.walker.lineContent = function( ignoreBr, isReject ) 
     418        { 
     419                return function( node ) 
     420                { 
     421                        var isLineContent = node.type == CKEDITOR.NODE_TEXT && !!CKEDITOR.tools.trim( node.getText() ) 
     422                                                                || ( node.type == CKEDITOR.NODE_ELEMENT 
     423                                                                         && !CKEDITOR.dtd.$removeEmpty[ node.getName() ] 
     424                                                                         && ( !ignoreBr || !node.is( 'br' ) ) ); 
     425                        return !!( isReject ^ isLineContent ); 
     426                }; 
     427        }; 
     428 
     429        /** 
    413430         * Whether the node is invisible in wysiwyg mode. 
    414431         * @param isReject 
    415432         */ 
© 2003 – 2011 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy