我已经使用(优秀的)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/