2 回答
TA贡献1946条经验 获得超3个赞
代码片段供参考:
componentDidMount() {
var textbox = ReactDOM.findDOMNode(this.refs.textarea);
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']
});
this.editor.on("valuechanged", (e, src) => {
this.props.fields.body.onChange(this.editor.getValue());
});
}
componentDidUpdate (prevProps) {
if (prevProps.body !== this.props.body) {
this.editor.setValue(this.props.body);
}
}
<textarea className="form-control" ref='textarea' rows="50" {...body}/>
添加回答
举报