javascript - 什么 WYSIWYG 编辑器适用于 Velocity 模板?

标签 javascript ckeditor nvelocity

我已经使用(优秀的)CKeditor 有一段时间了,但是当我开始将它与 NVelocity 结合使用时,我开始遇到麻烦。事实证明,如果我像这样使用上下文关键字(比如 $GarbagePailKids,其中包含表格行的 HTML):

<table>
  <tbody>$GarbagePailKids</tbody>
</table>

CKEditor的所见即所得模式将无效的HTML纠正为:

$GarbagePailKids
<table>
  <tbody></tbody>
</table>

现在我一直在阅读的所有内容都表明您不要(或不能)关闭 CKeditor 纠正无效 HTML 的能力,我不想切换回文本区域(在宠坏了我的用户这么久之后与这个编辑器)。关于 CKEditor 之类确实有效的东西或者甚至是 CKEditor 的插件可以防止这种行为的任何想法?

最佳答案

我不确定 CKEditor 是否允许您想要的行为。我建议调查 Raptor Editor - http://www.raptor-editor.com/

我整理了一个示例,说明如何使用选项实例化 Raptor,以确保编辑器不会尝试修复无效的 HTML - JSFiddle .

Raptor 实例化是:

<textarea id="raptor">
    <table>
      <tbody>$GarbagePailKids</tbody>
    </table>
</textarea>
​
<script type="text/javascript">
    $('#raptor').editor({
        // Enable editor immediately
        autoEnable: true,
        // Replace the element with the editor
        replace: true,
        // Disable the cancel, save & dock buttons
        disabledUi: ['cancel', 'save', 'dock'],
        // Disable the unsaved edits warning, and the clean & empty element plugins, both of which will attempt to fix broken HTML
        disabledPlugins: ['unsavedEditWarning', 'clean', 'emptyElement'],
        // Disable the "you have unsaved edits on this page" warning triggered when one attempts to leave the page after editing
        unloadWarning: false,
        // Plugin specific options
        plugins: {
            // Docking options forcing the editor to be always docked to the textarea
            dock: {
                docked: true,
                dockToElement: true,
                persistent: false
            }                
        }                
    }); 
</script>

无论如何,浏览器通常会尝试更正无效的 HTML。

关于javascript - 什么 WYSIWYG 编辑器适用于 Velocity 模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11893488/

相关文章:

javascript - javascript 中事件文本区域(ckeditor)上的 Keyevent

c# - nvelocity最新源码在哪里

javascript - 当按下特定按钮时如何清除 setInterval?

javascript - 更改工具栏大小,放大 CKEditor 中的图标

javascript - 如何访问 Fastify 请求的原始正文?

javascript - CKEditor - 小部件 - 为按钮设置工具栏

c# - "if x in array"的 nvelocity/C# 等价物是什么?

xss - 如何处理 NVelocity 上的 XSS

javascript - jquery中Ctrl+F5清除浏览器缓存

javascript - 开发语法应用 SharePoint Online PrismJS