CKeditor不会在源代码模式下更新文本区域

CKeditor does not update text area in source mode

本文关键字:更新 文本 区域 模式 源代码 CKeditor      更新时间:2023-09-26

我正在尝试在我的网站上使用CKeditor。我发现,当处于源模式时,被ckeditor替换的文本区域不会更新。我需要更新文本区域,因为页面上的代码设置为在保存时保存文本区域内容。

在正常模式下,正在更新文本。

$(document).ready(new function() {
    var editor = CKEDITOR.instances['content-text'];
    if (editor) { editor.destroy(true); }
    CKEDITOR.on('instanceCreated', function(e) {
        e.editor.on('contentDom', function() {
            e.editor.document.on('keyup', function(event) {
                // keyup event in ckeditor
                UpdateTextArea();
            });
        });
    });
    CKEDITOR.replace('content-text');
});
function UpdateTextArea() {
    CKEDITOR.instances['content-text'].updateElement();
}

非常感谢您的帮助。这是我第一次问问题,如果我遗漏了什么,很抱歉!

我当时有点笨。

在我的输入按钮的onclick事件上,我只需要添加:

function UpdateTextArea() {        
    var editor_data = CKEDITOR.instances['content-text'].getData();
    $('#content-text').html(editor_data);
}