@@ -7,17 +7,7 @@ import { markdownToHTML } from '../../helpers/markdownToState'
77class MarkdownText extends Component {
88 constructor ( props ) {
99 super ( props )
10- this . state = {
11- isChanged : false
12- }
13- this . blurTheField = this . blurTheField . bind ( this )
14- this . updateDescriptionThrottled = this . updateDescription . bind ( this )
15- // this.updateDescriptionThrottled = _.throttle(this.updateDescription.bind(this), 10000) // 10s
16- }
17-
18- blurTheField ( ) {
19- const { onChange } = this . props
20- onChange ( this . easymde . value ( ) )
10+ this . updateDescription = this . updateDescription . bind ( this )
2111 }
2212
2313 updateDescription ( ) {
@@ -30,25 +20,18 @@ class MarkdownText extends Component {
3020 if ( ! readOnly ) {
3121 this . easymde = new EasyMDE ( { element : this . refs . textarea , initialValue : value } )
3222 this . easymde . codemirror . on ( 'change' , ( ) => {
33- this . setState ( { isChanged : true } )
34- this . updateDescriptionThrottled ( this . easymde . value ( ) )
35- } )
36- this . easymde . codemirror . on ( 'blur' , ( ) => {
37- if ( this . state . isChanged ) {
38- this . setState ( { isChanged : false } )
39- this . blurTheField ( )
40- }
23+ this . updateDescription ( )
4124 } )
4225 } else {
43- this . ref . current . innerHTML = value ? markdownToHTML ( value ) : ''
26+ this . refs . textarea . innerHTML = value ? markdownToHTML ( value ) : ''
4427 }
4528 }
4629
4730 render ( ) {
4831 const { readOnly, placeholder } = this . props
4932 return ( < div className = { styles . editor } >
5033 { readOnly ? (
51- < div ref = "textarea" />
34+ < div ref = "textarea" className = "EasyMDEContainer-readonly" />
5235 ) : (
5336 < textarea
5437 ref = "textarea"
0 commit comments