Ckeditor autoUpdateElement设置为false仍会更新文本区域
我试图将ckeditor配置为不更改原始元素(textarea)中的任何内容,除非用户在加载编辑器后显式进行更改。我将autoUpdateElement设置为false,但一旦触发instanceReady事件,textarea就已经被修改 例如: 如果我有,然后加载ckeditor,它会自动将元素更改为小写() 我知道这在视觉上并不重要,但我正在尝试对其进行配置,以使所有原始内容完全保持不变Ckeditor autoUpdateElement设置为false仍会更新文本区域,ckeditor,ckeditor4.x,Ckeditor,Ckeditor4.x,我试图将ckeditor配置为不更改原始元素(textarea)中的任何内容,除非用户在加载编辑器后显式进行更改。我将autoUpdateElement设置为false,但一旦触发instanceReady事件,textarea就已经被修改 例如: 如果我有,然后加载ckeditor,它会自动将元素更改为小写() 我知道这在视觉上并不重要,但我正在尝试对其进行配置,以使所有原始内容完全保持不变 CKEDITOR.config.enterMode=CKEDITOR.ENTER\u BR;//不要
CKEDITOR.config.enterMode=CKEDITOR.ENTER\u BR;//不要用p标签包装所有东西
CKEDITOR.config.ignoreEmptyParagraph=false;//如果内容仅包含空段落,则输出空值(“”)。
CKEDITOR.config.allowedContent=true;//关闭高级内容过滤
CKEDITOR.config.fillEmptyBlocks=false;//不要添加*这将从中删除;设置为true,它将始终添加
CKEDITOR.config.autoUpdateElement=false;//还在更新吗?
CKEDITOR.on('instancerady',函数(事件){
警报($(“#item_ckeditor”).val());
//规范化已完成,内容已变脏。重置为可以确定用户更改
event.editor.resetDirty();
event.editor.execCommand('source');
});
$(“#item_ckeditor”).ckeditor();
$(“#item_docompare”)。在(“单击”上,函数(事件){
var$textarea=$(“#项_ckeditor”),
编辑器=$textarea.ckeditorGet();
警报($textarea.val());
if(editor.checkDirty())//仅在发生更改时更新textarea
{
警报(“更新”);
editor.updateElement();
}
editor.destroy();
警报($textarea.val());
});
我发现做我想做的事情的唯一方法是自己存储原始信息(.data(“originalvalue”))。我希望有人能回答为什么autoupdateelement属性设置为false时仍然自动更新元素
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").data("originalvalue", $("#item_ckeditor").val()).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();
}
else
$textarea.val($textarea.data("originalvalue"));
editor.destroy();
alert($textarea.val());
});
CKEDITOR.config.enterMode=CKEDITOR.ENTER\u BR;//不要用p标签包装所有东西
CKEDITOR.config.ignoreEmptyParagraph=false;//如果内容仅包含空段落,则输出空值(“”)。
CKEDITOR.config.allowedContent=true;//关闭高级内容过滤
CKEDITOR.config.fillEmptyBlocks=false;//不要添加*这将从中删除;设置为true,它将始终添加
CKEDITOR.config.autoUpdateElement=false;//还在更新吗?
CKEDITOR.on('instancerady',函数(事件){
警报($(“#item_ckeditor”).val());
//规范化已完成,内容已变脏。重置为可以确定用户更改
event.editor.resetDirty();
event.editor.execCommand('source');
});
$(“#item_ckeditor”).data(“原始值”,$(“#item_ckeditor”).val()).ckeditor();
$(“#item_docompare”)。在(“单击”上,函数(事件){
var$textarea=$(“#项_ckeditor”),
编辑器=$textarea.ckeditorGet();
警报($textarea.val());
if(editor.checkDirty())//仅在发生更改时更新textarea
{
警报(“更新”);
editor.updateElement();
}
其他的
$textarea.val($textarea.data(“originalvalue”);
editor.destroy();
警报($textarea.val());
});
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").data("originalvalue", $("#item_ckeditor").val()).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();
}
else
$textarea.val($textarea.data("originalvalue"));
editor.destroy();
alert($textarea.val());
});