Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,28 @@ Then open [`localhost:8000`](http://localhost:8000) in a browser.

## Installation

The easiest way to use codemirror is to install it from NPM and include it in your own React build process (using [Browserify](http://browserify.org), [Webpack](http://webpack.github.io/), etc).
```
npm install react-md-editor --save
```

And you may need to install codemirror. The easiest way to use codemirror is to install it from NPM and include it in your own React build process (using [Browserify](http://browserify.org), [Webpack](http://webpack.github.io/), etc).

You can also use the standalone build by including `dist/codemirror.js` in your page. If you use this, make sure you have already included React, and it is available as a global variable.

```
npm install codemirror --save
```


## Usage

```js
var React = require('react'),
Editor = require('react-md-editor');

// you may need import css in your js if you use webpack or tools can build css
// or @import in your less file like [the example.less](https://github.com/JedWatson/react-md-editor/blob/master/example/src/example.less#L77)
// import 'react-md-editor/dist/react-md-editor.min.css';

var App = React.createClass({
getInitialState: function() {
return {
Expand Down
4 changes: 3 additions & 1 deletion src/MDEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var MarkdownEditor = React.createClass({
options: React.PropTypes.object,
path: React.PropTypes.string,
value: React.PropTypes.string,
className: React.PropTypes.string,
},

getInitialState () {
Expand Down Expand Up @@ -125,9 +126,10 @@ var MarkdownEditor = React.createClass({
},

render () {
var editorWrapperClassName = classNames('MDEditor', this.props.className);
var editorClassName = classNames('MDEditor_editor', { 'MDEditor_editor--focused': this.state.isFocused });
return (
<div className="MDEditor">
<div className={editorWrapperClassName}>
{this.renderToolbar()}
<div className={editorClassName}>
<textarea ref="codemirror" name={this.props.path} defaultValue={this.props.value} autoComplete="off" />
Expand Down