From c4c87993c2fdce9cc90c43d84f48346b5f866602 Mon Sep 17 00:00:00 2001 From: Vijaya Krishna Date: Mon, 23 Apr 2018 18:04:29 +0530 Subject: [PATCH] Onchange support in diff (#428) * Onchange support in diff * diff.md updated --- docs/Diff.md | 1 + example/diff.js | 1 + src/diff.js | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/docs/Diff.md b/docs/Diff.md index 928fb7a6..a01b2c22 100644 --- a/docs/Diff.md +++ b/docs/Diff.md @@ -40,6 +40,7 @@ The diff editor is contained in a Split editor and will highlight differences be |name|'brace-editor'|string|Unique ID to be used for the split editor| |onLoad| | Function | called on editor load. The first argument is the instance of the editor | |onScroll| | Function | triggered by editor `scroll` event| + |onChange| | Function | occurs on document change it has one argument the values array| |onPaste| | Function | Triggered by editor `paste` event, and passes text as argument| |orientation|'beside'|String|The orientation of splits either 'beside' or 'below'| |readOnly| false| Boolean| make the editor read only | diff --git a/example/diff.js b/example/diff.js index e18db92d..edfd1395 100644 --- a/example/diff.js +++ b/example/diff.js @@ -94,6 +94,7 @@ class App extends Component { height="1000px" width="1000px" mode={this.state.mode} + onChange={this.onChange} /> diff --git a/src/diff.js b/src/diff.js index 7b80e52d..8ab16e6c 100644 --- a/src/diff.js +++ b/src/diff.js @@ -17,6 +17,9 @@ export default class DiffComponent extends Component { this.setState({ value: value }); + if(this.props.onChange){ + this.props.onChange(value); + } } diff() { @@ -231,6 +234,7 @@ DiffComponent.propTypes = { onLoad: PropTypes.func, onPaste: PropTypes.func, onScroll: PropTypes.func, + onChange:PropTypes.func, orientation: PropTypes.string, readOnly: PropTypes.bool, scrollMargin: PropTypes.array, @@ -262,6 +266,7 @@ DiffComponent.defaultProps = { onLoad: null, onScroll: null, onPaste: null, + onChange:null, orientation: 'beside', readOnly: false, scrollMargin: [ 0, 0, 0, 0],