|
1
|
1 |
import React, {Component} from 'react'; |
|
|
2 |
|
|
2
|
3 |
import ReactDOM from 'react-dom' |
|
|
4 |
import { Form, FormControl, FormGroup, Button } from 'react-bootstrap'; |
|
|
5 |
|
|
1
|
6 |
import PropTypes from 'prop-types'; |
|
5
|
7 |
import SlateEditor from './SlateEditor'; |
|
1
|
8 |
|
|
|
9 |
class NoteInput extends Component { |
|
|
10 |
constructor(props) { |
|
|
11 |
super(props); |
|
|
12 |
|
|
|
13 |
this.state = {value: ''}; |
|
|
14 |
|
|
|
15 |
this.onAddNoteClick = this.onAddNoteClick.bind(this); |
|
|
16 |
this.handleChange = this.handleChange.bind(this); |
|
|
17 |
} |
|
|
18 |
|
|
|
19 |
handleChange(event) { |
|
|
20 |
this.setState({value : event.target.value}); |
|
|
21 |
} |
|
|
22 |
|
|
|
23 |
onAddNoteClick(event) { |
|
5
|
24 |
const text = this.refs.editor.asPlain(); |
|
|
25 |
this.props.addNote(text); |
|
|
26 |
this.refs.editor.clear(); |
|
1
|
27 |
} |
|
|
28 |
|
|
|
29 |
componentDidMount() { |
|
5
|
30 |
// this.noteInput.focus(); |
|
1
|
31 |
} |
|
|
32 |
|
|
|
33 |
render() { |
|
|
34 |
return ( |
|
2
|
35 |
<Form> |
|
|
36 |
<FormGroup> |
|
5
|
37 |
<SlateEditor ref="editor" /> |
|
2
|
38 |
</FormGroup> |
|
|
39 |
<Button type="button" onClick={this.onAddNoteClick}>Add Note</Button> |
|
|
40 |
</Form> |
|
1
|
41 |
); |
|
|
42 |
} |
|
|
43 |
} |
|
|
44 |
|
|
|
45 |
NoteInput.propTypes = { |
|
|
46 |
addNote: PropTypes.func.isRequired |
|
|
47 |
}; |
|
|
48 |
|
|
|
49 |
export default NoteInput; |