我使用如下代码引入simiditor:
import React from 'react'
import Simditor from 'simditor'
import $ from 'jquery'
import '../../../node_modules/simditor/styles/simditor.css'
import '../../../node_modules/simditor-html/styles/simditor-html.css'
require('../../../node_modules/simditor-html/lib/simditor-html.js')
class Editor extends React.Component {
static defaultProps = {}
constructor(props, context) {
super(props, context)
this.state = {}
}
componentDidMount() {
let id = 'content_' + this.props.type
var textbox = ReactDOM.findDOMNode(this.refs[id])
this.editor = new Simditor({
textarea: $(textbox),
toolbar: [
'title',
'bold',
'italic',
'underline',
'strikethrough',
'fontScale',
'color',
'ol',
'ul',
'blockquote',
'code',
'table',
'link',
'image',
'indent',
'outdent',
'alignment',
'hr',
'|',
'html'
],
upload: {
url: URLS.image_upload_url, //文件上传的接口地址
params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
fileKey: 'file', //服务器端获取文件数据的参数名
connectionCount: 3,
leaveConfirm: '正在上传文件'
},
})
this.editor.on('valuechanged', (e, src) => {
// todo
})
}
render() {
let title = this.props.title
let id = 'content_' + this.props.type
let val = this.props.val
return (
<div>
<div style={{
marignTop: 10,
marginBottom: 10
}}>
<Button onClick={this.handleSubmit} htmlType="button" type="danger">保存『{title}』内容</Button>
</div>
<textarea className="form-control" ref={id} rows="30">{val}</textarea>
</div>
)
}
}
export default connect(({ loading }) => ({ loading }))(Editor)
simditor的版本,不知道遗漏了什么东西
重新安装一下
history
试试。再看看
simditor
与history
版本的关系。