Flask-CKEditor - 错误代码:编辑器元素冲突
Flask-CKEditor - Error code: editor-element-conflict
在我的 Flask 应用程序中,我在 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”class 添加到文本区域元素时,CKEditor 将尝试在其上初始化一个 CKEditor 编辑器框。同时,如果您使用 CKEDITOR.replace(...)
手动初始化一个 CKEditor 编辑框(这是 ckeditor.config()
所做的),则会发生错误:您无法在一个 textarea 元素上初始化两个 CKEditor 编辑框。
在我的 Flask 应用程序中,我在 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”class 添加到文本区域元素时,CKEditor 将尝试在其上初始化一个 CKEditor 编辑器框。同时,如果您使用 CKEDITOR.replace(...)
手动初始化一个 CKEditor 编辑框(这是 ckeditor.config()
所做的),则会发生错误:您无法在一个 textarea 元素上初始化两个 CKEditor 编辑框。