Add reformat button to JSONata test data editor

This commit is contained in:
Nick O'Leary
2017-07-03 21:57:55 +01:00
parent 92654a71fb
commit a737810c50
2 changed files with 17 additions and 3 deletions

View File

@@ -1943,6 +1943,17 @@ RED.editor = (function() {
}
});
$("#node-input-example-reformat").click(function(evt) {
evt.preventDefault();
var v = testDataEditor.getValue()||"";
try {
v = JSON.stringify(JSON.parse(v),null,4);
} catch(err) {
// TODO: do an optimistic auto-format
}
testDataEditor.getSession().setValue(v||"",-1);
});
testExpression();
},
close: function() {
@@ -2009,7 +2020,7 @@ RED.editor = (function() {
mode:"ace/mode/json"
});
expressionEditor.getSession().setValue(value||"",-1);
$("#node-input-expression-reformat").click(function(evt) {
$("#node-input-json-reformat").click(function(evt) {
evt.preventDefault();
var v = expressionEditor.getValue()||"";
try {