Skip to content

Instantly share code, notes, and snippets.

@sstur
Last active March 10, 2016 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sstur/7b0948125aa3b7dd57a4 to your computer and use it in GitHub Desktop.
Save sstur/7b0948125aa3b7dd57a4 to your computer and use it in GitHub Desktop.
StatefulRichTextEditor based on https://github.com/sstur/react-rte
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