helloflask / flask-ckeditor

CKEditor integration for Flask, including image upload, code syntax highlight, and more.
https://flask-ckeditor.readthedocs.io
MIT License
202 stars 68 forks source link

Ckeditor disappear when enable code snippet #10

Closed ghost closed 6 years ago

ghost commented 6 years ago

when i enable code snippets with (app.config['CKEDITOR_ENABLE_CODESNIPPET'] = True) ckeditor disappear.

I must have to install any plugin or lib ?

greyli commented 6 years ago

How do you include the CKEditor resources? Please provide the related code.

ghost commented 6 years ago

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

greyli commented 6 years ago

This line is redundant, please try to remove it:

<script src="https://cdn.ckeditor.com/4.10.0/standard/ckeditor.js"></script>
ghost commented 6 years ago

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 ?