File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
demo/client/components/DemoEditor Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments