0

我正在使用 Django 1.11 和django-ckeditor管理面板中的文本字段,以及管理外部的一些输入(以公共形式)。作为一个 CSS 框架 - 谷歌材料设计精简版。

当我尝试集成ckeditor到公共表单时,带有 ckeditor 的charfield根本不起作用。像我无法专注于这个领域,当我点击任何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;

表格.py:

from ckeditor_uploader.widgets import CKEditorUploadingWidget


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

要集成我{{ form.media }}在模板中使用的 ckeditor js 脚本。

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

当我检查所有 js 脚本时,我在 Google Material Design lite css 框架的 Javascript 中发现了这个问题https://github.com/google/material-design-lite

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

PS:这是我在这里提出的第一个问题,对任何不便表示歉意。

谢谢你的帮助!

4

1 回答 1

0

进行了一些更改以使 django-ckeditor 与 google material design lite 框架一起使用。如果需要,您可以使用这个版本的 django-ckeditor(我的 fork):https ://github.com/wardal/django-ckeditor我们在这里等待官方答案和解决方案:https ://github.com/django-ckeditor /django-ckeditor/issues/429

于 2017-09-13T07:49:47.700 回答