@elyra/canvas 12.10.0 → 12.11.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 (197) hide show
  1. package/dist/canvas-constants-7f93e705.js +2 -0
  2. package/dist/canvas-constants-7f93e705.js.map +1 -0
  3. package/dist/canvas-constants-ac5daafb.js +2 -0
  4. package/dist/canvas-constants-ac5daafb.js.map +1 -0
  5. package/dist/canvas-controller-183ff6a7.js +2 -0
  6. package/dist/canvas-controller-183ff6a7.js.map +1 -0
  7. package/dist/canvas-controller-d70a731e.js +2 -0
  8. package/dist/canvas-controller-d70a731e.js.map +1 -0
  9. package/dist/canvas-logger-815781bb.js +2 -0
  10. package/dist/canvas-logger-815781bb.js.map +1 -0
  11. package/dist/canvas-logger-a0f1beaa.js +2 -0
  12. package/dist/canvas-logger-a0f1beaa.js.map +1 -0
  13. package/dist/common-canvas-3e832a84.js +2 -0
  14. package/dist/common-canvas-3e832a84.js.map +1 -0
  15. package/dist/common-canvas-c50cb3f3.js +2 -0
  16. package/dist/common-canvas-c50cb3f3.js.map +1 -0
  17. package/dist/common-canvas.es.js +1 -1
  18. package/dist/common-canvas.es.js.map +1 -1
  19. package/dist/common-canvas.js +1 -1
  20. package/dist/common-canvas.js.map +1 -1
  21. package/dist/common-properties-4f471b2b.js +2 -0
  22. package/dist/common-properties-4f471b2b.js.map +1 -0
  23. package/dist/common-properties-9161cd27.js +2 -0
  24. package/dist/common-properties-9161cd27.js.map +1 -0
  25. package/dist/datarecord-metadata-v3-schema-bda88f2e.js +2 -0
  26. package/dist/datarecord-metadata-v3-schema-bda88f2e.js.map +1 -0
  27. package/dist/datarecord-metadata-v3-schema-d7ad05cd.js +2 -0
  28. package/dist/datarecord-metadata-v3-schema-d7ad05cd.js.map +1 -0
  29. package/dist/en-2ed89528.js +2 -0
  30. package/dist/en-2ed89528.js.map +1 -0
  31. package/dist/en-e93855cc.js +2 -0
  32. package/dist/en-e93855cc.js.map +1 -0
  33. package/dist/extends-39f57612.js +7 -0
  34. package/dist/extends-39f57612.js.map +1 -0
  35. package/dist/extends-51d9ddcc.js +7 -0
  36. package/dist/extends-51d9ddcc.js.map +1 -0
  37. package/dist/flexible-table-154a3359.js +2 -0
  38. package/dist/flexible-table-154a3359.js.map +1 -0
  39. package/dist/flexible-table-5e4a1e6d.js +2 -0
  40. package/dist/flexible-table-5e4a1e6d.js.map +1 -0
  41. package/dist/icon-811ffddd.js +2 -0
  42. package/dist/icon-811ffddd.js.map +1 -0
  43. package/dist/icon-d6909a68.js +2 -0
  44. package/dist/icon-d6909a68.js.map +1 -0
  45. package/dist/index-4fd90a14.js +2 -0
  46. package/dist/index-4fd90a14.js.map +1 -0
  47. package/dist/index-6d138021.js +2 -0
  48. package/dist/index-6d138021.js.map +1 -0
  49. package/dist/isArrayLikeObject-31e5e646.js +2 -0
  50. package/dist/isArrayLikeObject-31e5e646.js.map +1 -0
  51. package/dist/isArrayLikeObject-7c33c7fd.js +2 -0
  52. package/dist/isArrayLikeObject-7c33c7fd.js.map +1 -0
  53. package/dist/lib/canvas-controller.es.js +2 -0
  54. package/dist/lib/canvas-controller.es.js.map +1 -0
  55. package/dist/lib/canvas-controller.js +2 -0
  56. package/dist/lib/canvas-controller.js.map +1 -0
  57. package/dist/lib/canvas.es.js +1 -1
  58. package/dist/lib/canvas.js +1 -1
  59. package/dist/lib/context-menu.es.js +1 -1
  60. package/dist/lib/context-menu.es.js.map +1 -1
  61. package/dist/lib/context-menu.js +1 -1
  62. package/dist/lib/context-menu.js.map +1 -1
  63. package/dist/lib/properties/field-picker.es.js +1 -1
  64. package/dist/lib/properties/field-picker.js +1 -1
  65. package/dist/lib/properties/flexible-table.es.js +1 -1
  66. package/dist/lib/properties/flexible-table.js +1 -1
  67. package/dist/lib/properties.es.js +1 -1
  68. package/dist/lib/properties.js +1 -1
  69. package/dist/lib/tooltip.es.js +1 -1
  70. package/dist/lib/tooltip.es.js.map +1 -1
  71. package/dist/lib/tooltip.js +1 -1
  72. package/dist/lib/tooltip.js.map +1 -1
  73. package/dist/styles/common-canvas.min.css +1 -1
  74. package/dist/styles/common-canvas.min.css.map +1 -1
  75. package/dist/toolbar-335252dd.js +2 -0
  76. package/dist/toolbar-335252dd.js.map +1 -0
  77. package/dist/toolbar-85e6c77b.js +2 -0
  78. package/dist/toolbar-85e6c77b.js.map +1 -0
  79. package/locales/command-actions/locales/en.json +7 -1
  80. package/locales/command-actions/locales/eo.json +7 -1
  81. package/locales/command-actions/locales/index.js +3 -1
  82. package/locales/command-actions/locales/ko.json +9 -0
  83. package/locales/common-canvas/locales/en.json +1 -0
  84. package/locales/common-canvas/locales/eo.json +1 -0
  85. package/locales/common-canvas/locales/index.js +3 -1
  86. package/locales/common-canvas/locales/ko.json +32 -0
  87. package/locales/common-properties/locales/index.js +3 -1
  88. package/locales/common-properties/locales/ko.json +93 -0
  89. package/locales/palette/locales/index.js +3 -1
  90. package/locales/palette/locales/ko.json +10 -0
  91. package/locales/toolbar/locales/index.js +3 -1
  92. package/locales/toolbar/locales/ko.json +8 -0
  93. package/package.json +7 -3
  94. package/rollup.config.js +10 -7
  95. package/src/color-picker/color-picker-panel.jsx +61 -0
  96. package/src/color-picker/color-picker.jsx +37 -0
  97. package/src/color-picker/color-picker.scss +46 -0
  98. package/src/command-actions/colorSelectedObjectsAction.js +72 -0
  99. package/src/command-actions/deleteObjectsAction.js +16 -11
  100. package/src/command-actions/pasteAction.js +50 -21
  101. package/src/common-canvas/canvas-controller.js +32 -5
  102. package/src/common-canvas/cc-bottom-panel.jsx +34 -37
  103. package/src/common-canvas/cc-contents.jsx +114 -12
  104. package/src/common-canvas/cc-toolbar.jsx +3 -2
  105. package/src/common-canvas/common-canvas-utils.js +39 -78
  106. package/src/common-canvas/common-canvas.scss +28 -14
  107. package/src/common-canvas/constants/canvas-constants.js +17 -16
  108. package/src/common-canvas/label-util.js +1 -1
  109. package/src/common-canvas/svg-canvas-d3.js +20 -107
  110. package/src/common-canvas/svg-canvas-d3.scss +67 -6
  111. package/src/common-canvas/svg-canvas-pipeline.js +201 -0
  112. package/src/common-canvas/svg-canvas-renderer.js +155 -164
  113. package/src/common-canvas/svg-canvas-utils-links.js +3 -3
  114. package/src/common-canvas/svg-canvas-utils-nodes.js +22 -34
  115. package/src/common-properties/actions.js +4 -0
  116. package/src/common-properties/components/field-picker/field-picker.jsx +33 -36
  117. package/src/common-properties/components/field-picker/field-picker.scss +20 -23
  118. package/src/common-properties/components/flexible-table/flexible-table.jsx +46 -31
  119. package/src/common-properties/components/flexible-table/flexible-table.scss +14 -17
  120. package/src/common-properties/components/properties-buttons/properties-buttons.jsx +28 -21
  121. package/src/common-properties/components/table-buttons/table-buttons.jsx +3 -1
  122. package/src/common-properties/components/table-buttons/table-buttons.scss +8 -8
  123. package/src/common-properties/components/title-editor/title-editor.jsx +31 -4
  124. package/src/common-properties/components/title-editor/title-editor.scss +30 -5
  125. package/src/common-properties/components/virtualized-table/virtualized-table.jsx +120 -29
  126. package/src/common-properties/components/virtualized-table/virtualized-table.scss +72 -8
  127. package/src/common-properties/constants/constants.js +5 -1
  128. package/src/common-properties/constants/form-constants.js +1 -0
  129. package/src/common-properties/controls/abstract-table.jsx +12 -11
  130. package/src/common-properties/controls/abstract-table.scss +6 -2
  131. package/src/common-properties/controls/dropdown/dropdown.scss +4 -0
  132. package/src/common-properties/controls/expression/expression-builder/expression-select-field-function.jsx +2 -2
  133. package/src/common-properties/controls/passwordfield/passwordfield.jsx +2 -2
  134. package/src/common-properties/controls/readonlytable/readonlytable.jsx +4 -2
  135. package/src/common-properties/controls/selectcolumns/selectcolumns.scss +0 -19
  136. package/src/common-properties/controls/someofselect/someofselect.scss +2 -2
  137. package/src/common-properties/form/ControlInfo.js +8 -0
  138. package/src/common-properties/form/EditorForm.js +4 -0
  139. package/src/common-properties/form/ParameterInfo.js +4 -0
  140. package/src/common-properties/panels/sub-panel/cell.jsx +18 -23
  141. package/src/common-properties/panels/sub-panel/sub-panel.scss +5 -22
  142. package/src/common-properties/properties-controller.js +18 -0
  143. package/src/common-properties/properties-main/properties-main.jsx +15 -9
  144. package/src/common-properties/properties-main/properties-main.scss +9 -2
  145. package/src/common-properties/properties-store.js +27 -1
  146. package/src/common-properties/reducers/properties-settings.js +17 -1
  147. package/src/context-menu/common-context-menu.jsx +74 -29
  148. package/src/context-menu/context-menu-wrapper.jsx +2 -2
  149. package/src/icons/icon.jsx +5 -46
  150. package/src/index.scss +1 -0
  151. package/src/object-model/api-pipeline.js +25 -42
  152. package/src/object-model/object-model.js +27 -3
  153. package/src/object-model/redux/canvas-store.js +68 -0
  154. package/src/object-model/redux/reducers/canvasinfo.js +36 -0
  155. package/src/object-model/redux/reducers/comments.js +58 -10
  156. package/src/object-model/redux/reducers/externalpipelineflows.js +1 -0
  157. package/src/object-model/redux/reducers/links.js +9 -7
  158. package/src/object-model/redux/reducers/selectioninfo.js +2 -1
  159. package/src/palette/palette-content-list-item.jsx +8 -1
  160. package/src/palette/palette-dialog-content-grid-node.jsx +8 -1
  161. package/src/palette/palette-flyout-utils.js +3 -3
  162. package/src/toolbar/toolbar-action-item.jsx +77 -14
  163. package/src/toolbar/toolbar-overflow-item.jsx +2 -3
  164. package/src/tooltip/tooltip.jsx +4 -1
  165. package/stats.html +1 -1
  166. package/dist/canvas-controller-5c90a709.js +0 -2
  167. package/dist/canvas-controller-5c90a709.js.map +0 -1
  168. package/dist/canvas-controller-a851a663.js +0 -2
  169. package/dist/canvas-controller-a851a663.js.map +0 -1
  170. package/dist/common-properties-3758e3b2.js +0 -2
  171. package/dist/common-properties-3758e3b2.js.map +0 -1
  172. package/dist/common-properties-6334cca1.js +0 -2
  173. package/dist/common-properties-6334cca1.js.map +0 -1
  174. package/dist/datarecord-metadata-v3-schema-3a2957c3.js +0 -2
  175. package/dist/datarecord-metadata-v3-schema-3a2957c3.js.map +0 -1
  176. package/dist/datarecord-metadata-v3-schema-82f2b977.js +0 -2
  177. package/dist/datarecord-metadata-v3-schema-82f2b977.js.map +0 -1
  178. package/dist/en-9e368daa.js +0 -2
  179. package/dist/en-9e368daa.js.map +0 -1
  180. package/dist/en-a3710fcf.js +0 -2
  181. package/dist/en-a3710fcf.js.map +0 -1
  182. package/dist/extends-41535aa9.js +0 -7
  183. package/dist/extends-41535aa9.js.map +0 -1
  184. package/dist/extends-76e6b8d2.js +0 -8
  185. package/dist/extends-76e6b8d2.js.map +0 -1
  186. package/dist/flexible-table-2bbb9e48.js +0 -2
  187. package/dist/flexible-table-2bbb9e48.js.map +0 -1
  188. package/dist/flexible-table-756ff86a.js +0 -2
  189. package/dist/flexible-table-756ff86a.js.map +0 -1
  190. package/dist/index-1eff5860.js +0 -2
  191. package/dist/index-1eff5860.js.map +0 -1
  192. package/dist/index-7fba99b9.js +0 -2
  193. package/dist/index-7fba99b9.js.map +0 -1
  194. package/dist/isEmpty-3550e76f.js +0 -2
  195. package/dist/isEmpty-3550e76f.js.map +0 -1
  196. package/dist/isEmpty-c6f783dd.js +0 -2
  197. package/dist/isEmpty-c6f783dd.js.map +0 -1
@@ -24,12 +24,29 @@ import { injectIntl } from "react-intl";
24
24
  import defaultMessages from "../../locales/common-canvas/locales/en.json";
25
25
  import CommonCanvasContextMenu from "./cc-context-menu.jsx";
26
26
  import CommonCanvasStateTag from "./cc-state-tag.jsx";
27
+ import CanvasUtils from "./common-canvas-utils.js";
27
28
  import { FlowData16 } from "@carbon/icons-react";
28
29
  import { DND_DATA_TEXT, STATE_TAG_LOCKED, STATE_TAG_READ_ONLY } from "./constants/canvas-constants";
29
30
 
30
31
  import Logger from "../logging/canvas-logger.js";
31
32
  import SVGCanvasD3 from "./svg-canvas-d3.js";
32
33
 
34
+ const BACKSPACE_KEY = 8;
35
+ const DELETE_KEY = 46;
36
+ const A_KEY = 65;
37
+ const C_KEY = 67;
38
+ const P_KEY = 80;
39
+ const V_KEY = 86;
40
+ const X_KEY = 88;
41
+ const Y_KEY = 89;
42
+ const Z_KEY = 90;
43
+
44
+ // TODO - Implement nudge behavior for moving nodes and comments
45
+ // const LEFT_ARROW_KEY = 37;
46
+ // const UP_ARROW_KEY = 38;
47
+ // const RIGHT_ARROW_KEY = 39;
48
+ // const DOWN_ARROW_KEY = 40;
49
+
33
50
  class CanvasContents extends React.Component {
34
51
  constructor(props) {
35
52
  super(props);
@@ -53,6 +70,10 @@ class CanvasContents extends React.Component {
53
70
  // Record whether we added the event listeners or not.
54
71
  this.eventListenersAdded = false;
55
72
 
73
+ // Keeps track of mouse position to enable us to paste at mouse position
74
+ // using keyboard.
75
+ this.mousePos = { x: 0, y: 0 };
76
+
56
77
  this.drop = this.drop.bind(this);
57
78
  this.focusOnCanvas = this.focusOnCanvas.bind(this);
58
79
  this.setIsDropZoneDisplayed = this.setIsDropZoneDisplayed.bind(this);
@@ -65,6 +86,8 @@ class CanvasContents extends React.Component {
65
86
  this.onCut = this.onCut.bind(this);
66
87
  this.onCopy = this.onCopy.bind(this);
67
88
  this.onPaste = this.onPaste.bind(this);
89
+ this.onKeyDown = this.onKeyDown.bind(this);
90
+ this.onMouseMove = this.onMouseMove.bind(this);
68
91
 
69
92
  // Variables to handle strange HTML drag and drop behaviors. That is, pairs
70
93
  // of dragEnter/dragLeave events are fired as an external object is
@@ -115,7 +138,6 @@ class CanvasContents extends React.Component {
115
138
 
116
139
  componentWillUnmount() {
117
140
  this.removeEventListeners();
118
- this.svgCanvasD3.close();
119
141
  }
120
142
 
121
143
  onCut(evt) {
@@ -142,6 +164,82 @@ class CanvasContents extends React.Component {
142
164
  }
143
165
  }
144
166
 
167
+ onKeyDown(evt) {
168
+ // Make sure no tip is displayed, because having one displayed
169
+ // will interfere with drawing of the canvas as the result of any
170
+ // keyboard action.
171
+ this.props.canvasController.closeTip();
172
+ const actions = this.props.canvasController.getKeyboardConfig().actions;
173
+ // We don't handle key presses when:
174
+ // 1. We are editng text, because the text area needs to receive key
175
+ // presses for undo, redo, delete etc.
176
+ // 2. Dragging objects
177
+ if (this.svgCanvasD3.isEditingText() ||
178
+ this.svgCanvasD3.isDragging()) {
179
+ return;
180
+ }
181
+
182
+ // These actions alter the canvas objects so we need to check
183
+ // this.config.enableEditingActions before calling them.
184
+ if (this.props.canvasConfig.enableEditingActions) {
185
+ if ((evt.keyCode === BACKSPACE_KEY || evt.keyCode === DELETE_KEY) && actions.delete) {
186
+ CanvasUtils.stopPropagationAndPreventDefault(evt); // Some browsers interpret Delete as 'Back to previous page'. So prevent that.
187
+ this.props.canvasController.keyboardActionHandler("deleteSelectedObjects");
188
+
189
+ } else if (CanvasUtils.isCmndCtrlPressed(evt) &&
190
+ !evt.shiftKey && evt.keyCode === Z_KEY && actions.undo) {
191
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
192
+ this.props.canvasController.keyboardActionHandler("undo");
193
+
194
+ } else if (CanvasUtils.isCmndCtrlPressed(evt) &&
195
+ ((evt.shiftKey && evt.keyCode === Z_KEY) || evt.keyCode === Y_KEY && actions.redo)) {
196
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
197
+ this.props.canvasController.keyboardActionHandler("redo");
198
+
199
+ } else if (CanvasUtils.isCmndCtrlPressed(evt) && evt.keyCode === C_KEY && actions.copyToClipboard) {
200
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
201
+ this.props.canvasController.keyboardActionHandler("copy");
202
+
203
+ } else if (CanvasUtils.isCmndCtrlPressed(evt) && evt.keyCode === X_KEY && actions.cutToClipboard) {
204
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
205
+ this.props.canvasController.keyboardActionHandler("cut");
206
+
207
+ } else if (CanvasUtils.isCmndCtrlPressed(evt) && evt.keyCode === V_KEY && actions.pasteFromClipboard) {
208
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
209
+ if (this.mousePos) {
210
+ const mousePos = this.svgCanvasD3.convertPageCoordsToSnappedCanvasCoords(this.mousePos);
211
+ this.props.canvasController.keyboardActionHandler("paste", mousePos);
212
+ } else {
213
+ this.props.canvasController.keyboardActionHandler("paste");
214
+ }
215
+ }
216
+ }
217
+ // These last two keyboard actions do not alter the canvas objects so we
218
+ // do not need to check this.config.enableEditingActions before calling them.
219
+ if (CanvasUtils.isCmndCtrlPressed(evt) && evt.keyCode === A_KEY && actions.selectAll) {
220
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
221
+ this.props.canvasController.keyboardActionHandler("selectAll");
222
+
223
+ } else if (CanvasUtils.isCmndCtrlPressed(evt) && evt.shiftKey && evt.altKey && evt.keyCode === P_KEY) {
224
+ CanvasUtils.stopPropagationAndPreventDefault(evt);
225
+ Logger.switchLoggingState(); // Switch the logging on and off
226
+ }
227
+ }
228
+
229
+ // Records in mousePos the mouse pointer position when the pointer is inside
230
+ // the boundaries of the canvas or sets the mousePos to null. This position
231
+ // info can be used with keyboard operations.
232
+ onMouseMove(e) {
233
+ if (e.target.className.baseVal === "svg-area" || e.target.className.baseVal === "d3-svg-background") {
234
+ this.mousePos = {
235
+ x: e.clientX,
236
+ y: e.clientY
237
+ };
238
+ } else {
239
+ this.mousePos = null;
240
+ }
241
+ }
242
+
145
243
  getLabel(labelId) {
146
244
  return this.props.intl.formatMessage({ id: labelId, defaultMessage: defaultMessages[labelId] });
147
245
  }
@@ -223,7 +321,7 @@ class CanvasContents extends React.Component {
223
321
  // the div (which allows keyboard events to go there) and using -1 means
224
322
  // the user cannot tab to the div. Keyboard events are handled in svg-canvas-d3.js.
225
323
  // https://stackoverflow.com/questions/32911355/whats-the-tabindex-1-in-bootstrap-for
226
- return (<div tabIndex="-1" className="d3-svg-canvas-div" id={this.svgCanvasDivId} />);
324
+ return (<div tabIndex="-1" className="d3-svg-canvas-div" id={this.svgCanvasDivId} onKeyDown={this.onKeyDown} />);
227
325
  }
228
326
 
229
327
  setIsDropZoneDisplayed(isDropZoneDisplayed) {
@@ -266,6 +364,7 @@ class CanvasContents extends React.Component {
266
364
  document.addEventListener("cut", this.onCut, true);
267
365
  document.addEventListener("copy", this.onCopy, true);
268
366
  document.addEventListener("paste", this.onPaste, true);
367
+ document.addEventListener("mousemove", this.onMouseMove, true);
269
368
  this.eventListenersAdded = true;
270
369
  }
271
370
  }
@@ -275,24 +374,26 @@ class CanvasContents extends React.Component {
275
374
  document.removeEventListener("cut", this.onCut, true);
276
375
  document.removeEventListener("copy", this.onCopy, true);
277
376
  document.removeEventListener("paste", this.onPaste, true);
377
+ document.removeEventListener("mousemove", this.onMouseMove, true);
278
378
  this.eventListenersAdded = false;
279
379
  }
280
380
  }
281
381
 
282
382
  drop(event) {
283
383
  event.preventDefault();
384
+ this.setIsDropZoneDisplayed(false);
385
+
386
+ this.first = false;
387
+ this.second = false;
284
388
 
285
389
  if (!this.props.canvasConfig.enableEditingActions) {
286
390
  return;
287
391
  }
288
392
 
289
- this.first = false;
290
- this.second = false;
291
- this.setIsDropZoneDisplayed(false);
292
-
293
393
  const nodeTemplate = this.props.canvasController.getDragNodeTemplate();
294
394
  if (nodeTemplate) {
295
395
  this.svgCanvasD3.nodeTemplateDropped(nodeTemplate, event.clientX, event.clientY);
396
+ this.props.canvasController.nodeTemplateDragEnd();
296
397
 
297
398
  } else {
298
399
  let dropData = this.getDNDJson(event);
@@ -311,19 +412,20 @@ class CanvasContents extends React.Component {
311
412
  this.svgCanvasD3.externalObjectDropped(dropData, event.clientX, event.clientY);
312
413
  }
313
414
 
314
- // Clear the drag template.
315
- this.props.canvasController.setDragNodeTemplate(null);
316
-
317
415
  // Also clear dataTransfer data for when we get external objects.
318
416
  event.dataTransfer.clearData();
319
417
  }
320
418
 
321
419
  dragOver(event) {
322
- const nodeTemplate = this.props.canvasController.getDragNodeTemplate();
323
- if (nodeTemplate && (this.dragX !== event.clientX || this.dragY !== event.clientY)) {
420
+ // Drag over is continually fired so only pass on the event when the mouse
421
+ // cursor moves a reasonable distance.
422
+ if (Math.abs(this.dragX - event.clientX) > 5 || Math.abs(this.dragY - event.clientY) > 5) {
324
423
  this.dragX = event.clientX;
325
424
  this.dragY = event.clientY;
326
- this.svgCanvasD3.nodeTemplateDraggedOver(nodeTemplate, event.clientX, event.clientY);
425
+ const nodeTemplate = this.props.canvasController.getDragNodeTemplate();
426
+ if (nodeTemplate) {
427
+ this.svgCanvasD3.nodeTemplateDragOver(nodeTemplate, event.clientX, event.clientY);
428
+ }
327
429
  }
328
430
  }
329
431
 
@@ -23,7 +23,8 @@ import defaultToolbarMessages from "../../locales/toolbar/locales/en.json";
23
23
  import Toolbar from "../toolbar/toolbar.jsx";
24
24
  import Logger from "../logging/canvas-logger.js";
25
25
  import { ERROR, WARNING, SUCCESS, INFO, PALETTE_LAYOUT_NONE,
26
- NOTIFICATION_ICON_CLASS, TOOLBAR_ACTIONS, TOOLBAR_LAYOUT_TOP } from "../common-canvas/constants/canvas-constants";
26
+ NOTIFICATION_ICON_CLASS, TOOLBAR_TOGGLE_NOTIFICATION_PANEL, TOOLBAR_LAYOUT_TOP }
27
+ from "../common-canvas/constants/canvas-constants";
27
28
 
28
29
  class CommonCanvasToolbar extends React.Component {
29
30
  constructor(props) {
@@ -181,7 +182,7 @@ class CommonCanvasToolbar extends React.Component {
181
182
  const notificationCount = this.props.notificationMessages.length;
182
183
  const notificationTools = [
183
184
  { divider: true },
184
- { action: TOOLBAR_ACTIONS.TOOLBAR_TOGGLE_NOTIFICATION_PANEL,
185
+ { action: TOOLBAR_TOGGLE_NOTIFICATION_PANEL,
185
186
  label: this.props.notificationConfig.label,
186
187
  enable: true,
187
188
  isSelected: this.props.isNotificationOpen,
@@ -247,12 +247,13 @@ export default class CanvasUtils {
247
247
  }
248
248
 
249
249
  // Returns true if either the Command Key on Mac or Control key on Windows
250
- // is pressed.
251
- static isCmndCtrlPressed(d3Event) {
250
+ // is pressed. evnt can be either a regular event object OR the
251
+ // d3event object provided by d3.
252
+ static isCmndCtrlPressed(evnt) {
252
253
  if (this.isMacintosh()) {
253
- return d3Event.metaKey;
254
+ return evnt.metaKey;
254
255
  }
255
- return d3Event.ctrlKey;
256
+ return evnt.ctrlKey;
256
257
  }
257
258
 
258
259
  // Returns whether user platform is Mac.
@@ -261,10 +262,11 @@ export default class CanvasUtils {
261
262
  }
262
263
 
263
264
  // Stops propagation of events and prevents any default behavior from
264
- // being executed.
265
- static stopPropagationAndPreventDefault(d3Event) {
266
- d3Event.stopPropagation();
267
- d3Event.preventDefault();
265
+ // being executed. evnt can be either a regular event object OR the
266
+ // d3event object provided by d3.
267
+ static stopPropagationAndPreventDefault(evnt) {
268
+ evnt.stopPropagation();
269
+ evnt.preventDefault();
268
270
  }
269
271
 
270
272
  // Returns a snap-to-grid value for the value passed in based on a grid
@@ -856,6 +858,18 @@ export default class CanvasUtils {
856
858
  pos.y_pos < area.y2 + pad;
857
859
  }
858
860
 
861
+ static isSupernode(node) {
862
+ return node.type === SUPER_NODE;
863
+ }
864
+
865
+ static isExpanded(node) {
866
+ return node.is_expanded === true;
867
+ }
868
+
869
+ static isExpandedSupernode(node) {
870
+ return this.isSupernode(node) && this.isExpanded(node);
871
+ }
872
+
859
873
  // Returns true if the node passed in is a binding node in a subflow
860
874
  // for a supernode.
861
875
  static isSuperBindingNode(d) {
@@ -1077,76 +1091,23 @@ export default class CanvasUtils {
1077
1091
  return outLinks;
1078
1092
  }
1079
1093
 
1080
- // Preprocesses the pipeline to set the connected attribute of the ports
1081
- // for each node. This is used when rendering the connection satus of ports.
1082
- static preProcessPipeline(pipeline) {
1083
- this.setAllPortsDisconnected(pipeline);
1084
-
1085
- pipeline.links.forEach((link) => {
1086
- if (link.type === COMMENT_LINK) {
1087
- link.srcObj = this.getComment(link.srcNodeId, pipeline);
1088
- link.trgNode = this.getNode(link.trgNodeId, pipeline);
1089
-
1090
- } else {
1091
- link.srcObj = this.getNode(link.srcNodeId, pipeline);
1092
- link.trgNode = this.getNode(link.trgNodeId, pipeline);
1093
-
1094
- if (link.srcObj) {
1095
- this.setOutputPortConnected(link.srcObj, link.srcNodePortId);
1096
- }
1097
- if (link.trgNode) {
1098
- this.setInputPortConnected(link.trgNode, link.trgNodePortId);
1099
- }
1100
- }
1101
- });
1102
- return pipeline;
1103
- }
1104
-
1105
- // Returns the node, from the pipeline passed in, identfied by the node ID.
1106
- static getNode(nodeId, pipeline) {
1107
- return pipeline.nodes.find((nd) => nd.id === nodeId);
1108
- }
1109
-
1110
- // Returns the comment, from the pipeline passed in, identfied by the comment ID.
1111
- static getComment(commentId, pipeline) {
1112
- return pipeline.comments.find((com) => com.id === commentId);
1113
- }
1114
-
1115
- // Sets the isConnected property of all ports in the pipeline to fasle.
1116
- static setAllPortsDisconnected(pipeline) {
1117
- pipeline.nodes.forEach((n) => {
1118
- if (n.inputs) {
1119
- n.inputs.forEach((inp) => (inp.isConnected = false));
1120
- }
1121
- if (n.outputs) {
1122
- n.outputs.forEach((out) => (out.isConnected = false));
1123
- }
1124
- });
1125
- }
1126
-
1127
- // Sets the isConnected property of the port, identified by inPortId,
1128
- // for the trgNode to true.
1129
- static setInputPortConnected(trgNode, inPortId) {
1130
- const portId = inPortId || this.getDefaultInputPortId(trgNode);
1131
- if (trgNode.inputs) {
1132
- trgNode.inputs.forEach((inp) => {
1133
- if (inp.id === portId) {
1134
- inp.isConnected = true;
1135
- }
1136
- });
1137
- }
1138
- }
1139
-
1140
- // Sets the isConnected property of the port, identified by outPortId,
1141
- // for the srcNode to true.
1142
- static setOutputPortConnected(srcNode, outPortId) {
1143
- const portId = outPortId || this.getDefaultOutputPortId(srcNode);
1144
- if (srcNode.outputs) {
1145
- srcNode.outputs.forEach((out) => {
1146
- if (out.id === portId) {
1147
- out.isConnected = true;
1148
- }
1149
- });
1094
+ // Returns the color class in the className parameter, if one is found,
1095
+ // otherwise returns null.
1096
+ static getBkgColorClass(className) {
1097
+ if (className === "bkg-col-white-0" ||
1098
+ className === "bkg-col-yellow-20" ||
1099
+ className === "bkg-col-gray-20" ||
1100
+ className === "bkg-col-green-20" ||
1101
+ className === "bkg-col-teal-20" ||
1102
+ className === "bkg-col-cyan-20" ||
1103
+ className === "bkg-col-red-50" ||
1104
+ className === "bkg-col-orange-40" ||
1105
+ className === "bkg-col-gray-50" ||
1106
+ className === "bkg-col-green-50" ||
1107
+ className === "bkg-col-teal-50" ||
1108
+ className === "bkg-col-cyan-50") {
1109
+ return className;
1150
1110
  }
1111
+ return null;
1151
1112
  }
1152
1113
  }
@@ -65,17 +65,12 @@ $bottom-panel-height: 393px;
65
65
  top: $toolbar-button-height;
66
66
  overflow: hidden;
67
67
 
68
- &.common-canvas-bottom-panel-is-open {
69
- height: calc(100% - #{$toolbar-button-height} - #{$bottom-panel-height});
70
- }
71
-
72
68
  &.common-canvas-toolbar-none {
73
69
  height: 100%;
74
70
  top: 0;
75
71
  }
76
72
 
77
73
  &.common-canvas-toolbar-none.common-canvas-bottom-panel-is-open {
78
- height: calc(100% - #{$toolbar-button-height} - #{$bottom-panel-height});
79
74
  top: 0;
80
75
  }
81
76
  }
@@ -88,13 +83,32 @@ $bottom-panel-height: 393px;
88
83
  }
89
84
 
90
85
  .bottom-panel {
86
+ display: flex;
87
+ flex-direction: column;
88
+ height: $bottom-panel-height;
91
89
  position: absolute;
90
+ left:0;
91
+ right:0;
92
92
  bottom: 0;
93
- width: 100%;
94
- height: $bottom-panel-height;
95
- user-select: none; /* Prevent elements from being selectable */
96
- background-color: $ui-01;
97
93
  border-top: $palette-border-width solid $palette-border-color;
94
+ min-height: 75px;
95
+ }
96
+
97
+ .bottom-panel-drag {
98
+ background: $palette-border-color;
99
+ cursor: row-resize;
100
+ flex: 0 0 2px;
101
+ transition: all 0.2s ease-in;
102
+ &:hover {
103
+ background: $interactive-01;
104
+ }
105
+ }
106
+
107
+ .bottom-panel-contents {
108
+ background-color: $ui-01;
109
+ width: 100%;
110
+ user-select: none;
111
+ height: 100%;
98
112
  }
99
113
 
100
114
  /* Alternative layout for common-canvas components where canvas and right-side
@@ -186,17 +200,17 @@ $bottom-panel-height: 393px;
186
200
  border-width: 2px;
187
201
  }
188
202
 
189
- .toolbar-icon.notificationCounterIcon {
190
- &.error > svg > .dot {
203
+ .toolbar-item-content.notificationCounterIcon {
204
+ &.error > div > svg > .dot {
191
205
  fill: $support-01;
192
206
  }
193
- &.warning > svg > .dot {
207
+ &.warning > div > svg > .dot {
194
208
  fill: $support-03;
195
209
  }
196
- &.success > svg > .dot {
210
+ &.success > div > svg > .dot {
197
211
  fill: $support-02;
198
212
  }
199
- &.info > svg > .dot {
213
+ &.info > div > svg > .dot {
200
214
  fill: $support-04;
201
215
  }
202
216
  }
@@ -148,7 +148,6 @@ export const CANVAS_CARBON_ICONS = {
148
148
  UP: "chevron-up",
149
149
  DOWN: "chevron-down"
150
150
  },
151
- OVERFLOWMENU: "overflow-menu",
152
151
  SEARCH: "search",
153
152
  WARNING_UNFILLED: "warning16"
154
153
  };
@@ -159,21 +158,23 @@ export const CONTEXT_MENU_CARBON_ICONS = {
159
158
  }
160
159
  };
161
160
 
162
- export const TOOLBAR_ACTIONS = {
163
- TOOLBAR_STOP: "stop",
164
- TOOLBAR_RUN: "run",
165
- TOOLBAR_UNDO: "undo",
166
- TOOLBAR_REDO: "redo",
167
- TOOLBAR_CUT: "cut",
168
- TOOLBAR_COPY: "copy",
169
- TOOLBAR_PASTE: "paste",
170
- TOOLBAR_CREATE_AUTO_COMMENT: "createAutoComment",
171
- TOOLBAR_DELETE_SELECTED_OBJECTS: "deleteSelectedObjects",
172
- TOOLBAR_ZOOM_IN: "zoomIn",
173
- TOOLBAR_ZOOM_OUT: "zoomOut",
174
- TOOLBAR_ZOOM_FIT: "zoomToFit",
175
- TOOLBAR_TOGGLE_NOTIFICATION_PANEL: "toggleNotificationPanel"
176
- };
161
+ export const TOOLBAR_STOP = "stop";
162
+ export const TOOLBAR_RUN = "run";
163
+ export const TOOLBAR_UNDO = "undo";
164
+ export const TOOLBAR_REDO = "redo";
165
+ export const TOOLBAR_CUT = "cut";
166
+ export const TOOLBAR_COPY = "copy";
167
+ export const TOOLBAR_PASTE = "paste";
168
+ export const TOOLBAR_CREATE_AUTO_COMMENT = "createAutoComment";
169
+ export const TOOLBAR_DELETE_SELECTED_OBJECTS = "deleteSelectedObjects";
170
+ export const TOOLBAR_ZOOM_IN = "zoomIn";
171
+ export const TOOLBAR_ZOOM_OUT = "zoomOut";
172
+ export const TOOLBAR_ZOOM_FIT = "zoomToFit";
173
+ export const TOOLBAR_ARRANGE_HORIZONALLY = "arrangeHorizontally";
174
+ export const TOOLBAR_ARRANGE_VERTICALLY = "arrangeVertically";
175
+ export const TOOLBAR_TOGGLE_NOTIFICATION_PANEL = "toggleNotificationPanel";
176
+ export const TOOLBAR_OPEN_PALETTE = "paletteOpen";
177
+ export const TOOLBAR_CLOSE_PALETTE = "paletteClose";
177
178
 
178
179
  export const EDIT_ICON =
179
180
  "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\">" +
@@ -34,7 +34,7 @@ export default class LabelUtil {
34
34
 
35
35
  getActionLabel(action, key, substituteObj) {
36
36
  if (this.actionLabelHandler) {
37
- const label = this.actionLabelHandler(action);
37
+ const label = this.actionLabelHandler(action, substituteObj);
38
38
  if (label) {
39
39
  return label;
40
40
  }
@@ -19,42 +19,17 @@
19
19
  import * as d3 from "d3-selection";
20
20
  import { cloneDeep } from "lodash";
21
21
  import SVGCanvasRenderer from "./svg-canvas-renderer.js";
22
- import CanvasUtils from "./common-canvas-utils.js";
23
22
  import ConfigUtils from "../object-model/config-utils.js";
24
23
  import Logger from "../logging/canvas-logger.js";
25
24
 
26
- const BACKSPACE_KEY = 8;
27
- const DELETE_KEY = 46;
28
- const A_KEY = 65;
29
- const C_KEY = 67;
30
- const P_KEY = 80;
31
- const V_KEY = 86;
32
- const X_KEY = 88;
33
- const Y_KEY = 89;
34
- const Z_KEY = 90;
35
- // TODO - Implement nudge behavior for moving nodes and comments
36
- // const LEFT_ARROW_KEY = 37;
37
- // const UP_ARROW_KEY = 38;
38
- // const RIGHT_ARROW_KEY = 39;
39
- // const DOWN_ARROW_KEY = 40;
40
-
41
25
  export default class SVGCanvasD3 {
42
26
 
43
27
  constructor(canvasInfo, canvasDivSelector, config, canvasController) {
44
28
  this.logger = new Logger(["SVGCanvasD3", "FlowId", canvasInfo.id]);
45
29
  this.logger.logStartTimer("constructor");
46
- this.mousePos = {
47
- x: 0,
48
- y: 0
49
- };
50
30
  this.canvasController = canvasController;
51
- this.canvasDiv = this.initializeCanvasDiv(canvasDivSelector);
31
+ this.canvasDiv = d3.select(canvasDivSelector);
52
32
  this.logger.logEndTimer("constructor", true);
53
- document.addEventListener("mousemove", this.onMouseUpdate.bind(this), true);
54
- }
55
-
56
- close() {
57
- document.removeEventListener("mousemove", this.onMouseUpdate, true);
58
33
  }
59
34
 
60
35
  setCanvasInfo(canvasInfo, config) {
@@ -112,92 +87,30 @@ export default class SVGCanvasD3 {
112
87
  return cloneDeep(canvasInfo);
113
88
  }
114
89
 
115
- // Records in mousePos the mouse pointer position when the pointer is inside
116
- // the boundaries of the canvas or sets the mousePos to null. This position
117
- // info can be used with keyboard operations.
118
- onMouseUpdate(e) {
119
- if (e.target.className.baseVal === "svg-area" || e.target.className.baseVal === "d3-svg-background") {
120
- this.mousePos = {
121
- x: e.clientX,
122
- y: e.clientY
123
- };
124
- } else {
125
- this.mousePos = null;
126
- }
90
+ isEditingText() {
91
+ return this.renderer.isEditingText();
127
92
  }
128
93
 
129
- initializeCanvasDiv(canvasDivSelector) {
130
-
131
- // Add a listener to canvas div to catch key presses. The containing
132
- // canvas div must have tabindex set and the focus set on the div.
133
- const canvasDiv = d3.select(canvasDivSelector)
134
- .on("keydown", (d3Event) => {
135
- // Make sure no tip is displayed, because having one displayed
136
- // will interfere with drawing of the canvas as the result of any
137
- // keyboard action.
138
- this.canvasController.closeTip();
139
- const actions = this.canvasController.getKeyboardConfig().actions;
140
- // We don't handle key presses when:
141
- // 1. We are editng text, because the text area needs to receive key
142
- // presses for undo, redo, delete etc.
143
- // 2. Dragging objects
144
- if (this.renderer.isEditingText() ||
145
- this.renderer.isDragging()) {
146
- return;
147
- }
94
+ isDragging() {
95
+ return this.renderer.isDragging();
96
+ }
148
97
 
149
- // These actions alter the canvas objects so we need to check
150
- // this.config.enableEditingActions before calling them.
151
- if (this.config.enableEditingActions) {
152
- if ((d3Event.keyCode === BACKSPACE_KEY || d3Event.keyCode === DELETE_KEY) && actions.delete) {
153
- CanvasUtils.stopPropagationAndPreventDefault(d3Event); // Some browsers interpret Delete as 'Back to previous page'. So prevent that.
154
- this.canvasController.keyboardActionHandler("deleteSelectedObjects");
155
-
156
- } else if (CanvasUtils.isCmndCtrlPressed(d3Event) &&
157
- !d3Event.shiftKey && d3Event.keyCode === Z_KEY && actions.undo) {
158
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
159
- this.canvasController.keyboardActionHandler("undo");
160
-
161
- } else if (CanvasUtils.isCmndCtrlPressed(d3Event) &&
162
- ((d3Event.shiftKey && d3Event.keyCode === Z_KEY) || d3Event.keyCode === Y_KEY && actions.redo)) {
163
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
164
- this.canvasController.keyboardActionHandler("redo");
165
-
166
- } else if (CanvasUtils.isCmndCtrlPressed(d3Event) && d3Event.keyCode === C_KEY && actions.copyToClipboard) {
167
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
168
- this.canvasController.keyboardActionHandler("copy");
169
-
170
- } else if (CanvasUtils.isCmndCtrlPressed(d3Event) && d3Event.keyCode === X_KEY && actions.cutToClipboard) {
171
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
172
- this.canvasController.keyboardActionHandler("cut");
173
-
174
- } else if (CanvasUtils.isCmndCtrlPressed(d3Event) && d3Event.keyCode === V_KEY && actions.pasteFromClipboard) {
175
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
176
- if (this.mousePos) {
177
- this.mousePos = this.renderer.convertPageCoordsToCanvasCoords(this.mousePos.x, this.mousePos.y);
178
- this.mousePos = this.renderer.getMousePosSnapToGrid(this.mousePos);
179
- this.canvasController.keyboardActionHandler("paste", this.mousePos);
180
- } else {
181
- this.canvasController.keyboardActionHandler("paste");
182
- }
183
- }
184
- }
185
- // These last two keyboard actions do not alter the canvas objects so we
186
- // do not need to check this.config.enableEditingActions before calling them.
187
- if (CanvasUtils.isCmndCtrlPressed(d3Event) && d3Event.keyCode === A_KEY && actions.selectAll) {
188
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
189
- this.canvasController.keyboardActionHandler("selectAll");
190
-
191
- } else if (CanvasUtils.isCmndCtrlPressed(d3Event) && d3Event.shiftKey && d3Event.altKey && d3Event.keyCode === P_KEY) {
192
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
193
- Logger.switchLoggingState(); // Switch the logging on and off
194
- }
195
- });
196
- return canvasDiv;
98
+ convertPageCoordsToSnappedCanvasCoords(pos) {
99
+ let positon = this.renderer.convertPageCoordsToCanvasCoords(pos.x, pos.y);
100
+ positon = this.renderer.getMousePosSnapToGrid(positon);
101
+ return positon;
102
+ }
103
+
104
+ nodeTemplateDragStart(nodeTemplate) {
105
+ this.renderer.nodeTemplateDragStart(nodeTemplate);
106
+ }
107
+
108
+ nodeTemplateDragOver(nodeTemplate, x, y) {
109
+ this.renderer.nodeTemplateDragOver(nodeTemplate, x, y);
197
110
  }
198
111
 
199
- nodeTemplateDraggedOver(nodeTemplate, x, y) {
200
- this.renderer.nodeTemplateDraggedOver(nodeTemplate, x, y);
112
+ nodeTemplateDragEnd(nodeTemplate) {
113
+ this.renderer.nodeTemplateDragEnd(nodeTemplate);
201
114
  }
202
115
 
203
116
  nodeTemplateDropped(nodeTemplate, x, y) {