It does work this way, yes. I also remember that there was no easy way to extend the default exporter and/or to use this custom exporter for a text component instances, due to the complex class hierarchy and to missing properties to directly control this, but it could have been improved since I looked into it.
2013/11/4 Alex Harui <aha...@adobe.com> > So is it as simple as serializing non-strings to text and de-serializing > on import? > > > On 11/3/13 11:12 PM, "Harbs" <harbs.li...@gmail.com> wrote: > > >Here is a simple test case which illustrates the problem. I can change my > >app for custom handling of copy/paste, but it seems to me that this is a > >general short-coming in the was copy paste is handled in TLF. > > > >Note: customStyle1 is preserved when the TextFlow is exported because > >it's simple text, but customStyle2 is not preserved. > > > >The result of TextFlowExporter.export() is what's written to the > >clipboard, so it's missing any complex custom styles. > > > ><?xml version="1.0" encoding="utf-8"?> > ><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" > > xmlns:s="library://ns.adobe.com/flex/spark" > > xmlns:mx="library://ns.adobe.com/flex/mx" > minWidth="955" > >minHeight="600" creationComplete="onComplete()"> > > <fx:Script> > > <![CDATA[ > > import flashx.textLayout.conversion.ITextExporter; > > import flashx.textLayout.conversion.TextConverter; > > import flashx.textLayout.edit.EditManager; > > import flashx.textLayout.elements.ParagraphElement; > > import flashx.textLayout.elements.SpanElement; > > import flashx.textLayout.elements.TextFlow; > > import flashx.undo.UndoManager; > > [Bindable]private var textFlow:TextFlow; > > > > private function onComplete():void{ > > var para:ParagraphElement; > > var span:SpanElement; > > var i:int; > > textFlow = new TextFlow(); > > textFlow.interactionManager = new > EditManager(new UndoManager()); > > textFlow.tabStops = "s12 s72"; > > textFlow.paragraphSpaceAfter = 16; > > para = new ParagraphElement(); > > span = new SpanElement(); > > span.fontSize = 16; > > span.fontWeight = "bold"; > > span.text = "Here's some text."; > > span.setStyle("customStyle1","hello"); > > > span.setStyle("customStyle2",{id:1,content:"this is some custom > >content"}); > > para.addChild(span); > > textFlow.addChild(para); > > > > var exporter:ITextExporter = > >TextConverter.getExporter("textLayoutFormat"); > > var res:Object = > exporter.export(textFlow,"stringType"); > > trace(res); > > } > > ]]> > > </fx:Script> > > <s:RichEditableText verticalCenter="0" width="400" > >textFlow="{textFlow}"/> > > > ></s:Application> > > > >Harbs > > > >On Nov 4, 2013, at 7:21 AM, Alex Harui wrote: > > > >> I'm not sure what user styles are and why the aren't in the markup. Can > >> you provide more details? > >> > >> Consider whether this is a general TLF issue or just something you > >>should > >> do in your app to add functionality. A general TLF issue probably can't > >> bypass the Clipboard because you should be able to copy/paste from one > >>SWF > >> to another SWF. > >> > >> -Alex > >> > >> On 11/3/13 1:01 PM, "Gavriel Harbater" <gavha...@gmail.com> wrote: > >> > >>> Okay. After researching this, it looks like the problem is as follows: > >>> > >>> The TextFlow is saved to the clipboard as a string which is the markup > >>> representation of the TextFlow. The markup is produced using > >>> BaseTextLayoutExporter.export(). The markup produced from that is > >>>missing > >>> custom user styles. My custom user styles are actually quite complex > >>> classes. > >>> > >>> I'm looking for suggestions on the best way to handle this problem. I > >>>can > >>> think of three possible angles: > >>> 1) Somehow write user styles into the TextFlow markup. I'm not sure if > >>> there's a way to markup custom styles and complex ones are definitely > >>>an > >>> issue. > >>> 2) Write complex objects to the clipboard. Is this possible? If yes, > >>>why > >>> are strings currently used? > >>> 3) Skip the clipboard altogether and create some static function to > >>>call > >>> when the clipboard content is pasted to apply custom styles. > >>> > >>> Thoughts? > >>> > >>> On Nov 3, 2013, at 10:13 AM, Harbs wrote: > >>> > >>>> Looking into an issue I had, I noticed that user styles in TLF are not > >>>> preserved on copy/paste. (Actually, it would probably be more correct > >>>>to > >>>> say that they're not preserved on copy.) > >>>> > >>>> I'm looking into TextScrap/TextClipboard now, but if anyone has > >>>> experience here as to why the styles are being dropped, I'd love to > >>>>knowŠ > >>>> > >>>> Harbs > >>> > >> > > > >