You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
902 B
37 lines
902 B
var MARKDOWN_COMPONENT = `
|
|
var converter = new Showdown.converter();
|
|
|
|
var MarkdownEditor = React.createClass({
|
|
getInitialState: function() {
|
|
return {value: 'Type some *markdown* here!'};
|
|
},
|
|
handleChange: function() {
|
|
this.setState({value: this.refs.textarea.getDOMNode().value});
|
|
},
|
|
render: function() {
|
|
return (
|
|
<div className="MarkdownEditor">
|
|
<h3>Input</h3>
|
|
<textarea
|
|
onChange={this.handleChange}
|
|
ref="textarea"
|
|
defaultValue={this.state.value} />
|
|
<h3>Output</h3>
|
|
<div
|
|
className="content"
|
|
dangerouslySetInnerHTML={{
|
|
__html: converter.makeHtml(this.state.value)
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
});
|
|
|
|
React.render(<MarkdownEditor />, mountNode);
|
|
`;
|
|
|
|
React.render(
|
|
<ReactPlayground codeText={MARKDOWN_COMPONENT} />,
|
|
document.getElementById('markdownExample')
|
|
);
|
|
|