Closed ghost closed 6 years ago
How do you include the CKEditor resources? Please provide the related code.
init.py
from flask import Flask
from flask_ckeditor import CKEditor
app = Flask(__name__)
app.config['CKEDITOR_SERVE_LOCAL'] = True
app.config['CKEDITOR_ENABLE_CODESNIPPET'] = True
ckeditor = CKEditor(app)
post.html
<script src="https://cdn.ckeditor.com/4.10.0/standard/ckeditor.js"></script>
<form method="POST" action="" enctype="multipart/form-data">
<legend>{{ legend }}</legend>
{{ form.title.label }}<br>
{{ form.title() }}<br><br>
{{ form.content() }}<br>
{{ form.submit() }}
</form>
{{ ckeditor.load() }}
{{ ckeditor.config(name='content') }}
forms.py
from flask_ckeditor import CKEditorField
class PostForm(FlaskForm):
title = StringField('title', validators=[DataRequired()])
content = CKEditorField('content', validators=[DataRequired()])
submit = SubmitField('Post')
This line is redundant, please try to remove it:
<script src="https://cdn.ckeditor.com/4.10.0/standard/ckeditor.js"></script>
That solve the problem. Another question... is possible add a class to the tag generated by text editor before saving it to database, to add some CSS style ?
when i enable code snippets with (app.config['CKEDITOR_ENABLE_CODESNIPPET'] = True) ckeditor disappear.
I must have to install any plugin or lib ?