首先说一下网上其他的编辑器:
轻量级:
1.codeMirror :文档和代码对不上,没有diff功能
github地址:https://github.com/codemirror/CodeMirror
示例代码:https://uiwjs.github.io/react-codemirror/
2.react-code-diff 最近一次维护2018年,直接报错无法使用
重量级:
1.monaco :微软出品,值得信赖
github地址:https://github.com/microsoft/monaco-editor
2.diff2html:也是功能很全的编辑器
官网:https://diff2html.xyz/
gitbub地址:https://github.com/rtfpessoa/diff2html
3.aceEditor:今天的重点
官网:https://ace.c9.io/#nav=about&api=editor
github地址:https://github.com/ajaxorg/ace
aceEditor其他版本
官方的aceEditor是js版的,后续有其他团队陆续出了vue版和react版,是官方的拓展版本,使用可参考官方的文档,其中字段名和方法名都和官方一致,方便使用。
vue版github地址:https://github.com/chairuosen/vue2-ace-editor
react版github地址:https://github.com/securingsincity/react-ace
react版aceEditor
使用方法:
install
npm install react-ace ace-builds
import AceEditor from 'react-ace'</