From 362c0178867ebfc0dbceabd9282a96aee7121b47 Mon Sep 17 00:00:00 2001 From: Yilin Gao Date: Mon, 19 Jun 2017 12:50:03 -0700 Subject: [PATCH 1/2] Update README.md to add changeObj to onChange --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0367eed..50a8ebc 100644 --- a/README.md +++ b/README.md @@ -42,10 +42,11 @@ var App = React.createClass({ code: "// Code", }; }, - updateCode: function(newCode) { + updateCode: function(newCode, changeObj) { this.setState({ code: newCode, }); + // get changed valued from changeObj }, render: function() { var options = { @@ -92,7 +93,7 @@ You can interact with the CodeMirror instance using a `ref` and the `getCodeMirr * `defaultValue` `String` provides a default (not change tracked) value to the editor * `name` `String` sets the name of the editor input field * `options` `Object` options passed to the CodeMirror instance -* `onChange` `Function (newValue)` called when a change is made +* `onChange` `Function (newValue, changeObj)` called when a change is made (`changeObj` is the object returned from [CodeMirror Change Event](https://codemirror.net/doc/manual.html#events)) * `onCursorActivity` `Function (codemirror)` called when the cursor is moved * `onFocusChange` `Function (focused)` called when the editor is focused or loses focus * `onScroll` `Function (scrollInfo)` called when the editor is scrolled From 86d55479071287b1bf8accdeeb97fd0e39ac66ff Mon Sep 17 00:00:00 2001 From: YilinGao Date: Mon, 19 Jun 2017 13:01:06 -0700 Subject: [PATCH 2/2] update onchange examples --- README.md | 3 ++- example/src/example.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 50a8ebc..a2e704a 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ var App = React.createClass({ this.setState({ code: newCode, }); - // get changed valued from changeObj + // get changed value from changeObj + console.log(changeObj); }, render: function() { var options = { diff --git a/example/src/example.js b/example/src/example.js index 0a84c87..6987c05 100644 --- a/example/src/example.js +++ b/example/src/example.js @@ -20,10 +20,11 @@ var App = createReactClass({ mode: 'markdown', }; }, - updateCode (newCode) { + updateCode (newCode, changeObj) { this.setState({ code: newCode }); + console.log(changeObj); }, changeMode (e) { var mode = e.target.value;