@@ -6,65 +6,66 @@ var ReactRenderer = require('commonmark-react-renderer');
6
6
7
7
var propTypes = React . PropTypes ;
8
8
9
- var ReactMarkdown = React . createClass ( {
10
- displayName : 'ReactMarkdown' ,
9
+ function ReactMarkdown ( props ) {
10
+ React . Component . call ( this , props ) ;
11
+ }
11
12
12
- propTypes : {
13
- className : propTypes . string ,
14
- containerProps : propTypes . object ,
15
- source : propTypes . string . isRequired ,
16
- containerTagName : propTypes . string ,
17
- childBefore : propTypes . object ,
18
- childAfter : propTypes . object ,
19
- sourcePos : propTypes . bool ,
20
- escapeHtml : propTypes . bool ,
21
- skipHtml : propTypes . bool ,
22
- softBreak : propTypes . string ,
23
- allowNode : propTypes . func ,
24
- allowedTypes : propTypes . array ,
25
- disallowedTypes : propTypes . array ,
26
- transformLinkUri : propTypes . func ,
27
- transformImageUri : propTypes . func ,
28
- unwrapDisallowed : propTypes . bool ,
29
- renderers : propTypes . object ,
30
- walker : propTypes . func ,
31
- parserOptions : propTypes . object
32
- } ,
13
+ ReactMarkdown . prototype = Object . create ( React . Component . prototype ) ;
14
+ ReactMarkdown . prototype . constructor = ReactMarkdown ;
33
15
34
- getDefaultProps : function ( ) {
35
- return {
36
- containerTagName : 'div' ,
37
- parserOptions : { }
38
- } ;
39
- } ,
16
+ ReactMarkdown . prototype . render = function ( ) {
17
+ var containerProps = this . props . containerProps || { } ;
18
+ var renderer = new ReactRenderer ( this . props ) ;
19
+ var parser = new Parser ( this . props . parserOptions ) ;
20
+ var ast = parser . parse ( this . props . source || '' ) ;
40
21
41
- render : function ( ) {
42
- var containerProps = this . props . containerProps || { } ;
43
- var renderer = new ReactRenderer ( this . props ) ;
44
- var parser = new Parser ( this . props . parserOptions ) ;
45
- var ast = parser . parse ( this . props . source || '' ) ;
22
+ if ( this . props . walker ) {
23
+ var walker = ast . walker ( ) ;
24
+ var event ;
46
25
47
- if ( this . props . walker ) {
48
- var walker = ast . walker ( ) ;
49
- var event ;
50
-
51
- while ( ( event = walker . next ( ) ) ) {
52
- this . props . walker . call ( this , event , walker ) ;
53
- }
54
- }
55
-
56
- if ( this . props . className ) {
57
- containerProps . className = this . props . className ;
26
+ while ( ( event = walker . next ( ) ) ) {
27
+ this . props . walker . call ( this , event , walker ) ;
58
28
}
29
+ }
59
30
60
- return React . createElement . apply ( React ,
61
- [ this . props . containerTagName , containerProps , this . props . childBefore ]
62
- . concat ( renderer . render ( ast ) . concat (
63
- [ this . props . childAfter ]
64
- ) )
65
- ) ;
31
+ if ( this . props . className ) {
32
+ containerProps . className = this . props . className ;
66
33
}
67
- } ) ;
34
+
35
+ return React . createElement . apply ( React ,
36
+ [ this . props . containerTagName , containerProps , this . props . childBefore ]
37
+ . concat ( renderer . render ( ast ) . concat (
38
+ [ this . props . childAfter ]
39
+ ) )
40
+ ) ;
41
+ } ;
42
+
43
+ ReactMarkdown . propTypes = {
44
+ className : propTypes . string ,
45
+ containerProps : propTypes . object ,
46
+ source : propTypes . string . isRequired ,
47
+ containerTagName : propTypes . string ,
48
+ childBefore : propTypes . object ,
49
+ childAfter : propTypes . object ,
50
+ sourcePos : propTypes . bool ,
51
+ escapeHtml : propTypes . bool ,
52
+ skipHtml : propTypes . bool ,
53
+ softBreak : propTypes . string ,
54
+ allowNode : propTypes . func ,
55
+ allowedTypes : propTypes . array ,
56
+ disallowedTypes : propTypes . array ,
57
+ transformLinkUri : propTypes . func ,
58
+ transformImageUri : propTypes . func ,
59
+ unwrapDisallowed : propTypes . bool ,
60
+ renderers : propTypes . object ,
61
+ walker : propTypes . func ,
62
+ parserOptions : propTypes . object
63
+ } ;
64
+
65
+ ReactMarkdown . defaultProps = {
66
+ containerTagName : 'div' ,
67
+ parserOptions : { }
68
+ } ;
68
69
69
70
ReactMarkdown . types = ReactRenderer . types ;
70
71
ReactMarkdown . renderers = ReactRenderer . renderers ;
0 commit comments