diff -r 218abb8b1cad -r 6f572b6b6be3 client/src/components/SlateEditor.js --- a/client/src/components/SlateEditor.js Tue May 23 17:47:59 2017 +0200 +++ b/client/src/components/SlateEditor.js Wed May 31 18:08:22 2017 +0200 @@ -48,7 +48,7 @@ * @type {Component} */ -class RichText extends React.Component { +class SlateEditor extends React.Component { /** * Deserialize the initial editor state. @@ -57,7 +57,7 @@ */ state = { - state: Raw.deserialize(initialState, { terse: true }) + state: '' }; /** @@ -92,7 +92,10 @@ onChange = (state) => { this.setState({ state }) - + if(typeof(this.props.onChange) === 'function') { + this.props.onChange({target: { value: Plain.serialize(state)}}); + } + } asPlain = () => { @@ -101,7 +104,7 @@ clear = () => { const state = Plain.deserialize(''); - this.setState({ stateĀ }); + this.onChange(state); } /** @@ -221,6 +224,16 @@ } /** + * + * @param {*Cosntructor} props + */ + componentWillMount() { + const initialValue = Raw.deserialize(initialState, { terse: true }); + this.state = { state: initialValue}; + this.onChange(initialValue); + } + + /** * Render. * * @return {Element} @@ -322,4 +335,4 @@ * Export. */ -export default RichText \ No newline at end of file +export default SlateEditor \ No newline at end of file