@elyra/canvas 12.44.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 (69) hide show
  1. package/dist/{canvas-constants-69e90162.js → canvas-constants-3bbfc8b1.js} +2 -2
  2. package/dist/{canvas-constants-69e90162.js.map → canvas-constants-3bbfc8b1.js.map} +1 -1
  3. package/dist/{canvas-constants-089e7830.js → canvas-constants-8d240dc6.js} +2 -2
  4. package/dist/{canvas-constants-089e7830.js.map → canvas-constants-8d240dc6.js.map} +1 -1
  5. package/dist/{canvas-controller-3e6b8ce4.js → canvas-controller-a926ab2b.js} +2 -2
  6. package/dist/{canvas-controller-c6274fad.js.map → canvas-controller-a926ab2b.js.map} +1 -1
  7. package/dist/{canvas-controller-c6274fad.js → canvas-controller-e2503333.js} +2 -2
  8. package/dist/{canvas-controller-3e6b8ce4.js.map → canvas-controller-e2503333.js.map} +1 -1
  9. package/dist/common-canvas-41b0454f.js +2 -0
  10. package/dist/common-canvas-41b0454f.js.map +1 -0
  11. package/dist/common-canvas-460a4434.js +2 -0
  12. package/dist/common-canvas-460a4434.js.map +1 -0
  13. package/dist/common-canvas.es.js +1 -1
  14. package/dist/common-canvas.js +1 -1
  15. package/dist/{common-properties-b295acc8.js → common-properties-b25b4855.js} +2 -2
  16. package/dist/{common-properties-b295acc8.js.map → common-properties-b25b4855.js.map} +1 -1
  17. package/dist/{common-properties-88377242.js → common-properties-e262caa2.js} +2 -2
  18. package/dist/{common-properties-88377242.js.map → common-properties-e262caa2.js.map} +1 -1
  19. package/dist/{datarecord-metadata-v3-schema-07d18e19.js → datarecord-metadata-v3-schema-2311ecab.js} +2 -2
  20. package/dist/{datarecord-metadata-v3-schema-07d18e19.js.map → datarecord-metadata-v3-schema-2311ecab.js.map} +1 -1
  21. package/dist/{datarecord-metadata-v3-schema-df939dd1.js → datarecord-metadata-v3-schema-d279dbb0.js} +2 -2
  22. package/dist/{datarecord-metadata-v3-schema-df939dd1.js.map → datarecord-metadata-v3-schema-d279dbb0.js.map} +1 -1
  23. package/dist/{icon-56b27c4f.js → icon-65758bb8.js} +2 -2
  24. package/dist/{icon-56b27c4f.js.map → icon-65758bb8.js.map} +1 -1
  25. package/dist/{icon-8ec2f0ec.js → icon-b3738f1f.js} +2 -2
  26. package/dist/{icon-8ec2f0ec.js.map → icon-b3738f1f.js.map} +1 -1
  27. package/dist/{index-79543d41.js → index-9eeda306.js} +2 -2
  28. package/dist/{index-79543d41.js.map → index-9eeda306.js.map} +1 -1
  29. package/dist/{index-01cbacf9.js → index-d3371fd0.js} +2 -2
  30. package/dist/{index-01cbacf9.js.map → index-d3371fd0.js.map} +1 -1
  31. package/dist/lib/canvas-controller.es.js +1 -1
  32. package/dist/lib/canvas-controller.js +1 -1
  33. package/dist/lib/canvas.es.js +1 -1
  34. package/dist/lib/canvas.js +1 -1
  35. package/dist/lib/command-stack.es.js +1 -1
  36. package/dist/lib/command-stack.es.js.map +1 -1
  37. package/dist/lib/command-stack.js +1 -1
  38. package/dist/lib/command-stack.js.map +1 -1
  39. package/dist/lib/properties/field-picker.es.js +1 -1
  40. package/dist/lib/properties/field-picker.js +1 -1
  41. package/dist/lib/properties.es.js +1 -1
  42. package/dist/lib/properties.js +1 -1
  43. package/dist/styles/common-canvas.min.css +1 -1
  44. package/dist/styles/common-canvas.min.css.map +1 -1
  45. package/dist/{toolbar-6607e35c.js → toolbar-6af353fa.js} +2 -2
  46. package/dist/{toolbar-6607e35c.js.map → toolbar-6af353fa.js.map} +1 -1
  47. package/dist/{toolbar-235dfb9d.js → toolbar-c4e22755.js} +2 -2
  48. package/dist/{toolbar-235dfb9d.js.map → toolbar-c4e22755.js.map} +1 -1
  49. package/locales/command-actions/locales/en.json +1 -0
  50. package/locales/command-actions/locales/eo.json +1 -0
  51. package/package.json +2 -2
  52. package/src/command-actions/sizeAndPositionObjectsAction.js +4 -0
  53. package/src/command-stack/command-stack.js +4 -0
  54. package/src/common-canvas/canvas-controller.js +29 -9
  55. package/src/common-canvas/cc-context-toolbar.jsx +46 -2
  56. package/src/common-canvas/cc-toolbar.jsx +3 -0
  57. package/src/common-canvas/svg-canvas-d3.js +2 -2
  58. package/src/common-canvas/svg-canvas-pipeline.js +1 -1
  59. package/src/common-canvas/svg-canvas-renderer.js +2 -2
  60. package/src/common-canvas/svg-canvas-utils-drag-objects.js +3 -0
  61. package/src/common-canvas/svg-canvas-utils-zoom.js +5 -4
  62. package/src/object-model/object-model.js +1 -1
  63. package/src/toolbar/toolbar.jsx +1 -1
  64. package/src/toolbar/toolbar.scss +28 -31
  65. package/stats.html +1 -1
  66. package/dist/common-canvas-6ed21ab6.js +0 -2
  67. package/dist/common-canvas-6ed21ab6.js.map +0 -1
  68. package/dist/common-canvas-8abf016c.js +0 -2
  69. package/dist/common-canvas-8abf016c.js.map +0 -1
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@elyra/canvas",
3
- "version": "12.44.0",
3
+ "version": "12.45.0",
4
4
  "description": "Elyra common-canvas",
5
5
  "main": "dist/common-canvas.js",
6
6
  "module": "dist/common-canvas.es.js",
7
- "homepage": "https://github.com/elyra-ai/canvas",
7
+ "homepage": "https://elyra-ai.github.io/canvas/",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/elyra-ai/canvas/tree/main/canvas_modules/common-canvas"
@@ -40,6 +40,10 @@ export default class SizeAndPositionObjectsAction extends Action {
40
40
  }
41
41
 
42
42
  getLabel() {
43
+ const com = this.apiPipeline.getComment(this.data.selectedObjectIds[0]);
44
+ if (com) {
45
+ return this.labelUtil.getActionLabel(this, "action.sizeComment");
46
+ }
43
47
  return this.labelUtil.getActionLabel(this, "action.sizeAndPositionObjects");
44
48
  }
45
49
 
@@ -47,6 +47,10 @@ export default class CommandStack {
47
47
  return null;
48
48
  }
49
49
 
50
+ getAllUndoCommands() {
51
+ return this.commands.getUndoCommands().toArray();
52
+ }
53
+
50
54
  // need this for validation on unit tests
51
55
  getStack() {
52
56
  return {
@@ -1385,20 +1385,32 @@ export default class CanvasController {
1385
1385
  }
1386
1386
 
1387
1387
  // Calls the undo() method of the next available command on the command
1388
- // stack that can be undone, if one is available.
1388
+ // stack that can be undone, if one is available. Uses the editActionHandler
1389
+ // method which will cause the app's editActionHandler to be called.
1389
1390
  undo() {
1390
1391
  if (this.canUndo()) {
1391
- this.getCommandStack().undo();
1392
- this.objectModel.refreshToolbar();
1392
+ this.editActionHandler({ editType: "undo", editSource: "controller" });
1393
1393
  }
1394
1394
  }
1395
1395
 
1396
+ // Undoes a number of commands on the command stack as indicated by the
1397
+ // 'count' parameter. If 'count' is bigger than the number of commands
1398
+ // on the stack, all undoable commands currently on the command stack
1399
+ // will be undone. Uses the editActionHandler method which will cause
1400
+ // the app's editActionHandler to be called.
1401
+ undoMulti(count) {
1402
+ for (let i = 0; i < count && this.canUndo(); i++) {
1403
+ this.editActionHandler({ editType: "undo", editSource: "controller" });
1404
+ }
1405
+ }
1406
+
1407
+
1396
1408
  // Calls the redo() method of the next available command on the command
1397
- // stack that can be redone, if one is available.
1409
+ // stack that can be redone, if one is available. Uses the editActionHandler
1410
+ // method which will cause the app's editActionHandler to be called.
1398
1411
  redo() {
1399
1412
  if (this.canRedo()) {
1400
- this.getCommandStack().redo();
1401
- this.objectModel.refreshToolbar();
1413
+ this.editActionHandler({ editType: "redo", editSource: "controller" });
1402
1414
  }
1403
1415
  }
1404
1416
 
@@ -1414,6 +1426,12 @@ export default class CanvasController {
1414
1426
  return this.getCommandStack().canRedo();
1415
1427
  }
1416
1428
 
1429
+ // Returns an array of all undoable commands currently on the
1430
+ // command stack.
1431
+ getAllUndoCommands() {
1432
+ return this.getCommandStack().getAllUndoCommands();
1433
+ }
1434
+
1417
1435
  // Returns a string which is the label that descibes the next undoable
1418
1436
  // command.
1419
1437
  getUndoLabel() {
@@ -1724,11 +1742,13 @@ export default class CanvasController {
1724
1742
  // pixel amount to move. Negative left and positive right
1725
1743
  // y: Is the vertical translate amount which is a number indicating the
1726
1744
  // pixel amount to move. Negative up and positive down.
1727
- // k: is the scale amount which is a number greater than 0 where 1 is the
1745
+ // k: Is the scale amount which is a number greater than 0 where 1 is the
1728
1746
  // default scale size.
1729
- zoomTo(zoomObject) {
1747
+ // animateTime is a number of milliseconds that the animation should take.
1748
+ // It defaults to 500ms. Set to 0 for no animation.
1749
+ zoomTo(zoomObject, animateTime) {
1730
1750
  if (this.canvasContents) {
1731
- this.getSVGCanvasD3().zoomTo(zoomObject);
1751
+ this.getSVGCanvasD3().zoomTo(zoomObject, animateTime);
1732
1752
  }
1733
1753
  }
1734
1754
 
@@ -25,6 +25,8 @@ import ColorPicker from "../color-picker";
25
25
  const CM_TOOLBAR_GAP = 2;
26
26
  const CM_ICON_SIZE = 32;
27
27
  const CM_ICON_PAD = 2;
28
+ const ICON_SIZE_PLUS_GAP = CM_ICON_SIZE + CM_TOOLBAR_GAP;
29
+ const PADDING = 2;
28
30
 
29
31
  class CommonCanvasContextToolbar extends React.Component {
30
32
  constructor(props) {
@@ -162,6 +164,46 @@ class CommonCanvasContextToolbar extends React.Component {
162
164
  !this.props.contextSource.targetObject.is_expanded);
163
165
  }
164
166
 
167
+ // Returns adjusted x, y coordinates for the context menu to ensure it appears
168
+ // fully within the containing div (viewport).
169
+ adjustPosToFit(x, y, width, height) {
170
+ const containingDiv = document.getElementById(this.props.containingDivId);
171
+ const divRect = containingDiv
172
+ ? containingDiv.getBoundingClientRect()
173
+ : { top: -1000, bottom: 1000, left: -1000, right: 1000 }; // To enable Jest tests.
174
+
175
+ const rect = {
176
+ left: 0,
177
+ right: divRect.right - divRect.left,
178
+ top: 0,
179
+ bottom: divRect.bottom - divRect.top
180
+ };
181
+
182
+ let newX = x;
183
+ let newY = y;
184
+
185
+ const rightOver = (x + width) - rect.right;
186
+ const leftOver = rect.left - x;
187
+ const bottomOver = (y + height) - rect.bottom;
188
+ const topOver = rect.top - y;
189
+
190
+ if (rightOver > 0) {
191
+ newX -= rightOver + PADDING;
192
+
193
+ } else if (leftOver > 0) {
194
+ newX += leftOver + PADDING;
195
+ }
196
+
197
+ if (bottomOver > 0) {
198
+ newY -= bottomOver + PADDING;
199
+
200
+ } else if (topOver > 0) {
201
+ newY += topOver + PADDING;
202
+ }
203
+
204
+ return { x: newX, y: newY };
205
+ }
206
+
165
207
  render() {
166
208
  this.logger.log("render");
167
209
 
@@ -177,10 +219,12 @@ class CommonCanvasContextToolbar extends React.Component {
177
219
  // Note: cmPos is already adjusted as a starting point for the context
178
220
  // toolbar position by a calculation in svg-canvas-renderer.js.
179
221
  const pos = this.props.contextSource.cmPos || { x: 0, y: 0 };
180
- const x = this.shouldCenterJustifyToolbar()
222
+ let x = this.shouldCenterJustifyToolbar()
181
223
  ? pos.x - (toolbarWidth / 2)
182
224
  : pos.x - toolbarWidth;
183
- const y = (pos.y - CM_ICON_SIZE) - CM_TOOLBAR_GAP;
225
+ let y = pos.y - ICON_SIZE_PLUS_GAP;
226
+
227
+ ({ x, y } = this.adjustPosToFit(x, y, toolbarWidth, ICON_SIZE_PLUS_GAP));
184
228
 
185
229
  contextToolbar = (
186
230
  <div className={"context-toolbar"} style={{ left: x, top: y, width: toolbarWidth }}
@@ -223,6 +223,7 @@ class CommonCanvasToolbar extends React.Component {
223
223
 
224
224
  if (typeof toolbarConfig !== "undefined") {
225
225
  const editingAllowed = this.props.enableEditingActions;
226
+ this.applyToolState("multiUndo", toolbarConfig, editingAllowed && this.props.canMultiUndo);
226
227
  this.applyToolState("undo", toolbarConfig, editingAllowed && this.props.canUndo);
227
228
  this.applyToolState("redo", toolbarConfig, editingAllowed && this.props.canRedo);
228
229
  this.applyToolState("cut", toolbarConfig, editingAllowed && this.props.canCutCopy);
@@ -326,6 +327,7 @@ CommonCanvasToolbar.propTypes = {
326
327
  notificationConfigKeepOpen: PropTypes.bool,
327
328
  enableInternalObjectModel: PropTypes.bool,
328
329
  enableEditingActions: PropTypes.bool,
330
+ canMultiUndo: PropTypes.bool,
329
331
  canUndo: PropTypes.bool,
330
332
  canRedo: PropTypes.bool,
331
333
  canCutCopy: PropTypes.bool,
@@ -351,6 +353,7 @@ const mapStateToProps = (state, ownProps) => ({
351
353
  notificationMessages: state.notifications,
352
354
  enableInternalObjectModel: state.canvasconfig.enableInternalObjectModel,
353
355
  enableEditingActions: state.canvasconfig.enableEditingActions,
356
+ canMultiUndo: ownProps.canvasController.getAllUndoCommands().length > 1,
354
357
  canUndo: ownProps.canvasController.canUndo(),
355
358
  canRedo: ownProps.canvasController.canRedo(),
356
359
  canCutCopy: ownProps.canvasController.canCutCopy(),
@@ -130,8 +130,8 @@ export default class SVGCanvasD3 {
130
130
  this.renderer.externalObjectDropped(dropData, x, y);
131
131
  }
132
132
 
133
- zoomTo(zoomObject) {
134
- this.renderer.zoomTo(zoomObject);
133
+ zoomTo(zoomObject, animateTime) {
134
+ this.renderer.zoomTo(zoomObject, animateTime);
135
135
  }
136
136
 
137
137
  translateBy(x, y, animateTime) {
@@ -100,7 +100,7 @@ export default class SVGCanvasPipeline {
100
100
  // Returns true if the pipeline is empty except for any binding nodes.
101
101
  isEmptyOrBindingsOnly() {
102
102
  return (isEmpty(this.pipeline.nodes) || this.containsOnlyBindingNodes()) &&
103
- isEmpty(this.pipeline.comments);
103
+ isEmpty(this.pipeline.comments) && isEmpty(this.pipeline.links);
104
104
  }
105
105
 
106
106
  containsOnlyBindingNodes() {
@@ -187,8 +187,8 @@ export default class SVGCanvasRenderer {
187
187
  return this.zoomUtils.isSpaceKeyPressed();
188
188
  }
189
189
 
190
- zoomTo(zoomObject) {
191
- this.zoomUtils.zoomTo(zoomObject);
190
+ zoomTo(zoomObject, animateTime) {
191
+ this.zoomUtils.zoomTo(zoomObject, animateTime);
192
192
  }
193
193
 
194
194
  translateBy(x, y, animateTime) {
@@ -474,6 +474,9 @@ export default class SVGCanvasUtilsDragObjects {
474
474
  detachedLinksInfo: this.nodeSizingDetLinksInfo,
475
475
  pipelineId: this.ren.activePipeline.id
476
476
  });
477
+
478
+ // Clear the objects ready for next sizing action.
479
+ this.nodeSizingObjectsInfo = {};
477
480
  }
478
481
  }
479
482
 
@@ -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.
@@ -648,7 +648,7 @@ export default class ObjectModel {
648
648
  // layout, dimension and supernode binding status info. This uses the redux
649
649
  // layout information.
650
650
  setNodeAttributes(node) {
651
- return setNodeAttributesWithLayout(node, this.getNodeLayout(), this.getCanvasLayout());
651
+ return setNodeAttributesWithLayout(node, this.getNodeLayout(), this.getCanvasLayout(), this.layoutHandler);
652
652
  }
653
653
 
654
654
  // Returns a copy of the comment passed in with position adjusted for
@@ -345,7 +345,7 @@ class Toolbar extends React.Component {
345
345
  const ref = this.findFirstRightItemRefNotOnTopRow();
346
346
 
347
347
  const index = ref === null
348
- ? this.rightBar.length - 1
348
+ ? this.rightBar.length
349
349
  : this.rightBar.findIndex((ri) => ri.action === this.getRefAction(ref));
350
350
 
351
351
  return index;
@@ -103,7 +103,17 @@ $toolbar-divider-width: 1px;
103
103
  background-color: $ui-01;
104
104
  display: inline-block;
105
105
 
106
- & button {
106
+ &.toolbar-item-selected {
107
+ &.default,
108
+ &.ghost {
109
+ & > div > button {
110
+ background-color: $ui-03;
111
+ border-bottom: 2px solid $interactive-01;
112
+ }
113
+ }
114
+ }
115
+
116
+ & > div > button {
107
117
  padding: 0;
108
118
  min-height: 30px;
109
119
  height: $toolbar-button-height;
@@ -111,37 +121,34 @@ $toolbar-divider-width: 1px;
111
121
 
112
122
  &.default,
113
123
  &.ghost {
114
- & button {
124
+ & > div > button {
115
125
  background-color: $ui-01;
116
- }
117
126
 
118
- & button:hover {
119
- background-color: $hover-field;
120
- }
121
-
122
- & button:focus {
123
- background-color: $hover-field;
124
- }
127
+ &:hover,
128
+ &:focus {
129
+ background-color: $hover-field;
130
+ }
125
131
 
126
- & button:disabled:hover {
127
- background-color: $ui-01;
132
+ &:disabled:hover {
133
+ background-color: $ui-01;
134
+ }
128
135
  }
129
136
  }
130
137
 
131
138
  &.tertiary {
132
- & button {
139
+ & > div > button {
133
140
  color: $brand-03;
134
141
  background-color: $ui-01;
135
- }
136
142
 
137
- & button:hover {
138
- background-color: $hover-field;
139
- }
143
+ &:hover {
144
+ background-color: $hover-field;
145
+ }
140
146
 
141
- & button:disabled,
142
- & button:disabled:hover {
143
- color: $disabled-02;
144
- background-color: $ui-01;
147
+ &:disabled,
148
+ &:disabled:hover {
149
+ color: $disabled-02;
150
+ background-color: $ui-01;
151
+ }
145
152
  }
146
153
  }
147
154
  }
@@ -286,16 +293,6 @@ $toolbar-divider-width: 1px;
286
293
  padding: 0;
287
294
  }
288
295
 
289
- .toolbar-item-selected {
290
- &.default,
291
- &.ghost {
292
- & button {
293
- background-color: $ui-03;
294
- border-bottom: 2px solid $interactive-01;
295
- }
296
- }
297
- }
298
-
299
296
  .toolbar-divider {
300
297
  border-right: $toolbar-divider-width solid $ui-03;
301
298
  background-color: $ui-01;