我正在尝试将 ckeditor 配置为不更改原始元素(textarea)中的任何内容,除非用户在加载编辑器后明确进行更改。我将 autoUpdateElement 设置为 false,但是一旦触发了 instanceReady 事件,textarea 就已经被修改了。
例如:如果我有然后加载ckeditor,它会自动将元素更改为小写()。
我知道在视觉上这并不重要,但我正在尝试对其进行配置,以使所有原始内容都完全不变。
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; // don't wrap everything with p tags
CKEDITOR.config.ignoreEmptyParagraph = false; // output an empty value ('') if its content only consists of an empty paragraph.
CKEDITOR.config.allowedContent = true; // turn off advanced content filtering
CKEDITOR.config.fillEmptyBlocks = false; // don't add * This will remove from <p> </p>; set to true and it will ALWAY ADD
CKEDITOR.config.autoUpdateElement = false; // still updating?
CKEDITOR.on('instanceReady', function (event) {
alert($("#item_ckeditor").val());
// normalize has been done and the contents has been made dirty. reset to we can determine user changes
event.editor.resetDirty();
event.editor.execCommand('source');
});
$("#item_ckeditor").ckeditor();
$("#item_docompare").on("click", function (event) {
var $textarea = $("#item_ckeditor"),
editor = $textarea.ckeditorGet();
alert($textarea.val());
if (editor.checkDirty()) // only update the textarea if something was changed
{
alert('updating');
editor.updateElement();
}
editor.destroy();
alert($textarea.val());
});