<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WhyPad &#187; adobe air</title>
	<atom:link href="http://www.whypad.com/tag/adobe-air/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whypad.com</link>
	<description>Tips, tricks, and hacks for life and tech...</description>
	<lastBuildDate>Tue, 06 Jul 2010 15:21:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adobe AIR: Using a Rich Text Editor &#8211; TinyMCE Tutorial</title>
		<link>http://www.whypad.com/posts/adobe-air-using-a-rich-text-editor-tinymce-tutorial/139/</link>
		<comments>http://www.whypad.com/posts/adobe-air-using-a-rich-text-editor-tinymce-tutorial/139/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 00:12:43 +0000</pubDate>
		<dc:creator>Byron Bennett</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[adobe air]]></category>
		<category><![CDATA[rich text editor]]></category>
		<category><![CDATA[tinymce]]></category>

		<guid isPermaLink="false">http://www.whypad.com/posts/adobe-air-using-a-rich-text-editor-tinymce-tutorial/139/</guid>
		<description><![CDATA[UPDATE: Please note that this original article was written for a Beat version of AIR. Commenter Jaawad below has indicated that the code here no longer works in the newly released version of AIR. Here&#8217;s the old article&#8230;First off, I am psyched about Adobe AIR and its possibilities as a development platform. But I&#8217;ll save [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Adobe AIR" rel="attachment wp-att-143" href="http://www.whypad.com/posts/adobe-air-using-a-rich-text-editor-tinymce-tutorial/139/adobe-air/"><img class="imgleft" src="http://www.whypad.com/wp-content/uploads/air_logo2.jpg" alt="Adobe AIR" /></a><strong>UPDATE:   Please note that this original article was written for a Beat version of AIR.   Commenter Jaawad below has indicated that the code here no longer works in the newly released version of AIR.   Here&#8217;s the old article&#8230;</strong>First off, I am psyched about Adobe AIR and its possibilities as a development platform. But I&#8217;ll save that for a later date.   In this post, I want to share a simple example of using Adobe AIR with the TinyMCE rich text editor (wysiwyg editor). To get the lowdown on using TinyMCE, check out the Moxiecode website <a title="TinyMCE by Moxiecode" href="http://tinymce.moxiecode.com/">here</a>&#8230;.This tutorial includes example files for download below.<span id="more-139"></span></p>
<h3>Choosing the TinyMCE Editor &amp; Why FCKEditor doesn&#8217;t work with AIR</h3>
<p>There are a number of very good and free HTML editors on the web that you can use in your applications. These include Yahoo&#8217;s <a href="http://developer.yahoo.com/yui/editor/">YUI Rich Text Editor</a>, the <a href="http://www.fckeditor.net/">FCKEditor</a>, Dojo&#8217;s <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-2-dijit/advanced-editing-and-display/editor-rich-text">Dijit Editor,</a> the <a href="http://extjs.com/">Ext framework&#8217;s</a> HTMLEditor, and <a href="http://tinymce.moxiecode.com/">TinyMCE</a> among others. Unfortunately, not all editors will work within Adobe AIR. AIR uses WebKit as its HTML rendering engine. This is the same engine used by Safari, so if your chosen editor does not support Safari, it is likely that you will not be able to use it in AIR. At this point (10/19/2007) <a href="http://www.fckeditor.net/">FCKEditor</a> does not work with versions of Safari prior to version 3.0, so it probably doesn&#8217;t work in AIR either (see their compatibility list on front page &#8211; upper right corner, hover over the Safari icon).</p>
<p>I mention FCKEditor because I like some of the functions it has, like built in image and file uploading, and a sweet little plugin that lets you switch toolbars on the fly so you can set up tabs like on <a href="http://docs.google.com/">Google Docs</a>  to change the toolset. You may be able to do these with TinyMCE, but I haven&#8217;t found them yet.</p>
<p>Regardless of the editor you choose, this method for displaying and accessing your editor should work as long as it&#8217;s compatible with AIR. You&#8217;ll need to use your editor&#8217;s methods for instantiating itself, but the sandbox concept is all AIR.</p>
<h3>Using TinyMCE in Adobe AIR Tutorial and Example</h3>
<p>I spent several hours trying to get TinyMCE working in AIR and finally did! Even Google was of no help in finding the answers. Ultimately, it required reverse engineering Adobe&#8217;s Bee.AIR sample application. So I hope that this example will save you some time.</p>
<p>I started my journey by creating a basic  HTML file that included the TinyMCE.js file just like the examples on their site showed. In this file, you would have a &lt;textarea&gt; tag and a couple of lines of javascript using the tinyMCE.init() function to transform the textarea into the TinyMCE editor.   Running this locally in Safari  worked perfectly, so at least the plumbing should work in AIR.</p>
<p>If you use Dreamweaver or Aptana, check out Adobe&#8217;s <a href="http://labs.adobe.com/wiki/index.php/AIR:Dreamweaver_CS3_Extension">AIR extension for Dreamweaver</a> (they also have a plugin for Aptana). This will save you from having to run your debug and packaging  in the command line.   Make sure you&#8217;ve got your site set up as a site in DW, then go to Site/Air Application Settings. The full documentation for using AIR in Dreamweaver is <a href="http://livedocs.adobe.com/labs/air/1/devappshtml/help.html?content=AIR_extension_3.html">here</a>.</p>
<p>Previewing  the application (from within Dreamweaver menu path: Site/Air Application Settings), did not transform the textarea into a TinyMCE editor.   Adobe&#8217;s blog editing <a title="Adobe AIR sample applications" href="http://labs.adobe.com/technologies/air/samples/">sample application</a> Bee.AIR came to the rescue for figuring out how to get TinyMCE to do its thing in AIR.   The problem was that you have to place the editor in a remote sandbox.   The example below describes how to set that up.</p>
<p>I have included the source code for a very simple working sample application below, as well as a packaged/installable version of the AIR application. Here goes with the steps it took to get this to work:</p>
<ol>
<li>Make sure you have installed the latest version of Adobe Air Integrated Runtime on your computer (Air Beta 2 at the time of this writing). Download at the Adobe download page <a href="http://www.adobe.com/devnet/air/ajax/">here</a>.</li>
<li>You must have the Air SDK installed (available at Adobe download page). A great, and almost required, tutorial is <a title="Installing the Adobe Air SDK" href="http://airdev.org/gettingstarted">here</a> at Airdev.org. I use a Mac and have never monkeyed around with Terminal. So this came in very handy.</li>
<li>Install the <a href="http://labs.adobe.com/wiki/index.php/AIR:Dreamweaver_CS3_Extension">extension</a> for your IDE (available at Adobe download page): Dreamweaver and Aptana are provided by Adobe</li>
<li>Your app will need 2 html files plus the TinyMCE package
<ol>
<li>Main application .html file representing the Application Sandbox.   You can access the AIR API&#8217;s directly from this file and from script files you include here</li>
<li>An .html file containing the TinyMCE setup and textarea.   This will be placed in the remote Sandbox.   To access AIR API&#8217;s here, you&#8217;ll need to use the Sandbox Bridge.   Read more on the security model at the Abode AIR with HTML &amp; AJAX <a href="http://livedocs.adobe.com/labs/air/1/devappshtml/help.html?content=AIR_extension_3.html">Documentation</a>.   Navigate the tree to: Application Development Essentials/AIR Security/Sandboxes.</li>
<li>The TinyMCE package&#8230;this is a big Gotcha! You can download TinyMCE from the MoxieCode website, but using this does not work when trying to install your finished application. Using the official version downloaded from MoxieCode works just fine in Preview from within Dreamweaver (which launches the ADL tool that comes with the SDK). Even using the Create AIR File option in Dreamweaver to build your AIR application package works fine. But trying to install your AIR application will give you the following error:<br />
<blockquote><p>Installation error:<br />
Missing digested package file: tinymce/jscripts/tiny_mce/plugins/cleanup/editor_plugin.js</p></blockquote>
<p>This was fixed by simply using the TinyMCE folder provided with the Bee source files. This version of the editor appears to be the current version on the Moxiecode website, but it contains several modifications, including an override of the &lt;hr/&gt; insert function which you may want to fix. Now the app installs and the editor is visible, but it&#8217;s disabled. This is fixed by replacing the tiny_mce_src.js file in Bee&#8217;s version with the copy of the file provided with the official version. If you do all of that, it should work. Or, you can just use the package provided in the sample application I provide below.</p>
<p><strong>If anybody figures out what the deal is with this, please&#8230;please&#8230;let share that in the comments.</strong></li>
<li>The other files included in the attached sample application are not required for using tinyMCE with Air. Prototype is just there to make my life easier. The AIRAliases.js file contains aliases to Air classes, shortening your code when using the AIR API. These aliases aren&#8217;t used at all in this example even though I included the file.</li>
</ol>
</li>
<li>Your TinyMCE editor will need to go in an iframe in your main HTML file.     This iframe sets up the remote sandbox, giving it security priviledges that are not available in the application sandbox.   The markup for putting your TinyMCE editor on your page should look something like:<br />
<blockquote><p><code><br />
&lt;div style="margin-top: 20px;"&gt;<br />
&lt;iframe src="http://air/tinymce.html" id="pp_content_txt" sandboxRoot="http://air/"<br />
documentRoot="app-resource:/" scrolling="no" width="100%" height="270"<br />
onfocus = "this.contentWindow.childSandboxBridge.focus()"&gt;<br />
&lt;/iframe&gt;<br />
&lt;/div&gt;</code></p></blockquote>
</li>
<li>That iframe pulls in your tinymce.html file as its source. This file contains the code to include the TinyMCE javascript files and instantiate an editor. It will look like a standard html file with some key items:
<ul>
<li>A script tag, pulling in the tiny_mce_src.js file</li>
<li>Script in the head that initializes the TinyMCE instance: uses the tinyMCE.init() function</li>
<li>More script in the head (or potentially an included .js file) that handles the tinyMCE functions like: setContent() and getContent(), etc</li>
<li>A textarea that will be transformed into the editor by the tinyMCE.init() function</li>
</ul>
</li>
</ol>
<p>The example files are available for download below. If you haven&#8217;t already done so, you&#8217;ll need to get steps 1 through 3 done first. Just because you can run Air apps (step 1) on your computer doesn&#8217;t mean you&#8217;re configured to create them (steps 2 &amp; 3&#8230;with 3 being optional, but recommended).</p>
<p><strong>Update:</strong> I&#8217;ve learned a lot about the Sandboxes over the last couple of weeks and now have an understanding of how and why to use it. The Sandbox is definitely your friend. TinyMCE has to reside in the remote sandbox because it uses eval() and possibly other functions that are not allowed in the application sandbox (where the main app resides). If you&#8217;re doing an HTML/Javascript app, you&#8217;ll likely do most of your HTML and a good bit of your JS in the remote sandbox. You can&#8217;t reach the AIR API&#8217;s from the remote sandbox directly, so you have to build objects that expose function to both the parent and child sandboxes so they can communicate. There&#8217;s a lot to learn here. A good start is found in the Abode AIR with HTML &amp; AJAX <a href="http://livedocs.adobe.com/labs/air/1/devappshtml/help.html?content=AIR_extension_3.html">Documentation</a>  under: Application Development Essentials/AIR Security/Sandboxes.</p>
<p>Downloads for the example app:</p>
<p><a title="Adobe Air: TinyMCE Example (AIR application)" href="http://www.whypad.com/wp-content/uploads/tinymceonair.air">Adobe Air: TinyMCE Example (AIR application)</a><br />
<a title="Adobe Air: TinyMCE Example (Source files)" href="http://www.whypad.com/wp-content/uploads/tinymce_air_ex.zip">Adobe Air: TinyMCE Example (Source files)</a></p>
<p>Other helpful Adobe Air tutorials and links:</p>
<ul>
<li>Adobe AIR <a href="http://www.adobe.com/devnet/air/ajax/">downloads</a></li>
<li><a href="http://labs.adobe.com/technologies/air/samples/">Adobe AIR sample applications</a></li>
<li><a href="http://livedocs.adobe.com/labs/air/1/devappshtml/help.html?content=HTMLHelloWorld_dw_1.html">Creating your first HTML AIR app in Dreamweaver</a> &#8211; Adobe&#8217;s tutorial</li>
<li><a href="http://airdev.org/tutorials/creating-your-first-html-air-app/mac">Creating your first HTML &amp; Javascript app in Adobe Air</a> &#8211; Airdev.org&#8217;s tutorial</li>
<li><a href="http://airdev.org/gettingstarted">Installing the Adobe AIR SDK</a> &#8211; a must read as far as I&#8217;m concerned</li>
<li>more to come&#8230;make your own suggestions below!</li>
</ul>
<img src="http://www.whypad.com/?ak_action=api_record_view&id=139&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.whypad.com/posts/adobe-air-using-a-rich-text-editor-tinymce-tutorial/139/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
