import React, { Component } from 'react';
import { Editor } from 'react-draft-wysiwyg';
import { EditorState } from 'draft-js';
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
import dtohtml from "draftjs-to-html"
// Draft 富文本编辑器
class Draft extends Component {
constructor(props) {
super(props)
this.state = {
editorState: EditorState.createEmpty(),
contentState: {}
}
}
editorStateChange(editorState) {
this.setState({
editorState
})
}
contentStateChange(contentState) {
//console.log(dtohtml(contentState)) //富文本中的内容
}
render() {
return (
<Editor editorState={this.state.editorState} onEditorStateChange={this.editorStateChange.bind(this)}
onContentStateChange={this.contentStateChange.bind(this)}></Editor>
)
}
}
export default Draft
react draftjs富文本编辑器使用
最新推荐文章于 2023-09-14 16:52:08 发布