diff --git a/editor/js/ui/clipboard.js b/editor/js/ui/clipboard.js index b27c529c8..c78176017 100644 --- a/editor/js/ui/clipboard.js +++ b/editor/js/ui/clipboard.js @@ -119,8 +119,13 @@ RED.clipboard = (function() { var selection = RED.view.selection(); if (selection.nodes) { var nns = RED.nodes.createExportableNodeSet(selection.nodes); + if (RED.settings.flowFilePretty) { + nns = JSON.stringify(nns,null,4); + } else { + nns = JSON.stringify(nns); + } $("#clipboard-export") - .val(JSON.stringify(nns)) + .val(nns) .focus(function() { var textarea = $(this); textarea.select(); diff --git a/red/api/info.js b/red/api/info.js index a9f79a0d4..462868735 100644 --- a/red/api/info.js +++ b/red/api/info.js @@ -37,6 +37,10 @@ module.exports = { safeSettings.paletteCategories = settings.paletteCategories; } + if (settings.flowFilePretty) { + safeSettings.flowFilePretty = settings.flowFilePretty; + } + res.json(safeSettings); } } diff --git a/red/runtime/storage/localfilesystem.js b/red/runtime/storage/localfilesystem.js index 1ba46adeb..b783756b0 100644 --- a/red/runtime/storage/localfilesystem.js +++ b/red/runtime/storage/localfilesystem.js @@ -390,6 +390,9 @@ var localfilesystem = { headers += "// "+i+": "+meta[i]+"\n"; } } + if (type === "flows" && settings.flowFilePretty) { + body = JSON.stringify(JSON.parse(body),null,4); + } return promiseDir(fspath.dirname(fn)).then(function () { writeFile(fn,headers+body); }); diff --git a/test/red/api/flows_spec.js b/test/red/api/flows_spec.js index 970a0ea83..0ec10171c 100644 --- a/test/red/api/flows_spec.js +++ b/test/red/api/flows_spec.js @@ -36,6 +36,7 @@ describe("flows api", function() { it('returns flow', function(done) { flows.init({ + settings: {}, log:{warn:function(){},_:function(){},audit:function(){}}, nodes:{ getFlows: function() { return [1,2,3]; }