Ticket #6107: 6107_3.patch
File 6107_3.patch, 3.9 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 { 899 if ( !this.checkElementRemovable( block ) ) 900 continue; 901 902 removeFromElement( this, block, 1 ); 903 } 904 905 range.moveToBookmark( bookmark ); 906 } 907 884 908 // Replace the original block with new one, with special treatment 885 909 // for <pre> blocks to make sure content format is well preserved, and merging/splitting adjacent 886 910 // when necessary.(#3188) … … 1057 1081 } 1058 1082 1059 1083 // Removes a style from an element itself, don't care about its subtree. 1060 function removeFromElement( style, element )1084 function removeFromElement( style, element, removeMatch ) 1061 1085 { 1062 1086 var def = style._.definition, 1063 1087 attributes = CKEDITOR.tools.extend( {}, def.attributes, getOverrides( style )[ element.getName() ] ), … … 1087 1111 element.removeStyle( styleName ); 1088 1112 } 1089 1113 1090 removeEmpty && removeNoAttribsElement( element ); 1114 // Rename the element if the element is the same element in the style definition and has attributes left. 1115 if ( removeEmpty && removeMatch && element.hasAttributes() && element.getName() == def.element ) 1116 element.renameNode( CKEDITOR.dtd.$inline[ element.getName() ] ? 'span' : style._.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ); 1117 else if ( removeEmpty ) 1118 removeNoAttribsElement( element ); 1091 1119 } 1092 1120 1093 1121 // Removes a style from inside an element. … … 1433 1461 1434 1462 var iterator = ranges.createIterator(); 1435 1463 while ( ( range = iterator.getNextRange() ) ) 1436 {1437 1464 func.call( this, range ); 1438 }1439 1465 1440 1466 selection.selectRanges( ranges ); 1441 1467 -
_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 },