代码之家  ›  专栏  ›  技术社区  ›  CCCC

react-如果我想添加一些自定义插件,管理ckeditor的正确方法是什么

  •  2
  • CCCC  · 技术社区  · 5 年前

    我正在使用ckeditor,我想知道在中管理它的正确方法是什么 React.JS .

    我当前的解决方法
    我在关注 this tutorial 通过运行将ckeditor安装到我的项目 npm install --save @ckeditor/ckeditor5-react @ckeditor/ckeditor5-build-classic .

    在App.js中

    return(
      <CKEditor
                        editor={ ClassicEditor }
                        config={
                            {
                                toolbar: ['heading', '|', 'bold', 'italic', 'blockQuote', 'link', 'numberedList', 'bulletedList', 'imageUpload', 'insertTable',
                                'tableColumn', 'tableRow', 'mergeTableCells', 'mediaEmbed', '|', 'undo', 'redo'],
                                heading: {
                                    options: [
                                        { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
                                        { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
                                        { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }
                                    ]
                                }
                            }
                        }
                        data={content}
                        onReady={ editor => {
                            console.log( 'Editor is ready to use!', editor );
                        } }
                        onChange={ ( event, editor ) => {
                            const data = editor.getData();
                            console.log( { event, editor, data } );
                        } }
                />
    )
    

    之后,我发现我需要使用 insert image 需要插件的函数 Base64 image upload adapter .

    在我做了一些研究之后,我正在考虑使用以下方法:

    下载 ckeditor5-build-classic-stable 和修改 src/ckeditor.js 根据 this tutorial ,然后让它引用我的项目中的node_modules**
    但我发现它有一些缺点,比如需要运行 npm run build 当我想查看更改时。

    有什么建议吗?

    0 回复  |  直到 5 年前
    推荐文章