CKEDITOR-无法编辑文本或使用任何按钮

CKEDITOR - cannot edit text or use any of the buttons

本文关键字:任何 按钮 文本 编辑 CKEDITOR-      更新时间:2023-09-26

我有一个div,单击它将打开CKEDITOR。我希望将div的内容加载到编辑器中。当我点击关闭编辑器时,我希望编辑器的内容显示在div中

这是我的代码:

<script>
    var editor;
    $(function () {
        if (editor != null) {
            editor.destroy(true);
        }
        else {
            editor = null;
        }
        editor = CKEDITOR.replace('editor1');
       $('.textObj').on('dblclick', function () {
          $('#cke_editor1').show();       
          $("#cke_1_contents").html($('.textObj').html());
       })
       $('#cke_1_top').on('dblclick', function () {
          $('.textObj').html($('#cke_1_contents').html());
          $('#cke_editor1').hide();
       })
</script>
<div class="textObj">Here is some Text</div>
<textarea name="editor1" id="editor1" contenteditable="true"></textarea>

当我双击div时,它会按预期打开编辑器,编辑器中确实包含div中的文本。但是,我无法编辑文本,当我单击其中一个按钮时,我会收到错误:Unaught TypeError:无法读取undefined的属性"getSelection"。

有人能帮忙吗?

为什么要同时拥有textarea和div?

使用ckeditor内联编辑。

删除文本区域。

将contenteditable="true"添加到div。

相关文章: