Ticket #3475: 3475.patch
File 3475.patch, 1.1 KB (added by , 15 years ago) |
---|
-
_source/plugins/styles/plugin.js
1029 1029 1030 1030 function applyStyle( document, remove ) 1031 1031 { 1032 // Get all ranges from the selection. 1033 var selection = document.getSelection(); 1034 var ranges = selection.getRanges(); 1032 // Creating bookmarks here, since the range might be 1033 // mangled during processing. 1034 var selection = document.getSelection(), 1035 ranges = selection.getRanges(), 1036 bookmarks = selection.createBookmarks(); 1035 1037 var func = remove ? this.removeFromRange : this.applyToRange; 1036 1038 1037 // Apply the style to the ranges. 1038 for ( var i = 0 ; i < ranges.length ; i++ ) 1039 // Apply the style to the ranges in reverse order to avoid 1040 // range changes could impact on others. (#3475) 1041 for ( var i = ranges.length - 1 ; i >= 0 ; i-- ) 1039 1042 func.call( this, ranges[ i ] ); 1040 1043 1041 // Select the ranges again. 1042 selection.selectRanges( ranges ); 1044 selection.selectBookmarks( bookmarks ); 1043 1045 } 1044 1046 })(); 1045 1047