1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
\r
3 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
4 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
6 <html xmlns="http://www.w3.org/1999/xhtml">
\r
8 <title>HTML compliant output - CKEditor Sample</title>
\r
9 <meta content="text/html; charset=utf-8" http-equiv="content-type" />
\r
10 <script type="text/javascript" src="../ckeditor.js"></script>
\r
11 <script src="sample.js" type="text/javascript"></script>
\r
12 <link href="sample.css" rel="stylesheet" type="text/css" />
\r
18 <!-- This <div> holds alert messages to be display in the sample page. -->
\r
22 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
\r
23 support, like yours, you should still see the contents (HTML data) and you should
\r
24 be able to edit it normally, without a rich editor interface.
\r
28 <form action="sample_posteddata.php" method="post">
\r
30 This sample shows CKEditor configured to produce a legacy <strong>HTML4</strong> document. Traditional
\r
31 HTML elements like <b>, <i>, and <font> are used in place of
\r
32 <strong>, <em> and CSS styles.</p>
\r
34 <label for="editor1">
\r
35 Editor 1:</label><br />
\r
36 <textarea cols="80" id="editor1" name="editor1" rows="10"><p>This is some <b>sample text</b>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea>
\r
37 <script type="text/javascript">
\r
40 CKEDITOR.replace( 'editor1',
\r
43 * Style sheet for the contents
\r
45 contentsCss : 'body {color:#000; background-color#FFF;}',
\r
48 * Simple HTML5 doctype
\r
50 docType : '<!DOCTYPE HTML>',
\r
55 coreStyles_bold : { element : 'b' },
\r
56 coreStyles_italic : { element : 'i' },
\r
57 coreStyles_underline : { element : 'u'},
\r
58 coreStyles_strike : { element : 'strike' },
\r
63 // Define the way font elements will be applied to the document. The "font"
\r
64 // element will be used.
\r
68 attributes : { 'face' : '#(family)' }
\r
74 fontSize_sizes : 'xx-small/1;x-small/2;small/3;medium/4;large/5;x-large/6;xx-large/7',
\r
78 attributes : { 'size' : '#(size)' }
\r
84 colorButton_enableMore : true,
\r
86 colorButton_foreStyle :
\r
89 attributes : { 'color' : '#(color)' },
\r
90 overrides : [ { element : 'span', attributes : { 'class' : /^FontColor(?:1|2|3)$/ } } ]
\r
93 colorButton_backStyle :
\r
96 styles : { 'background-color' : '#(color)' }
\r
104 { name : 'Computer Code', element : 'code' },
\r
105 { name : 'Keyboard Phrase', element : 'kbd' },
\r
106 { name : 'Sample Text', element : 'samp' },
\r
107 { name : 'Variable', element : 'var' },
\r
109 { name : 'Deleted Text', element : 'del' },
\r
110 { name : 'Inserted Text', element : 'ins' },
\r
112 { name : 'Cited Work', element : 'cite' },
\r
113 { name : 'Inline Quotation', element : 'q' }
\r
116 on : { 'instanceReady' : configureHtmlOutput }
\r
120 * Adjust the behavior of the dataProcessor to avoid styles
\r
121 * and make it look like FCKeditor HTML output.
\r
123 function configureHtmlOutput( ev )
\r
125 var editor = ev.editor,
\r
126 dataProcessor = editor.dataProcessor,
\r
127 htmlFilter = dataProcessor && dataProcessor.htmlFilter;
\r
129 // Out self closing tags the HTML4 way, like <br>.
\r
130 dataProcessor.writer.selfClosingEnd = '>';
\r
132 // Make output formatting behave similar to FCKeditor
\r
133 var dtd = CKEDITOR.dtd;
\r
134 for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )
\r
136 dataProcessor.writer.setRules( e,
\r
139 breakBeforeOpen : true,
\r
140 breakAfterOpen : false,
\r
141 breakBeforeClose : !dtd[ e ][ '#' ],
\r
142 breakAfterClose : true
\r
146 // Output properties as attributes, not styles.
\r
147 htmlFilter.addRules(
\r
151 $ : function( element )
\r
153 // Output dimensions of images as width and height
\r
154 if ( element.name == 'img' )
\r
156 var style = element.attributes.style;
\r
160 // Get the width from the style.
\r
161 var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style ),
\r
162 width = match && match[1];
\r
164 // Get the height from the style.
\r
165 match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style );
\r
166 var height = match && match[1];
\r
170 element.attributes.style = element.attributes.style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' );
\r
171 element.attributes.width = width;
\r
176 element.attributes.style = element.attributes.style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' );
\r
177 element.attributes.height = height;
\r
182 // Output alignment of paragraphs using align
\r
183 if ( element.name == 'p' )
\r
185 style = element.attributes.style;
\r
189 // Get the align from the style.
\r
190 match = /(?:^|\s)text-align\s*:\s*(\w*);/i.exec( style );
\r
191 var align = match && match[1];
\r
195 element.attributes.style = element.attributes.style.replace( /(?:^|\s)text-align\s*:\s*(\w*);?/i , '' );
\r
196 element.attributes.align = align;
\r
201 if ( !element.attributes.style )
\r
202 delete element.attributes.style;
\r
210 style : function( value, element )
\r
212 // Return #RGB for background and border colors
\r
213 return convertRGBToHex( value );
\r
221 * Convert a CSS rgb(R, G, B) color back to #RRGGBB format.
\r
222 * @param Css style string (can include more than one color
\r
223 * @return Converted css style.
\r
225 function convertRGBToHex( cssStyle )
\r
227 return cssStyle.replace( /(?:rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\))/gi, function( match, red, green, blue )
\r
229 red = parseInt( red, 10 ).toString( 16 );
\r
230 green = parseInt( green, 10 ).toString( 16 );
\r
231 blue = parseInt( blue, 10 ).toString( 16 );
\r
232 var color = [red, green, blue] ;
\r
234 // Add padding zeros if the hex value is less than 0x10.
\r
235 for ( var i = 0 ; i < color.length ; i++ )
\r
236 color[i] = String( '0' + color[i] ).slice( -2 ) ;
\r
238 return '#' + color.join( '' ) ;
\r
245 <input type="submit" value="Submit" />
\r
251 CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>
\r
254 Copyright © 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico
\r
255 Knabben. All rights reserved.
\r