Ticket #7387: 7387.patch
File 7387.patch, 3.7 KB (added by , 12 years ago) |
---|
-
_source/core/dom/node.js
534 534 return false; 535 535 }, 536 536 537 /** 538 * Get an ascendant whose tag name is included in 539 * the provided hash object 540 */ 541 getAscendantInHash : function( hash, includeSelf ) 542 { 543 var $ = this.$; 544 545 if ( !includeSelf ) 546 $ = $.parentNode; 547 548 while ( $ ) 549 { 550 if ( $.nodeName && hash[ $.nodeName.toLowerCase() ] ) 551 return new CKEDITOR.dom.node( $ ); 552 553 $ = $.parentNode; 554 } 555 return null; 556 }, 557 537 558 move : function( target, toStart ) 538 559 { 539 560 target.append( this.remove(), toStart ); -
_source/plugins/styles/plugin.js
100 100 101 101 var element = this.element = ( styleDefinition.element || '*' ).toLowerCase(); 102 102 103 this.type = 103 // A style definition can specify how it wants to be applied, although it 104 // might not work as expected (can't really create a td out of nowhere) 105 this.type = styleDefinition.type || 104 106 blockElements[ element ] ? 105 107 CKEDITOR.STYLE_BLOCK 106 108 : objectElements[ element ] ? … … 108 110 : 109 111 CKEDITOR.STYLE_INLINE; 110 112 113 // Optionally a definition can define a set of elements that it can be applied to 114 this.elements = styleDefinition.elements; 115 // In that case, it will be applied like an object style: only to existing elements 116 if ( this.elements ) 117 this.type = CKEDITOR.STYLE_OBJECT 118 111 119 this._ = 112 120 { 113 121 definition : styleDefinition … … 179 187 && ( element == elementPath.block || element == elementPath.blockLimit ) ) 180 188 continue; 181 189 182 if( this.type == CKEDITOR.STYLE_OBJECT 183 && !( element.getName() in objectElements ) ) 190 if( this.type == CKEDITOR.STYLE_OBJECT ) 191 { 192 var name = element.getName(); 193 if ( name != this.element && 194 !(this.elements && ( name in this.elements)) ) 184 195 continue; 196 } 185 197 186 198 if ( this.checkElementRemovable( element, true ) ) 187 199 return true; … … 203 215 break; 204 216 205 217 case CKEDITOR.STYLE_OBJECT : 206 return elementPath.lastElement.getAscendant( this.element, true ); 218 var root = elementPath.lastElement; 219 return this.elements ? root.getAscendantInHash( this.elements, true ) : root.getAscendant( this.element, true ); 207 220 } 208 221 209 222 return true; … … 217 230 return false; 218 231 219 232 var def = this._.definition, 220 attribs; 233 attribs, 234 name = element.getName(); 221 235 222 236 // If the element name is the same as the style name. 223 if ( element.getName() == this.element)237 if ( name == this.element || ( this.elements && name in this.elements ) ) 224 238 { 225 239 // If no attributes are defined in the element. 226 240 if ( !fullMatch && !element.hasAttributes() ) … … 814 828 function applyObjectStyle( range ) 815 829 { 816 830 var root = range.getCommonAncestor( true, true ), 817 element = root.getAscendant( this.element, true );831 element = this.elements ? root.getAscendantInHash( this.elements, true ) : root.getAscendant( this.element, true ); 818 832 element && setupElement( element, this ); 819 833 } 820 834 821 835 function removeObjectStyle( range ) 822 836 { 823 837 var root = range.getCommonAncestor( true, true ), 824 element = root.getAscendant( this.element, true );838 element = this.elements ? root.getAscendantInHash( this.elements, true ) : root.getAscendant( this.element, true ); 825 839 826 840 if ( !element ) 827 841 return;