1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
4 For licensing, see LICENSE.html or http://ckeditor.com/license
6 <html xmlns=
"http://www.w3.org/1999/xhtml">
8 <title>Output for Flash
— CKEditor Sample
</title>
9 <meta content=
"text/html; charset=utf-8" http-equiv=
"content-type" />
10 <script type=
"text/javascript" src=
"../ckeditor.js"></script>
11 <script src=
"sample.js" type=
"text/javascript"></script>
12 <link href=
"sample.css" rel=
"stylesheet" type=
"text/css" />
13 <script type=
"text/javascript" src=
"assets/swfobject.js"></script>
14 <script type=
"text/javascript">
15 function sendToFlash()
17 var html = CKEDITOR.instances.editor1.getData() ;
18 var flash = document.getElementById( 'ckFlash' ) ;
19 flash.setData( html ) ;
24 var so = new SWFObject(
"assets/output_for_flash.swf",
"ckFlash",
"550",
"400",
"8",
"#ffffff") ;
25 so.addParam(
"wmode",
"transparent");
26 so.write(
"ckFlashContainer") ;
30 <body onload=
"init()">
32 CKEditor Sample
— Producing Flash Compliant HTML Output
34 <div class=
"description">
36 This sample shows how to configure CKEditor to output
37 HTML code that can be used with
38 <a class=
"samples" href=
"http://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000922.html">
40 The code will contain a subset of standard HTML elements like
<code><b
></code>,
41 <code><i
></code>, and
<code><p
></code> as well as HTML attributes.
44 To add a CKEditor instance outputting Flash compliant HTML code, load the editor using a standard
45 JavaScript call, and define CKEditor features to use HTML elements and attributes.
48 For details on how to create this setup check the source code of this sample page.
52 To see how it works, create some content in the editing area of CKEditor on the left
53 and send it to the Flash object on the right side of the page by using the
54 <strong>Send to Flash
</strong> button.
57 <!-- This <div> holds alert messages to be display in the sample page. -->
61 <strong>CKEditor requires JavaScript to run
</strong>. In a browser with no JavaScript
62 support, like yours, you should still see the contents (HTML data) and you should
63 be able to edit it normally, without a rich editor interface.
68 <table width=
"100%" cellpadding=
"0" cellspacing=
"0">
70 <td style=
"width: 100%">
71 <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>
72 <script type=
"text/javascript">
75 if ( document.location.protocol == 'file:' )
76 alert( 'Warning: This samples does not work when loaded from local filesystem due to security restrictions implemented in Flash.' +
77 '\n\nPlease load the sample from a web server instead.') ;
79 CKEDITOR.replace( 'editor1',
84 ['Source','-','Bold','Italic','Underline','-','BulletedList','-','Link','Unlink'],
85 ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
88 ['TextColor','-','About']
92 * Style sheet for the contents
94 contentsCss : 'body {color:#
000; background-color#FFF; font-family: Arial; font-size:
80%;} p, ol, ul {margin-top:
0px; margin-bottom:
0px;}',
99 docType : '
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">',
104 coreStyles_bold : { element : 'b' },
105 coreStyles_italic : { element : 'i' },
106 coreStyles_underline : { element : 'u'},
111 // Define the way font elements will be applied to the document. The
"font"
112 // element will be used.
116 attributes : { 'face' : '#(family)' }
121 * The CSS part of the font sizes isn't used by Flash, it is there to get the
122 * font rendered correctly in CKEditor.
124 fontSize_sizes : '
8px/
8;
9px/
9;
10px/
10;
11px/
11;
12px/
12;
14px/
14;
16px/
16;
18px/
18;
20px/
20;
22px/
22;
24px/
24;
26px/
26;
28px/
28;
36px/
36;
48px/
48;
72px/
72',
128 attributes : { 'size' : '#(size)' },
129 styles : { 'font-size' : '#(size)px' }
135 colorButton_enableMore : true,
137 colorButton_foreStyle :
140 attributes : { 'color' : '#(color)' }
143 colorButton_backStyle :
146 styles : { 'background-color' : '#(color)' }
150 on : { 'instanceReady' : configureFlashOutput }
154 * Adjust the behavior of the dataProcessor to match the
155 * requirements of Flash
157 function configureFlashOutput( ev )
159 var editor = ev.editor,
160 dataProcessor = editor.dataProcessor,
161 htmlFilter = dataProcessor && dataProcessor.htmlFilter;
163 // Out self closing tags the HTML4 way, like
<br>.
164 dataProcessor.writer.selfClosingEnd = '
>';
166 // Make output formatting match Flash expectations
167 var dtd = CKEDITOR.dtd;
168 for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )
170 dataProcessor.writer.setRules( e,
173 breakBeforeOpen : false,
174 breakAfterOpen : false,
175 breakBeforeClose : false,
176 breakAfterClose : false
179 dataProcessor.writer.setRules( 'br',
182 breakBeforeOpen : false,
183 breakAfterOpen : false,
184 breakBeforeClose : false,
185 breakAfterClose : false
188 // Output properties as attributes, not styles.
193 $ : function( element )
195 var style, match, width, height, align;
197 // Output dimensions of images as width and height
198 if ( element.name == 'img' )
200 style = element.attributes.style;
204 // Get the width from the style.
205 match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style );
206 width = match && match[
1];
208 // Get the height from the style.
209 match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style );
210 height = match && match[
1];
214 element.attributes.style = element.attributes.style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' );
215 element.attributes.width = width;
220 element.attributes.style = element.attributes.style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' );
221 element.attributes.height = height;
226 // Output alignment of paragraphs using align
227 if ( element.name == 'p' )
229 style = element.attributes.style;
233 // Get the align from the style.
234 match = /(?:^|\s)text-align\s*:\s*(\w*);?/i.exec( style );
235 align = match && match[
1];
239 element.attributes.style = element.attributes.style.replace( /(?:^|\s)text-align\s*:\s*(\w*);?/i , '' );
240 element.attributes.align = align;
245 if ( element.attributes.style === '' )
246 delete element.attributes.style;
257 <input type=
"button" value=
"Send to Flash" onclick=
"sendToFlash();" />
259 <td valign=
"top" style=
"padding-left: 15px" id=
"ckFlashContainer">
267 CKEditor - The text editor for the Internet -
<a class=
"samples" href=
"http://ckeditor.com/">http://ckeditor.com
</a>
270 Copyright
© 2003-
2011,
<a class=
"samples" href=
"http://cksource.com/">CKSource
</a> - Frederico
271 Knabben. All rights reserved.