Can you clarify:
* How you're putting data on the clipboard, and in which formats?
* How you're determining that data is not available in HTML?
A short example demonstrating the issue would be great.
I'd expect that by default when you select and copy (Ctrl+C) content that is rendered in an HTML browser control within an AIR app, that content would be placed on the clipboard as "HTML", so that when you paste it into a rich text editor (Word, or an email client), it would retain the original formatting and structure (tables, links, etc) .. just like you get when copy+paste from a standard web browser. When I copy from an embedded browser control in AIR, all I get is plain text.
Through a bit of processing, I am able to trap the KeyboardEvent and watch for a Ctrl+C, then extract the underlying HTML from the current selection, and stuff that into the system clipboard as HTML. This does allow the pasted content to be properly formatted HTML.
My first question is .. am I going about this the hard way? Is there just some flag to set on the HTML control that allows a standard copy to retain the HTML formatting?
However, to complicate matters, my application embeds the FCK Editor into the HTML control in the AIR app. When I copy formatted content from the FCK editor and paste it into a different location in the same insttance of the FCK editor .. any formatting is lost .. even if I use the "bit of processing" described above. I'm not expecting that anyone will have the whole answer for me (but I can hope, eh). The FCK editor adds a lot of its own processing and control over things, and that's fairly complicated to figure out. However, outside of AIR (in a standard browser), you can copy formatted content from the FCK editor to itself and the formatting remains .. but inside of AIR, this isn't the case. AIR is definitely doing something to restrict copying of formatted content. I was hoping that perhaps there's a flag that controls this.
I suppose it could also have something to do with the version or implementation of webkit in AIR. I've tested this in Safari, but from what I understand the webkit in AIR may not be as fully featured even though it comes from the same source.
Any ideas are appreciated!
Unfortunately, there is not magic flag that solves this and I think your "bit of processing" is a cool workaround to this issue. We also logged an enhancement request.
I didn't have the time to look at the FCKEditor and check what their processing is doing on paste. I now suspect (but without being backed up by actual research) that may be something in that area. Can you do the same "bit of processing" for the CTRL+V and see if the content comes up right?
There doesn't appear to be a problem (or as much of one) on paste. If you copy from a non-AIR source, links, tables, and some other tags come through (inline formatting doesn't seem to). It's mostly that when copying from an HTML control in AIR that it only copies the plain text. The following function is my "bit of processing", and seems to work well for copying content from the main portion of a web page in the embedded HTML control .. but it doesn't work for content that's in the FCK editor within the HTML control (in AIR).
The getSelectedHTML function is used within an event listener function that's watching for keypresss (Ctrl+C in particular) .. although this also is trapped by FCK and causes other issues.
// portions borrowed from .. http://www.codingforums.com/archive/index.php/t-154848.html
private function getSelectedHTML(htmlWindow:Object):String
var sel:Object = htmlWindow.getSelection()
var html:String = "";
for (var i:int=0;i<sel.rangeCount;i++)
var d:Object = htmlWindow.document.createElement("span");
var r:Object = sel.getRangeAt(i);
var parent_element:Object = r.commonAncestorContainer;
var prev_html:String = parent_element.innerHTML;
html += d.innerHTML;
parent_element.innerHTML = prev_html;
private function keyListener(event:KeyboardEvent):void
var html:String = getSelectedHTML(html1.htmlLoader.window);
systemClipboard.setData(ClipboardFormats.HTML_FORMAT, html, false);
1 person found this helpful
I've logged an internal feature request for enabling rich (HTML) copy-paste in AIR HTMLLoader so this may come up sometimes in the future versions of AIR (no promise though)
I also came across this project that uses FCKEditor in Flex/AIR http://labs.aboutme.be/flex_fckeditor/ but of course the issue still exists as AIR only copies simple text - http://adobeair.walrusclub.com/2009/08/18/using-fckeditor-in-flex-and-air-at-aboutme-blog/
At least I'm not missing anything here .. I'll see what I can do to work around it for now and hope that this functionality is added in the future.
Indeed we logged your problem and it also got fixed. To the best of my knowledge, this issue should work fine in the latest beta of AIR 2 (beta2).
Hope this helps,
Sorry for the delayed reply. It definitely looks like this has been fixed .. thank you so much!