Skip to content

Update README.md and example to add changeObj parameter to onChange property #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ var App = React.createClass({
code: "// Code",
};
},
updateCode: function(newCode) {
updateCode: function(newCode, changeObj) {
this.setState({
code: newCode,
});
// get changed value from changeObj
console.log(changeObj);
},
render: function() {
var options = {
Expand Down Expand Up @@ -92,7 +94,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
Expand Down
3 changes: 2 additions & 1 deletion example/src/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down