Skip to main content
Inspiring
June 3, 2010
Question

whiteSpaceCollapse not working on textFlow created from HTML

  • June 3, 2010
  • 2 replies
  • 4102 views

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

This topic has been closed for replies.

2 replies

April 9, 2012

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_HTML_FORMAT);

textArea.textFlow = importtedTextFlow;

Adobe Employee
June 4, 2010

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

Richard

December 15, 2011

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...

Participating Frequently
December 16, 2011

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