CKeditor5 React - 添加自定义按钮

CK editor5 React - Add custom button

我已经使用教程 https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/react.html

实现了 React CK 编辑器

代码如下

import React, {Component} from 'react';
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

class App extends Component {
    render() {
        return ( 
            <div className = "App">                
            <h2> Using CKEditor 5 build in React < /h2> 
            <
            CKEditor editor = {
                ClassicEditor
            }
            data = "<p>Hello from CKEditor 5!</p>"
            onInit = {
                editor => {
                    // You can store the "editor" and use when it's needed.
                    console.log('Editor is ready to use!', editor);
                }
            }
            onChange = {
                (event, editor) => {
                    const data = editor.getData();
                    console.log({
                        event,
                        editor,
                        data
                    });
                }
            }
            />
            </div>
        );
    }
}

export default App;

现在我需要在工具栏上添加一个自定义按钮,单击该按钮时需要调用一个函数。

我看过关于添加新插件的帖子,但我不确定如何以反应方式实现它。

如有任何帮助,我们将不胜感激。

您需要创建一个插件来注册一个新按钮。然后你可以将你的插件加载到编辑器中。我会给您留下一些对您有帮助的文档链接: