Django,django-ckeditor,Google MDL:无法读取未定义的 属性 'getSelection'

Django, django-ckeditor, Google MDL: Cannot read property 'getSelection' of undefined

我正在使用 Django 1.11 和 django-ckeditor 管理面板中的文本字段,以及管理外的一些输入(在 public 表单中)。作为 CSS 框架 - Google material 精简设计。

当我尝试将 ckeditor 集成到 public 表单时,charfield 与 ckeditor 根本不起作用。我无法专注于此字段,当我点击任何 ckeditor control 元素时,我收到错误

Uncaught TypeError: Cannot read property 'getSelection' of undefined
at CKEDITOR.dom.selection.getNative (ckeditor.js:445)
    at CKEDITOR.dom.selection (ckeditor.js:443)
    at a.CKEDITOR.editor.getSelection (ckeditor.js:440)
    at CKEDITOR.plugins.undo.Image (ckeditor.js:1174)
    at CKEDITOR.plugins.undo.UndoManager.save (ckeditor.js:1169)
    at a.b (ckeditor.js:1164)
    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.execCommand (ckeditor.js:271)

并且在 Firefox 中:

TypeError: this.document.getWindow(...).$ is undefined
getNative http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:445:29
    CKEDITOR.dom.selection http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:443:54
    CKEDITOR.editor.prototype.getSelection http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:440:319
    CKEDITOR.plugins.undo.Image http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:1174:458
    save http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:1169:123
    b http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:1164:291
    n http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:10:222
    CKEDITOR.event.prototype</<.fire</< http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:12:42
    CKEDITOR.editor.prototype.fire http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:13:212
    execCommand http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:271:120
    CKEDITOR.ui.button/<.click< http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:654:417
    execute http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:655:478
    render/q< http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:656:324
    addFunction/< http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:31:216
    callFunction http://127.0.0.1:8000/static/ckeditor/ckeditor/ckeditor.js:31:332
    onclick http://127.0.0.1:8000/accounts/trip/2/:1:1

ckeditor.js 445行:

x?this.document.$.selection:this.document.getWindow().$.getSelection()},getType:x?function(){var a=this._.cache;if(a.type)return a.type;var b=CKEDITOR.SELECTION_NONE;try{var c=this.getNative(),d=c.type;"Text"==d&&(b=CKEDITOR.SELECTION_TEXT);"Control"==d&&(b=CKEDITOR.SELECTION_ELEMENT);c.createRange().parentElement()&&(b=CKEDITOR.SELECTION_TEXT)}catch(e){}return a.type=b}:function(){var a=this._.cache;if(a.type)return a.type;var b=CKEDITOR.SELECTION_TEXT,c=this.getNative();if(!c||!c.rangeCount)b=CKEDITOR.SELECTION_NONE;

Forms.py:

from ckeditor_uploader.widgets import CKEditorUploadingWidget


class PaymentForm(forms.Form):
    comments = forms.CharField(widget=CKEditorUploadingWidget())

为了集成 ckeditor js 脚本,我在模板中使用 {{ form.media }}

首先,我尝试搜索有关此错误的信息和任何已知的修复方法,但发现的任何方法都不适合我。我在这里也发现了一些与 ckeditor 类似的问题,但没有任何有效的解决方案。

当我检查所有 js 脚本时,我在 Google material design lite css framework https://github.com/google/material-design-lite[=23= 的 Javascript 中发现了问题]

material.min.js 集成到页面脚本时 - ckeditor 不工作。未缩小框架 js:https://code.getmdl.io/1.3.0/material.js

PS: 这是我第一次在这里提问,不便之处,敬请谅解。

感谢您的帮助!

进行了一些更改以使 django-ckeditor 与 google material design lite 框架一起工作。如果需要,您可以使用此版本的 django-ckeditor(我的叉子):https://github.com/wardal/django-ckeditor while we waiting official answer and solutions here: https://github.com/django-ckeditor/django-ckeditor/issues/429