helloflask / flask-ckeditor

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

关于数据回显的问题 #31

Closed weijiang1994 closed 4 years ago

weijiang1994 commented 4 years ago

Q1: 我编写完了博客,然后保存到了数据库中,但是过了几天我想修改博客的内容,怎么能将数据库中的数据回显到CKEditor的编辑区域呢?

Q2: 图片好像不支持响应式?怎么在img标签上默认添加上class="img-fuild"标签呢?

Cyberbolt commented 4 years ago

同问Q1

Cyberbolt commented 4 years ago

Q1已解决,如果您没有使用Flask-WTF,通过 value传值即可。如 {{ ckeditor.create(value = 'test') }}

weijiang1994 commented 4 years ago

Q1已解决,如果您没有使用Flask-WTF,通过 value传值即可。如 {{ ckeditor.create(value = 'test') }}

使用了Flask-WTF怎么弄呢?

Cyberbolt commented 4 years ago

Q1已解决,如果您没有使用Flas-WTF,通过value传值即可。如{{ckeditor.create(value ='test')}}

使用了Flask-WTF怎么弄呢?

如果使用了Flask-WTF/WTForms,可以在调用render_template()渲染页面前为对应字段赋值,比如form.username.data = 'blah...'。(辉大神的原话,试试吧)

weijiang1994 commented 4 years ago

Q1已解决,如果您没有使用Flas-WTF,通过value传值即可。如{{ckeditor.create(value ='test')}}

使用了Flask-WTF怎么弄呢?

如果使用了Flask-WTF/WTForms,可以在调用render_template()渲染页面前为对应字段赋值,比如form.username.data = 'blah...'。(辉大神的原话,试试吧)

你在哪里看到辉神的原话的 有连接吗 我只在知乎上看到了 辉神那边CKEditor的文章

Cyberbolt commented 4 years ago

Q1已解决,如果您没有使用Flas-WTF,通过值传值即可。如{{ckeditor.create(value ='test')}}}

使用了Flask-WTF怎么弄呢?

如果使用了Flask-WTF / WTForms,可以在调用render_template()呈现页面前为对应的分配赋值,则form.username.data ='blah ...'。(辉大神的原话,试试吧)

你在哪里看到辉神的原话的有连接吗我只在知乎上看到了辉神那边CKEditor的文章

知乎那篇文章,评论区有人遇到了相同的问题 https://zhuanlan.zhihu.com/p/38643309

weijiang1994 commented 4 years ago

https://zhuanlan.zhihu.com/p/38643309

看到了 感谢

weijiang1994 commented 4 years ago

Q1已解决,如果您没有使用Flas-WTF,通过值传值即可。如{{ckeditor.create(value ='test')}}}

使用了Flask-WTF怎么弄呢?

如果使用了Flask-WTF / WTForms,可以在调用render_template()呈现页面前为对应的分配赋值,则form.username.data ='blah ...'。(辉大神的原话,试试吧)

你在哪里看到辉神的原话的有连接吗我只在知乎上看到了辉神那边CKEditor的文章

知乎那篇文章,评论区有人遇到了相同的问题 https://zhuanlan.zhihu.com/p/38643309

我发现了一个问题,就是将代码段回显到CKEditor的编辑区域时,行间的换行符没了,所有代码全都在一行了?

Cyberbolt commented 4 years ago

Q1已解决,如果您没有使用Flas-WTF,通过值传值即可。如{{ckeditor.create(value ='test')}}}

使用了Flask-WTF怎么弄呢?

如果使用了Flask-WTF / WTForms,可以在调用render_template()呈现页面前为对应的分配赋值,则form.username.data ='blah ...'。。(辉大神的原话,试试吧)

你在哪里看到辉神的原话的有连接吗我只在知乎上看到了辉神那边CKEditor的文章

知乎那篇文章,评论区有人遇到了相同的问题https://zhuanlan.zhihu.com/p/38643309

我发现了一个问题,就是将代码段回显到CKEditor的编辑区域时,行间的换行符没了,所有代码全都在一行了?

我没有使用Flask-WTF,没出现这个问题。我的文章保存数据库时是以html形式存放,代码回显到CKEditor正常

greyli commented 4 years ago

Q2 怎么在img标签上默认添加上class="img-fuild"标签呢?

可以注册一个回调函数:

{{ ckeditor.load() }}
{{ ckeditor.config(name='body') }}
<script>
    CKEDITOR.on( 'instanceReady', function( evt ) {
    evt.editor.dataProcessor.htmlFilter.addRules( {
        elements: {
            img: function(el) {
                 el.addClass('img-fluid');
                 }
            }
        });
    });
</script>

来源:https://stackoverflow.com/a/44779175/5511849

tsui98 commented 4 years ago

大佬那个图书管理的数据库文件能发我一份吗?邮箱:1351123205@qq.com