CkEditor - 未捕获的类型错误:无法读取未定义的属性“getSelection”

Sho*_*ani 3 javascript jquery ckeditor

我正在CKEditor我的应用程序中实现。当我尝试实例化CKEditor到 textarea 时,出现以下错误

Cannot read property 'getSelection' of undefined
Run Code Online (Sandbox Code Playgroud)

在 ckeditor 的下面一行

getNative: function() {
 return void 0 !== this._.cache.nativeSel ? this._.cache.nativeSel : this._.cache.nativeSel = B ? this.document.$.selection : this.document.getWindow().$.getSelection() }
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢。

Bri*_*hez 5

  1. 我有一个文章列表。
  2. 每次我点击任何文章时,都应该打开一个“对话框/模式”。
  3. 在这样的对话框或模式中,我的文章内容有一个 ckeditor 元素。
  4. 当我点击第一个时,它就像一个魅力。
  5. 问题是在点击第二个、第三个、第四个等之后。

然后我开始出现这个错误。

    TypeError: Cannot read property 'getSelection' of undefined
    at CKEDITOR.dom.selection.getNative (ckeditor.js:448)
    at new CKEDITOR.dom.selection (ckeditor.js:446)
    at a.CKEDITOR.editor.getSelection (ckeditor.js:443)
    at new CKEDITOR.plugins.undo.Image (ckeditor.js:1182)
    at CKEDITOR.plugins.undo.UndoManager.save (ckeditor.js:1177)
    at a.<anonymous> (ckeditor.js:1173)
    at a.n (ckeditor.js:10)
    at a.CKEDITOR.event.CKEDITOR.event.fire (ckeditor.js:12)
    at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
    at a.setData (ckeditor.js:275)
Run Code Online (Sandbox Code Playgroud)

我的解决方案很简单,告诉计算机在对话框/模式关闭时销毁 ckeditor 实例。容易!..现在就像一个魅力=)

           $mdDialog.show({
             parent:      parentEl,
             targetEvent: $event,
             templateUrl: '/md-templates/blog-article.html',
             controller:  DialogController,
             scope:         $scope,
             preserveScope: true,
            onRemoving: function (event, removePromise) {
                if (CKEDITOR.instances.body) CKEDITOR.instances.body.destroy();
            }
        });
Run Code Online (Sandbox Code Playgroud)