Ticket #3475: 3475_2.patch

File 3475_2.patch, 3.4 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/styles/plugin.js

     
    119119                {
    120120                        applyStyle.call( this, document, true );
    121121                },
    122 
     122               
     123                /**
     124                 * Apply the current style to the specified range.
     125                 * Note : the range will be mangled after this method,
     126                 * so the range should be bookmarked before invoking it.
     127                 *
     128                 * @param {CKEDITOR.dom.range} range
     129                 * @example
     130                 * // Apply style defined as 'mystyle' to a range.
     131                 * var style = new CKEDITOR.style( editor.config.mystyle );
     132                 * var bookmark = range.createBookmark();
     133                 * style.spplyToRange( range );
     134                 * range.moveToBookmark( bookmark );
     135                 */
    123136                applyToRange : function( range )
    124137                {
    125138                        return ( this.applyToRange =
     
    130143                                                : null ).call( this, range );
    131144                },
    132145
     146                /**
     147                 * @see {@link CKEDITOR.style.applyToRange}
     148                 */
    133149                removeFromRange : function( range )
    134150                {
    135151                        return ( this.removeFromRange =
     
    305321                // Get the DTD definition for the element. Defaults to "span".
    306322                var dtd = CKEDITOR.dtd[ elementName ] || ( isUnknownElement = true, CKEDITOR.dtd.span );
    307323
    308                 // Bookmark the range so we can re-select it after processing.
    309                 var bookmark = range.createBookmark();
    310 
    311324                // Expand the range.
    312325                range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
    313326                range.trim();
     
    503516                        }
    504517                }
    505518
    506 //              this._FixBookmarkStart( startNode );
    507 
    508                 range.moveToBookmark( bookmark );
    509519        }
    510520
    511521        function removeInlineStyle( range )
     
    10301040
    10311041        function applyStyle( document, remove )
    10321042        {
    1033                 // Get all ranges from the selection.
    1034                 var selection = document.getSelection();
    1035                 var ranges = selection.getRanges();
     1043                // Creating bookmarks here, since the range might be
     1044                // mangled during processing.
     1045                var selection = document.getSelection(),
     1046                        ranges = selection.getRanges(),
     1047                        bookmarks = selection.createBookmarks();
    10361048                var func = remove ? this.removeFromRange : this.applyToRange;
    10371049
    1038                 // Apply the style to the ranges.
    1039                 for ( var i = 0 ; i < ranges.length ; i++ )
     1050                // Apply the style to the ranges in reverse order to avoid
     1051                // range changes could impact on others. (#3475)
     1052                for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
    10401053                        func.call( this, ranges[ i ] );
    10411054
    1042                 // Select the ranges again.
    1043                 selection.selectRanges( ranges );
     1055                selection.selectBookmarks( bookmarks );
    10441056        }
    10451057})();
    10461058
  • _source/plugins/find/dialogs/find.js

     
    279279                                        this.removeHighlight();
    280280
    281281                                // Apply the highlight.
    282                                 var range = this.toDomRange();
     282                                var range = this.toDomRange(),
     283                                        bookmark = range.createBookmark();
    283284                                highlightStyle.applyToRange( range );
     285                                range.moveToBookmark( bookmark );
    284286                                this._.highlightRange = range;
    285287
    286288                                // Scroll the editor to the highlighted area.
     
    301303                                if ( !this._.highlightRange )
    302304                                        return;
    303305
     306                                var bookmark = this._.highlightRange.createBookmark();
    304307                                highlightStyle.removeFromRange( this._.highlightRange );
     308                                this._.highlightRange.moveToBookmark( bookmark );
    305309                                this.updateFromDomRange( this._.highlightRange );
    306310                                this._.highlightRange = null;
    307311                        },
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy