Fixed #730: in `code` mode, there was an initial undo action which clears the content
This commit is contained in:
parent
df386b6f1b
commit
bc0e99ab4a
|
@ -3,6 +3,12 @@
|
|||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## not yet published, version 6.1.1
|
||||
|
||||
- Fixed #730: in `code` mode, there was an initial undo action which clears
|
||||
the content.
|
||||
|
||||
|
||||
## 2019-06-22, version 6.1.0
|
||||
|
||||
- Implemented menu options `sort` and `transform` for modes `code` and `text`.
|
||||
|
|
|
@ -734,10 +734,12 @@ textmode.getText = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* Set the text contents of the editor
|
||||
* Set the text contents of the editor and optionally clear the history
|
||||
* @param {String} jsonText
|
||||
* @param {boolean} clearHistory Only applicable for mode 'code'
|
||||
* @private
|
||||
*/
|
||||
textmode.setText = function(jsonText) {
|
||||
textmode._setText = function(jsonText, clearHistory) {
|
||||
var text;
|
||||
|
||||
if (this.options.escapeUnicode === true) {
|
||||
|
@ -756,12 +758,28 @@ textmode.setText = function(jsonText) {
|
|||
|
||||
this.aceEditor.setValue(text, -1);
|
||||
|
||||
if (clearHistory) {
|
||||
// prevent initial undo action clearing the initial contents
|
||||
var me = this;
|
||||
setTimeout(function () {
|
||||
me.aceEditor.session.getUndoManager().reset();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
this.onChangeDisabled = false;
|
||||
}
|
||||
// validate JSON schema
|
||||
this._debouncedValidate();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the text contents of the editor
|
||||
* @param {String} jsonText
|
||||
*/
|
||||
textmode.setText = function(jsonText) {
|
||||
this._setText(jsonText, true)
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the text contents
|
||||
* @param {string} jsonText
|
||||
|
@ -772,9 +790,7 @@ textmode.updateText = function(jsonText) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.onChangeDisabled = true; // don't fire an onChange event
|
||||
this.setText(jsonText);
|
||||
this.onChangeDisabled = false;
|
||||
this._setText(jsonText, false);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue