Fixed #222: editor throwing `onChange` events when switching mode

This commit is contained in:
jos 2016-01-12 17:25:33 +01:00
parent 68e22bb982
commit c0077250ef
4 changed files with 10 additions and 6 deletions

View File

@ -11,6 +11,7 @@ https://github.com/josdejong/jsoneditor
- Implemented #183: display a checkbox left from boolean values, so you can
easily switch between true/false.
- Added a minimalist bundle to the `dist` folder, excluding `ace` and `ajv`.
- Fixed #222: editor throwing `onChange` events when switching mode.
- Fixed an error throw when switching to mode "code" via the menu.
- Fixed interfering shortcut keys: changed quick keys to select multiple fields
from `Shift+Arrow Up/Down` to `Ctrl+Shift+Arrow Up/Down`.

View File

@ -58,12 +58,6 @@ var compilerMinimalist = webpack({
new webpack.IgnorePlugin(new RegExp('^brace$')),
new webpack.IgnorePlugin(new RegExp('^ajv'))
],
//exclude: [
// 'brace',
// 'ajv/dist/ajv.bundle.js'
//],
cache: true
});

View File

@ -365,7 +365,13 @@ textmode.setText = function(jsonText) {
this.textarea.value = text;
}
if (this.aceEditor) {
// prevent emitting onChange events while setting new text
var originalOnChange = this.options.onChange;
this.options.onChange = null;
this.aceEditor.setValue(text, -1);
this.options.onChange = originalOnChange;
}
// validate JSON schema

View File

@ -46,6 +46,9 @@
onError: function (err) {
alert(err.toString());
},
onChange: function () {
console.log('change');
},
indentation: 4,
escapeUnicode: true
};