ckeditor - CK Editor div 标签被替换为 p 标签(React JS)

标签 ckeditor ckeditor5

我正在使用 CK 编辑器并将初始数据传递给编辑器,如下所示

import React from 'react';
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

classEditor extends React.Component{
constructor(props){
super(props)
this.state={
editorState:'<div class="main"><div class="child-1"><div>Iam inside </div></div><div class="child-2">Child 2</div></div>'
}
}
render(){
return           <CKEditor
                      editor={ClassicEditor}
                      data={this.state.editorState}
                      onInit={editor => {
                        // You can store the "editor" and use when it is needed.
                        console.log('Editor is ready to use!', editor);
                      }}
                      config={{
                        allowedContent:true,
                        extraAllowedContent:true
                      }}
                      onChange={(event, editor) => {
                        const data = editor.getData();
                        this.handleEditorChange(data);
                        console.log(data);
                      }}
                    />
}
}

当调用 OnChange 处理程序时,它会将最初传递的 html 更改为类似这样的内容

<p>Iam inside</p><p>Child 2</p>

如何停止 CK 编辑器用 p 标签替换 div 标签并允许自定义样式和类名

最佳答案

尼基尔 关于您的帖子,您似乎要在编辑器中为内联文本创建自定义主题。我不确定这是否正确。 但是,如果是这样,您可以自定义编辑器主题并将其用于您的目的。 CKEditor 具有强大的内置功能。 另外,如果你想自定义编辑器,你也可以这样做。 请查看以下链接: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/basic-api.html#creating-an-editor https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/ui/theme-customization.html 希望这有帮助。

关于ckeditor - CK Editor div 标签被替换为 p 标签(React JS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63986665/

相关文章:

ckeditor5 - CKEditor 5 将选定的内容从一个编辑器复制到另一个编辑器

javascript - 在 Javascript 中跟踪对多个 Ckeditor 5 实例的更改

javascript - 使用 Bower 向 CKEditor 添加额外的插件

javascript - 获取 CKEDITOR 5 中突出显示/选定的文本

angular6 - CKEditor 5 抛出无法读取 Angular6 项目中未定义的属性 'create'

ruby - rails 生成 ckeditor :install --orm=active_record --backend=active_storag not worked Rails 5

ckeditor - 在 ckeditor5 下拉项上注册点击监听器

javascript - CKeditor单选垂直

javascript - 如何使用组合键使用 'key' 事件在 CK Editor 中调用自定义方法

javascript - 在 CKEditor 中设置字体大小和字体系列