Ticket #536: 536.patch
File 536.patch, 4.7 KB (added by , 14 years ago) |
---|
-
_source/plugins/stylescombo/plugin.js
109 109 var style = styles[ value ], 110 110 selection = editor.getSelection(); 111 111 112 if ( style.type == CKEDITOR.STYLE_OBJECT )113 {114 var element = selection.getSelectedElement();115 if ( element )116 style.applyToObject( element );117 118 return;119 }120 121 112 var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() ); 122 113 123 114 if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) ) … … 169 160 var selection = editor.getSelection(); 170 161 171 162 var element = selection.getSelectedElement(), 172 elementName = element && element.getName(),173 163 elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ); 174 164 175 165 var counter = [ 0, 0, 0, 0 ]; … … 180 170 var style = styles[ name ], 181 171 type = style.type; 182 172 183 if ( type == CKEDITOR.STYLE_OBJECT ) 184 { 185 if ( element && style.element == elementName ) 186 { 187 if ( style.checkElementRemovable( element, true ) ) 188 this.mark( name ); 189 190 counter[ type ]++; 191 } 192 else 193 this.hideItem( name ); 173 if ( style.checkActive( elementPath ) ) 174 this.mark( name ); 175 else if ( type == CKEDITOR.STYLE_OBJECT && !style.checkApplicable( elementPath ) ) 176 { 177 this.hideItem( name ); 178 counter[ type ]--; 194 179 } 195 else196 {197 if ( style.checkActive( elementPath ) )198 this.mark( name );199 180 200 counter[ type ]++; 201 } 202 } 181 counter[ type ]++; 182 } 203 183 204 184 if ( !counter[ CKEDITOR.STYLE_BLOCK ] ) 205 185 this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_BLOCK ) ] ); -
_source/plugins/styles/plugin.js
127 127 applyInlineStyle 128 128 : this.type == CKEDITOR.STYLE_BLOCK ? 129 129 applyBlockStyle 130 : this.type == CKEDITOR.STYLE_OBJECT ? 131 applyObjectStyle 130 132 : null ).call( this, range ); 131 133 }, 132 134 … … 154 156 case CKEDITOR.STYLE_BLOCK : 155 157 return this.checkElementRemovable( elementPath.block || elementPath.blockLimit, true ); 156 158 159 case CKEDITOR.STYLE_OBJECT : 157 160 case CKEDITOR.STYLE_INLINE : 158 161 159 162 var elements = elementPath.elements; 160 163 161 164 for ( var i = 0, element ; i < elements.length ; i++ ) 162 165 { 163 element = elements[ i];166 element = elements[ i ]; 164 167 165 if ( element == elementPath.block || element == elementPath.blockLimit ) 168 if ( this.type == CKEDITOR.STYLE_INLINE 169 && ( element == elementPath.block || element == elementPath.blockLimit ) ) 166 170 continue; 167 171 172 if( this.type == CKEDITOR.STYLE_OBJECT 173 && !( element.getName() in objectElements ) ) 174 continue; 175 168 176 if ( this.checkElementRemovable( element, true ) ) 169 177 return true; 170 178 } 171 179 } 172 180 return false; 173 181 }, 174 182 183 checkApplicable : function( elementPath ) 184 { 185 switch ( this.type ) 186 { 187 case CKEDITOR.STYLE_INLINE : 188 case CKEDITOR.STYLE_BLOCK : 189 return true; 190 191 case CKEDITOR.STYLE_OBJECT : 192 return elementPath.lastElement.getAscendant( this.element, true ); 193 } 194 }, 195 175 196 // Checks if an element, or any of its attributes, is removable by the 176 197 // current style definition. 177 198 checkElementRemovable : function( element, fullMatch ) … … 668 689 range.moveToBookmark( bookmark ); 669 690 } 670 691 692 function applyObjectStyle( range ) 693 { 694 var root = range.getCommonAncestor( true, true ), 695 element = root.getAscendant( this.element, true ); 696 element && setupElement( element, this ); 697 } 698 671 699 function applyBlockStyle( range ) 672 700 { 673 701 // Serializible bookmarks is needed here since -
_source/plugins/stylescombo/styles/default.js
81 81 'border' : '2', 82 82 'align' : 'right' 83 83 } 84 } 84 }, 85 86 { name : 'Borderless Table' , element : 'table', styles: { 'border-style': 'hidden', 'background-color' : '#E6E6FA' } }, 87 { name : 'Square Bulleted List' , element : 'ul', styles : { 'list-style-type' : 'square' } } 88 85 89 ]);