-\r
- // Output properties as attributes, not styles.\r
- htmlFilter.addRules( {\r
- elements: {\r
- $: function( element ) {\r
- // Output dimensions of images as width and height\r
- if ( element.name == 'img' ) {\r
- var style = element.attributes.style;\r
-\r
- if ( style ) {\r
- // Get the width from the style.\r
- var match = ( /(?:^|\s)width\s*:\s*(\d+)px/i ).exec( style ),\r
- width = match && match[ 1 ];\r
-\r
- // Get the height from the style.\r
- match = ( /(?:^|\s)height\s*:\s*(\d+)px/i ).exec( style );\r
- var height = match && match[ 1 ];\r
-\r
- if ( width ) {\r
- element.attributes.style = element.attributes.style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' );\r
- element.attributes.width = width;\r
- }\r
-\r
- if ( height ) {\r
- element.attributes.style = element.attributes.style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' );\r
- element.attributes.height = height;\r
- }\r
- }\r
- }\r
-\r
- // Output alignment of paragraphs using align\r
- if ( element.name == 'p' ) {\r
- style = element.attributes.style;\r
-\r
- if ( style ) {\r
- // Get the align from the style.\r
- match = ( /(?:^|\s)text-align\s*:\s*(\w*);/i ).exec( style );\r
- var align = match && match[ 1 ];\r
-\r
- if ( align ) {\r
- element.attributes.style = element.attributes.style.replace( /(?:^|\s)text-align\s*:\s*(\w*);?/i , '' );\r
- element.attributes.align = align;\r
- }\r
- }\r
- }\r
-\r
- if ( !element.attributes.style )\r
- delete element.attributes.style;\r
-\r
- return element;\r
- }\r
- },\r
-\r
- attributes: {\r
- style: function( value, element ) {\r
- // Return #RGB for background and border colors\r
- return CKEDITOR.tools.convertRgbToHex( value );\r
- }\r
- }\r
- });\r