1- import React , { Component } from ' react' ;
2- import Editor from ' draft-js-plugins-editor' ;
1+ import React , { Component } from " react" ;
2+ import Editor from " draft-js-plugins-editor" ;
33
4- import createMarkdownShortcutsPlugin from ' draft-js-markdown-shortcuts-plugin' ; // eslint-disable-line
4+ import createMarkdownShortcutsPlugin from " draft-js-markdown-shortcuts-plugin" ; // eslint-disable-line
55import Draft , {
66 convertToRaw ,
77 // convertFromRaw,
88 ContentState ,
99 EditorState ,
10- } from ' draft-js' ;
11- import styles from ' ./styles.css' ;
12- import Prism from ' prismjs' ;
13- import ' prismjs/components/prism-java' ;
14- import ' prismjs/components/prism-scala' ;
15- import ' prismjs/components/prism-go' ;
16- import ' prismjs/components/prism-sql' ;
17- import ' prismjs/components/prism-bash' ;
18- import ' prismjs/components/prism-c' ;
19- import ' prismjs/components/prism-cpp' ;
20- import ' prismjs/components/prism-kotlin' ;
21- import ' prismjs/components/prism-perl' ;
22- import ' prismjs/components/prism-ruby' ;
23- import ' prismjs/components/prism-swift' ;
24- import createPrismPlugin from ' draft-js-prism-plugin' ;
10+ } from " draft-js" ;
11+ import styles from " ./styles.css" ;
12+ import Prism from " prismjs" ;
13+ import " prismjs/components/prism-java" ;
14+ import " prismjs/components/prism-scala" ;
15+ import " prismjs/components/prism-go" ;
16+ import " prismjs/components/prism-sql" ;
17+ import " prismjs/components/prism-bash" ;
18+ import " prismjs/components/prism-c" ;
19+ import " prismjs/components/prism-cpp" ;
20+ import " prismjs/components/prism-kotlin" ;
21+ import " prismjs/components/prism-perl" ;
22+ import " prismjs/components/prism-ruby" ;
23+ import " prismjs/components/prism-swift" ;
24+ import createPrismPlugin from " draft-js-prism-plugin" ;
2525const prismPlugin = createPrismPlugin ( {
2626 prism : Prism ,
2727} ) ;
2828
2929window . Draft = Draft ;
3030
31- const plugins = [
32- prismPlugin ,
33- createMarkdownShortcutsPlugin ( )
34- ] ;
31+ const plugins = [ prismPlugin , createMarkdownShortcutsPlugin ( ) ] ;
3532
36- const contentState = ContentState . createFromText ( '' ) ;
33+ const contentState = ContentState . createFromText ( "" ) ;
3734const initialEditorState = EditorState . createWithContent ( contentState ) ;
3835
3936export default class DemoEditor extends Component {
40-
4137 state = {
42- editorState : initialEditorState
38+ editorState : initialEditorState ,
4339 } ;
4440
4541 componentDidMount = ( ) => {
4642 const { editor } = this ;
4743 if ( editor ) {
4844 setTimeout ( editor . focus . bind ( editor ) , 1000 ) ;
4945 }
50- }
46+ } ;
5147
52- onChange = ( editorState ) => {
48+ onChange = editorState => {
5349 window . editorState = editorState ;
5450 window . rawContent = convertToRaw ( editorState . getCurrentContent ( ) ) ;
5551
@@ -60,7 +56,9 @@ export default class DemoEditor extends Component {
6056
6157 render ( ) {
6258 const { editorState } = this . state ;
63- const placeholder = editorState . getCurrentContent ( ) . hasText ( ) ? null : < div className = { styles . placeholder } > Write something here...</ div > ;
59+ const placeholder = editorState . getCurrentContent ( ) . hasText ( ) ? null : (
60+ < div className = { styles . placeholder } > Write something here...</ div >
61+ ) ;
6462 return (
6563 < div className = { styles . root } >
6664 { placeholder }
@@ -70,7 +68,9 @@ export default class DemoEditor extends Component {
7068 onChange = { this . onChange }
7169 plugins = { plugins }
7270 spellCheck
73- ref = { ( element ) => { this . editor = element ; } }
71+ ref = { element => {
72+ this . editor = element ;
73+ } }
7474 />
7575 </ div >
7676 </ div >
0 commit comments