gab-social/app/javascript/gabsocial/components/composer.js

37 lines
596 B
JavaScript
Raw Normal View History

2020-03-25 03:08:43 +00:00
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>
)
}
}