@node-red/editor-client 3.1.8 → 3.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/editor-client",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
package/public/red/about CHANGED
@@ -1,3 +1,10 @@
1
+ #### 3.1.9: Maintenance Release
2
+
3
+ - Prevent subflow being added to itself (#4654) @knolleary
4
+ - Fix use of spawn on windows with cmd files (#4652) @knolleary
5
+ - Guard refresh of unknown subflow (#4640) @knolleary
6
+ - Fix subflow module sending messages to debug sidebar (#4642) @knolleary
7
+
1
8
  #### 3.1.8: Maintenance Release
2
9
 
3
10
  - Add validation and error handling on subflow instance properties (#4632) @knolleary
package/public/red/red.js CHANGED
@@ -21212,120 +21212,128 @@ RED.view = (function() {
21212
21212
  }
21213
21213
  d3.event = event;
21214
21214
  var selected_tool = $(ui.draggable[0]).attr("data-palette-type");
21215
- var result = createNode(selected_tool);
21216
- if (!result) {
21217
- return;
21218
- }
21219
- var historyEvent = result.historyEvent;
21220
- var nn = RED.nodes.add(result.node);
21215
+ try {
21216
+ var result = createNode(selected_tool);
21217
+ if (!result) {
21218
+ return;
21219
+ }
21220
+ var historyEvent = result.historyEvent;
21221
+ var nn = RED.nodes.add(result.node);
21221
21222
 
21222
- var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
21223
- if (showLabel !== undefined && (nn._def.hasOwnProperty("showLabel")?nn._def.showLabel:true) && !nn._def.defaults.hasOwnProperty("l")) {
21224
- nn.l = showLabel;
21225
- }
21223
+ var showLabel = RED.utils.getMessageProperty(RED.settings.get('editor'),"view.view-node-show-label");
21224
+ if (showLabel !== undefined && (nn._def.hasOwnProperty("showLabel")?nn._def.showLabel:true) && !nn._def.defaults.hasOwnProperty("l")) {
21225
+ nn.l = showLabel;
21226
+ }
21226
21227
 
21227
- var helperOffset = d3.touches(ui.helper.get(0))[0]||d3.mouse(ui.helper.get(0));
21228
- var helperWidth = ui.helper.width();
21229
- var helperHeight = ui.helper.height();
21230
- var mousePos = d3.touches(this)[0]||d3.mouse(this);
21228
+ var helperOffset = d3.touches(ui.helper.get(0))[0]||d3.mouse(ui.helper.get(0));
21229
+ var helperWidth = ui.helper.width();
21230
+ var helperHeight = ui.helper.height();
21231
+ var mousePos = d3.touches(this)[0]||d3.mouse(this);
21231
21232
 
21232
- try {
21233
- var isLink = (nn.type === "link in" || nn.type === "link out")
21234
- var hideLabel = nn.hasOwnProperty('l')?!nn.l : isLink;
21235
-
21236
- var label = RED.utils.getNodeLabel(nn, nn.type);
21237
- var labelParts = getLabelParts(label, "red-ui-flow-node-label");
21238
- if (hideLabel) {
21239
- nn.w = node_height;
21240
- nn.h = Math.max(node_height,(nn.outputs || 0) * 15);
21241
- } else {
21242
- nn.w = Math.max(node_width,20*(Math.ceil((labelParts.width+50+(nn._def.inputs>0?7:0))/20)) );
21243
- nn.h = Math.max(6+24*labelParts.lines.length,(nn.outputs || 0) * 15, 30);
21244
- }
21245
- } catch(err) {
21246
- }
21233
+ try {
21234
+ var isLink = (nn.type === "link in" || nn.type === "link out")
21235
+ var hideLabel = nn.hasOwnProperty('l')?!nn.l : isLink;
21247
21236
 
21248
- mousePos[1] += this.scrollTop + ((helperHeight/2)-helperOffset[1]);
21249
- mousePos[0] += this.scrollLeft + ((helperWidth/2)-helperOffset[0]);
21250
- mousePos[1] /= scaleFactor;
21251
- mousePos[0] /= scaleFactor;
21237
+ var label = RED.utils.getNodeLabel(nn, nn.type);
21238
+ var labelParts = getLabelParts(label, "red-ui-flow-node-label");
21239
+ if (hideLabel) {
21240
+ nn.w = node_height;
21241
+ nn.h = Math.max(node_height,(nn.outputs || 0) * 15);
21242
+ } else {
21243
+ nn.w = Math.max(node_width,20*(Math.ceil((labelParts.width+50+(nn._def.inputs>0?7:0))/20)) );
21244
+ nn.h = Math.max(6+24*labelParts.lines.length,(nn.outputs || 0) * 15, 30);
21245
+ }
21246
+ } catch(err) {
21247
+ }
21252
21248
 
21253
- nn.x = mousePos[0];
21254
- nn.y = mousePos[1];
21249
+ mousePos[1] += this.scrollTop + ((helperHeight/2)-helperOffset[1]);
21250
+ mousePos[0] += this.scrollLeft + ((helperWidth/2)-helperOffset[0]);
21251
+ mousePos[1] /= scaleFactor;
21252
+ mousePos[0] /= scaleFactor;
21255
21253
 
21256
- var minX = nn.w/2 -5;
21257
- if (nn.x < minX) {
21258
- nn.x = minX;
21259
- }
21260
- var minY = nn.h/2 -5;
21261
- if (nn.y < minY) {
21262
- nn.y = minY;
21263
- }
21264
- var maxX = space_width -nn.w/2 +5;
21265
- if (nn.x > maxX) {
21266
- nn.x = maxX;
21267
- }
21268
- var maxY = space_height -nn.h +5;
21269
- if (nn.y > maxY) {
21270
- nn.y = maxY;
21271
- }
21254
+ nn.x = mousePos[0];
21255
+ nn.y = mousePos[1];
21272
21256
 
21273
- if (snapGrid) {
21274
- var gridOffset = RED.view.tools.calculateGridSnapOffsets(nn);
21275
- nn.x -= gridOffset.x;
21276
- nn.y -= gridOffset.y;
21277
- }
21257
+ var minX = nn.w/2 -5;
21258
+ if (nn.x < minX) {
21259
+ nn.x = minX;
21260
+ }
21261
+ var minY = nn.h/2 -5;
21262
+ if (nn.y < minY) {
21263
+ nn.y = minY;
21264
+ }
21265
+ var maxX = space_width -nn.w/2 +5;
21266
+ if (nn.x > maxX) {
21267
+ nn.x = maxX;
21268
+ }
21269
+ var maxY = space_height -nn.h +5;
21270
+ if (nn.y > maxY) {
21271
+ nn.y = maxY;
21272
+ }
21278
21273
 
21279
- var linkToSplice = $(ui.helper).data("splice");
21280
- if (linkToSplice) {
21281
- spliceLink(linkToSplice, nn, historyEvent)
21282
- }
21274
+ if (snapGrid) {
21275
+ var gridOffset = RED.view.tools.calculateGridSnapOffsets(nn);
21276
+ nn.x -= gridOffset.x;
21277
+ nn.y -= gridOffset.y;
21278
+ }
21283
21279
 
21284
- var group = $(ui.helper).data("group");
21285
- if (group) {
21286
- var oldX = group.x;
21287
- var oldY = group.y;
21288
- RED.group.addToGroup(group, nn);
21289
- var moveEvent = null;
21290
- if ((group.x !== oldX) ||
21291
- (group.y !== oldY)) {
21292
- moveEvent = {
21293
- t: "move",
21294
- nodes: [{n: group,
21295
- ox: oldX, oy: oldY,
21296
- dx: group.x -oldX,
21297
- dy: group.y -oldY}],
21298
- dirty: true
21299
- };
21280
+ var linkToSplice = $(ui.helper).data("splice");
21281
+ if (linkToSplice) {
21282
+ spliceLink(linkToSplice, nn, historyEvent)
21300
21283
  }
21301
- historyEvent = {
21302
- t: 'multi',
21303
- events: [historyEvent],
21304
21284
 
21305
- };
21306
- if (moveEvent) {
21307
- historyEvent.events.push(moveEvent)
21285
+ var group = $(ui.helper).data("group");
21286
+ if (group) {
21287
+ var oldX = group.x;
21288
+ var oldY = group.y;
21289
+ RED.group.addToGroup(group, nn);
21290
+ var moveEvent = null;
21291
+ if ((group.x !== oldX) ||
21292
+ (group.y !== oldY)) {
21293
+ moveEvent = {
21294
+ t: "move",
21295
+ nodes: [{n: group,
21296
+ ox: oldX, oy: oldY,
21297
+ dx: group.x -oldX,
21298
+ dy: group.y -oldY}],
21299
+ dirty: true
21300
+ };
21301
+ }
21302
+ historyEvent = {
21303
+ t: 'multi',
21304
+ events: [historyEvent],
21305
+
21306
+ };
21307
+ if (moveEvent) {
21308
+ historyEvent.events.push(moveEvent)
21309
+ }
21310
+ historyEvent.events.push({
21311
+ t: "addToGroup",
21312
+ group: group,
21313
+ nodes: nn
21314
+ })
21308
21315
  }
21309
- historyEvent.events.push({
21310
- t: "addToGroup",
21311
- group: group,
21312
- nodes: nn
21313
- })
21314
- }
21315
21316
 
21316
- RED.history.push(historyEvent);
21317
- RED.editor.validateNode(nn);
21318
- RED.nodes.dirty(true);
21319
- // auto select dropped node - so info shows (if visible)
21320
- clearSelection();
21321
- nn.selected = true;
21322
- movingSet.add(nn);
21323
- updateActiveNodes();
21324
- updateSelection();
21325
- redraw();
21317
+ RED.history.push(historyEvent);
21318
+ RED.editor.validateNode(nn);
21319
+ RED.nodes.dirty(true);
21320
+ // auto select dropped node - so info shows (if visible)
21321
+ clearSelection();
21322
+ nn.selected = true;
21323
+ movingSet.add(nn);
21324
+ updateActiveNodes();
21325
+ updateSelection();
21326
+ redraw();
21326
21327
 
21327
- if (nn._def.autoedit) {
21328
- RED.editor.edit(nn);
21328
+ if (nn._def.autoedit) {
21329
+ RED.editor.edit(nn);
21330
+ }
21331
+ } catch (error) {
21332
+ if (error.code != "NODE_RED") {
21333
+ RED.notify(RED._("notification.error",{message:error.toString()}),"error");
21334
+ } else {
21335
+ RED.notify(RED._("notification.error",{message:error.message}),"error");
21336
+ }
21329
21337
  }
21330
21338
  }
21331
21339
  });
@@ -26629,14 +26637,19 @@ RED.view = (function() {
26629
26637
  function createNode(type, x, y, z) {
26630
26638
  const wasDirty = RED.nodes.dirty()
26631
26639
  var m = /^subflow:(.+)$/.exec(type);
26632
- var activeSubflow = z ? RED.nodes.subflow(z) : null;
26640
+ var activeSubflow = (z || RED.workspaces.active()) ? RED.nodes.subflow(z || RED.workspaces.active()) : null;
26641
+
26633
26642
  if (activeSubflow && m) {
26634
26643
  var subflowId = m[1];
26644
+ let err
26635
26645
  if (subflowId === activeSubflow.id) {
26636
- throw new Error(RED._("notification.error", { message: RED._("notification.errors.cannotAddSubflowToItself") }))
26646
+ err = new Error(RED._("notification.errors.cannotAddSubflowToItself"))
26647
+ } else if (RED.nodes.subflowContains(m[1], activeSubflow.id)) {
26648
+ err = new Error(RED._("notification.errors.cannotAddCircularReference"))
26637
26649
  }
26638
- if (RED.nodes.subflowContains(m[1], activeSubflow.id)) {
26639
- throw new Error(RED._("notification.error", { message: RED._("notification.errors.cannotAddCircularReference") }))
26650
+ if (err) {
26651
+ err.code = 'NODE_RED'
26652
+ throw err
26640
26653
  }
26641
26654
  }
26642
26655
 
@@ -31214,8 +31227,10 @@ RED.sidebar.help = (function() {
31214
31227
 
31215
31228
  function refreshSubflow(sf) {
31216
31229
  var item = treeList.treeList('get',"node-type:subflow:"+sf.id);
31217
- item.subflowLabel = sf._def.label().toLowerCase();
31218
- item.treeList.replaceElement(getNodeLabel({_def:sf._def,type:sf._def.label()}));
31230
+ if (item) {
31231
+ item.subflowLabel = sf._def.label().toLowerCase();
31232
+ item.treeList.replaceElement(getNodeLabel({_def:sf._def,type:sf._def.label()}));
31233
+ }
31219
31234
  }
31220
31235
 
31221
31236
  function hideTOC() {