@node-red/editor-client 4.0.0-beta.4 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public/red/red.js CHANGED
@@ -6757,6 +6757,13 @@ RED.nodes = (function() {
6757
6757
  } else {
6758
6758
  delete n.g
6759
6759
  }
6760
+ // If importing into a subflow, ensure an outbound-link doesn't get added
6761
+ if (activeSubflow && /^link /.test(n.type) && n.links) {
6762
+ n.links = n.links.filter(function(id) {
6763
+ const otherNode = node_map[id] || RED.nodes.node(id);
6764
+ return (otherNode && otherNode.z === activeWorkspace);
6765
+ });
6766
+ }
6760
6767
  for (var d3 in n._def.defaults) {
6761
6768
  if (n._def.defaults.hasOwnProperty(d3)) {
6762
6769
  if (n._def.defaults[d3].type) {
@@ -6780,14 +6787,6 @@ RED.nodes = (function() {
6780
6787
  }
6781
6788
  }
6782
6789
  }
6783
- // If importing into a subflow, ensure an outbound-link doesn't
6784
- // get added
6785
- if (activeSubflow && /^link /.test(n.type) && n.links) {
6786
- n.links = n.links.filter(function(id) {
6787
- const otherNode = node_map[id] || RED.nodes.node(id);
6788
- return (otherNode && otherNode.z === activeWorkspace)
6789
- });
6790
- }
6791
6790
  }
6792
6791
  for (i=0;i<new_subflows.length;i++) {
6793
6792
  n = new_subflows[i];
@@ -10129,11 +10128,25 @@ RED.utils = (function() {
10129
10128
  return parts;
10130
10129
  }
10131
10130
 
10132
- function validatePropertyExpression(str) {
10131
+ /**
10132
+ * Validate a property expression
10133
+ * @param {*} str - the property value
10134
+ * @returns {boolean|string} whether the node proprty is valid. `true`: valid `false|String`: invalid
10135
+ */
10136
+ function validatePropertyExpression(str, opt) {
10133
10137
  try {
10134
- var parts = normalisePropertyExpression(str);
10138
+ const parts = normalisePropertyExpression(str);
10135
10139
  return true;
10136
10140
  } catch(err) {
10141
+ // If the validator has opt, it is a 3.x validator that
10142
+ // can return a String to mean 'invalid' and provide a reason
10143
+ if (opt) {
10144
+ if (opt.label) {
10145
+ return opt.label + ': ' + err.message;
10146
+ }
10147
+ return err.message;
10148
+ }
10149
+ // Otherwise, a 2.x returns a false value
10137
10150
  return false;
10138
10151
  }
10139
10152
  }
@@ -10151,22 +10164,24 @@ RED.utils = (function() {
10151
10164
  // Allow ${ENV_VAR} value
10152
10165
  return true
10153
10166
  }
10154
- let error
10167
+ let error;
10155
10168
  if (propertyType === 'json') {
10156
10169
  try {
10157
10170
  JSON.parse(propertyValue);
10158
10171
  } catch(err) {
10159
10172
  error = RED._("validator.errors.invalid-json", {
10160
10173
  error: err.message
10161
- })
10174
+ });
10162
10175
  }
10163
10176
  } else if (propertyType === 'msg' || propertyType === 'flow' || propertyType === 'global' ) {
10164
- if (!RED.utils.validatePropertyExpression(propertyValue)) {
10165
- error = RED._("validator.errors.invalid-prop")
10177
+ // To avoid double label
10178
+ const valid = RED.utils.validatePropertyExpression(propertyValue, opt ? {} : null);
10179
+ if (valid !== true) {
10180
+ error = opt ? valid : RED._("validator.errors.invalid-prop");
10166
10181
  }
10167
10182
  } else if (propertyType === 'num') {
10168
10183
  if (!/^NaN$|^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$|^[+-]?(0b|0B)[01]+$|^[+-]?(0o|0O)[0-7]+$|^[+-]?(0x|0X)[0-9a-fA-F]+$/.test(propertyValue)) {
10169
- error = RED._("validator.errors.invalid-num")
10184
+ error = RED._("validator.errors.invalid-num");
10170
10185
  }
10171
10186
  } else if (propertyType === 'jsonata') {
10172
10187
  try {
@@ -10174,16 +10189,16 @@ RED.utils = (function() {
10174
10189
  } catch(err) {
10175
10190
  error = RED._("validator.errors.invalid-expr", {
10176
10191
  error: err.message
10177
- })
10192
+ });
10178
10193
  }
10179
10194
  }
10180
10195
  if (error) {
10181
10196
  if (opt && opt.label) {
10182
- return opt.label+': '+error
10197
+ return opt.label + ': ' + error;
10183
10198
  }
10184
- return error
10199
+ return error;
10185
10200
  }
10186
- return true
10201
+ return true;
10187
10202
  }
10188
10203
 
10189
10204
  function getMessageProperty(msg,expr) {
@@ -15231,61 +15246,64 @@ RED.stack = (function() {
15231
15246
  { value: "_session", source: ["websocket out","tcp out"] },
15232
15247
  ]
15233
15248
  var allOptions = {
15234
- msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression, autoComplete: msgAutoComplete(msgCompletions)},
15235
- flow: {value:"flow",label:"flow.",hasValue:true,
15236
- options:[],
15237
- validate:RED.utils.validatePropertyExpression,
15249
+ msg: { value: "msg", label: "msg.", validate: RED.utils.validatePropertyExpression, autoComplete: msgAutoComplete(msgCompletions) },
15250
+ flow: { value: "flow", label: "flow.", hasValue: true,
15251
+ options: [],
15252
+ validate: RED.utils.validatePropertyExpression,
15238
15253
  parse: contextParse,
15239
15254
  export: contextExport,
15240
15255
  valueLabel: contextLabel,
15241
15256
  autoComplete: contextAutoComplete
15242
15257
  },
15243
- global: {value:"global",label:"global.",hasValue:true,
15244
- options:[],
15245
- validate:RED.utils.validatePropertyExpression,
15258
+ global: {
15259
+ value: "global", label: "global.", hasValue: true,
15260
+ options: [],
15261
+ validate: RED.utils.validatePropertyExpression,
15246
15262
  parse: contextParse,
15247
15263
  export: contextExport,
15248
15264
  valueLabel: contextLabel,
15249
15265
  autoComplete: contextAutoComplete
15250
15266
  },
15251
- str: {value:"str",label:"string",icon:"red/images/typedInput/az.svg"},
15252
- num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate: function(v) {
15253
- return (true === RED.utils.validateTypedProperty(v, "num"));
15267
+ str: { value: "str", label: "string", icon: "red/images/typedInput/az.svg" },
15268
+ num: { value: "num", label: "number", icon: "red/images/typedInput/09.svg", validate: function (v, o) {
15269
+ return RED.utils.validateTypedProperty(v, "num", o);
15254
15270
  } },
15255
- bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.svg",options:["true","false"]},
15271
+ bool: { value: "bool", label: "boolean", icon: "red/images/typedInput/bool.svg", options: ["true", "false"] },
15256
15272
  json: {
15257
- value:"json",
15258
- label:"JSON",
15259
- icon:"red/images/typedInput/json.svg",
15260
- validate: function(v) { try{JSON.parse(v);return true;}catch(e){return false;}},
15261
- expand: function() {
15273
+ value: "json",
15274
+ label: "JSON",
15275
+ icon: "red/images/typedInput/json.svg",
15276
+ validate: function (v, o) {
15277
+ return RED.utils.validateTypedProperty(v, "json", o);
15278
+ },
15279
+ expand: function () {
15262
15280
  var that = this;
15263
15281
  var value = this.value();
15264
15282
  try {
15265
- value = JSON.stringify(JSON.parse(value),null,4);
15266
- } catch(err) {
15283
+ value = JSON.stringify(JSON.parse(value), null, 4);
15284
+ } catch (err) {
15267
15285
  }
15268
15286
  RED.editor.editJSON({
15269
15287
  value: value,
15270
15288
  stateId: RED.editor.generateViewStateId("typedInput", that, "json"),
15271
15289
  focus: true,
15272
- complete: function(v) {
15290
+ complete: function (v) {
15273
15291
  var value = v;
15274
15292
  try {
15275
15293
  value = JSON.stringify(JSON.parse(v));
15276
- } catch(err) {
15294
+ } catch (err) {
15277
15295
  }
15278
15296
  that.value(value);
15279
15297
  }
15280
15298
  })
15281
15299
  }
15282
15300
  },
15283
- re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.svg"},
15301
+ re: { value: "re", label: "regular expression", icon: "red/images/typedInput/re.svg" },
15284
15302
  date: {
15285
- value:"date",
15286
- label:"timestamp",
15287
- icon:"fa fa-clock-o",
15288
- options:[
15303
+ value: "date",
15304
+ label: "timestamp",
15305
+ icon: "fa fa-clock-o",
15306
+ options: [
15289
15307
  {
15290
15308
  label: 'milliseconds since epoch',
15291
15309
  value: ''
@@ -15304,15 +15322,17 @@ RED.stack = (function() {
15304
15322
  value: "jsonata",
15305
15323
  label: "expression",
15306
15324
  icon: "red/images/typedInput/expr.svg",
15307
- validate: function(v) { try{jsonata(v);return true;}catch(e){return false;}},
15308
- expand:function() {
15325
+ validate: function (v, o) {
15326
+ return RED.utils.validateTypedProperty(v, "jsonata", o);
15327
+ },
15328
+ expand: function () {
15309
15329
  var that = this;
15310
15330
  RED.editor.editExpression({
15311
- value: this.value().replace(/\t/g,"\n"),
15331
+ value: this.value().replace(/\t/g, "\n"),
15312
15332
  stateId: RED.editor.generateViewStateId("typedInput", that, "jsonata"),
15313
15333
  focus: true,
15314
- complete: function(v) {
15315
- that.value(v.replace(/\n/g,"\t"));
15334
+ complete: function (v) {
15335
+ that.value(v.replace(/\n/g, "\t"));
15316
15336
  }
15317
15337
  })
15318
15338
  }
@@ -15321,13 +15341,13 @@ RED.stack = (function() {
15321
15341
  value: "bin",
15322
15342
  label: "buffer",
15323
15343
  icon: "red/images/typedInput/bin.svg",
15324
- expand: function() {
15344
+ expand: function () {
15325
15345
  var that = this;
15326
15346
  RED.editor.editBuffer({
15327
15347
  value: this.value(),
15328
15348
  stateId: RED.editor.generateViewStateId("typedInput", that, "bin"),
15329
15349
  focus: true,
15330
- complete: function(v) {
15350
+ complete: function (v) {
15331
15351
  that.value(v);
15332
15352
  }
15333
15353
  })
@@ -15343,9 +15363,9 @@ RED.stack = (function() {
15343
15363
  value: "node",
15344
15364
  label: "node",
15345
15365
  icon: "red/images/typedInput/target.svg",
15346
- valueLabel: function(container,value) {
15366
+ valueLabel: function (container, value) {
15347
15367
  var node = RED.nodes.node(value);
15348
- var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).css({
15368
+ var nodeDiv = $('<div>', { class: "red-ui-search-result-node" }).css({
15349
15369
  "margin-top": "2px",
15350
15370
  "margin-left": "3px"
15351
15371
  }).appendTo(container);
@@ -15354,117 +15374,117 @@ RED.stack = (function() {
15354
15374
  "margin-left": "6px"
15355
15375
  }).appendTo(container);
15356
15376
  if (node) {
15357
- var colour = RED.utils.getNodeColor(node.type,node._def);
15358
- var icon_url = RED.utils.getNodeIcon(node._def,node);
15377
+ var colour = RED.utils.getNodeColor(node.type, node._def);
15378
+ var icon_url = RED.utils.getNodeIcon(node._def, node);
15359
15379
  if (node.type === 'tab') {
15360
15380
  colour = "#C0DEED";
15361
15381
  }
15362
- nodeDiv.css('backgroundColor',colour);
15363
- var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
15382
+ nodeDiv.css('backgroundColor', colour);
15383
+ var iconContainer = $('<div/>', { class: "red-ui-palette-icon-container" }).appendTo(nodeDiv);
15364
15384
  RED.utils.createIconElement(icon_url, iconContainer, true);
15365
- var l = RED.utils.getNodeLabel(node,node.id);
15385
+ var l = RED.utils.getNodeLabel(node, node.id);
15366
15386
  nodeLabel.text(l);
15367
15387
  } else {
15368
15388
  nodeDiv.css({
15369
15389
  'backgroundColor': '#eee',
15370
- 'border-style' : 'dashed'
15390
+ 'border-style': 'dashed'
15371
15391
  });
15372
15392
 
15373
15393
  }
15374
15394
  },
15375
- expand: function() {
15395
+ expand: function () {
15376
15396
  var that = this;
15377
15397
  RED.tray.hide();
15378
15398
  RED.view.selectNodes({
15379
15399
  single: true,
15380
15400
  selected: [that.value()],
15381
- onselect: function(selection) {
15401
+ onselect: function (selection) {
15382
15402
  that.value(selection.id);
15383
15403
  RED.tray.show();
15384
15404
  },
15385
- oncancel: function() {
15405
+ oncancel: function () {
15386
15406
  RED.tray.show();
15387
15407
  }
15388
15408
  })
15389
15409
  }
15390
15410
  },
15391
- cred:{
15392
- value:"cred",
15393
- label:"credential",
15394
- icon:"fa fa-lock",
15411
+ cred: {
15412
+ value: "cred",
15413
+ label: "credential",
15414
+ icon: "fa fa-lock",
15395
15415
  inputType: "password",
15396
- valueLabel: function(container,value) {
15416
+ valueLabel: function (container, value) {
15397
15417
  var that = this;
15398
- container.css("pointer-events","none");
15399
- container.css("flex-grow",0);
15418
+ container.css("pointer-events", "none");
15419
+ container.css("flex-grow", 0);
15400
15420
  this.elementDiv.hide();
15401
15421
  var buttons = $('<div>').css({
15402
15422
  position: "absolute",
15403
- right:"6px",
15423
+ right: "6px",
15404
15424
  top: "6px",
15405
- "pointer-events":"all"
15425
+ "pointer-events": "all"
15406
15426
  }).appendTo(container);
15407
15427
  var eyeButton = $('<button type="button" class="red-ui-button red-ui-button-small"></button>').css({
15408
- width:"20px"
15409
- }).appendTo(buttons).on("click", function(evt) {
15428
+ width: "20px"
15429
+ }).appendTo(buttons).on("click", function (evt) {
15410
15430
  evt.preventDefault();
15411
15431
  var cursorPosition = that.input[0].selectionStart;
15412
15432
  var currentType = that.input.attr("type");
15413
15433
  if (currentType === "text") {
15414
- that.input.attr("type","password");
15434
+ that.input.attr("type", "password");
15415
15435
  eyeCon.removeClass("fa-eye-slash").addClass("fa-eye");
15416
- setTimeout(function() {
15436
+ setTimeout(function () {
15417
15437
  that.input.focus();
15418
15438
  that.input[0].setSelectionRange(cursorPosition, cursorPosition);
15419
- },50);
15439
+ }, 50);
15420
15440
  } else {
15421
- that.input.attr("type","text");
15441
+ that.input.attr("type", "text");
15422
15442
  eyeCon.removeClass("fa-eye").addClass("fa-eye-slash");
15423
- setTimeout(function() {
15443
+ setTimeout(function () {
15424
15444
  that.input.focus();
15425
15445
  that.input[0].setSelectionRange(cursorPosition, cursorPosition);
15426
- },50);
15446
+ }, 50);
15427
15447
  }
15428
15448
  }).hide();
15429
- var eyeCon = $('<i class="fa fa-eye"></i>').css("margin-left","-2px").appendTo(eyeButton);
15449
+ var eyeCon = $('<i class="fa fa-eye"></i>').css("margin-left", "-2px").appendTo(eyeButton);
15430
15450
 
15431
15451
  if (value === "__PWRD__") {
15432
15452
  var innerContainer = $('<div><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i></div>').css({
15433
- padding:"6px 6px",
15434
- borderRadius:"4px"
15453
+ padding: "6px 6px",
15454
+ borderRadius: "4px"
15435
15455
  }).addClass("red-ui-typedInput-value-label-inactive").appendTo(container);
15436
- var editButton = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-pencil"></i></button>').appendTo(buttons).on("click", function(evt) {
15456
+ var editButton = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-pencil"></i></button>').appendTo(buttons).on("click", function (evt) {
15437
15457
  evt.preventDefault();
15438
15458
  innerContainer.hide();
15439
- container.css("background","none");
15440
- container.css("pointer-events","none");
15459
+ container.css("background", "none");
15460
+ container.css("pointer-events", "none");
15441
15461
  that.input.val("");
15442
15462
  that.element.val("");
15443
15463
  that.elementDiv.show();
15444
15464
  editButton.hide();
15445
15465
  cancelButton.show();
15446
15466
  eyeButton.show();
15447
- setTimeout(function() {
15467
+ setTimeout(function () {
15448
15468
  that.input.focus();
15449
- },50);
15469
+ }, 50);
15450
15470
  });
15451
- var cancelButton = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-times"></i></button>').css("margin-left","3px").appendTo(buttons).on("click", function(evt) {
15471
+ var cancelButton = $('<button type="button" class="red-ui-button red-ui-button-small"><i class="fa fa-times"></i></button>').css("margin-left", "3px").appendTo(buttons).on("click", function (evt) {
15452
15472
  evt.preventDefault();
15453
15473
  innerContainer.show();
15454
- container.css("background","");
15474
+ container.css("background", "");
15455
15475
  that.input.val("__PWRD__");
15456
15476
  that.element.val("__PWRD__");
15457
15477
  that.elementDiv.hide();
15458
15478
  editButton.show();
15459
15479
  cancelButton.hide();
15460
15480
  eyeButton.hide();
15461
- that.input.attr("type","password");
15481
+ that.input.attr("type", "password");
15462
15482
  eyeCon.removeClass("fa-eye-slash").addClass("fa-eye");
15463
15483
 
15464
15484
  }).hide();
15465
15485
  } else {
15466
- container.css("background","none");
15467
- container.css("pointer-events","none");
15486
+ container.css("background", "none");
15487
+ container.css("pointer-events", "none");
15468
15488
  this.elementDiv.show();
15469
15489
  eyeButton.show();
15470
15490
  }
@@ -16411,26 +16431,48 @@ RED.stack = (function() {
16411
16431
  }
16412
16432
  }
16413
16433
  },
16414
- validate: function() {
16415
- var result;
16416
- var value = this.value();
16417
- var type = this.type();
16434
+ validate: function(options) {
16435
+ let valid = true;
16436
+ const value = this.value();
16437
+ const type = this.type();
16418
16438
  if (this.typeMap[type] && this.typeMap[type].validate) {
16419
- var val = this.typeMap[type].validate;
16420
- if (typeof val === 'function') {
16421
- result = val(value);
16439
+ const validate = this.typeMap[type].validate;
16440
+ if (typeof validate === 'function') {
16441
+ valid = validate(value, {});
16422
16442
  } else {
16423
- result = val.test(value);
16443
+ // Regex
16444
+ valid = validate.test(value);
16445
+ if (!valid) {
16446
+ valid = RED._("validator.errors.invalid-regexp");
16447
+ }
16424
16448
  }
16425
- } else {
16426
- result = true;
16427
16449
  }
16428
- if (result) {
16429
- this.uiSelect.removeClass('input-error');
16450
+ if ((typeof valid === "string") || !valid) {
16451
+ this.element.addClass("input-error");
16452
+ this.uiSelect.addClass("input-error");
16453
+ if (typeof valid === "string") {
16454
+ let tooltip = this.element.data("tooltip");
16455
+ if (tooltip) {
16456
+ tooltip.setContent(valid);
16457
+ } else {
16458
+ tooltip = RED.popover.tooltip(this.elementDiv, valid);
16459
+ this.element.data("tooltip", tooltip);
16460
+ }
16461
+ }
16430
16462
  } else {
16431
- this.uiSelect.addClass('input-error');
16463
+ this.element.removeClass("input-error");
16464
+ this.uiSelect.removeClass("input-error");
16465
+ const tooltip = this.element.data("tooltip");
16466
+ if (tooltip) {
16467
+ this.element.data("tooltip", null);
16468
+ tooltip.delete();
16469
+ }
16432
16470
  }
16433
- return result;
16471
+ if (options?.returnErrorMessage === true) {
16472
+ return valid;
16473
+ }
16474
+ // Must return a boolean for no 3.x validator
16475
+ return (typeof valid === "string") ? false : valid;
16434
16476
  },
16435
16477
  show: function() {
16436
16478
  this.uiSelect.show();
@@ -31783,7 +31825,7 @@ RED.sidebar.info = (function() {
31783
31825
  evt.stopPropagation();
31784
31826
  RED.search.show("type:subflow:"+n.id);
31785
31827
  })
31786
- // RED.popover.tooltip(userCountBadge,function() { return RED._('editor.nodesUse',{count:n.users.length})});
31828
+ RED.popover.tooltip(subflowInstanceBadge,function() { return RED._('subflow.subflowInstances',{count:n.instances.length})});
31787
31829
  }
31788
31830
  if (n._def.category === "config" && n.type !== "group") {
31789
31831
  var userCountBadge = $('<button type="button" class="red-ui-info-outline-item-control-users red-ui-button red-ui-button-small"><i class="fa fa-toggle-right"></i></button>').text(n.users.length).appendTo(controls).on("click",function(evt) {
@@ -35338,7 +35380,10 @@ RED.editor = (function() {
35338
35380
  const input = $("#"+prefix+"-"+property);
35339
35381
  const isTypedInput = input.length > 0 && input.next(".red-ui-typedInput-container").length > 0;
35340
35382
  if (isTypedInput) {
35341
- valid = input.typedInput("validate");
35383
+ valid = input.typedInput("validate", { returnErrorMessage: true });
35384
+ if (typeof valid === "string") {
35385
+ return label ? label + ": " + valid : valid;
35386
+ }
35342
35387
  }
35343
35388
  }
35344
35389
  }
@@ -35558,11 +35603,8 @@ RED.editor = (function() {
35558
35603
  if (selectedOpt?.data('env')) {
35559
35604
  disableButton(addButton, true);
35560
35605
  disableButton(editButton, true);
35561
- // disable the edit button if no options available
35562
- } else if (optionsLength === 1 && selectedOpt.val() === "_ADD_") {
35563
- disableButton(addButton, false);
35564
- disableButton(editButton, true);
35565
- } else if (selectedOpt.val() === "") {
35606
+ // disable the edit button if no options available or 'none' selected
35607
+ } else if (optionsLength === 1 || selectedOpt.val() === "_ADD_") {
35566
35608
  disableButton(addButton, false);
35567
35609
  disableButton(editButton, true);
35568
35610
  } else {
@@ -35571,14 +35613,9 @@ RED.editor = (function() {
35571
35613
  }
35572
35614
  });
35573
35615
 
35574
- var label = "";
35575
- var configNode = RED.nodes.node(nodeValue);
35576
-
35577
- if (configNode) {
35578
- label = RED.utils.getNodeLabel(configNode, configNode.id);
35579
- }
35580
-
35581
- input.val(label);
35616
+ // If the value is "", 'add new...' option if no config node available or 'none' option
35617
+ // Otherwise, it's a config node
35618
+ select.val(nodeValue || '_ADD_');
35582
35619
  }
35583
35620
 
35584
35621
  /**
@@ -36079,9 +36116,11 @@ RED.editor = (function() {
36079
36116
  }
36080
36117
 
36081
36118
  if (!configNodes.length) {
36119
+ // Add 'add new...' option
36082
36120
  select.append('<option value="_ADD_" selected>' + RED._("editor.addNewType", { type: label }) + '</option>');
36083
36121
  } else {
36084
- select.append('<option value="">' + RED._("editor.inputs.none") + '</option>');
36122
+ // Add 'none' option
36123
+ select.append('<option value="_ADD_">' + RED._("editor.inputs.none") + '</option>');
36085
36124
  }
36086
36125
 
36087
36126
  window.setTimeout(function() { select.trigger("change");},50);
@@ -43573,6 +43612,7 @@ RED.clipboard = (function() {
43573
43612
  var currentPopoverError;
43574
43613
  var activeTab;
43575
43614
  var libraryBrowser;
43615
+ var clipboardTabs;
43576
43616
 
43577
43617
  var activeLibraries = {};
43578
43618
 
@@ -43762,6 +43802,13 @@ RED.clipboard = (function() {
43762
43802
  open: function( event, ui ) {
43763
43803
  RED.keyboard.disable();
43764
43804
  },
43805
+ beforeClose: function(e) {
43806
+ if (clipboardTabs && activeTab === "red-ui-clipboard-dialog-export-tab-clipboard") {
43807
+ const jsonTabIndex = clipboardTabs.getTabIndex('red-ui-clipboard-dialog-export-tab-clipboard-json')
43808
+ const activeTabIndex = clipboardTabs.activeIndex()
43809
+ RED.settings.set("editor.dialog.export.json-view", activeTabIndex === jsonTabIndex )
43810
+ }
43811
+ },
43765
43812
  close: function(e) {
43766
43813
  RED.keyboard.enable();
43767
43814
  if (popover) {
@@ -43775,12 +43822,23 @@ RED.clipboard = (function() {
43775
43822
 
43776
43823
  exportNodesDialog =
43777
43824
  '<div class="form-row">'+
43778
- '<label style="width:auto;margin-right: 10px;" data-i18n="common.label.export"></label>'+
43779
- '<span id="red-ui-clipboard-dialog-export-rng-group" class="button-group">'+
43780
- '<a id="red-ui-clipboard-dialog-export-rng-selected" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.selected"></a>'+
43781
- '<a id="red-ui-clipboard-dialog-export-rng-flow" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.current"></a>'+
43782
- '<a id="red-ui-clipboard-dialog-export-rng-full" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.all"></a>'+
43783
- '</span>'+
43825
+ '<div style="display: flex; justify-content: space-between;">'+
43826
+ '<div class="form-row">'+
43827
+ '<label style="width:auto;margin-right: 10px;" data-i18n="common.label.export"></label>'+
43828
+ '<span id="red-ui-clipboard-dialog-export-rng-group" class="button-group">'+
43829
+ '<a id="red-ui-clipboard-dialog-export-rng-selected" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.selected"></a>'+
43830
+ '<a id="red-ui-clipboard-dialog-export-rng-flow" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.current"></a>'+
43831
+ '<a id="red-ui-clipboard-dialog-export-rng-full" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.all"></a>'+
43832
+ '</span>'+
43833
+ '</div>'+
43834
+ '<div class="form-row">'+
43835
+ '<label style="width:auto;margin-right: 10px;" data-i18n="common.label.format"></label>'+
43836
+ '<span id="red-ui-clipboard-dialog-export-fmt-group" class="button-group">'+
43837
+ '<a id="red-ui-clipboard-dialog-export-fmt-mini" class="red-ui-button red-ui-button toggle" href="#" data-i18n="clipboard.export.compact"></a>'+
43838
+ '<a id="red-ui-clipboard-dialog-export-fmt-full" class="red-ui-button red-ui-button toggle" href="#" data-i18n="clipboard.export.formatted"></a>'+
43839
+ '</span>'+
43840
+ '</div>'+
43841
+ '</div>'+
43784
43842
  '</div>'+
43785
43843
  '<div class="red-ui-clipboard-dialog-box">'+
43786
43844
  '<div class="red-ui-clipboard-dialog-tabs">'+
@@ -43795,15 +43853,9 @@ RED.clipboard = (function() {
43795
43853
  '<div id="red-ui-clipboard-dialog-export-tab-clipboard-preview-list"></div>'+
43796
43854
  '</div>'+
43797
43855
  '<div class="red-ui-clipboard-dialog-export-tab-clipboard-tab" id="red-ui-clipboard-dialog-export-tab-clipboard-json">'+
43798
- '<div class="form-row" style="height:calc(100% - 40px)">'+
43856
+ '<div class="form-row" style="height:calc(100% - 10px)">'+
43799
43857
  '<textarea readonly id="red-ui-clipboard-dialog-export-text"></textarea>'+
43800
43858
  '</div>'+
43801
- '<div class="form-row" style="text-align: right;">'+
43802
- '<span id="red-ui-clipboard-dialog-export-fmt-group" class="button-group">'+
43803
- '<a id="red-ui-clipboard-dialog-export-fmt-mini" class="red-ui-button red-ui-button-small toggle" href="#" data-i18n="clipboard.export.compact"></a>'+
43804
- '<a id="red-ui-clipboard-dialog-export-fmt-full" class="red-ui-button red-ui-button-small toggle" href="#" data-i18n="clipboard.export.formatted"></a>'+
43805
- '</span>'+
43806
- '</div>'+
43807
43859
  '</div>'+
43808
43860
  '</div>'+
43809
43861
  '<div class="form-row" id="red-ui-clipboard-dialog-export-tab-library-filename">'+
@@ -44116,7 +44168,7 @@ RED.clipboard = (function() {
44116
44168
 
44117
44169
  dialogContainer.empty();
44118
44170
  dialogContainer.append($(exportNodesDialog));
44119
-
44171
+ clipboardTabs = null
44120
44172
  var tabs = RED.tabs.create({
44121
44173
  id: "red-ui-clipboard-dialog-export-tabs",
44122
44174
  vertical: true,
@@ -44177,7 +44229,7 @@ RED.clipboard = (function() {
44177
44229
  $("#red-ui-clipboard-dialog-tab-library-name").on('paste',function() { setTimeout(validateExportFilename,10)});
44178
44230
  $("#red-ui-clipboard-dialog-export").button("enable");
44179
44231
 
44180
- var clipboardTabs = RED.tabs.create({
44232
+ clipboardTabs = RED.tabs.create({
44181
44233
  id: "red-ui-clipboard-dialog-export-tab-clipboard-tabs",
44182
44234
  onchange: function(tab) {
44183
44235
  $(".red-ui-clipboard-dialog-export-tab-clipboard-tab").hide();
@@ -44194,6 +44246,9 @@ RED.clipboard = (function() {
44194
44246
  id: "red-ui-clipboard-dialog-export-tab-clipboard-json",
44195
44247
  label: RED._("editor.types.json")
44196
44248
  });
44249
+ if (RED.settings.get("editor.dialog.export.json-view") === true) {
44250
+ clipboardTabs.activateTab("red-ui-clipboard-dialog-export-tab-clipboard-json");
44251
+ }
44197
44252
 
44198
44253
  var previewList = $("#red-ui-clipboard-dialog-export-tab-clipboard-preview-list").css({position:"absolute",top:0,right:0,bottom:0,left:0}).treeList({
44199
44254
  data: []
@@ -48821,7 +48876,7 @@ RED.subflow = (function() {
48821
48876
  input.val(val.value);
48822
48877
  break;
48823
48878
  case "cred":
48824
- input = $('<input type="password">').css('width','70%').appendTo(row);
48879
+ input = $('<input type="password">').css('width','70%').attr('id', elId).appendTo(row);
48825
48880
  if (node.credentials) {
48826
48881
  if (node.credentials[tenv.name]) {
48827
48882
  input.val(node.credentials[tenv.name]);
@@ -49067,7 +49122,7 @@ RED.subflow = (function() {
49067
49122
  }
49068
49123
  break;
49069
49124
  case "cred":
49070
- item.value = input.val();
49125
+ item.value = input.typedInput('value');
49071
49126
  item.type = 'cred';
49072
49127
  break;
49073
49128
  case "spinner":