【问题标题】:How to get HTML text from Adobe Flex Builder RichTextEditor?如何从 Adob​​e Flex Builder RichTextEditor 获取 HTML 文本?
【发布时间】:2011-01-10 23:13:21
【问题描述】:

如何从输入和编辑的文本中获取 HTML 文本到Adobe Flex Builder RichTextEditor control?我的意思是 具有来自 Flex RichTextEditor 组件的有效 HTML

不是格式错误的 HTML,没有空格,标签没有关闭!

所以我们用 RTE a-la 编辑了一些文本 alt text http://livedocs.adobe.com/flex/3/html/images/RTE1.png

我们希望以 HTML 格式获取其内容。这种事情怎么办?

【问题讨论】:

    标签: flash apache-flex actionscript mxml rich-text-editor


    【解决方案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, “”);
    

    这就解释了缺少的&lt;/p&gt; 标签。

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-03-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-07
        • 2010-09-28
        相关资源
        最近更新 更多