ReactJS中使用CKeditor 笔记

本文介绍了在ReactJS项目中集成CKeditor5的详细步骤,包括安装、配置及解决遇到的问题,如CKeditor在bootstrap-modal中的弹出功能显示问题、焦点丢失以及表格未居中等。
摘要由CSDN通过智能技术生成

背景

最近在用ReacJS写一个小的前端项目,需要将编辑框改成富文本框,网上搜索了一下,觉得CKeditor比较好看,这里记录一下实现的步骤。

使用版本

ReactJS 16.8.6
CKeditor-5

步骤

1.安装组件

首先安装两个组件ckeditor5-react和ckeditor5-build-classic

npm install --save @ckeditor/ckeditor5-react @ckeditor/ckeditor5-build-classic

2.导入组件

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

3.调用组件

 <CKEditor
                    editor={ ClassicEditor }
                    data={this.state.detail}
                    onInit={ editor => {
                        // You can store the "editor" and use when it is needed.
                        console.log( 'Editor is ready to use!', editor );
                    } }
                    onChange={ ( event, editor ) => {
                      const data = editor.getData();
                        this.setState({
                          detail:data
                        });
                        
                        console.log( { event, editor, data } );
                    } }
                    onBlur={ editor => {
                        console.log( 'Blur.', editor );
                    } }
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值