3

How to get HTML text from inputed and edited text into Adobe Flex Builder RichTextEditor control? I mean with valid HTML coming from the Flex RichTextEditor component

Not Badly formated HTML, with no spaces, with tags not closed!

So we have some text edited with RTE a-la alt text http://livedocs.adobe.com/flex/3/html/images/RTE1.png

We want to get its content as HTML. how to do such thing?

4

2 回答 2

3

有一个非常好的类称为RteHtmlParser,它可以将 RTE 生成的“html”转换为 html 并返回。我一直在一个项目中使用它,效果很好。您可以在此处查看实时示例并获取源代码:http: //blog.flashweb.org/archives/7

于 2010-01-29T19:38:03.213 回答
1

您使用的是什么版本的框架?当我尝试使用 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>标签。

我不确定他们的用例是什么,但它看起来与您想要的不同。如果您想清除htmlTextRichTextEditor 返回的默认值,您可以考虑修改博客代码以满足您的需要。

于 2010-01-29T18:40:47.407 回答