0

Ich benutze Django 1.11 und django-ckeditor für Textfelder im Admin-Panel und auch für einige Eingaben außerhalb des Admins (in öffentlichen Formularen). Als CSS Framework - Google Material Design Lite.Django, django-ckeditor, Google MDL: Eigenschaft 'getSelection' von undefined nicht lesen

Wenn ich versuche, ckeditor zu öffentlichen Formularen zu integrieren, funktioniert Charfield mit ckeditor überhaupt nicht. So etwas kann ich nicht auf diesen Bereich konzentrieren, und wenn ich zu einem ckeditor control Elemente klicken bekomme ich Fehler

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) 

Und in 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 line:

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()) 

Um ckeditor js Skripte zu integrieren verwende ich {{ form.media }} in Vorlage.

Zuerst habe ich versucht, Informationen über diese Fehler und alle bekannten Fixes zu suchen, aber irgendeine der gegründeten funktioniert nicht für mich. Auch hier habe ich einige ähnliche Fragen mit ckeditor gestellt, aber ohne funktionierende Lösung.

Wenn ich all js Skripte überprüft, fand ich dieses Problem in Javascript von Google-Material-Design lite CSS-Framework https://github.com/google/material-design-lite

Wenn material.min.js auf Seite Skripte integriert werden - ckeditor funktioniert nicht. Nicht verkleinerten Rahmen js: https://code.getmdl.io/1.3.0/material.js

PS: Dies ist meine erste Frage, die jemals hier gemacht, Entschuldigung für etwaige Unannehmlichkeiten.

Danke für jede Hilfe!

Antwort

Verwandte Themen