Skip to content

Commit

Permalink
Onchange support in diff (#428)
Browse files Browse the repository at this point in the history
* Onchange support in diff

* diff.md updated
  • Loading branch information
Vijaya Krishna authored and securingsincity committed Apr 23, 2018
1 parent dd4b1f8 commit c4c8799
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions example/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class App extends Component {
height="1000px"
width="1000px"
mode={this.state.mode}
onChange={this.onChange}
/>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export default class DiffComponent extends Component {
this.setState({
value: value
});
if(this.props.onChange){
this.props.onChange(value);
}
}

diff() {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -262,6 +266,7 @@ DiffComponent.defaultProps = {
onLoad: null,
onScroll: null,
onPaste: null,
onChange:null,
orientation: 'beside',
readOnly: false,
scrollMargin: [ 0, 0, 0, 0],
Expand Down

0 comments on commit c4c8799

Please sign in to comment.