Skip to content

Commit 6707e43

Browse files
committed
Merge pull request JedWatson#8 from lachenmayer/master
Add onFocusChanged prop.
2 parents ad88cc0 + e9fa444 commit 6707e43

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ React.render(<App />, document.getElementById('app'));
6161
* `value` `String` the editor value
6262
* `options` `Object (newValue)` options passed to the CodeMirror instance
6363
* `onChange` `Function (newValue)` called when a change is made
64+
* `onFocusChange` `Function (focused)` called when the editor is focused or loses focus
6465

6566
See the [CodeMirror API Docs](https://codemirror.net/doc/manual.html#api) for the available options.
6667

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-codemirror",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "Codemirror",
55
"main": "lib/Codemirror.js",
66
"author": "Jed Watson",

src/Codemirror.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var CodeMirror = React.createClass({
55

66
propTypes: {
77
onChange: React.PropTypes.func,
8+
onFocusChange: React.PropTypes.func,
89
options: React.PropTypes.object,
910
path: React.PropTypes.string,
1011
value: React.PropTypes.string
@@ -51,6 +52,7 @@ var CodeMirror = React.createClass({
5152
this.setState({
5253
isFocused: focused
5354
});
55+
this.props.onFocusChange && this.props.onFocusChange(focused);
5456
},
5557

5658
codemirrorValueChanged (doc, change) {

0 commit comments

Comments
 (0)