A Pen by Brian Puschell on CodePen.
Created
January 25, 2017 02:30
-
-
Save lordmalvern/93b66642362bf92ed44950222148c8f7 to your computer and use it in GitHub Desktop.
Zipline Markdown Previewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="content"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MarkdownBox = React.createClass({ | |
getInitialState: function() { | |
return { | |
text: 'Hello World!\n======\n2nd heading \n-------\n\n### Subheading' | |
}; | |
}, | |
changeText: function(e) { | |
this.setState({ | |
text: e.target.value | |
}); | |
}, | |
render: function() { | |
return ( <div> | |
< | |
textarea value = { | |
this.state.text | |
} | |
onChange = { | |
this.changeText | |
} | |
/> < | |
MarkdownPreview data = { | |
this.state.text | |
} | |
/> </div> | |
); | |
} | |
}); | |
var MarkdownPreview = React.createClass({ | |
markup: function() { | |
var raw = marked(this.props.data, { | |
sanitize: true | |
}); | |
return { | |
__html: raw | |
}; | |
}, | |
render: function() { | |
return ( < div className = "markdownPreview" > | |
< | |
span dangerouslySetInnerHTML = { | |
this.markup() | |
} | |
/></div> | |
) | |
} | |
}); | |
//ReactDOM.render(<h1>Hello world!</h1>, document.getElementById('content')); | |
ReactDOM.render( < MarkdownBox / > , document.getElementById('content')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$maxwidth: 600px | |
$maxheight: 400px | |
textarea | |
width: $maxwidth | |
height: $maxheight | |
.markdownPreview | |
display: inline-block | |
float: right | |
width: $maxwidth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment