-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreview.js
37 lines (32 loc) · 965 Bytes
/
preview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var App = App || {};
(function() {
'use strict';
var e = React.createElement
, converter = new Showdown.converter();
App.Preview = React.createClass({
componentDidUpdate: function(prevProps) {
if (this.props.scrollTop != prevProps.scrollTop) {
this.refs.preview.getDOMNode().scrollTop = this.props.scrollTop;
}
},
render: function() {
return (
e('div', {className: 'preview',},
e('div', {className: 'floatingheader'},
e('small', null, 'Preview',
e('span', {className: 'word-count'}, this.props.words + ' words')
)
),
e('div', {className: 'preview-content scrollthis', ref: 'preview'},
e('div', {
className: 'rendered-markdown',
dangerouslySetInnerHTML: {
__html: converter.makeHtml(this.props.value)
}
})
)
)
)
}
});
})();