Last active
March 10, 2016 23:57
-
-
Save sstur/7b0948125aa3b7dd57a4 to your computer and use it in GitHub Desktop.
StatefulRichTextEditor based on https://github.com/sstur/react-rte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RichTextEditor from 'react-rte'; | |
import React from 'react'; | |
class StatefulRichTextEditor { | |
constructor() { | |
this.state = { | |
value: RichTextEditor.createEmptyValue(), | |
}; | |
} | |
render() { | |
let onChange = (value) => this.setState({value}); | |
return ( | |
<RichTextEditor value={this.state.value} onChange={onChange} /> | |
); | |
} | |
getHTML() { | |
return this.state.value.toString('html'); | |
} | |
setHTML(html) { | |
let value = RichTextEditor.createValueFromString(html, 'html'); | |
this.setState({value}); | |
} | |
} | |
export default StatefulRichTextEditor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment