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-2011, 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>Output for Flash — 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
13 <script type="text/javascript" src="assets/swfobject.js"></script>
\r
14 <script type="text/javascript">
\r
15 function sendToFlash()
\r
17 var html = CKEDITOR.instances.editor1.getData() ;
\r
18 var flash = document.getElementById( 'ckFlash' ) ;
\r
19 flash.setData( html ) ;
\r
24 var so = new SWFObject("assets/output_for_flash.swf", "ckFlash", "550", "400", "8", "#ffffff") ;
\r
25 so.addParam("wmode", "transparent");
\r
26 so.write("ckFlashContainer") ;
\r
30 <body onload="init()">
\r
31 <h1 class="samples">
\r
32 CKEditor Sample — Producing Flash Compliant HTML Output
\r
34 <div class="description">
\r
36 This sample shows how to configure CKEditor to output
\r
37 HTML code that can be used with
\r
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">
\r
40 The code will contain a subset of standard HTML elements like <code><b></code>,
\r
41 <code><i></code>, and <code><p></code> as well as HTML attributes.
\r
44 To add a CKEditor instance outputting Flash compliant HTML code, load the editor using a standard
\r
45 JavaScript call, and define CKEditor features to use HTML elements and attributes.
\r
48 For details on how to create this setup check the source code of this sample page.
\r
52 To see how it works, create some content in the editing area of CKEditor on the left
\r
53 and send it to the Flash object on the right side of the page by using the
\r
54 <strong>Send to Flash</strong> button.
\r
57 <!-- This <div> holds alert messages to be display in the sample page. -->
\r
61 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
\r
62 support, like yours, you should still see the contents (HTML data) and you should
\r
63 be able to edit it normally, without a rich editor interface.
\r
68 <table width="100%" cellpadding="0" cellspacing="0">
\r
70 <td style="width: 100%">
\r
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>
\r
72 <script type="text/javascript">
\r
75 if ( document.location.protocol == 'file:' )
\r
76 alert( 'Warning: This samples does not work when loaded from local filesystem due to security restrictions implemented in Flash.' +
\r
77 '\n\nPlease load the sample from a web server instead.') ;
\r
79 CKEDITOR.replace( 'editor1',
\r
84 ['Source','-','Bold','Italic','Underline','-','BulletedList','-','Link','Unlink'],
\r
85 ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
\r
87 ['Font','FontSize','-','TextColor','-','About']
\r
91 * Style sheet for the contents
\r
93 contentsCss : 'body {color:#000; background-color#FFF; font-family: Arial; font-size:80%;} p, ol, ul {margin-top: 0px; margin-bottom: 0px;}',
\r
98 docType : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">',
\r
103 coreStyles_bold : { element : 'b' },
\r
104 coreStyles_italic : { element : 'i' },
\r
105 coreStyles_underline : { element : 'u'},
\r
110 // Define the way font elements will be applied to the document. The "font"
\r
111 // element will be used.
\r
115 attributes : { 'face' : '#(family)' }
\r
120 * The CSS part of the font sizes isn't used by Flash, it is there to get the
\r
121 * font rendered correctly in CKEditor.
\r
123 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',
\r
127 attributes : { 'size' : '#(size)' },
\r
128 styles : { 'font-size' : '#(size)px' }
\r
134 colorButton_enableMore : true,
\r
136 colorButton_foreStyle :
\r
139 attributes : { 'color' : '#(color)' }
\r
142 colorButton_backStyle :
\r
145 styles : { 'background-color' : '#(color)' }
\r
149 on : { 'instanceReady' : configureFlashOutput }
\r
153 * Adjust the behavior of the dataProcessor to match the
\r
154 * requirements of Flash
\r
156 function configureFlashOutput( ev )
\r
158 var editor = ev.editor,
\r
159 dataProcessor = editor.dataProcessor,
\r
160 htmlFilter = dataProcessor && dataProcessor.htmlFilter;
\r
162 // Out self closing tags the HTML4 way, like <br>.
\r
163 dataProcessor.writer.selfClosingEnd = '>';
\r
165 // Make output formatting match Flash expectations
\r
166 var dtd = CKEDITOR.dtd;
\r
167 for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) )
\r
169 dataProcessor.writer.setRules( e,
\r
172 breakBeforeOpen : false,
\r
173 breakAfterOpen : false,
\r
174 breakBeforeClose : false,
\r
175 breakAfterClose : false
\r
178 dataProcessor.writer.setRules( 'br',
\r
181 breakBeforeOpen : false,
\r
182 breakAfterOpen : false,
\r
183 breakBeforeClose : false,
\r
184 breakAfterClose : false
\r
187 // Output properties as attributes, not styles.
\r
188 htmlFilter.addRules(
\r
192 $ : function( element )
\r
194 var style, match, width, height, align;
\r
196 // Output dimensions of images as width and height
\r
197 if ( element.name == 'img' )
\r
199 style = element.attributes.style;
\r
203 // Get the width from the style.
\r
204 match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style );
\r
205 width = match && match[1];
\r
207 // Get the height from the style.
\r
208 match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style );
\r
209 height = match && match[1];
\r
213 element.attributes.style = element.attributes.style.replace( /(?:^|\s)width\s*:\s*(\d+)px;?/i , '' );
\r
214 element.attributes.width = width;
\r
219 element.attributes.style = element.attributes.style.replace( /(?:^|\s)height\s*:\s*(\d+)px;?/i , '' );
\r
220 element.attributes.height = height;
\r
225 // Output alignment of paragraphs using align
\r
226 if ( element.name == 'p' )
\r
228 style = element.attributes.style;
\r
232 // Get the align from the style.
\r
233 match = /(?:^|\s)text-align\s*:\s*(\w*);?/i.exec( style );
\r
234 align = match && match[1];
\r
238 element.attributes.style = element.attributes.style.replace( /(?:^|\s)text-align\s*:\s*(\w*);?/i , '' );
\r
239 element.attributes.align = align;
\r
244 if ( element.attributes.style === '' )
\r
245 delete element.attributes.style;
\r
256 <input type="button" value="Send to Flash" onclick="sendToFlash();" />
\r
258 <td valign="top" style="padding-left: 15px" id="ckFlashContainer">
\r
266 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
\r
269 Copyright © 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
\r
270 Knabben. All rights reserved.
\r