Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app"></div>
              
            
!

CSS

              
                $header-color: #bada55
$bg: #f9f9f9
$card-shadow: 2px 2px 4px #888, -2px 0px 4px #888

*
	box-sizing: border-box

body
	margin: 0
	background: $bg
	font-family: 'Open Sans', sans-serif

header
	height: 56px
	background: $header-color
	color: #fff
	box-shadow: 5px 0 8px #888
	margin-bottom: 10px
	.center
		h1
			margin: 0
			padding: 0
			line-height: 56px
			text-align: center

.info
	text-align: center
	display: flex
	justify-content: space-around
	p
		padding: 0
		margin: 0
		font-size: 21px
		color: #888
		font-weight: bold
	
.container
	width: 100%
	height: calc(100vh - 95px)
	display: flex
	.editor,.preview
		flex-basis: calc(50% - 20px)
		height: calc(100vh - 105px)
		margin: 0 10px
		box-shadow: $card-shadow
		padding: 0 16px
	.editor
		border: none
		padding: 16px
	.preview
		background: #fff
		overflow-y: auto
		pre
			background: #444
			padding: 10px
			color: #fff
	
@media(max-width: 760px)
	.info
		p:last-child
			display: none
	.container
		flex-direction: column
		height: 100%
		.preview
			margin-top: 50px
			&:before
				position: absolute
				content: "Preview"
				transform: translateY(-30px)
				font-size: 21px
				color: #888
				left: 40%
				font-weight: bold
				
				
			
              
            
!

JS

              
                const markdown = (
	"#(GitHub-Flavored) Markdown Editor\n\nI\'m no good at writing sample / filler text, so go write something yourself.\n\n##Look, a list!\n\n* foo\n* bar\n* baz\n\n##And here\'s some code!\n\n```javascript\n\n$(document).ready(function(){\n\t$(\'div\').html(\'I am a div.\');\n});\n\n```\n\n##Look, an Image!\n\n![kitten](https://res.cloudinary.com/vinaypuppal/image/upload/v1511183636/my_avatar.png)\n\nThis is on GitHub (https://github.com/vinaypuppal/react-markdown-editor) so let me know if I've b0rked it somewhere."
)

const Preview =(props)=>{
		return(
			<div className="preview">
				<div dangerouslySetInnerHTML={{__html:marked(props.html,{sanitize: true})}} />
			</div>
		);
}

const Editor = (props)=>{
		return(
			<textarea onChange={(e)=>
				{props.onChange(e.target.value);}}
				className="editor">
				{props.code}
			</textarea>
		);
}

class MarkdownContainer extends React.Component{
	constructor(props){
		super(props)
		this.state={
			code:markdown
		}
	}
	handelChange(code){
		this.setState({code});
	}
	render(){
		return(
			<div className="container">
				<Editor code={this.state.code} 
					onChange={this.handelChange.bind(this)} />
			<Preview html={this.state.code} />
			</div>
		)
	}
}

const Header = ()=>{
	return(
		<header>
			<div className="center">
				<h1>Markdown Editor</h1>
			</div>
		</header>
	)
}

const App = ()=>{
	return (
		<div>
			<Header />
			<div className="info">
				<p>Edit Here</p>
				<p>Preview</p>
			</div>
			<MarkdownContainer />
		</div>
	);
}

ReactDOM.render(<App />,document.getElementById("app"));
              
            
!
999px

Console