1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
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 {

View File

@ -188,7 +188,10 @@
</div>
<div id="node-input-expression-tab-test" class="node-input-expression-tab-content hide">
<div>
<span style="display: inline-block; width: calc(50% - 5px);" data-i18n="expressionEditor.data"></span>
<span style="display: inline-block; width: calc(50% - 5px);">
<span data-i18n="expressionEditor.data"></span>
<button style="float: right; margin-right: 5px;" id="node-input-example-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button>
</span>
<span style="display: inline-block; width: calc(50% - 5px);" data-i18n="expressionEditor.result"></span>
</div>
<div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-data"></div>
@ -200,7 +203,7 @@
</script>
<script type="text/x-red" data-template-name="_json">
<div class="form-row" style="margin-bottom: 3px; text-align: right;">
<button id="node-input-expression-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button>
<button id="node-input-json-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button>
</div>
<div class="form-row node-text-editor-row">
<div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-json"></div>