@elyra/canvas 12.43.0 → 12.45.0

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.
Files changed (144) hide show
  1. package/dist/{canvas-constants-acb99f64.js → canvas-constants-3bbfc8b1.js} +2 -2
  2. package/dist/{canvas-constants-acb99f64.js.map → canvas-constants-3bbfc8b1.js.map} +1 -1
  3. package/dist/{canvas-constants-ff5cf88e.js → canvas-constants-8d240dc6.js} +2 -2
  4. package/dist/{canvas-constants-ff5cf88e.js.map → canvas-constants-8d240dc6.js.map} +1 -1
  5. package/dist/canvas-controller-a926ab2b.js +2 -0
  6. package/dist/canvas-controller-a926ab2b.js.map +1 -0
  7. package/dist/canvas-controller-e2503333.js +2 -0
  8. package/dist/canvas-controller-e2503333.js.map +1 -0
  9. package/dist/{canvas-logger-295dafe4.js → canvas-logger-6f4b2551.js} +2 -2
  10. package/dist/{canvas-logger-295dafe4.js.map → canvas-logger-6f4b2551.js.map} +1 -1
  11. package/dist/{canvas-logger-e07a0b4a.js → canvas-logger-ab9d9048.js} +2 -2
  12. package/dist/{canvas-logger-e07a0b4a.js.map → canvas-logger-ab9d9048.js.map} +1 -1
  13. package/dist/common-canvas-41b0454f.js +2 -0
  14. package/dist/common-canvas-41b0454f.js.map +1 -0
  15. package/dist/common-canvas-460a4434.js +2 -0
  16. package/dist/common-canvas-460a4434.js.map +1 -0
  17. package/dist/common-canvas.es.js +1 -1
  18. package/dist/common-canvas.js +1 -1
  19. package/dist/common-properties-b25b4855.js +2 -0
  20. package/dist/{common-properties-08707efe.js.map → common-properties-b25b4855.js.map} +1 -1
  21. package/dist/common-properties-e262caa2.js +2 -0
  22. package/dist/{common-properties-acd55e94.js.map → common-properties-e262caa2.js.map} +1 -1
  23. package/dist/context-menu-wrapper-949393c7.js +2 -0
  24. package/dist/{context-menu-wrapper-e4a7ab4d.js.map → context-menu-wrapper-949393c7.js.map} +1 -1
  25. package/dist/context-menu-wrapper-f62dfcdb.js +2 -0
  26. package/dist/{context-menu-wrapper-271eb2df.js.map → context-menu-wrapper-f62dfcdb.js.map} +1 -1
  27. package/dist/{createClass-440000a3.js → createClass-02596015.js} +2 -2
  28. package/dist/createClass-02596015.js.map +1 -0
  29. package/dist/createClass-155bf7da.js +2 -0
  30. package/dist/createClass-155bf7da.js.map +1 -0
  31. package/dist/datarecord-metadata-v3-schema-2311ecab.js +2 -0
  32. package/dist/{datarecord-metadata-v3-schema-03427296.js.map → datarecord-metadata-v3-schema-2311ecab.js.map} +1 -1
  33. package/dist/datarecord-metadata-v3-schema-d279dbb0.js +2 -0
  34. package/dist/{datarecord-metadata-v3-schema-dba0b214.js.map → datarecord-metadata-v3-schema-d279dbb0.js.map} +1 -1
  35. package/dist/defineProperty-ad55dbff.js +2 -0
  36. package/dist/{defineProperty-3dc7d8d0.js.map → defineProperty-ad55dbff.js.map} +1 -1
  37. package/dist/{defineProperty-6d406743.js → defineProperty-bcc9968d.js} +2 -2
  38. package/dist/{defineProperty-6d406743.js.map → defineProperty-bcc9968d.js.map} +1 -1
  39. package/dist/flexible-table-c6a8b402.js +2 -0
  40. package/dist/{flexible-table-107ca2fd.js.map → flexible-table-c6a8b402.js.map} +1 -1
  41. package/dist/flexible-table-f7b294a0.js +2 -0
  42. package/dist/{flexible-table-5cc1ad6b.js.map → flexible-table-f7b294a0.js.map} +1 -1
  43. package/dist/{icon-2caf035c.js → icon-65758bb8.js} +2 -2
  44. package/dist/{icon-2caf035c.js.map → icon-65758bb8.js.map} +1 -1
  45. package/dist/{icon-e622f99b.js → icon-b3738f1f.js} +2 -2
  46. package/dist/{icon-e622f99b.js.map → icon-b3738f1f.js.map} +1 -1
  47. package/dist/index-9eeda306.js +2 -0
  48. package/dist/{index-5dac3da8.js.map → index-9eeda306.js.map} +1 -1
  49. package/dist/index-d3371fd0.js +2 -0
  50. package/dist/{index-fee06179.js.map → index-d3371fd0.js.map} +1 -1
  51. package/dist/inherits-42ae8426.js +2 -0
  52. package/dist/inherits-42ae8426.js.map +1 -0
  53. package/dist/inherits-75817f22.js +2 -0
  54. package/dist/inherits-75817f22.js.map +1 -0
  55. package/dist/isArrayLikeObject-04f333a5.js +1 -1
  56. package/dist/isArrayLikeObject-04f333a5.js.map +1 -1
  57. package/dist/isArrayLikeObject-7a30aa4b.js +1 -1
  58. package/dist/isArrayLikeObject-7a30aa4b.js.map +1 -1
  59. package/dist/lib/canvas-controller.es.js +1 -1
  60. package/dist/lib/canvas-controller.js +1 -1
  61. package/dist/lib/canvas.es.js +1 -1
  62. package/dist/lib/canvas.js +1 -1
  63. package/dist/lib/command-stack.es.js +1 -1
  64. package/dist/lib/command-stack.es.js.map +1 -1
  65. package/dist/lib/command-stack.js +1 -1
  66. package/dist/lib/command-stack.js.map +1 -1
  67. package/dist/lib/context-menu.es.js +1 -1
  68. package/dist/lib/context-menu.js +1 -1
  69. package/dist/lib/properties/field-picker.es.js +1 -1
  70. package/dist/lib/properties/field-picker.js +1 -1
  71. package/dist/lib/properties/flexible-table.es.js +1 -1
  72. package/dist/lib/properties/flexible-table.js +1 -1
  73. package/dist/lib/properties.es.js +1 -1
  74. package/dist/lib/properties.js +1 -1
  75. package/dist/lib/tooltip.es.js +1 -1
  76. package/dist/lib/tooltip.es.js.map +1 -1
  77. package/dist/lib/tooltip.js +1 -1
  78. package/dist/lib/tooltip.js.map +1 -1
  79. package/dist/styles/common-canvas.min.css +1 -1
  80. package/dist/styles/common-canvas.min.css.map +1 -1
  81. package/dist/toolbar-6af353fa.js +2 -0
  82. package/dist/toolbar-6af353fa.js.map +1 -0
  83. package/dist/toolbar-c4e22755.js +2 -0
  84. package/dist/toolbar-c4e22755.js.map +1 -0
  85. package/locales/command-actions/locales/en.json +1 -0
  86. package/locales/command-actions/locales/eo.json +1 -0
  87. package/package.json +2 -2
  88. package/src/command-actions/sizeAndPositionObjectsAction.js +4 -0
  89. package/src/command-stack/command-stack.js +4 -0
  90. package/src/common-canvas/canvas-controller.js +47 -10
  91. package/src/common-canvas/cc-context-toolbar.jsx +46 -2
  92. package/src/common-canvas/cc-toolbar.jsx +12 -4
  93. package/src/common-canvas/common-canvas-utils.js +73 -2
  94. package/src/common-canvas/common-canvas.scss +5 -5
  95. package/src/common-canvas/constants/canvas-constants.js +1 -0
  96. package/src/common-canvas/svg-canvas-d3.js +2 -2
  97. package/src/common-canvas/svg-canvas-pipeline.js +1 -1
  98. package/src/common-canvas/svg-canvas-renderer.js +142 -75
  99. package/src/common-canvas/svg-canvas-utils-drag-objects.js +3 -0
  100. package/src/common-canvas/svg-canvas-utils-external.js +1 -1
  101. package/src/common-canvas/svg-canvas-utils-links.js +28 -32
  102. package/src/common-canvas/svg-canvas-utils-nodes.js +5 -13
  103. package/src/common-canvas/svg-canvas-utils-zoom.js +5 -4
  104. package/src/icons/icon.scss +1 -1
  105. package/src/object-model/config-utils.js +2 -2
  106. package/src/object-model/layout-dimensions.js +82 -87
  107. package/src/object-model/object-model-utils.js +271 -0
  108. package/src/object-model/object-model.js +28 -240
  109. package/src/toolbar/toolbar-action-item.jsx +2 -1
  110. package/src/toolbar/toolbar-button-item.jsx +3 -2
  111. package/src/toolbar/toolbar-overflow-item.jsx +10 -4
  112. package/src/toolbar/toolbar.jsx +5 -2
  113. package/src/toolbar/toolbar.scss +28 -31
  114. package/stats.html +1 -1
  115. package/dist/canvas-controller-6726b9ac.js +0 -2
  116. package/dist/canvas-controller-6726b9ac.js.map +0 -1
  117. package/dist/canvas-controller-6c6bc68f.js +0 -2
  118. package/dist/canvas-controller-6c6bc68f.js.map +0 -1
  119. package/dist/common-canvas-9374ef35.js +0 -2
  120. package/dist/common-canvas-9374ef35.js.map +0 -1
  121. package/dist/common-canvas-a6435bdb.js +0 -2
  122. package/dist/common-canvas-a6435bdb.js.map +0 -1
  123. package/dist/common-properties-08707efe.js +0 -2
  124. package/dist/common-properties-acd55e94.js +0 -2
  125. package/dist/context-menu-wrapper-271eb2df.js +0 -2
  126. package/dist/context-menu-wrapper-e4a7ab4d.js +0 -2
  127. package/dist/createClass-440000a3.js.map +0 -1
  128. package/dist/createClass-5ca26865.js +0 -2
  129. package/dist/createClass-5ca26865.js.map +0 -1
  130. package/dist/datarecord-metadata-v3-schema-03427296.js +0 -2
  131. package/dist/datarecord-metadata-v3-schema-dba0b214.js +0 -2
  132. package/dist/defineProperty-3dc7d8d0.js +0 -2
  133. package/dist/flexible-table-107ca2fd.js +0 -2
  134. package/dist/flexible-table-5cc1ad6b.js +0 -2
  135. package/dist/index-5dac3da8.js +0 -2
  136. package/dist/index-fee06179.js +0 -2
  137. package/dist/inherits-226dfdb2.js +0 -2
  138. package/dist/inherits-226dfdb2.js.map +0 -1
  139. package/dist/inherits-41673c87.js +0 -2
  140. package/dist/inherits-41673c87.js.map +0 -1
  141. package/dist/toolbar-ccc1d600.js +0 -2
  142. package/dist/toolbar-ccc1d600.js.map +0 -1
  143. package/dist/toolbar-e4445bf8.js +0 -2
  144. package/dist/toolbar-e4445bf8.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -245,34 +245,29 @@ export default class SvgCanvasLinks {
245
245
  }
246
246
 
247
247
  getNodeLinkCoordsForPorts(srcNode, srcPortId, trgNode, trgPortId) {
248
- let srcX = srcNode.width + srcNode.layout.outputPortRightPosX;
249
- let srcY = srcNode.layout.outputPortRightPosY;
250
- let trgX = trgNode.layout.inputPortLeftPosX;
251
- let trgY = trgNode.layout.inputPortLeftPosY;
252
-
253
- if (this.canvasLayout.linkDirection === LINK_DIR_TOP_BOTTOM) {
254
- srcX = srcNode.layout.outputPortBottomPosX;
255
- srcY = srcNode.height + srcNode.layout.outputPortBottomPosY;
256
- trgX = trgNode.layout.inputPortTopPosX;
257
- trgY = trgNode.layout.inputPortTopPosY;
258
-
259
- } else if (this.canvasLayout.linkDirection === LINK_DIR_BOTTOM_TOP) {
260
- srcX = srcNode.layout.outputPortBottomPosX;
261
- srcY = srcNode.layout.outputPortBottomPosY;
262
- trgX = trgNode.layout.inputPortTopPosX;
263
- trgY = trgNode.height + trgNode.layout.inputPortTopPosY;
264
- }
248
+ let srcX;
249
+ let srcY;
250
+ let trgX;
251
+ let trgY;
265
252
 
266
253
  if (srcNode.outputs && srcNode.outputs.length > 0) {
267
254
  const port = srcNode.outputs.find((srcPort) => srcPort.id === srcPortId);
268
255
  srcX = port ? port.cx : srcX;
269
256
  srcY = port ? port.cy : srcY;
257
+
258
+ } else {
259
+ srcX = this.nodeUtils.getNodePortPosX(srcNode.layout.outputPortPositions[0], srcNode);
260
+ srcY = this.nodeUtils.getNodePortPosY(srcNode.layout.outputPortPositions[0], srcNode);
270
261
  }
271
262
 
272
263
  if (trgNode.inputs && trgNode.inputs.length > 0) {
273
264
  const port = trgNode.inputs.find((trgPort) => trgPort.id === trgPortId);
274
265
  trgX = port ? port.cx : trgX;
275
266
  trgY = port ? port.cy : trgY;
267
+
268
+ } else {
269
+ trgX = this.nodeUtils.getNodePortPosX(trgNode.layout.inputPortPositions[0], trgNode);
270
+ trgY = this.nodeUtils.getNodePortPosY(trgNode.layout.inputPortPositions[0], trgNode);
276
271
  }
277
272
 
278
273
  return {
@@ -284,31 +279,32 @@ export default class SvgCanvasLinks {
284
279
  }
285
280
 
286
281
  getAssociationCurveLinkCoords(srcNode, trgNode, assocLinkVariation) {
287
- let x1 = 0;
288
- let x2 = 0;
282
+ let srcX = 0;
283
+ let trgX = 0;
289
284
 
290
285
  if (assocLinkVariation === ASSOC_VAR_CURVE_RIGHT) {
291
- x1 = srcNode.x_pos + srcNode.width;
292
- x2 = trgNode.x_pos;
286
+ srcX = srcNode.width;
287
+ trgX = 0;
293
288
 
294
289
  } else if (assocLinkVariation === ASSOC_VAR_CURVE_LEFT) {
295
- x1 = srcNode.x_pos;
296
- x2 = trgNode.x_pos + trgNode.width;
290
+ srcX = 0;
291
+ trgX = trgNode.width;
297
292
 
298
293
  } else if (assocLinkVariation === ASSOC_VAR_DOUBLE_BACK_LEFT) {
299
- x1 = srcNode.x_pos;
300
- x2 = trgNode.x_pos;
294
+ srcX = 0;
295
+ trgX = 0;
301
296
 
302
297
  } else {
303
- x1 = srcNode.x_pos + srcNode.width;
304
- x2 = trgNode.x_pos + trgNode.width;
298
+ srcX = srcNode.width;
299
+ trgX = trgNode.width;
305
300
  }
306
301
 
307
302
  return {
308
- x1: x1,
309
- y1: srcNode.y_pos + srcNode.layout.outputPortRightPosY,
310
- x2: x2,
311
- y2: trgNode.y_pos + trgNode.layout.inputPortLeftPosY };
303
+ x1: srcNode.x_pos + srcX,
304
+ y1: srcNode.y_pos + this.nodeUtils.getNodePortPosY(srcNode.layout.outputPortPositions[0], srcNode),
305
+ x2: trgNode.x_pos + trgX,
306
+ y2: trgNode.y_pos + this.nodeUtils.getNodePortPosY(trgNode.layout.inputPortPositions[0], trgNode)
307
+ };
312
308
  }
313
309
 
314
310
  getCommentLinkCoords(srcComment, trgNode) {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -339,20 +339,12 @@ export default class SvgCanvasNodes {
339
339
  return node.layout.errorHeight;
340
340
  }
341
341
 
342
- getNodeInputPortLeftPosX(node) {
343
- return this.getElementPosX(node.width, node.layout.inputPortLeftPosX, node.layout.inputPortLeftPosition);
342
+ getNodePortPosX(posInfo, node) {
343
+ return this.getElementPosX(node.width, posInfo.x_pos, posInfo.pos);
344
344
  }
345
345
 
346
- getNodeInputPortLeftPosY(node) {
347
- return this.getElementPosY(node.height, node.layout.inputPortLeftPosY, node.layout.inputPortLeftPosition);
348
- }
349
-
350
- getNodeOutputPortRightPosX(node) {
351
- return this.getElementPosX(node.width, node.layout.outputPortRightPosX, node.layout.outputPortRightPosition);
352
- }
353
-
354
- getNodeOutputPortRightPosY(node) {
355
- return this.getElementPosY(node.height, node.layout.outputPortRightPosY, node.layout.outputPortRightPosition);
346
+ getNodePortPosY(posInfo, node) {
347
+ return this.getElementPosY(node.height, posInfo.y_pos, posInfo.pos);
356
348
  }
357
349
 
358
350
  getElementPosX(width, xOffset = 0, position = "topLeft") {
@@ -132,10 +132,11 @@ export default class SVGCanvasUtilsZoom {
132
132
  this.zoomTransform = d3.zoomIdentity.translate(0, 0).scale(1);
133
133
  }
134
134
 
135
- // Zooms the canvas to the extent specified in the zoom object.
136
- zoomTo(zoomObject) {
137
- const animateTime = 500;
138
- this.zoomCanvasInvokeZoomBehavior(zoomObject, animateTime);
135
+ // Zooms the canvas to the extent specified in the zoom object. Animate
136
+ // the zoom by the time specified (in milliseconds) or by 500ms by default.
137
+ zoomTo(zoomObject, animateTime) {
138
+ const at = typeof animateTime === "undefined" ? 500 : animateTime;
139
+ this.zoomCanvasInvokeZoomBehavior(zoomObject, at);
139
140
  }
140
141
 
141
142
  // Pans the canvas by the x and y amount specified in the time specified.
@@ -51,5 +51,5 @@ svg.canvas-state-icon-info {
51
51
  }
52
52
 
53
53
  svg.canvas-state-icon-information-hollow {
54
- fill: $icon-01;
54
+ fill: $icon-02;
55
55
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import { isMatch, isMatchWith, omit } from "lodash";
21
21
  import LayoutDimensions from "./layout-dimensions.js";
22
22
  import { ASSOC_STRAIGHT, LINK_SELECTION_NONE } from "../common-canvas/constants/canvas-constants";
23
23
 
24
- export default class CanvasUtils {
24
+ export default class ConfigUtils {
25
25
 
26
26
  // Returns a config object which is the result of merging config into
27
27
  // startConfig.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { cloneDeep } from "lodash";
18
+
17
19
  const portsHorizontalDefaultLayout = {
18
20
  nodeLayout: {
19
21
  // Default node sizes. The height might be overridden for nodes with more ports
@@ -154,26 +156,19 @@ const portsHorizontalDefaultLayout = {
154
156
  inputPortWidth: 12,
155
157
  inputPortHeight: 12,
156
158
 
157
- // Position of left single input port. Multiple input ports will be
158
- // automatically positioned with the Y coordinate being overriden. These
159
- // values are an offset from the top left corner of the node outline.
160
- // Used when linkDirection is "LeftRight".
161
- inputPortLeftPosX: 0,
162
- inputPortLeftPosY: 20,
163
-
164
- // Position of top single input port. Multiple input ports will be
165
- // automatically positioned with the X coordinate being overriden. These
166
- // values are an offset from the top left corner of the node outline.
167
- // Used when linkDirection is "TopBottom".
168
- inputPortTopPosX: 80,
169
- inputPortTopPosY: 0,
170
-
171
- // Position of bottom single input port. Multiple input ports will be
172
- // automatically positioned with the X coordinate being overriden. These
173
- // values are an offset from the bottom left corner of the node outline.
174
- // Used when linkDirection is "BottomTop".
175
- inputPortBottomPosX: 80,
176
- inputPortBottomPosY: 0,
159
+ // Indicates whether multiple input ports should be automatically
160
+ // positioned (true) or positioned based on the contents of
161
+ // inputPortPositions array (false).
162
+ inputPortAutoPosition: true,
163
+
164
+ // An array of input port positions. Each element is structured like
165
+ // this: { x_pos: 5, y_pos: 10, pos: "topLeft" }. x_pos and y_pos are
166
+ // offsets from the pos point on the node.
167
+ // The order of the elements corresponds to the order of ports in the
168
+ // inputs array for the node.
169
+ inputPortPositions: [
170
+ { x_pos: 0, y_pos: 20, pos: "topLeft" }
171
+ ],
177
172
 
178
173
  // The 'guide' is the object drawn at the mouse position as a new line
179
174
  // is being dragged outwards.
@@ -196,27 +191,19 @@ const portsHorizontalDefaultLayout = {
196
191
  outputPortWidth: 12,
197
192
  outputPortHeight: 12,
198
193
 
199
- // Position of right single output port. Multiple input ports will be
200
- // automatically positioned with the Y coordinate being overriden. These
201
- // values are an offset from the top right corner of the node outline.
202
- // Used when linkDirection is "LeftRight".
203
- outputPortRightPosition: "topRight",
204
- outputPortRightPosX: 0,
205
- outputPortRightPosY: 20,
206
-
207
- // Position of top single output port. Multiple input ports will be
208
- // automatically positioned with the X coordinate being overriden. These
209
- // values are an offset from the top left corner of the node outline.
210
- // Used when linkDirection is "BottomTop".
211
- outputPortTopPosX: 80,
212
- outputPortTopPosY: 0,
213
-
214
- // Position of bottom single output port. Multiple input ports will be
215
- // automatically positioned with the X coordinate being overriden. These
216
- // values are an offset from the bottom left corner of the node outline.
217
- // Used when linkDirection is "TopBottom".
218
- outputPortBottomPosX: 80,
219
- outputPortBottomPosY: 0,
194
+ // Indicates whether multiple output ports should be automatically
195
+ // positioned (true) or positioned based on the contents of
196
+ // outputPortPositions array (false).
197
+ outputPortAutoPosition: true,
198
+
199
+ // An array of output port positions. Each element is structured like
200
+ // this: { x_pos: 5, y_pos: 10, pos: "topRight" }. x_pos and y_pos are
201
+ // offsets from the pos point on the node.
202
+ // The order of the elements corresponds to the order of ports in the
203
+ // outputs array for the node.
204
+ outputPortPositions: [
205
+ { x_pos: 0, y_pos: 20, pos: "topRight" }
206
+ ],
220
207
 
221
208
  // The 'guide' is the object drawn at the mouse position as a new line
222
209
  // is being dragged outwards.
@@ -412,7 +399,7 @@ const portsHorizontalDefaultLayout = {
412
399
  // to switch the data-new-link-over attribute to "yes".
413
400
  nodeProximity: 20,
414
401
 
415
- // Adds additional area around the ghost areaa dragged from the palette
402
+ // Adds additional area around the ghost area dragged from the palette
416
403
  // which can increase the possibility of detecting detached links.
417
404
  ghostAreaPadding: 10,
418
405
 
@@ -569,26 +556,19 @@ const portsVerticalDefaultLayout = {
569
556
  inputPortWidth: 12,
570
557
  inputPortHeight: 12,
571
558
 
572
- // Position of left single input port. Multiple input ports will be
573
- // automatically positioned with the Y coordinate being overriden. These
574
- // values are an offset from the top left corner of the node outline.
575
- // Used when linkDirection is "LeftRight".
576
- inputPortLeftPosX: 0,
577
- inputPortLeftPosY: 29,
578
-
579
- // Position of top single input port. Multiple input ports will be
580
- // automatically positioned with the X coordinate being overriden. These
581
- // values are an offset from the top left corner of the node outline.
582
- // Used when linkDirection is "TopBottom".
583
- inputPortTopPosX: 35,
584
- inputPortTopPosY: 0,
585
-
586
- // Position of bottom single input port. Multiple input ports will be
587
- // automatically positioned with the X coordinate being overriden. These
588
- // values are an offset from the bottom left corner of the node outline.
589
- // Used when linkDirection is "BottomTop".
590
- inputPortBottomPosX: 35,
591
- inputPortBottomPosY: 0,
559
+ // Indicates whether multiple input ports should be automatically
560
+ // positioned (true) or positioned based on the contents of
561
+ // inputPortPositions array (false).
562
+ inputPortAutoPosition: true,
563
+
564
+ // An array of input port positions. Each element is structured like
565
+ // this: { x_pos: 5, y_pos: 10, pos: "topLeft" }. x_pos and y_pos are
566
+ // offsets from the pos point on the node.
567
+ // The order of the elements corresponds to the order of ports in the
568
+ // inputs array for the node.
569
+ inputPortPositions: [
570
+ { x_pos: 0, y_pos: 29, pos: "topLeft" }
571
+ ],
592
572
 
593
573
  // The 'guide' is the object drawn at the mouse position as a new line
594
574
  // is being dragged outwards.
@@ -611,27 +591,19 @@ const portsVerticalDefaultLayout = {
611
591
  outputPortWidth: 12,
612
592
  outputPortHeight: 12,
613
593
 
614
- // Position of right single input port. Multiple input ports will be
615
- // automatically positioned with the Y coordinate being overriden. These
616
- // values are an offset from the top right corner of the node outline.
617
- // Used when linkDirection is "LeftRight".
618
- outputPortRightPosition: "topRight",
619
- outputPortRightPosX: 0,
620
- outputPortRightPosY: 29,
621
-
622
- // Position of top single input port. Multiple input ports will be
623
- // automatically positioned with the X coordinate being overriden. These
624
- // values are an offset from the top left corner of the node outline.
625
- // Used when linkDirection is "BottomTop".
626
- outputPortTopPosX: 35,
627
- outputPortTopPosY: 0,
628
-
629
- // Position of bottom single input port. Multiple input ports will be
630
- // automatically positioned with the X coordinate being overriden. These
631
- // values are an offset from the bottom left corner of the node outline.
632
- // Used when linkDirection is "TopBottom".
633
- outputPortBottomPosX: 35,
634
- outputPortBottomPosY: 0,
594
+ // Indicates whether multiple output ports should be automatically
595
+ // positioned (true) or positioned based on the contents of
596
+ // outputPortPositions array (false).
597
+ outputPortAutoPosition: true,
598
+
599
+ // An array of output port positions. Each element is structured like
600
+ // this: { x_pos: 5, y_pos: 10, pos: "topRight" }. x_pos and y_pos are
601
+ // offsets from the pos point on the node.
602
+ // The order of the elements corresponds to the order of ports in the
603
+ // outputs array for the node.
604
+ outputPortPositions: [
605
+ { x_pos: 0, y_pos: 29, pos: "topRight" }
606
+ ],
635
607
 
636
608
  // The 'guide' is the object drawn at the mouse position as a new line
637
609
  // is being dragged outwards.
@@ -827,7 +799,7 @@ const portsVerticalDefaultLayout = {
827
799
  // to switch the data-new-link-over attribute to "yes".
828
800
  nodeProximity: 20,
829
801
 
830
- // Adds additional area around the ghost areaa dragged from the palette
802
+ // Adds additional area around the ghost area dragged from the palette
831
803
  // which can increase the possibility of detecting detached links.
832
804
  ghostAreaPadding: 10,
833
805
 
@@ -850,7 +822,8 @@ export default class LayoutDimensions {
850
822
  let newLayout = this.getDefaultLayout(config);
851
823
 
852
824
  if (config) {
853
- newLayout = this.overrideNodeLayout(newLayout, overlayLayout); // Do this first because snap-to-grid depends on this.
825
+ newLayout = this.overridePortPositions(newLayout, config); // Must do this before overrideNodeLayout
826
+ newLayout = this.overrideNodeLayout(newLayout, overlayLayout); // Must do this before overrideSnapToGrid
854
827
  newLayout = this.overrideCanvasLayout(newLayout, config, overlayLayout);
855
828
  newLayout = this.overrideLinkType(newLayout, config);
856
829
  newLayout = this.overrideSnapToGrid(newLayout, config);
@@ -867,7 +840,7 @@ export default class LayoutDimensions {
867
840
  } else {
868
841
  defaultLayout = portsHorizontalDefaultLayout;
869
842
  }
870
- return Object.assign({}, defaultLayout);
843
+ return cloneDeep(defaultLayout);
871
844
  }
872
845
 
873
846
  static overrideNodeLayout(layout, overlayLayout) {
@@ -939,4 +912,26 @@ export default class LayoutDimensions {
939
912
  }
940
913
  return Number.parseInt(snapToGridSizeStr, 10);
941
914
  }
915
+
916
+ // Overrides the port positioning fields in the layout based on the type of node
917
+ // and the link direction.
918
+ static overridePortPositions(layout, config) {
919
+ if (config.enableLinkDirection === "BottomTop") {
920
+ layout.nodeLayout.inputPortPositions = [
921
+ { x_pos: 0, y_pos: 0, pos: "bottomCenter" }
922
+ ];
923
+ layout.nodeLayout.outputPortPositions = [
924
+ { x_pos: 0, y_pos: 0, pos: "topCenter" }
925
+ ];
926
+
927
+ } else if (config.enableLinkDirection === "TopBottom") {
928
+ layout.nodeLayout.inputPortPositions = [
929
+ { x_pos: 0, y_pos: 0, pos: "topCenter" }
930
+ ];
931
+ layout.nodeLayout.outputPortPositions = [
932
+ { x_pos: 0, y_pos: 0, pos: "bottomCenter" }
933
+ ];
934
+ }
935
+ return layout;
936
+ }
942
937
  }