react-ace
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -43,2 +43,3 @@ # Diff 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| | ||
@@ -52,3 +53,3 @@ |orientation|'beside'|String|The orientation of splits either 'beside' or 'below'| | ||
|style| | Object | camelCased properties | | ||
|tabSize|4|Number|Number of spaces to include as tab| | ||
|tabSize|4|Number|Number of spaces to include as tab| | ||
|theme|'github'|String|Theme to use| | ||
@@ -55,0 +56,0 @@ |value|['','']|Array of Strings|Index 0: Value of first editor. Index 1: Value of second editor| |
@@ -63,2 +63,3 @@ # Split Editor | ||
|tabSize| 4| Number| tabSize| | ||
|debounceChangePeriod| null| Number| A debounce delay period for the onChange event| | ||
|onLoad| | Function | called on editor load. The first argument is the instance of the editor | | ||
@@ -65,0 +66,0 @@ |onBeforeLoad| | Function | called before editor load. the first argument is an instance of `ace`| |
@@ -51,2 +51,3 @@ 'use strict'; | ||
}); | ||
_this.debounce = _editorOptions.debounce; | ||
return _this; | ||
@@ -166,15 +167,2 @@ } | ||
}, { | ||
key: 'debounce', | ||
value: function debounce(fn, delay) { | ||
var timer = null; | ||
return function () { | ||
var context = this, | ||
args = arguments; | ||
clearTimeout(timer); | ||
timer = setTimeout(function () { | ||
fn.apply(context, args); | ||
}, delay); | ||
}; | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
@@ -181,0 +169,0 @@ value: function componentWillReceiveProps(nextProps) { |
@@ -55,2 +55,5 @@ 'use strict'; | ||
}); | ||
if (this.props.onChange) { | ||
this.props.onChange(value); | ||
} | ||
} | ||
@@ -282,2 +285,3 @@ }, { | ||
onScroll: _propTypes2.default.func, | ||
onChange: _propTypes2.default.func, | ||
orientation: _propTypes2.default.string, | ||
@@ -314,2 +318,3 @@ readOnly: _propTypes2.default.bool, | ||
onPaste: null, | ||
onChange: null, | ||
orientation: 'beside', | ||
@@ -316,0 +321,0 @@ readOnly: false, |
@@ -9,4 +9,15 @@ 'use strict'; | ||
var editorEvents = ['onChange', 'onFocus', 'onInput', 'onBlur', 'onCopy', 'onPaste', 'onSelectionChange', 'onCursorChange', 'onScroll', 'handleOptions', 'updateRef']; | ||
var debounce = function debounce(fn, delay) { | ||
var timer = null; | ||
return function () { | ||
var context = this, | ||
args = arguments; | ||
clearTimeout(timer); | ||
timer = setTimeout(function () { | ||
fn.apply(context, args); | ||
}, delay); | ||
}; | ||
}; | ||
exports.editorOptions = editorOptions; | ||
exports.editorEvents = editorEvents; | ||
exports.editorEvents = editorEvents; | ||
exports.debounce = debounce; |
@@ -60,2 +60,3 @@ 'use strict'; | ||
}); | ||
_this.debounce = _editorOptions.debounce; | ||
return _this; | ||
@@ -110,2 +111,5 @@ } | ||
var availableOptions = this.splitEditor.$options; | ||
if (this.props.debounceChangePeriod) { | ||
this.onChange = this.debounce(this.onChange, this.props.debounceChangePeriod); | ||
} | ||
split.forEach(function (editor, index) { | ||
@@ -447,2 +451,3 @@ for (var i = 0; i < editorProps.length; i++) { | ||
defaultValue: _propTypes2.default.arrayOf(_propTypes2.default.string), | ||
debounceChangePeriod: _propTypes2.default.number, | ||
onLoad: _propTypes2.default.func, | ||
@@ -449,0 +454,0 @@ onSelectionChange: _propTypes2.default.func, |
{ | ||
"name": "react-ace", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "A react component for Ace Editor", | ||
@@ -44,12 +44,12 @@ "main": "lib/index.js", | ||
"jsdom": "^11.0.0", | ||
"mocha": "5.0.5", | ||
"nyc": "11.6.0", | ||
"react": "^16.3.1", | ||
"react-dom": "^16.3.1", | ||
"mocha": "5.1.1", | ||
"nyc": "11.7.1", | ||
"react": "^16.3.2", | ||
"react-dom": "^16.3.2", | ||
"react-test-renderer": "^16.0.0", | ||
"rimraf": "2.6.2", | ||
"sinon": "5.0.0", | ||
"webpack": "4.5.0", | ||
"webpack": "4.6.0", | ||
"webpack-cli": "^2.0.9", | ||
"webpack-dev-server": "3.1.2" | ||
"webpack-dev-server": "^3.1.3" | ||
}, | ||
@@ -56,0 +56,0 @@ "keywords": [ |
@@ -7,3 +7,3 @@ import ace from 'brace' | ||
const { Range } = ace.acequire('ace/range'); | ||
import { editorOptions, editorEvents } from './editorOptions.js' | ||
import { editorOptions, editorEvents,debounce } from './editorOptions.js' | ||
@@ -16,2 +16,3 @@ export default class ReactAce extends Component { | ||
}); | ||
this.debounce=debounce; | ||
} | ||
@@ -126,12 +127,3 @@ | ||
debounce(fn, delay) { | ||
var timer = null; | ||
return function () { | ||
var context = this, args = arguments; | ||
clearTimeout(timer); | ||
timer = setTimeout(function () { | ||
fn.apply(context, args); | ||
}, delay); | ||
}; | ||
} | ||
@@ -138,0 +130,0 @@ componentWillReceiveProps(nextProps) { |
@@ -20,2 +20,5 @@ import SplitEditor from './split.js'; | ||
}); | ||
if(this.props.onChange){ | ||
this.props.onChange(value); | ||
} | ||
} | ||
@@ -235,2 +238,3 @@ | ||
onScroll: PropTypes.func, | ||
onChange:PropTypes.func, | ||
orientation: PropTypes.string, | ||
@@ -267,2 +271,3 @@ readOnly: PropTypes.bool, | ||
onPaste: null, | ||
onChange:null, | ||
orientation: 'beside', | ||
@@ -269,0 +274,0 @@ readOnly: false, |
@@ -25,6 +25,16 @@ const editorOptions = [ | ||
] | ||
const debounce=(fn, delay)=>{ | ||
var timer = null; | ||
return function () { | ||
var context = this, args = arguments; | ||
clearTimeout(timer); | ||
timer = setTimeout(function () { | ||
fn.apply(context, args); | ||
}, delay); | ||
}; | ||
} | ||
export { | ||
editorOptions, | ||
editorEvents | ||
editorEvents, | ||
debounce, | ||
} |
@@ -8,3 +8,3 @@ import ace from 'brace' | ||
import { editorOptions, editorEvents } from './editorOptions.js' | ||
import { editorOptions, editorEvents,debounce } from './editorOptions.js' | ||
const { Range } = ace.acequire('ace/range'); | ||
@@ -21,2 +21,3 @@ | ||
}); | ||
this.debounce=debounce; | ||
} | ||
@@ -65,2 +66,5 @@ | ||
const availableOptions = this.splitEditor.$options; | ||
if (this.props.debounceChangePeriod) { | ||
this.onChange = this.debounce(this.onChange, this.props.debounceChangePeriod); | ||
} | ||
split.forEach((editor, index) => { | ||
@@ -371,2 +375,3 @@ for (let i = 0; i < editorProps.length; i++) { | ||
defaultValue: PropTypes.arrayOf(PropTypes.string), | ||
debounceChangePeriod:PropTypes.number, | ||
onLoad: PropTypes.func, | ||
@@ -373,0 +378,0 @@ onSelectionChange: PropTypes.func, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2040196
9228