Home
> Uncategorized > Preserving whitespace when importing html into RichText / RichEditableText
Preserving whitespace when importing html into RichText / RichEditableText
If you import some HTML into a RichText or RichEditableText by default it won’t preserve whitespaces.
myRichTextComponent.textFlow = TextConverter.importToFlow(value, TextConverter.TEXT_FIELD_HTML_FORMAT);
To make it preserve whitespace you have to create a configuration and set it properly like that :
var format:TextLayoutFormat = new TextLayoutFormat();
format.whiteSpaceCollapse = WhiteSpaceCollapse.PRESERVE;
var config:Configuration = new Configuration();
config.textFlowInitialFormat = format;
And then you can use it to import your HTML in your RichText or RichEditableText :
myRichTextComponent.textFlow = TextConverter.importToFlow(html, TextConverter.TEXT_FIELD_HTML_FORMAT, config);
Categories: Uncategorized
Comments (0)
Trackbacks (0)
Leave a comment
Trackback