flask - Flask-CKEditor - 错误代码:编辑器元素冲突
问题描述
在我的烧瓶应用程序中,我在 2 个不同的文件上有 2 个 CKEditor 实例。
<div>
{{ ckeditor.create(name="message_body") }}
{{ ckeditor.load(pkg_type="standard") }}
{{ ckeditor.config(name="message_body", width=1000, height=500) }}
</div>
和
<div>
{{ ckeditor.create(name="newsletter_body") }}
{{ ckeditor.load(pkg_type="standard") }}
{{ ckeditor.config(name="newsletter_body", width=1000, height=500) }}
</div>
这些中的每一个<div>
都在{% block main %}
我使用这些行从 2 个不同的文件中获取数据:
request.form.get("message_body")
和
request.form.get("newsletter_body")
一切似乎都很好,我得到了数据,但在我的浏览器中我得到了这个错误:
[CKEDITOR] Error code: editor-element-conflict.
Object { editorName: "message_body" }
相关文档如下:
Description: There is already an editor’s instance attached to the provided element and attaching another one to it is not allowed.
Additional data:
editorName: The name of the already attached editor.
但我不明白为什么。任何人都可以帮助我摆脱这些错误吗?非常感谢
解决方案
我刚刚发布了0.4.5来解决这个问题,请升级:
pip install -U flask-ckeditor
此错误背后的原因是:
当您将“ckeditor”类添加到 textarea 元素时,CKEditor 将尝试在其之上初始化 CKEditor 编辑器框。同时,如果你手动初始化一个 CKEditor 编辑器框CKEDITOR.replace(...)
(这就是它ckeditor.config()
所做的),就会发生错误:你不能在一个 textarea 元素上初始化两个 CKEditor 编辑器框。
推荐阅读
- python - 为什么我不能在惩罚函数中将元组解包到 scipy quad 中?
- webpack - 从 node_modules 导入时,我自己的模块未正确转译
- vue.js - 在 Vue 中分解出一个自定义按钮
- python - PULP 最小化成本和偏差/错误限制
- haskell - 为什么我们不能在 Haskell 中为枚举派生 Random 类实例?
- asp.net-mvc - 数据表 MVC 中的时间
- java - 为什么每个按钮的全局变量重置或不同?
- javascript - 如何获取已由 JavaScript 设置的标签的值
- php - 尝试使用 XAMPP 在我的计算机上访问网站时出现 PHP 致命错误
- rabbitmq - 为什么消息优先级不对 RabbitMQ 中的消息进行排序?