@node-red/editor-client 1.3.3 → 1.3.7

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
@@ -3399,6 +3399,10 @@ RED.nodes = (function() {
3399
3399
  }
3400
3400
  },
3401
3401
  addNodeSet: function(ns) {
3402
+ if (!ns.types) {
3403
+ // A node has been loaded without any types. Ignore it.
3404
+ return;
3405
+ }
3402
3406
  ns.added = false;
3403
3407
  nodeSets[ns.id] = ns;
3404
3408
  for (var j=0;j<ns.types.length;j++) {
@@ -3676,6 +3680,7 @@ RED.nodes = (function() {
3676
3680
  } else {
3677
3681
  var users = configNode.users;
3678
3682
  users.splice(users.indexOf(node),1);
3683
+ RED.events.emit('nodes:change',configNode)
3679
3684
  }
3680
3685
  }
3681
3686
  }
@@ -4737,6 +4742,8 @@ RED.nodes = (function() {
4737
4742
  nid = getID();
4738
4743
  workspace_map[n.id] = nid;
4739
4744
  n.id = nid;
4745
+ } else {
4746
+ workspace_map[n.id] = n.id;
4740
4747
  }
4741
4748
  addWorkspace(n);
4742
4749
  RED.workspaces.add(n);
@@ -4836,7 +4843,7 @@ RED.nodes = (function() {
4836
4843
  }
4837
4844
  }
4838
4845
  } else {
4839
- if (n.z && !workspaces[n.z] && !subflow_map[n.z]) {
4846
+ if (n.z && !workspace_map[n.z] && !subflow_map[n.z]) {
4840
4847
  n.z = activeWorkspace;
4841
4848
  }
4842
4849
  }
@@ -4934,7 +4941,7 @@ RED.nodes = (function() {
4934
4941
  node.id = getID();
4935
4942
  } else {
4936
4943
  node.id = n.id;
4937
- if (node.z == null || (!workspaces[node.z] && !subflow_map[node.z])) {
4944
+ if (node.z == null || (!workspace_map[node.z] && !subflow_map[node.z])) {
4938
4945
  if (createMissingWorkspace) {
4939
4946
  if (missingWorkspace === null) {
4940
4947
  missingWorkspace = RED.workspaces.add(null,true);
@@ -5339,6 +5346,7 @@ RED.nodes = (function() {
5339
5346
  if (configNode) {
5340
5347
  if (configNode.users.indexOf(n) === -1) {
5341
5348
  configNode.users.push(n);
5349
+ RED.events.emit('nodes:change',configNode)
5342
5350
  }
5343
5351
  }
5344
5352
  }
@@ -6496,12 +6504,14 @@ RED.history = (function() {
6496
6504
  var importedResult = RED.nodes.import(ev.config,{importMap: importMap})
6497
6505
  inverseEv = {
6498
6506
  t: 'replace',
6499
- config: importedResult.removedNodes
6507
+ config: importedResult.removedNodes,
6508
+ dirty: RED.nodes.dirty()
6500
6509
  }
6501
6510
  }
6502
6511
  } else if (ev.t == 'add') {
6503
6512
  inverseEv = {
6504
6513
  t: "delete",
6514
+ dirty: RED.nodes.dirty()
6505
6515
  };
6506
6516
  if (ev.nodes) {
6507
6517
  inverseEv.nodes = [];
@@ -6588,7 +6598,8 @@ RED.history = (function() {
6588
6598
 
6589
6599
  } else if (ev.t == "delete") {
6590
6600
  inverseEv = {
6591
- t: "add"
6601
+ t: "add",
6602
+ dirty: RED.nodes.dirty()
6592
6603
  };
6593
6604
  if (ev.workspaces) {
6594
6605
  inverseEv.workspaces = [];
@@ -6730,11 +6741,12 @@ RED.history = (function() {
6730
6741
  } else if (ev.t == "move") {
6731
6742
  inverseEv = {
6732
6743
  t: 'move',
6733
- nodes: []
6744
+ nodes: [],
6745
+ dirty: RED.nodes.dirty()
6734
6746
  };
6735
6747
  for (i=0;i<ev.nodes.length;i++) {
6736
6748
  var n = ev.nodes[i];
6737
- var rn = {n: n.n, ox: n.n.x, oy: n.n.y, dirty: true, moved: n.moved};
6749
+ var rn = {n: n.n, ox: n.n.x, oy: n.n.y, dirty: true, moved: n.n.moved};
6738
6750
  inverseEv.nodes.push(rn);
6739
6751
  n.n.x = n.ox;
6740
6752
  n.n.y = n.oy;
@@ -6766,7 +6778,9 @@ RED.history = (function() {
6766
6778
  } else if (ev.t == "edit") {
6767
6779
  inverseEv = {
6768
6780
  t: "edit",
6769
- changes: {}
6781
+ changes: {},
6782
+ changed: ev.node.changed,
6783
+ dirty: RED.nodes.dirty()
6770
6784
  };
6771
6785
  inverseEv.node = ev.node;
6772
6786
  for (i in ev.changes) {
@@ -6982,7 +6996,8 @@ RED.history = (function() {
6982
6996
  } else if (ev.t == "reorder") {
6983
6997
  inverseEv = {
6984
6998
  t: 'reorder',
6985
- order: RED.nodes.getWorkspaceOrder()
6999
+ order: RED.nodes.getWorkspaceOrder(),
7000
+ dirty: RED.nodes.dirty()
6986
7001
  };
6987
7002
  if (ev.order) {
6988
7003
  RED.workspaces.order(ev.order);
@@ -8001,6 +8016,7 @@ RED.utils = (function() {
8001
8016
  obj[key] = value;
8002
8017
  }
8003
8018
  }
8019
+
8004
8020
  function separateIconPath(icon) {
8005
8021
  var result = {module: "", file: ""};
8006
8022
  if (icon) {
@@ -8008,10 +8024,10 @@ RED.utils = (function() {
8008
8024
  if (index === 0) {
8009
8025
  icon = icon.substring((RED.settings.apiRootUrl+'icons/').length);
8010
8026
  }
8011
- index = icon.indexOf('/');
8012
- if (index !== -1) {
8013
- result.module = icon.slice(0, index);
8014
- result.file = icon.slice(index + 1);
8027
+ var match = /^((?:@[^/]+\/)?[^/]+)\/(.*)$/.exec(icon);
8028
+ if (match) {
8029
+ result.module = match[1];
8030
+ result.file = match[2];
8015
8031
  } else {
8016
8032
  result.file = icon;
8017
8033
  }
@@ -8020,6 +8036,7 @@ RED.utils = (function() {
8020
8036
  }
8021
8037
 
8022
8038
  function getDefaultNodeIcon(def,node) {
8039
+ def = def || {};
8023
8040
  var icon_url;
8024
8041
  if (node && node.type === "subflow") {
8025
8042
  icon_url = "node-red/subflow.svg";
@@ -8057,6 +8074,7 @@ RED.utils = (function() {
8057
8074
  }
8058
8075
 
8059
8076
  function getNodeIcon(def,node) {
8077
+ def = def || {};
8060
8078
  if (node && node.type === '_selection_') {
8061
8079
  return "font-awesome/fa-object-ungroup";
8062
8080
  } else if (node && node.type === 'group') {
@@ -8144,6 +8162,7 @@ RED.utils = (function() {
8144
8162
  }
8145
8163
 
8146
8164
  function getNodeColor(type, def) {
8165
+ def = def || {};
8147
8166
  var result = def.color;
8148
8167
  var paletteTheme = RED.settings.theme('palette.theme') || [];
8149
8168
  if (paletteTheme.length > 0) {
@@ -8270,9 +8289,9 @@ RED.utils = (function() {
8270
8289
  imageIconElement.css("backgroundImage", "url("+iconUrl+")");
8271
8290
  }
8272
8291
 
8273
- function createNodeIcon(node) {
8292
+ function createNodeIcon(node, includeLabel) {
8274
8293
  var def = node._def;
8275
- var nodeDiv = $('<div>',{class:"red-ui-search-result-node"})
8294
+ var nodeDiv = $('<div>',{class:"red-ui-node-icon"})
8276
8295
  if (node.type === "_selection_") {
8277
8296
  nodeDiv.addClass("red-ui-palette-icon-selection");
8278
8297
  } else if (node.type === "group") {
@@ -8292,8 +8311,20 @@ RED.utils = (function() {
8292
8311
  }
8293
8312
 
8294
8313
  var icon_url = RED.utils.getNodeIcon(def,node);
8295
- var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
8296
- RED.utils.createIconElement(icon_url, iconContainer, true);
8314
+ RED.utils.createIconElement(icon_url, nodeDiv, true);
8315
+
8316
+ if (includeLabel) {
8317
+ var container = $('<span>');
8318
+ nodeDiv.appendTo(container);
8319
+ var labelText = RED.utils.getNodeLabel(node,node.name || (node.type+": "+node.id));
8320
+ var label = $('<div>',{class:"red-ui-node-label"}).appendTo(container);
8321
+ if (labelText) {
8322
+ label.text(labelText)
8323
+ } else {
8324
+ label.html("&nbsp;")
8325
+ }
8326
+ return container;
8327
+ }
8297
8328
  return nodeDiv;
8298
8329
  }
8299
8330
 
@@ -9136,6 +9167,7 @@ RED.utils = (function() {
9136
9167
  }
9137
9168
  if (child.depth !== parent.depth+1) {
9138
9169
  child.depth = parent.depth+1;
9170
+ // var labelPaddingWidth = ((child.gutter ? child.gutter[0].offsetWidth + 2 : 0) + (child.depth * 20));
9139
9171
  var labelPaddingWidth = ((child.gutter?child.gutter.width()+2:0)+(child.depth*20));
9140
9172
  child.treeList.labelPadding.width(labelPaddingWidth+'px');
9141
9173
  if (child.element) {
@@ -9172,6 +9204,18 @@ RED.utils = (function() {
9172
9204
  that._selected.delete(item);
9173
9205
  delete item.treeList;
9174
9206
  delete that._items[item.id];
9207
+ if(item.depth === 0) {
9208
+ for(var key in that._items) {
9209
+ if (that._items.hasOwnProperty(key)) {
9210
+ var child = that._items[key];
9211
+ if(child.parent && child.parent.id === item.id) {
9212
+ delete that._items[key].treeList;
9213
+ delete that._items[key];
9214
+ }
9215
+ }
9216
+ }
9217
+ that._data = that._data.filter(function(data) { return data.id !== item.id})
9218
+ }
9175
9219
  }
9176
9220
  item.treeList.insertChildAt = function(newItem,position,select) {
9177
9221
  newItem.parent = item;
@@ -9304,7 +9348,10 @@ RED.utils = (function() {
9304
9348
  if (item.treeList.container) {
9305
9349
  $(item.element).remove();
9306
9350
  $(element).appendTo(item.treeList.label);
9307
- var labelPaddingWidth = (item.gutter?item.gutter.width()+2:0)+(item.depth*20);
9351
+ // using the JQuery Object, the gutter width will
9352
+ // be wrong when the element is reattached the second time
9353
+ var labelPaddingWidth = (item.gutter ? item.gutter[0].offsetWidth + 2 : 0) + (item.depth * 20);
9354
+
9308
9355
  $(element).css({
9309
9356
  width: "calc(100% - "+(labelPaddingWidth+20+(item.icon?20:0))+"px)"
9310
9357
  })
@@ -9341,6 +9388,7 @@ RED.utils = (function() {
9341
9388
 
9342
9389
  }
9343
9390
  var labelPaddingWidth = (item.gutter?item.gutter.width()+2:0)+(depth*20);
9391
+ // var labelPaddingWidth = (item.gutter ? item.gutter[0].offsetWidth + 2 : 0) + (depth * 20)
9344
9392
  item.treeList.labelPadding = $('<span>').css({
9345
9393
  display: "inline-block",
9346
9394
  width: labelPaddingWidth+'px'
@@ -10956,7 +11004,22 @@ RED.tabs = (function() {
10956
11004
  if (options.scrollable) {
10957
11005
  wrapper.addClass("red-ui-tabs-scrollable");
10958
11006
  scrollContainer.addClass("red-ui-tabs-scroll-container");
10959
- scrollContainer.on("scroll",updateScroll);
11007
+ scrollContainer.on("scroll",function(evt) {
11008
+ // Generated by trackpads - not mousewheel
11009
+ updateScroll(evt);
11010
+ });
11011
+ scrollContainer.on("wheel", function(evt) {
11012
+ if (evt.originalEvent.deltaX === 0) {
11013
+ // Prevent the scroll event from firing
11014
+ evt.preventDefault();
11015
+
11016
+ // Assume this is wheel event which might not trigger
11017
+ // the scroll event, so do things manually
11018
+ var sl = scrollContainer.scrollLeft();
11019
+ sl -= evt.originalEvent.deltaY;
11020
+ scrollContainer.scrollLeft(sl);
11021
+ }
11022
+ })
10960
11023
  scrollLeft = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-left"><a href="#" style="display:none;"><i class="fa fa-caret-left"></i></a></div>').appendTo(wrapper).find("a");
10961
11024
  scrollLeft.on('mousedown',function(evt) { scrollEventHandler(evt,'-=150') }).on('click',function(evt){ evt.preventDefault();});
10962
11025
  scrollRight = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-right"><a href="#" style="display:none;"><i class="fa fa-caret-right"></i></a></div>').appendTo(wrapper).find("a");
@@ -11626,6 +11689,9 @@ RED.tabs = (function() {
11626
11689
  count: function() {
11627
11690
  return ul.find("li.red-ui-tab").length;
11628
11691
  },
11692
+ activeIndex: function() {
11693
+ return ul.find("li.active").index()
11694
+ },
11629
11695
  contains: function(id) {
11630
11696
  return ul.find("a[href='#"+id+"']").length > 0;
11631
11697
  },
@@ -11882,7 +11948,7 @@ RED.stack = (function() {
11882
11948
  **/
11883
11949
  (function($) {
11884
11950
  var contextParse = function(v,defaultStore) {
11885
- var parts = RED.utils.parseContextKey(v, defaultStore);
11951
+ var parts = RED.utils.parseContextKey(v, defaultStore&&defaultStore.value);
11886
11952
  return {
11887
11953
  option: parts.store,
11888
11954
  value: parts.key
@@ -12146,6 +12212,14 @@ RED.stack = (function() {
12146
12212
  var contextStores = RED.settings.context.stores;
12147
12213
  var contextOptions = contextStores.map(function(store) {
12148
12214
  return {value:store,label: store, icon:'<i class="red-ui-typedInput-icon fa fa-database"></i>'}
12215
+ }).sort(function(A,B) {
12216
+ if (A.value === RED.settings.context.default) {
12217
+ return -1;
12218
+ } else if (B.value === RED.settings.context.default) {
12219
+ return 1;
12220
+ } else {
12221
+ return A.value.localeCompare(B.value);
12222
+ }
12149
12223
  })
12150
12224
  if (contextOptions.length < 2) {
12151
12225
  allOptions.flow.options = [];
@@ -12256,6 +12330,11 @@ RED.stack = (function() {
12256
12330
  evt.stopPropagation();
12257
12331
  }).on('focus', function() {
12258
12332
  that.uiSelect.addClass('red-ui-typedInput-focus');
12333
+ }).on('blur', function() {
12334
+ var opt = that.typeMap[that.propertyType];
12335
+ if (opt.hasValue === false) {
12336
+ that.uiSelect.removeClass('red-ui-typedInput-focus');
12337
+ }
12259
12338
  })
12260
12339
 
12261
12340
  // explicitly set optionSelectTrigger display to inline-block otherwise jQ sets it to 'inline'
@@ -12305,7 +12384,11 @@ RED.stack = (function() {
12305
12384
  });
12306
12385
 
12307
12386
  this._showMenu(this.optionMenu,this.optionSelectTrigger);
12308
- var selectedOption = this.optionMenu.find("[value='"+this.optionValue+"']");
12387
+ var targetValue = this.optionValue;
12388
+ if (this.optionValue === null || this.optionValue === undefined) {
12389
+ targetValue = this.value();
12390
+ }
12391
+ var selectedOption = this.optionMenu.find("[value='"+targetValue+"']");
12309
12392
  if (selectedOption.length === 0) {
12310
12393
  selectedOption = this.optionMenu.children(":first");
12311
12394
  }
@@ -17197,7 +17280,11 @@ RED.workspaces = (function() {
17197
17280
  if (!workspace_tabs.contains(id)) {
17198
17281
  var sf = RED.nodes.subflow(id);
17199
17282
  if (sf) {
17200
- addWorkspace({type:"subflow",id:id,icon:"red/images/subflow_tab.svg",label:sf.name, closeable: true});
17283
+ addWorkspace(
17284
+ {type:"subflow",id:id,icon:"red/images/subflow_tab.svg",label:sf.name, closeable: true},
17285
+ null,
17286
+ workspace_tabs.activeIndex()+1
17287
+ );
17201
17288
  } else {
17202
17289
  return;
17203
17290
  }
@@ -18754,15 +18841,15 @@ RED.view = (function() {
18754
18841
  var mouseY = node.n.y;
18755
18842
  if (outer[0][0].getIntersectionList) {
18756
18843
  var svgRect = outer[0][0].createSVGRect();
18757
- svgRect.x = mouseX;
18758
- svgRect.y = mouseY;
18844
+ svgRect.x = mouseX*scaleFactor;
18845
+ svgRect.y = mouseY*scaleFactor;
18759
18846
  svgRect.width = 1;
18760
18847
  svgRect.height = 1;
18761
18848
  nodes = outer[0][0].getIntersectionList(svgRect, outer[0][0]);
18762
18849
  } else {
18763
18850
  // Firefox doesn"t do getIntersectionList and that
18764
18851
  // makes us sad
18765
- nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
18852
+ nodes = RED.view.getLinksAtPoint(mouseX*scaleFactor,mouseY*scaleFactor);
18766
18853
  }
18767
18854
  for (var i=0;i<nodes.length;i++) {
18768
18855
  if (d3.select(nodes[i]).classed("red-ui-flow-link-background")) {
@@ -19029,7 +19116,6 @@ RED.view = (function() {
19029
19116
  }
19030
19117
  }
19031
19118
  if (mouse_mode == RED.state.IMPORT_DRAGGING) {
19032
- RED.keyboard.remove("escape");
19033
19119
  updateActiveNodes();
19034
19120
  RED.nodes.dirty(true);
19035
19121
  }
@@ -19064,6 +19150,9 @@ RED.view = (function() {
19064
19150
  }
19065
19151
 
19066
19152
  function selectNone() {
19153
+ if (mouse_mode === RED.state.MOVING || mouse_mode === RED.state.MOVING_ACTIVE) {
19154
+ return;
19155
+ }
19067
19156
  if (mouse_mode === RED.state.IMPORT_DRAGGING) {
19068
19157
  clearSelection();
19069
19158
  RED.history.pop();
@@ -19611,6 +19700,7 @@ RED.view = (function() {
19611
19700
  var textDimensionPlaceholder = {};
19612
19701
  var textDimensionCache = {};
19613
19702
  function calculateTextDimensions(str,className) {
19703
+ var cacheKey = "!"+str;
19614
19704
  if (!textDimensionPlaceholder[className]) {
19615
19705
  textDimensionPlaceholder[className] = document.createElement("span");
19616
19706
  textDimensionPlaceholder[className].className = className;
@@ -19619,15 +19709,15 @@ RED.view = (function() {
19619
19709
  document.getElementById("red-ui-editor").appendChild(textDimensionPlaceholder[className]);
19620
19710
  textDimensionCache[className] = {};
19621
19711
  } else {
19622
- if (textDimensionCache[className][str]) {
19623
- return textDimensionCache[className][str]
19712
+ if (textDimensionCache[className][cacheKey]) {
19713
+ return textDimensionCache[className][cacheKey]
19624
19714
  }
19625
19715
  }
19626
19716
  textDimensionPlaceholder[className].textContent = (str||"");
19627
19717
  var w = textDimensionPlaceholder[className].offsetWidth;
19628
19718
  var h = textDimensionPlaceholder[className].offsetHeight;
19629
- textDimensionCache[className][str] = [w,h];
19630
- return textDimensionCache[className][str];
19719
+ textDimensionCache[className][cacheKey] = [w,h];
19720
+ return textDimensionCache[className][cacheKey];
19631
19721
  }
19632
19722
 
19633
19723
  function convertLineBreakCharacter(str) {
@@ -20721,6 +20811,7 @@ RED.view = (function() {
20721
20811
  }
20722
20812
  }
20723
20813
  function getGroupAt(x,y) {
20814
+ // x,y expected to be in node-co-ordinate space
20724
20815
  var candidateGroups = {};
20725
20816
  for (var i=0;i<activeGroups.length;i++) {
20726
20817
  var g = activeGroups[i];
@@ -22357,6 +22448,9 @@ RED.view = (function() {
22357
22448
  return scaleFactor;
22358
22449
  },
22359
22450
  getLinksAtPoint: function(x,y) {
22451
+ // x,y must be in SVG co-ordinate space
22452
+ // if they come from a node.x/y, they will need to be scaled using
22453
+ // scaleFactor first.
22360
22454
  var result = [];
22361
22455
  var links = outer.selectAll(".red-ui-flow-link-background")[0];
22362
22456
  for (var i=0;i<links.length;i++) {
@@ -23373,7 +23467,7 @@ RED.sidebar = (function() {
23373
23467
  id = RED.settings.get("editor.sidebar.order",["info", "help", "version-control", "debug"])[0]
23374
23468
  }
23375
23469
  if (id) {
23376
- if (!containsTab(id)) {
23470
+ if (!containsTab(id) && knownTabs[id]) {
23377
23471
  sidebar_tabs.addTab(knownTabs[id]);
23378
23472
  }
23379
23473
  sidebar_tabs.activateTab(id);
@@ -23770,12 +23864,12 @@ RED.palette = (function() {
23770
23864
  var paletteNode = getPaletteNode(nt);
23771
23865
  ui.originalPosition.left = paletteNode.offset().left;
23772
23866
  mouseX = ui.position.left - paletteWidth + (ui.helper.width()/2) + chart.scrollLeft();
23773
- mouseY = ui.position.top - paletteTop + (ui.helper.height()/2) + chart.scrollTop();
23867
+ mouseY = ui.position.top - paletteTop + (ui.helper.height()/2) + chart.scrollTop() + 10;
23774
23868
  if (!groupTimer) {
23775
23869
  groupTimer = setTimeout(function() {
23776
- mouseX /= RED.view.scale();
23777
- mouseY /= RED.view.scale();
23778
- var group = RED.view.getGroupAtPoint(mouseX,mouseY);
23870
+ var mx = mouseX / RED.view.scale();
23871
+ var my = mouseY / RED.view.scale();
23872
+ var group = RED.view.getGroupAtPoint(mx,my);
23779
23873
  if (group !== hoverGroup) {
23780
23874
  if (hoverGroup) {
23781
23875
  document.getElementById("group_select_"+hoverGroup.id).classList.remove("red-ui-flow-group-hovered");
@@ -23807,23 +23901,20 @@ RED.palette = (function() {
23807
23901
  svgRect.width = 1;
23808
23902
  svgRect.height = 1;
23809
23903
  nodes = chartSVG.getIntersectionList(svgRect,chartSVG);
23810
- mouseX /= RED.view.scale();
23811
- mouseY /= RED.view.scale();
23812
23904
  } else {
23813
23905
  // Firefox doesn't do getIntersectionList and that
23814
23906
  // makes us sad
23815
- mouseX /= RED.view.scale();
23816
- mouseY /= RED.view.scale();
23817
23907
  nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
23818
23908
  }
23819
-
23909
+ var mx = mouseX / RED.view.scale();
23910
+ var my = mouseY / RED.view.scale();
23820
23911
  for (var i=0;i<nodes.length;i++) {
23821
23912
  var node = d3.select(nodes[i]);
23822
23913
  if (node.classed('red-ui-flow-link-background') && !node.classed('red-ui-flow-link-link')) {
23823
23914
  var length = nodes[i].getTotalLength();
23824
23915
  for (var j=0;j<length;j+=10) {
23825
23916
  var p = nodes[i].getPointAtLength(j);
23826
- var d2 = ((p.x-mouseX)*(p.x-mouseX))+((p.y-mouseY)*(p.y-mouseY));
23917
+ var d2 = ((p.x-mx)*(p.x-mx))+((p.y-my)*(p.y-my));
23827
23918
  if (d2 < 200 && d2 < bestDistance) {
23828
23919
  bestDistance = d2;
23829
23920
  bestLink = nodes[i];
@@ -24628,7 +24719,7 @@ RED.sidebar.info = (function() {
24628
24719
  return;
24629
24720
  }
24630
24721
  }
24631
- while ((m=/(\[(.*?)\])/.exec(tip))) {
24722
+ while ((m=/(\[([a-z]*?)\])/.exec(tip))) {
24632
24723
  tip = tip.replace(m[1],RED.keyboard.formatKey(m[2]));
24633
24724
  }
24634
24725
  tipBox.html(tip).fadeIn(200);
@@ -24808,36 +24899,11 @@ RED.sidebar.info = (function() {
24808
24899
  return item;
24809
24900
  }
24810
24901
 
24811
- function getNodeLabelText(n) {
24812
- var label = n.name || n.type+": "+n.id;
24813
- if (n._def.label) {
24814
- try {
24815
- label = (typeof n._def.label === "function" ? n._def.label.call(n) : n._def.label)||"";
24816
- } catch(err) {
24817
- console.log("Definition error: "+n.type+".label",err);
24818
- }
24819
- }
24820
- var newlineIndex = label.indexOf("\\n");
24821
- if (newlineIndex > -1) {
24822
- label = label.substring(0,newlineIndex)+"...";
24823
- }
24824
- return label;
24825
- }
24826
-
24827
24902
  function getNodeLabel(n) {
24828
- var div = $('<div>',{class:"red-ui-info-outline-item"});
24829
- RED.utils.createNodeIcon(n).appendTo(div);
24830
- var contentDiv = $('<div>',{class:"red-ui-search-result-description"}).appendTo(div);
24831
- var labelText = getNodeLabelText(n);
24832
- var label = $('<div>',{class:"red-ui-search-result-node-label red-ui-info-outline-item-label"}).appendTo(contentDiv);
24833
- if (labelText) {
24834
- label.text(labelText)
24835
- } else {
24836
- label.html("&nbsp;")
24837
- }
24838
-
24903
+ var div = $('<div>',{class:"red-ui-node-list-item red-ui-info-outline-item"});
24904
+ RED.utils.createNodeIcon(n, true).appendTo(div);
24905
+ div.find(".red-ui-node-label").addClass("red-ui-info-outline-item-label")
24839
24906
  addControls(n, div);
24840
-
24841
24907
  return div;
24842
24908
  }
24843
24909
 
@@ -25165,7 +25231,7 @@ RED.sidebar.info = (function() {
25165
25231
  var existingObject = objects[n.id];
25166
25232
  var parent = n.g||n.z||"__global__";
25167
25233
 
25168
- var nodeLabelText = getNodeLabelText(n);
25234
+ var nodeLabelText = RED.utils.getNodeLabel(n,n.name || (n.type+": "+n.id));
25169
25235
  if (nodeLabelText) {
25170
25236
  existingObject.element.find(".red-ui-info-outline-item-label").text(nodeLabelText);
25171
25237
  } else {
@@ -25634,10 +25700,9 @@ RED.sidebar.help = (function() {
25634
25700
  }
25635
25701
 
25636
25702
  function getNodeLabel(n) {
25637
- var div = $('<div>',{class:"red-ui-info-outline-item"});
25703
+ var div = $('<div>',{class:"red-ui-node-list-item"});
25638
25704
  RED.utils.createNodeIcon(n).appendTo(div);
25639
- var contentDiv = $('<div>',{class:"red-ui-search-result-description"}).appendTo(div);
25640
- $('<div>',{class:"red-ui-search-result-node-label red-ui-info-outline-item-label"}).text(n.name||n.type).appendTo(contentDiv);
25705
+ $('<div>',{class:"red-ui-node-label"}).text(n.name||n.type).appendTo(div);
25641
25706
  return div;
25642
25707
  }
25643
25708
 
@@ -33074,7 +33139,7 @@ RED.clipboard = (function() {
33074
33139
 
33075
33140
  var libraries = RED.settings.libraries || [];
33076
33141
  libraries.forEach(function(lib) {
33077
- var tabId = "red-ui-clipboard-dialog-import-tab-library-"+lib.id
33142
+ var tabId = "red-ui-clipboard-dialog-import-tab-"+lib.id
33078
33143
  tabs.addTab({
33079
33144
  id: tabId,
33080
33145
  label: RED._(lib.label||lib.id)
@@ -33808,22 +33873,6 @@ RED.clipboard = (function() {
33808
33873
  }
33809
33874
  }
33810
33875
 
33811
- function getNodeLabelText(n) {
33812
- var label = n.name || n.type+": "+n.id;
33813
- if (n._def.label) {
33814
- try {
33815
- label = (typeof n._def.label === "function" ? n._def.label.call(n) : n._def.label)||"";
33816
- } catch(err) {
33817
- console.log("Definition error: "+n.type+".label",err);
33818
- }
33819
- }
33820
- var newlineIndex = label.indexOf("\\n");
33821
- if (newlineIndex > -1) {
33822
- label = label.substring(0,newlineIndex)+"...";
33823
- }
33824
- return label;
33825
- }
33826
-
33827
33876
  function getFlowLabel(n) {
33828
33877
  n = JSON.parse(JSON.stringify(n));
33829
33878
  n._def = RED.nodes.getType(n.type) || {};
@@ -33849,16 +33898,8 @@ RED.clipboard = (function() {
33849
33898
  if (n._def) {
33850
33899
  n._ = n._def._;
33851
33900
  }
33852
- var div = $('<div>',{class:"red-ui-info-outline-item"});
33853
- RED.utils.createNodeIcon(n).appendTo(div);
33854
- var contentDiv = $('<div>',{class:"red-ui-search-result-description"}).appendTo(div);
33855
- var labelText = getNodeLabelText(n);
33856
- var label = $('<div>',{class:"red-ui-search-result-node-label red-ui-info-outline-item-label"}).appendTo(contentDiv);
33857
- if (labelText) {
33858
- label.text(labelText)
33859
- } else {
33860
- label.html(n.type)
33861
- }
33901
+ var div = $('<div>',{class:"red-ui-node-list-item"});
33902
+ RED.utils.createNodeIcon(n,true).appendTo(div);
33862
33903
  return div;
33863
33904
  }
33864
33905
 
@@ -33906,22 +33947,27 @@ RED.clipboard = (function() {
33906
33947
  hideDropTarget();
33907
33948
  })
33908
33949
  .on("drop",function(event) {
33909
- if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
33910
- var data = event.originalEvent.dataTransfer.getData("text/plain");
33911
- data = data.substring(data.indexOf('['),data.lastIndexOf(']')+1);
33912
- importNodes(data);
33913
- } else if ($.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
33914
- var files = event.originalEvent.dataTransfer.files;
33915
- if (files.length === 1) {
33916
- var file = files[0];
33917
- var reader = new FileReader();
33918
- reader.onload = (function(theFile) {
33919
- return function(e) {
33920
- importNodes(e.target.result);
33921
- };
33922
- })(file);
33923
- reader.readAsText(file);
33950
+ try {
33951
+ if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
33952
+ var data = event.originalEvent.dataTransfer.getData("text/plain");
33953
+ data = data.substring(data.indexOf('['),data.lastIndexOf(']')+1);
33954
+ importNodes(data);
33955
+ } else if ($.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
33956
+ var files = event.originalEvent.dataTransfer.files;
33957
+ if (files.length === 1) {
33958
+ var file = files[0];
33959
+ var reader = new FileReader();
33960
+ reader.onload = (function(theFile) {
33961
+ return function(e) {
33962
+ importNodes(e.target.result);
33963
+ };
33964
+ })(file);
33965
+ reader.readAsText(file);
33966
+ }
33924
33967
  }
33968
+ } catch(err) {
33969
+ // Ensure any errors throw above doesn't stop the drop target from
33970
+ // being hidden.
33925
33971
  }
33926
33972
  hideDropTarget();
33927
33973
  event.preventDefault();