gab-social/app/javascript/gabsocial/components/composer.js
2020-03-24 23:08:43 -04:00

37 lines
596 B
JavaScript

import {
Editor,
EditorState,
RichUtils
} from 'draft-js'
export default class Composer extends PureComponent {
state = {
editorState: EditorState.createEmpty(),
}
onChange = (editorState) => {
this.setState({ editorState })
}
onBoldClick() {
this.onChange(RichUtils.toggleInlineStyle(this.state.editorState, 'BOLD'));
}
render() {
return (
<div>
{/*<button onClick={this.onBoldClick.bind(this)}>Bold</button>*/}
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
/>
</div>
)
}
}