7 Replies Latest reply on Jul 10, 2009 2:45 PM by jdesko

    RichTextEditor

    jdesko Level 2

      I left a post earlier about the RichTextEditor when saving text and than retrieving,  extra line feeds are being added. 

      But another issue is -

      The RichTextEditor is a Halo component, and RichText is a spark component so with similar names it seems that RichText would have an easy html method like RichTextEditor (ie RichTextEditor.html = ""), plus RichText would be for display and RichTextEditor would be for creating/editing; maybe it's me and I'm missing something or maybe Adobe should change the names.  But that's a complaint or stupidity on my part. 

       

      Without using an itemrenderer, for sake of simplicity, is there an easy way of loading RichTextEditor html/rich text into a textarea or textbase?  So far I just load it into another instance of RichTextEditor (I do use itemrenderers to display it in Alerts or DataGrids), but I would like the rich/html text in a component without the user having editing ability but still have cut and paste to another component or good visibility (unlike when the RTE is disabled).  When it is loaded into RichTextEditor for viewing, the controls can be removed, but a user can still edit the text (just not save), and if disabled than they lose the ability to cut and paste to something else from it.  This would all be a moot point if the RTE doesn't use anymore overhead than another component that displays its text.

       

      Thanks in advance

      (If you've read this far, sorry for the rambling, can you tell it's been a long day of coding?)

        • 1. Re: RichTextEditor
          GordonSmith Level 4

          > The RichTextEditor is a Halo component, and RichText is a spark component so with similar names

           

          The new Spark "text primitives" are SimpleText, RichText, and RichEditableText. This nomenclature may create some confusion with the old Halo RichTextEditor, but after lots of discussions we felt they were the best names to describe what they do, and we wanted the best names going forward. RichTextEditor, like other Halo components, will at some point become obsolete when the Spark component set is complete.

           

          > it seems that RichText would have an easy html method like RichTextEditor

           

          The richness that RichText and RichEditableText is that of TLF, the new Text Layout Framework. TLF has a markup language that is similar to XHTML, but in TLF the primary representation of rich text isn't markup. Instead, it's a tree of ActionScript objects such as DivElements, ParagraphElements, and SpanElements. The root of this tree is an object known as a TextFlow.

           

          Therefore in the latest trunk builds of Gumbo, RichText and RichEditableText expose a 'textFlow' property which you set to a TextFlow. If you have markup as a String or as XML, there is now a utility class called TextFlowUtil for converting the markup to and from a TextFlow. A TextFlow is very powerful because you can access its parts as ActionScript objects and change them at runtime.

           

          Halo components did not have an object-oriented model of rich text, so they just exposed the htmlText:String property, which is not as powerful when you want to change just part of a long document.

           

          > is there an easy way of loading RichTextEditor html/rich text into a textarea

           

          Doesn't myTextArea.htmlText = myRichTextEditor.htmlText do what you want?

           

          Gordon Smith

          Adobe Flex SDK Team

          • 2. Re: RichTextEditor
            jdesko Level 2

            Gordon;

            Thank you very much for the reply, it was extremely informative and helpful;

            and thank you for your time.

             

            John D.

            • 3. Re: RichTextEditor
              jdesko Level 2

              Gordon;

               

              Before I wrote my message in the forum I did try a sparks TextArea declared

              in MXML and then in a script try to access the htmlText as you showed below

              - this is flex's response:

               

              Description    Resource    Path    Location    Type

              1119: Access of possibly

              undefined property htmlText through a reference with static type

              spark.components:TextArea.   line 177    Flex Problem

               

              Also, in the language reference I did not see mention of htmltext property

              or method.

               

              I always say has to be user error.

               

              Thanks again for your help and time,

              John

              • 4. Re: RichTextEditor
                GordonSmith Level 4

                Sorry, I thought you were trying to just take HTML out of a Halo RichTextEditor and put it into a Halo TextArea. It sounds like you want to put it into a Spark TextArea.

                 

                In current builds, I think you could do this by using TLF's TextConverter class. It supports various formats of markup strings, including HTML_FORMAT, and lets you create TextFlows from them. So you could try doing something like this:

                 

                mySparkTextArea.textFlow = TextConverter.importToFlow(myRichTextEditor.htmlText, TextConverter.HTML_FORMAT);

                 

                Gordon Smith

                Adobe Flex SDK Team

                • 5. Re: RichTextEditor
                  jdesko Level 2

                  Gordon;

                   

                  Thanks again for the replay.  To be a little clearer...

                   

                  I am trying to use all sparks components if possible, as was suggested in

                  Adobe docs, plus it sounds like Halo is being phased out.

                   

                  One part of this app is to have users write text and/or cut and paste from

                  another app, and Halo's RichTextEditor was the simplest interface to

                  implement and it fit this task perfectly with all the UIComponents and

                  RichText capability.  Another part of the app was to have the users view the

                  original docs in one panel and in a side panel edit/update the originals,

                  plus have the ability to cut and paste from the original if need be. Again,

                  Halo RTE was the simplest for me to implement and it fit this task

                  perfectly, but I am trying to use Spark components if possible (less

                  re-writes down the road to keep up to date).

                   

                  Thanks again for your time and help, much appreciated,

                  John

                  • 6. Re: RichTextEditor
                    GordonSmith Level 4

                    I'd be concerned that trying to "interop" between the two text models might cause problems... The way text renders in a Halo component like RichTextEditor, which is based on TextField, can be somewhat different from the way it renders in a Spark component like RichText, which is based on FTE and TLF. My suggestion would be to develop your own version of RichTextEditor, by taking the Spark TextArea component and adding a toolbar above it with formatting controls.

                     

                    Gordon Smith

                    Adobe Flex SDK Team

                    • 7. Re: RichTextEditor
                      jdesko Level 2

                      Gordon;

                       

                      Again, thank you for your time and insight.

                       

                      I had planned on doing your suggestion below, as I've seen this recently

                      recommended.

                       

                      Please let me know when your FlashBuilder book comes out; I'll be first in

                      line. 

                       

                      I appreciate and enjoy your thorough answers.

                       

                      John