CK editor5 React-添加自定义按钮

时间:2018-10-08 09:29:06

标签: javascript reactjs ckeditor

我已使用教程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;

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

我已经看到了有关添加新插件的帖子,但是我不确定如何以反应方式实现它。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

您需要创建一个将注册新按钮的插件。然后,您可以将插件加载到编辑器。我将为您提供一些对文档有帮助的链接: