Ticket #3475: 3475_2.patch
File 3475_2.patch, 3.4 KB (added by , 15 years ago) |
---|
-
_source/plugins/styles/plugin.js
119 119 { 120 120 applyStyle.call( this, document, true ); 121 121 }, 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 */ 123 136 applyToRange : function( range ) 124 137 { 125 138 return ( this.applyToRange = … … 130 143 : null ).call( this, range ); 131 144 }, 132 145 146 /** 147 * @see {@link CKEDITOR.style.applyToRange} 148 */ 133 149 removeFromRange : function( range ) 134 150 { 135 151 return ( this.removeFromRange = … … 305 321 // Get the DTD definition for the element. Defaults to "span". 306 322 var dtd = CKEDITOR.dtd[ elementName ] || ( isUnknownElement = true, CKEDITOR.dtd.span ); 307 323 308 // Bookmark the range so we can re-select it after processing.309 var bookmark = range.createBookmark();310 311 324 // Expand the range. 312 325 range.enlarge( CKEDITOR.ENLARGE_ELEMENT ); 313 326 range.trim(); … … 503 516 } 504 517 } 505 518 506 // this._FixBookmarkStart( startNode );507 508 range.moveToBookmark( bookmark );509 519 } 510 520 511 521 function removeInlineStyle( range ) … … 1030 1040 1031 1041 function applyStyle( document, remove ) 1032 1042 { 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(); 1036 1048 var func = remove ? this.removeFromRange : this.applyToRange; 1037 1049 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-- ) 1040 1053 func.call( this, ranges[ i ] ); 1041 1054 1042 // Select the ranges again. 1043 selection.selectRanges( ranges ); 1055 selection.selectBookmarks( bookmarks ); 1044 1056 } 1045 1057 })(); 1046 1058 -
_source/plugins/find/dialogs/find.js
279 279 this.removeHighlight(); 280 280 281 281 // Apply the highlight. 282 var range = this.toDomRange(); 282 var range = this.toDomRange(), 283 bookmark = range.createBookmark(); 283 284 highlightStyle.applyToRange( range ); 285 range.moveToBookmark( bookmark ); 284 286 this._.highlightRange = range; 285 287 286 288 // Scroll the editor to the highlighted area. … … 301 303 if ( !this._.highlightRange ) 302 304 return; 303 305 306 var bookmark = this._.highlightRange.createBookmark(); 304 307 highlightStyle.removeFromRange( this._.highlightRange ); 308 this._.highlightRange.moveToBookmark( bookmark ); 305 309 this.updateFromDomRange( this._.highlightRange ); 306 310 this._.highlightRange = null; 307 311 },