【问题标题】:CLEditor/TinyMCE rendering incorectlyCLEditor/TinyMCE 渲染不正确
【发布时间】:2013-11-13 01:42:33
【问题描述】:

我正在尝试将CLEditor 合并到我的一个应用程序中。但在某处,这是一个导致一些渲染问题的断开连接。

前端使用 jQuery/HTML/CSS 后端使用 Java/Oracle/Spring/Struts 2,我不太确定问题出在哪里。我认为是 CLEditor 不知何故弄糊涂了。

我的代码如下所示。

<textarea id="editor" name="contractTemplate.contractBody" value="${contractTemplate.contractBody}"></textarea>

在页面下方,我将 CLEditor 设置如下:

<script type="text/javascript">
  $(function() {

    $('#editor').cleditor({
      width: 'auto',
      height: 300,
      controls: "font bold italic | " +
              "bullets numbering | " +
              "alignleft center alignright justify | " +
              "outdent indent | " +
              "undo redo " +
              "rule | cut copy paste pastetext | print source",
      fonts: // font names in the font popup
              "Arial,Arial Black,Courier New,Narrow,Garamond," +
              "Georgia,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",
      bodyStyle: "margin:4px; font: 10pt Arial, Verdana; cursor:text",
      docType: '<!DOCTYPE html>'
    });


  });
</script>

当我第一次加载textarea 所在的页面时,它显示得很好。我可以使用左对齐,右对齐,居中来格式化我希望的东西。我能够创建外观合适的ulol(我需要的大部分功能)。我还可以使用提供的Show Source 查看代码。我提交给我的Action,它按预期保存了我在CLOB 中发送的格式化文本。但是,当我重新访问要编辑的页面(我的一个用例)时,以前格式化的文本已损坏...通常,如果我右对齐了一些文本,它会从其中剥离标签,强制左对齐,并在末尾添加 "&gt; textarea 的。你可以想象从那里引入的混乱。如果您没有捕捉到 "&gt; 并保存它,则会删除所有文本,只有 "&gt; 幸存,随后的保存将使您将 "&amp;gt; 保存到数据库中。

这个问题可能来自哪里?到目前为止,我找不到任何有类似问题的人。

提前感谢您的帮助!

编辑:

也许问题与 CLEditor 无关...我只是通过快速安装抛出 TinyMCE

<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script>
        tinymce.init({selector:'textarea'});
</script>

我得到了同样的行为......

编辑:

进一步调查表明,沿线某处没有正确逃脱。

这是来自Inspect Element 功能:

<textarea aria-hidden="true" style="display: none;" id="editor" name="contractTemplate.contractBody" value="<p style=" text-align:="" right;"="">Right Align&lt;/p&gt;
&lt;p style="text-align: center;"&gt;Center&lt;/p&gt;
&lt;p style="text-align: left;"&gt;Left Align&lt;/p&gt;"&gt;</textarea>

如您所见,value="&lt;p style" 最终关闭了引用并且没有正确地逃避事情。页面越往下,事情就会从 &lt; and &gt; 变为 &amp;gt; and &amp;lt; 我看到了问题,但不知道如何解决。

【问题讨论】:

    标签: java spring oracle tinymce cleditor


    【解决方案1】:

    希望有人会从我缺乏关注中受益……两位编辑都没有错。上面描述的问题是我没有注意我在做什么。我不会删除问题,而是留下它,希望有人会搜索并查看我在解决他们的问题时做错了什么......

    使用textarea 时不要使用&lt;textarea value="some value"&gt;&lt;/textarea&gt; 使用&lt;textarea&gt;some value&lt;/textarea&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多