--- /dev/null
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+CKEDITOR.editorConfig = function( config )\r
+{\r
+ // Define changes to default configuration here. For example:\r
+ // config.language = 'fr';\r
+ // config.uiColor = '#AADC6E';\r
+ \r
+ CKEDITOR.on('instanceReady', function (ev) {\r
+ var editor = ev.editor,\r
+ dataProcessor = editor.dataProcessor,\r
+ htmlFilter = dataProcessor && dataProcessor.htmlFilter;\r
+\r
+ // Out self closing tags the HTML4 way, like <br>.\r
+ dataProcessor.writer.selfClosingEnd = '/>';\r
+\r
+ // Make output formatting behave similar to FCKeditor\r
+ var dtd = CKEDITOR.dtd;\r
+ for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )\r
+ {\r
+ dataProcessor.writer.setRules( e,\r
+ {\r
+ indent : true,\r
+ breakBeforeOpen : true,\r
+ breakAfterOpen : false,\r
+ breakBeforeClose : !dtd[ e ][ '#' ],\r
+ breakAfterClose : true\r
+ });\r
+ }\r
+\r
+ // Output properties as attributes, not styles.\r
+ htmlFilter.addRules(\r
+ {\r
+ elements :\r
+ {\r
+ $ : function( element )\r
+ {\r
+ // Output dimensions of images as width and height\r
+ if ( element.name == 'img' )\r
+ {\r
+ var style = element.attributes.style;\r
+\r
+ if ( style )\r
+ {\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
+ {\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
+ {\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
+ {\r
+ style = element.attributes.style;\r
+\r
+ if ( style )\r
+ {\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
+ {\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
+ {\r
+ style : function( value, element )\r
+ {\r
+ // Return #RGB for background and border colors\r
+ return convertRGBToHex( value );\r
+ }\r
+ }\r
+ } );\r
+ });\r
+\r
+ /**\r
+ * Convert a CSS rgb(R, G, B) color back to #RRGGBB format.\r
+ * @param Css style string (can include more than one color\r
+ * @return Converted css style.\r
+ */\r
+ function convertRGBToHex( cssStyle )\r
+ {\r
+ return cssStyle.replace( /(?:rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\))/gi, function( match, red, green, blue )\r
+ {\r
+ red = parseInt( red, 10 ).toString( 16 );\r
+ green = parseInt( green, 10 ).toString( 16 );\r
+ blue = parseInt( blue, 10 ).toString( 16 );\r
+ var color = [red, green, blue] ;\r
+\r
+ // Add padding zeros if the hex value is less than 0x10.\r
+ for ( var i = 0 ; i < color.length ; i++ )\r
+ color[i] = String( '0' + color[i] ).slice( -2 ) ;\r
+\r
+ return '#' + color.join( '' ) ;\r
+ });\r
+ }\r
+};\r