Parse directly after setText
This commit is contained in:
parent
72455e3302
commit
2b6caba3df
|
@ -2,16 +2,16 @@
|
|||
|
||||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## not yet published, version 6.2.0
|
||||
|
||||
- Implemented new mode `preview`, capable of working with JSON documents
|
||||
- Implemented new mode `preview`, capable of working with large JSON documents
|
||||
up to 500 MiB.
|
||||
- Fixed #730: in `code` mode, there was an initial undo action which clears
|
||||
the content.
|
||||
- Upgraded dependencies `vanilla-picker@2.9.1`, `mobius1-selectr@2.4.13`,
|
||||
`ajv@6.10.2`.
|
||||
|
||||
|
||||
## 2019-06-22, version 6.1.0
|
||||
|
||||
- Implemented menu options `sort` and `transform` for modes `code` and `text`.
|
||||
|
|
|
@ -525,9 +525,7 @@ previewmode.get = function() {
|
|||
var text = this.getText();
|
||||
|
||||
try {
|
||||
console.time('parse') // TODO: cleanup
|
||||
this.json = util.parse(text); // this can throw an error
|
||||
console.timeEnd('parse') // TODO: cleanup
|
||||
}
|
||||
catch (err) {
|
||||
// try to sanitize json, replace JavaScript notation with JSON notation
|
||||
|
@ -547,14 +545,10 @@ previewmode.get = function() {
|
|||
*/
|
||||
previewmode.getText = function() {
|
||||
if (this.text === undefined) {
|
||||
console.time('stringify') // TODO: cleanup
|
||||
this.text = JSON.stringify(this.json, null, this.indentation);
|
||||
console.timeEnd('stringify') // TODO: cleanup
|
||||
|
||||
if (this.options.escapeUnicode === true) {
|
||||
console.time('escape') // TODO: cleanup
|
||||
this.text = util.escapeUnicodeChars(this.text);
|
||||
console.timeEnd('escape') // TODO: cleanup
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,9 +588,7 @@ previewmode.updateText = function(jsonText) {
|
|||
*/
|
||||
previewmode._setText = function(jsonText, json) {
|
||||
if (this.options.escapeUnicode === true) {
|
||||
console.time('escape') // TODO: cleanup
|
||||
this.text = util.escapeUnicodeChars(jsonText);
|
||||
console.timeEnd('escape') // TODO: cleanup
|
||||
}
|
||||
else {
|
||||
this.text = jsonText;
|
||||
|
@ -605,7 +597,18 @@ previewmode._setText = function(jsonText, json) {
|
|||
|
||||
this._renderPreview();
|
||||
|
||||
if (this.json === undefined) {
|
||||
var me = this;
|
||||
this.executeWithBusyMessage(function () {
|
||||
// force parsing the json now, else it will be done in validate without feedback
|
||||
me.json = me.get();
|
||||
me._renderPreview();
|
||||
me._pushHistory();
|
||||
}, 'parsing...');
|
||||
}
|
||||
else {
|
||||
this._pushHistory();
|
||||
}
|
||||
|
||||
this._debouncedValidate();
|
||||
};
|
||||
|
|
|
@ -252,14 +252,10 @@ function showTransformModal (container, json, onTransform) {
|
|||
|
||||
function updatePreview() {
|
||||
try {
|
||||
console.time('transform') // TODO: cleanup
|
||||
var transformed = jmespath.search(value, query.value);
|
||||
console.timeEnd('transform') // TODO: cleanup
|
||||
|
||||
console.time('stringify') // TODO: cleanup
|
||||
preview.className = 'jsoneditor-transform-preview';
|
||||
preview.value = stringifyPartial(transformed, 2, MAX_PREVIEW_CHARACTERS);
|
||||
console.timeEnd('stringify') // TODO: cleanup
|
||||
|
||||
ok.disabled = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue