jsqip 2019-06-30
由于需要用到react下的markdown编辑器功能,网上开源的react markdown编辑器不多,没有找到合适的,索性自己写一个。markdown编辑器主要功能就是预览,for-editor是一款react下的markdown编辑器,拥有预览,快捷添加标签,上一步,下一步功能,行号等功能,后续逐步完善更多功能。
for-editor源码地址 欢迎issue,欢迎star。

npm install for-editor -S
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import Editor from 'for-editor'
class App extends Component {
constructor() {
super()
this.state = {
value: ''
}
}
handleChange(value) {
this.setState({
value
})
}
render() {
const { value } = this.state
return (
<Editor value={value} onChange={this.handleChange.bind(this)} />
)
}
}
ReactDOM.render(
<Editor />,
document.getElementById('container')
)| name | type | default | description |
|---|---|---|---|
| placeholder | String | 请输入内容... | 占位文本 |
| value | String | - | 输入框内容 |
| lineNum | Boolean | true | 是否显示行号 |
| name | type | default | description |
|---|---|---|---|
| onChange | function(e) | - | 内容改变时回调 |
| onSave | function(e) | - | 保存时回调 |
| name | description |
|---|---|
| tab | 两个空格缩进 |
| ctrl+s | 保存 |
| ctrl+z | 上一步 |
| ctrl+y | 下一步 |
2019-01-07 v0.0.9
2018-12-29 v0.0.8
2018-12-27 v0.0.6
2018-12-26 v0.0.5
2018-12-25 v0.0.4
2018-12-24 v0.0.3
2018-12-23 v0.0.0