看起来,
CKEditor 5
正在做一些sanitization
,所以自定义标签和Javascript
代码从内容中删除。
需要什么配置才能允许 custom html tags
和 CKEditor5
中的 java 脚本代码?
下面是我的
React component
:
import React from 'react';
import { CKEditor } from "@ckeditor/ckeditor5-react";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import * as PropTypes from 'prop-types';
const HTMLEditor = ({ setHtml, content }) => {
return (
<div>
<CKEditor
editor={ClassicEditor}
data={content}
onChange={(event, editor) => {
setHtml(editor.getData());
}}
config={ {
toolbar: [ 'bold', 'italic' ],
allowedContent: true,
extraAllowedContent: '*(*);*{*}'
} }
onInit={editor => {
console.log(editor);
debugger;
editor.config.allowedContent = true;
editor.config.extraAllowedContent = '*(*)';
}}
/>
</div>
);
}
export default HTMLEditor;
我尝试添加以下配置,但似乎不起作用:
config={ {
toolbar: [ 'bold', 'italic' ],
allowedContent: true,
extraAllowedContent: '*(*);*{*}'
} }
以下是依赖项:
"@ckeditor/ckeditor5-build-classic": "^37.0.1",
"@ckeditor/ckeditor5-react": "^6.0.0",