react-editor-markdown
一款简洁易用的React Markdown编辑器,基于 Marked.js、CodeMirror、Prism。
Installation
npm install react-editor-markdown --save
Example
本地运行项目示例:
npm installnpm run dev
在浏览器中打开 localhost:3000
。
Usage
Title <!-- 需引用ali icon svg -->
;;; { superprops; } onChange = { console } { const options = value: 'hello editor markdown' toolbarIcons: 'bold' 'italic' 'separator' 'h1' 'h2' 'h3' 'h4' 'h5' 'separator' 'quote' 'list' 'olist' 'separator' 'link' 'image' 'separator' 'watch' 'clear' 'save' isWatch: true customToolbar: save: text: '保存' { console } return <div className="app"> <Editor options=options onChange=thisonChange ></Editor> </div> ; }} ;
Properties
className
编辑器类名
onChange
编辑器change事件,
用法:
{ }
Options
- Value
string
: markdown value - isWatch
boolean
: 是否实时预览 - toolbarIcons
array
: 工具栏 - customToolbar
object
: 自定义工具栏 - onChange
Function (newValue, newPreHtml)
: 编辑器change事件
value
初始化md的值
默认值: start editor now
isWatch
是否实时预览
默认值:true
toolbarIcons
工具栏设置,可按icon名称顺序排序,separator
为分隔符|。
默认值:
'bold' 'italic' 'separator' 'h1' 'h2' 'h3' 'h4' 'h5' 'separator' 'quote' 'list' 'olist' 'separator' 'link' 'image' 'separator' 'watch' 'clear'
customToolbar
自定义toolbar
用法:
customToolbar: save: text: '保存' { console }