/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\r
CKEDITOR.style = function( styleDefinition, variablesValues )\r
{\r
+ // Inline style text as attribute should be converted\r
+ // to styles object.\r
+ var attrs = styleDefinition.attributes;\r
+ if ( attrs && attrs.style )\r
+ {\r
+ styleDefinition.styles = CKEDITOR.tools.extend( {},\r
+ styleDefinition.styles, parseStyleText( attrs.style ) );\r
+ delete attrs.style;\r
+ }\r
+\r
if ( variablesValues )\r
{\r
styleDefinition = CKEDITOR.tools.clone( styleDefinition );\r
return true;\r
},\r
\r
- // Checks if an element, or any of its attributes, is removable by the\r
- // current style definition.\r
- checkElementRemovable : function( element, fullMatch )\r
+ // Check if the element matches the current style definition.\r
+ checkElementMatch : function( element, fullMatch )\r
{\r
var def = this._.definition;\r
\r
return true;\r
}\r
\r
- // Check if the element can be somehow overriden.\r
+ return false;\r
+ },\r
+\r
+ // Checks if an element, or any of its attributes, is removable by the\r
+ // current style definition.\r
+ checkElementRemovable : function( element, fullMatch )\r
+ {\r
+ // Check element matches the style itself.\r
+ if ( this.checkElementMatch( element, fullMatch ) )\r
+ return true;\r
+\r
+ // Check if the element matches the style overrides.\r
var override = getOverrides( this )[ element.getName() ] ;\r
if ( override )\r
{\r
+ var attribs, attName;\r
+\r
// If no attributes have been defined, remove the element.\r
if ( !( attribs = override.attributes ) )\r
return true;\r
function removeFromElement( style, element )\r
{\r
var def = style._.definition,\r
- attributes = CKEDITOR.tools.extend( {}, def.attributes, getOverrides( style )[ element.getName() ] ),\r
+ attributes = def.attributes,\r
styles = def.styles,\r
+ overrides = getOverrides( style )[ element.getName() ],\r
// If the style is only about the element itself, we have to remove the element.\r
removeEmpty = CKEDITOR.tools.isEmpty( attributes ) && CKEDITOR.tools.isEmpty( styles );\r
\r
element.removeStyle( styleName );\r
}\r
\r
+ // Remove overrides, but don't remove the element if it's a block element\r
+ removeOverrides( element, overrides, blockElements[ element.getName() ] ) ;\r
+\r
if ( removeEmpty )\r
{\r
!CKEDITOR.dtd.$block[ element.getName() ] || style._.enterMode == CKEDITOR.ENTER_BR && !element.hasAttributes() ?\r
* Note: Remove the element if no attributes remain.\r
* @param {Object} element\r
* @param {Object} overrides\r
+ * @param {Boolean} Don't remove the element\r
*/\r
- function removeOverrides( element, overrides )\r
+ function removeOverrides( element, overrides, dontRemove )\r
{\r
var attributes = overrides && overrides.attributes ;\r
\r
}\r
}\r
\r
- removeNoAttribsElement( element );\r
+ if ( !dontRemove )\r
+ removeNoAttribsElement( element );\r
}\r
\r
// If the element has no more attributes, remove it.\r