Skip navigation
Currently Being Moderated

whiteSpaceCollapse not working on textFlow created from HTML

Jun 3, 2010 12:31 PM

Is there a trick to getting whiteSpaceCollapse to work with imported HTML? Here's my current code, where value is HTML text (e.g. "<p>Blah</p>.."):

 

textFlow = TextConverter.importToFlow( value, TextConverter.TEXT_FIELD_HTML_FORMAT);

 

 

 

 

 

textFlow.whiteSpaceCollapse = WhiteSpaceCollapse.COLLAPSE;

 

I've also set whiteSpaceCollapse on the RichEditableText to "collapse" but I'm still noticing vertical space differences if my external HTML has linebreaks between <p></p> nodes. Many thanks in advance for any suggestions.

 

-Robert

 
Replies
  • Currently Being Moderated
    Jun 4, 2010 10:51 AM   in reply to ROBERT REINHARDT

    WhiteSpaceCollapse is applied as part of the import.  After that changing it or modifying it has no effect.

     

    Richard

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2011 3:27 PM   in reply to rdermer

    And so ? How do we set the TextConverter to avoid collapsing white spaces on import now ?

     

    I ve tried many ways but still no way to avoid a WEIRD behavior.
    If I set spaces and I want to collapse them, then I can do it with a simple search/replace, there are plenty

    of regex out there to do this.

    I don't need the framework to behave strangely right ? So why did the flex engineers spend time

    on putting together stuff that is totally weird ?
    Plus the TextConverter has a lot of tlf_internal methods, just to avoid us to overload its functionnalities...

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2011 9:23 PM   in reply to aliman

    Hi aliman,

    Did you set format string to TextConvertr.PLAIN_TEXT_FORMAT ? That will preserve your spaces I think. 

    var textFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.PLAIN_TEXT_FORMAT); 

     

    And for tlf_internal, i just find one tlf_internal function in TextConverter. Others are public.

    static tlf_internal function setFormatsToDefault():void

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2012 11:16 AM   in reply to ROBERT REINHARDT

    this is the way to solve this bug and no need for changing any xml settings , simple and it works

     

    exporting the textflow:

     

    var richTextXML:xml = new XML("<"+"richTextXML"+"/>");

     

    richTextXML.appendChild(getCdataXMl());

     

    private function getCdataXMl():xml{

     

      var textFlowStr:String = TextConverter.export(textFlow,TextConverter.TEXT_FIELD_HTML_FORMAT

     

    , ConversionType.STRING_TYPE).toString();

     

    var textFlowXMl:xml = new XMl("<![CDATA["+textFlowStr+"]]>");

     

    return textFlowXMl;

     

    }

     

    importing TextFlow from XMl :

     

    var htmlTextInStr:String = richTextXMl.text();

     

    var importtedTextFlow:TextFlow = TextConverter.importToFlow(htmlTextInStr,TextConverter.TEXT_FIELD_HTM L_FORMAT);

     

    textArea.textFlow = importtedTextFlow;

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points