Ticket #3256: 3256_4.patch
File 3256_4.patch, 4.0 KB (added by , 14 years ago) |
---|
-
_source/plugins/justify/plugin.js
66 66 justifyCommand.prototype = { 67 67 exec : function( editor ) 68 68 { 69 var selection = editor.getSelection(), 70 range = selection && selection.getRanges()[0]; 71 72 if ( !range ) 69 var selection = editor.getSelection(); 70 if ( !selection ) 73 71 return; 74 72 75 73 var bookmarks = selection.createBookmarks(), 76 cssClassName = this.cssClassName, 77 iterator = range.createIterator(), 78 block; 74 ranges = selection.getRanges(); 79 75 80 while ( ( block = iterator.getNextParagraph() ) ) 81 { 82 block.removeAttribute( 'align' ); 83 84 if ( cssClassName ) 85 { 86 // Remove any of the alignment classes from the className. 87 var className = block.$.className = 88 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) ); 89 90 // Append the desired class name. 91 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 92 block.addClass( cssClassName ); 93 else if ( !className ) 94 block.removeAttribute( 'class' ); 95 } 96 else 97 { 98 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 99 block.setStyle( 'text-align', this.value ); 100 else 101 block.removeStyle( 'text-align' ); 102 } 103 } 104 76 77 var cssClassName = this.cssClassName, 78 iterator, 79 block; 80 for ( var i = ranges.length-1 ; i >= 0 ; i-- ) { 81 iterator = ranges[ i ].createIterator(); 82 while ( ( block = iterator.getNextParagraph() ) ) 83 { 84 block.removeAttribute( 'align' ); 85 86 if ( cssClassName ) 87 { 88 // Remove any of the alignment classes from the className. 89 var className = block.$.className = 90 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) ); 91 92 // Append the desired class name. 93 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 94 block.addClass( cssClassName ); 95 else if ( !className ) 96 block.removeAttribute( 'class' ); 97 } 98 else 99 { 100 if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign ) 101 block.setStyle( 'text-align', this.value ); 102 else 103 block.removeStyle( 'text-align' ); 104 } 105 } 106 107 } 108 105 109 editor.focus(); 106 110 editor.forceNextSelectionCheck(); 107 111 selection.selectBookmarks( bookmarks ); -
_source/plugins/selection/plugin.js
868 868 createBookmarks : function( serializable ) 869 869 { 870 870 var retval = [], 871 ranges = this.getRanges(); 872 for ( var i = 0 ; i < ranges.length ; i++ ) 873 retval.push( ranges[i].createBookmark( serializable ) ); 871 ranges = this.getRanges(), 872 length = ranges.length; 873 for ( var i = 0; i < length ; i++ ) 874 { 875 // Updating the offset values for rest of ranges which have been mangled(#3256). 876 for ( var j = i + 1 ; j < length ; j++ ) 877 { 878 retval.push( ranges[ i ].createBookmark( serializable, true ) ); 879 880 var dirtyRange = ranges[ j ]; 881 function updateDirtyRange( isRangeStart, isBookmarkStart ) 882 { 883 if ( dirtyRange[ isRangeStart ? 884 'startContainer' : 'endContainer' ].equals( 885 retval[ i ][ isBookmarkStart ? 886 'startNode' : 'endNode' ].getParent() ) ) 887 dirtyRange[ isRangeStart ? 'startOffset' : 'endOffset' ]++; 888 } 889 890 updateDirtyRange( false, true ); 891 updateDirtyRange( false, false ); 892 updateDirtyRange( true, true ); 893 updateDirtyRange( true, false ); 894 } 895 } 896 897 // Update ranges caches on dirty. 898 if ( dirtyRange ) 899 this._.cache.ranges = ranges; 874 900 return retval; 875 901 }, 876 902