@@ -2,57 +2,57 @@ var CM = require('codemirror');
2
2
var React = require ( 'react' ) ;
3
3
4
4
var CodeMirror = React . createClass ( {
5
-
6
- getInitialState : function ( ) {
5
+
6
+ getInitialState ( ) {
7
7
return {
8
8
isFocused : false
9
9
} ;
10
10
} ,
11
-
12
- componentDidMount : function ( ) {
11
+
12
+ componentDidMount ( ) {
13
13
this . codeMirror = CM . fromTextArea ( this . refs . codemirror . getDOMNode ( ) , this . props . options ) ;
14
14
this . codeMirror . on ( 'change' , this . codemirrorValueChanged ) ;
15
15
this . codeMirror . on ( 'focus' , this . focusChanged . bind ( this , true ) ) ;
16
16
this . codeMirror . on ( 'blur' , this . focusChanged . bind ( this , false ) ) ;
17
17
this . _currentCodemirrorValue = this . props . value ;
18
18
} ,
19
-
20
- componentWillUnmount : function ( ) {
19
+
20
+ componentWillUnmount ( ) {
21
21
// todo: is there a lighter-weight way to remove the cm instance?
22
22
if ( this . codeMirror ) {
23
23
this . codeMirror . toTextArea ( ) ;
24
24
}
25
25
} ,
26
-
27
- componentWillReceiveProps : function ( nextProps ) {
26
+
27
+ componentWillReceiveProps ( nextProps ) {
28
28
if ( this . codeMirror && this . _currentCodemirrorValue !== nextProps . value ) {
29
29
this . codeMirror . setValue ( nextProps . value ) ;
30
30
}
31
31
} ,
32
32
33
- getCodeMirror : function ( ) {
33
+ getCodeMirror ( ) {
34
34
return this . codeMirror ;
35
35
} ,
36
-
37
- focus : function ( ) {
36
+
37
+ focus ( ) {
38
38
if ( this . codeMirror ) {
39
39
this . codeMirror . focus ( ) ;
40
40
}
41
41
} ,
42
-
43
- focusChanged : function ( focused ) {
42
+
43
+ focusChanged ( focused ) {
44
44
this . setState ( {
45
45
isFocused : focused
46
46
} ) ;
47
47
} ,
48
-
49
- codemirrorValueChanged : function ( doc , change ) {
48
+
49
+ codemirrorValueChanged ( doc , change ) {
50
50
var newValue = doc . getValue ( ) ;
51
51
this . _currentCodemirrorValue = newValue ;
52
52
this . props . onChange && this . props . onChange ( newValue ) ;
53
53
} ,
54
-
55
- render : function ( ) {
54
+
55
+ render ( ) {
56
56
var className = 'ReactCodeMirror' ;
57
57
if ( this . state . isFocused ) {
58
58
className += ' ReactCodeMirror--focused' ;
@@ -63,7 +63,7 @@ var CodeMirror = React.createClass({
63
63
</ div >
64
64
) ;
65
65
}
66
-
66
+
67
67
} ) ;
68
68
69
69
module . exports = CodeMirror ;
0 commit comments