Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
WhiteSpaceCollapse is applied as part of the import. After that changing it or modifying it has no effect.
Richard
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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;