Skip to content

Commit 22c9fee

Browse files
committed
Create placeholder for demo
1 parent 2528fcc commit 22c9fee

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

demo/client/components/DemoEditor/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,24 @@ export default class DemoEditor extends Component {
2727
editorState: EditorState.createWithContent(contentState)
2828
};
2929

30+
componentDidMount = () => {
31+
if (this.editor) {
32+
this.editor.focus();
33+
}
34+
}
35+
3036
onChange = (editorState) => {
3137
this.setState({
3238
editorState,
3339
});
3440
};
3541

3642
render() {
43+
const { editorState } = this.state;
44+
const placeholder = editorState.getCurrentContent().hasText() ? null : <div className={styles.placeholder}>Write something here...</div>;
3745
return (
3846
<div className={styles.root}>
47+
{placeholder}
3948
<div className={styles.editor} onClick={this.focus}>
4049
<Editor
4150
editorState={this.state.editorState}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
.root {
22
background: #FFF;
33
height: 100%;
4+
position: relative;
45
}
56

67
.editor {
78
margin: 2.5% auto 0 auto;
89
height: 95%;
910
width: 95%;
1011
}
12+
13+
.placeholder {
14+
color: #ccc;
15+
font-size: 1em;
16+
position: absolute;
17+
width: 95%;
18+
top: 0;
19+
left: 2.5%;
20+
}

0 commit comments

Comments
 (0)