我正在我的应用程序中实现CKEditor
。当我尝试将 CKEditor
实例化到文本区域时,出现以下错误
Cannot read property 'getSelection' of undefined
在 ckeditor 的下面一行
getNative: function() {
return void 0 !== this._.cache.nativeSel ? this._.cache.nativeSel : this._.cache.nativeSel = B ? this.document.$.selection : this.document.getWindow().$.getSelection() }
非常感谢任何帮助。
最佳答案
- 我有一个文章列表。
- 每次我点击任何文章时,都会打开一个“对话框/模式”。
- 在这样的对话框或模式中,有一个用于我文章内容的 ckeditor 元素。
- 当我点击第一个时,它就像一个魅力。
- 问题出在点击第二个、第三个、第四个等之后。
然后我开始遇到这个错误。
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)
对我来说,解决方案很简单,告诉计算机在对话框/模式关闭时销毁 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();
}
});
关于javascript - CckEditor - 未捕获类型错误 : Cannot read property 'getSelection' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42005430/