首页 > 解决方案 > 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.

但我不明白为什么。任何人都可以帮助我摆脱这些错误吗?非常感谢

标签: flaskckeditorpython-3.8flask-ckeditor

解决方案


我刚刚发布了0.4.5来解决这个问题,请升级:

pip install -U flask-ckeditor

此错误背后的原因是:

当您将“ckeditor”类添加到 textarea 元素时,CKEditor 将尝试在其之上初始化 CKEditor 编辑器框。同时,如果你手动初始化一个 CKEditor 编辑器框CKEDITOR.replace(...)(这就是它ckeditor.config()所做的),就会发生错误:你不能在一个 textarea 元素上初始化两个 CKEditor 编辑器框。


推荐阅读