Ticket #6107: 6107_8.patch
File 6107_8.patch, 5.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/format/plugin.js
54 54 editor.focus(); 55 55 editor.fire( 'saveSnapshot' ); 56 56 57 styles[ value ].apply( editor.document ); 57 var style = styles[ value ], 58 elementPath = new CKEDITOR.dom.elementPath( editor.getSelection().getStartElement() ); 58 59 60 style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); 61 59 62 // Save the undo snapshot after all changes are affected. (#4899) 60 63 setTimeout( function() 61 64 { -
_source/plugins/styles/plugin.js
149 149 return ( this.removeFromRange = 150 150 this.type == CKEDITOR.STYLE_INLINE ? 151 151 removeInlineStyle 152 : this.type == CKEDITOR.STYLE_BLOCK ? 153 removeBlockStyle 152 154 : this.type == CKEDITOR.STYLE_OBJECT ? 153 155 removeObjectStyle 154 156 : null ).call( this, range ); … … 881 883 range.moveToBookmark( bookmark ); 882 884 } 883 885 886 function removeBlockStyle( range ) 887 { 888 // Serializible bookmarks is needed here since 889 // elements may be merged. 890 var bookmark = range.createBookmark( 1 ); 891 892 var iterator = range.createIterator(); 893 iterator.enforceRealBlocks = true; 894 iterator.enlargeBr = this._.enterMode != CKEDITOR.ENTER_BR; 895 896 var block; 897 while ( ( block = iterator.getNextParagraph() ) ) 898 this.checkElementRemovable( block ) && removeFromElement( this, block, 1 ); 899 900 range.moveToBookmark( bookmark ); 901 } 902 884 903 // Replace the original block with new one, with special treatment 885 904 // for <pre> blocks to make sure content format is well preserved, and merging/splitting adjacent 886 905 // when necessary.(#3188) … … 1090 1109 element.removeStyle( styleName ); 1091 1110 } 1092 1111 1093 removeEmpty && removeNoAttribsElement( element ); 1112 if ( removeEmpty ) 1113 { 1114 !CKEDITOR.dtd.$block[ element.getName() ] || style._.enterMode == CKEDITOR.ENTER_BR && !element.hasAttributes() ? 1115 removeNoAttribsElement( element ) : 1116 element.renameNode( style._.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ); 1117 } 1094 1118 } 1095 1119 1096 1120 // Removes a style from inside an element. … … 1160 1184 removeNoAttribsElement( element ); 1161 1185 } 1162 1186 1187 var nonWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 ); 1163 1188 // If the element has no more attributes, remove it. 1164 1189 function removeNoAttribsElement( element ) 1165 1190 { … … 1167 1192 // leaving its children. 1168 1193 if ( !element.hasAttributes() ) 1169 1194 { 1170 // Removing elements may open points where merging is possible,1171 // so let's cache the first and last nodes for later checking.1172 var firstChild = element.getFirst();1173 var lastChild = element.getLast();1195 if ( CKEDITOR.dtd.$block[ element.getName() ] ) 1196 { 1197 var previous = element.getPrevious( nonWhitespaces ), 1198 next = element.getNext( nonWhitespaces ); 1174 1199 1175 element.remove( true ); 1200 if ( previous && ( previous.type == CKEDITOR.NODE_TEXT || !previous.isBlockBoundary( { br : 1 } ) ) ) 1201 element.append( 'br', 1 ); 1202 if ( next && ( next.type == CKEDITOR.NODE_TEXT || !next.isBlockBoundary( { br : 1 } ) ) ) 1203 element.append( 'br' ); 1176 1204 1177 if ( firstChild ) 1205 element.remove( true ); 1206 } 1207 else 1178 1208 { 1179 // Check the cached nodes for merging. 1180 firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.mergeSiblings(); 1209 // Removing elements may open points where merging is possible, 1210 // so let's cache the first and last nodes for later checking. 1211 var firstChild = element.getFirst(); 1212 var lastChild = element.getLast(); 1181 1213 1182 if ( lastChild && !firstChild.equals( lastChild ) 1183 && lastChild.type == CKEDITOR.NODE_ELEMENT ) 1184 lastChild.mergeSiblings(); 1214 element.remove( true ); 1215 1216 if ( firstChild ) 1217 { 1218 // Check the cached nodes for merging. 1219 firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.mergeSiblings(); 1220 1221 if ( lastChild && !firstChild.equals( lastChild ) 1222 && lastChild.type == CKEDITOR.NODE_ELEMENT ) 1223 lastChild.mergeSiblings(); 1224 } 1225 1185 1226 } 1186 1227 } 1187 1228 } … … 1436 1477 1437 1478 var iterator = ranges.createIterator(); 1438 1479 while ( ( range = iterator.getNextRange() ) ) 1439 {1440 1480 func.call( this, range ); 1441 }1442 1481 1443 1482 selection.selectRanges( ranges ); 1444 1483 -
_source/plugins/stylescombo/plugin.js
106 106 107 107 var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() ); 108 108 109 if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) ) 110 style.remove( editor.document ); 111 else if ( style.type == CKEDITOR.STYLE_OBJECT && style.checkActive( elementPath ) ) 112 style.remove( editor.document ); 113 else 114 style.apply( editor.document ); 109 style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document ); 115 110 116 111 editor.fire( 'saveSnapshot' ); 117 112 },