0 Replies Latest reply on Jan 19, 2011 9:49 AM by Esfera Critica

    Spark TextArea: Save selected text with format

    Esfera Critica Level 1

      Hello!

       

      I'm having a problem with text, the I'm going to try and explain the best I can.

       

      This is what I have:

       

      - A Spark TextArea;
      - Buttons with some functions similar to RichTextEditor;
      - A "Save Selection" button.

       

      This is what I want:

       

      - The user writes a text;
      - He formats it - Bold, font, color, underline, etc;
      - The user saves all the text - It goes to sql throught php - including format;
      - The text saved correctly including format;

       

      - The user selects a bit of text;
      - The user hits "Save Selection";
      - The text looses some format;

       

      Example:

       

      This is <b>just a <u>text</u> for demonstrating</b> my problem...

       

      - If the user starts selecting the second word - "is" - the selection is saved correctly;
      - If the user starts selecting the 5 word - "text" - the selection is saved with Underline, but without Bold;
      - If I copy/paste the selection, it keeps the Bold and the Underline.

       

      For what I'm seeing, I need to somehow get the opening tag, in this case the Bold tag.

       

      I thought of the following:

      - Read the selected string until it finds a "</", then go back until it finds the correspondent open tag. The problem is that it can contain several close tags. If a user makes a wide selection and changes the font, then a smaller selection and changes the color, then an even smaller selection and puts the bold in it...

       

      Is there a way/function in Flex to do something like the system copy/paste. If so, when the user hits "Save Selection" I would copy the selection to an invisible TextArea, and send that TextArea content to php/sql. I thought of this because if I copy/paste(Ctrl+C, Ctrl+V) the text it keeps everything formated.

       

      I'm sorry for my long post, but was trying to explain the best I can, and I'm not english, so sorry for some errors...

       

      Best regards,
      Alexandre