您使用的是什么版本的框架?当我尝试使用 3.2 创建链接示例的副本时,我得到了格式正确的 HTML。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:HBox width="100%" height="100%">
<mx:RichTextEditor id="rte" />
<mx:TextArea height="{rte.height}" width="{rte.width}" text="{rte.htmlText}" />
</mx:HBox>
</mx:Application>
我的 Flex 3.2 输出看起来像这样,丑陋但格式良好:
<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Verdana" SIZE="12" COLOR="#009900" LETTERSPACING="0" KERNING="1"><B>This is the way the world ends</B></FONT></P></TEXTFORMAT>
您的示例站点中的相同文本给出了错误的格式:
<P text-align:CENTER;><span style="font-family:Verdana; font-size:12px; color:#009900; "><strong>This is the way the world ends</strong></span>
(您可能会发布示例的源代码;您启用了“查看源代码”,但它实际上不可用。)
编辑:
您正在使用的外部代码执行以下修改,以及其他修改:
pattern = /<\/P>/g;
str = str.replace(pattern, “”);
这样就解释了缺少的</p>
标签。
我不确定他们的用例是什么,但它看起来与您想要的不同。如果您想清除htmlText
RichTextEditor 返回的默认值,您可以考虑修改博客代码以满足您的需要。