@elyra/canvas 12.14.0 → 12.15.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/_baseForOwn-7d4e8506.js.map +1 -1
  2. package/dist/_baseForOwn-d38b560e.js.map +1 -1
  3. package/dist/canvas-constants-34cdb7df.js.map +1 -1
  4. package/dist/canvas-constants-3c09c7f6.js.map +1 -1
  5. package/dist/canvas-controller-720a509c.js +2 -0
  6. package/dist/canvas-controller-720a509c.js.map +1 -0
  7. package/dist/canvas-controller-73113a1b.js +2 -0
  8. package/dist/canvas-controller-73113a1b.js.map +1 -0
  9. package/dist/common-canvas-21b6ab50.js +2 -0
  10. package/dist/common-canvas-21b6ab50.js.map +1 -0
  11. package/dist/common-canvas-baef2726.js +2 -0
  12. package/dist/common-canvas-baef2726.js.map +1 -0
  13. package/dist/common-canvas.es.js +1 -1
  14. package/dist/common-canvas.es.js.map +1 -1
  15. package/dist/common-canvas.js +1 -1
  16. package/dist/common-canvas.js.map +1 -1
  17. package/dist/{common-properties-6d839df1.js → common-properties-86de4c9f.js} +2 -2
  18. package/dist/{common-properties-40648163.js.map → common-properties-86de4c9f.js.map} +1 -1
  19. package/dist/common-properties-9e579309.js +2 -0
  20. package/dist/{common-properties-6d839df1.js.map → common-properties-9e579309.js.map} +1 -1
  21. package/dist/createClass-32a0cf0f.js.map +1 -1
  22. package/dist/createClass-6db89a23.js.map +1 -1
  23. package/dist/datarecord-metadata-v3-schema-6b6384ff.js.map +1 -1
  24. package/dist/datarecord-metadata-v3-schema-81228a9a.js.map +1 -1
  25. package/dist/en-7a0f1db1.js.map +1 -1
  26. package/dist/en-8647c347.js.map +1 -1
  27. package/dist/extends-1139e06f.js.map +1 -1
  28. package/dist/extends-8d17c85c.js.map +1 -1
  29. package/dist/flexible-table-d3598aa8.js.map +1 -1
  30. package/dist/flexible-table-fe7fbc13.js.map +1 -1
  31. package/dist/getPrototypeOf-a1c3fe64.js.map +1 -1
  32. package/dist/getPrototypeOf-bf88242f.js.map +1 -1
  33. package/dist/index-669f95a7.js.map +1 -1
  34. package/dist/index-6d3404e1.js.map +1 -1
  35. package/dist/isArrayLikeObject-a9c7973b.js.map +1 -1
  36. package/dist/isArrayLikeObject-f3b27f64.js.map +1 -1
  37. package/dist/lib/canvas-controller.es.js +1 -1
  38. package/dist/lib/canvas-controller.js +1 -1
  39. package/dist/lib/canvas.es.js +1 -1
  40. package/dist/lib/canvas.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-29ec7983.js.map +1 -1
  46. package/dist/toolbar-3f4b173f.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/common-canvas/common-canvas-utils.js +37 -4
  49. package/src/common-canvas/svg-canvas-d3.scss +17 -11
  50. package/src/common-canvas/svg-canvas-pipeline.js +10 -3
  51. package/src/common-canvas/svg-canvas-renderer.js +43 -469
  52. package/src/common-canvas/svg-canvas-utils-decs.js +0 -5
  53. package/src/common-canvas/svg-canvas-utils-nodes.js +0 -5
  54. package/src/common-canvas/svg-canvas-utils-textarea.js +472 -0
  55. package/src/common-properties/components/title-editor/title-editor.jsx +2 -2
  56. package/src/common-properties/components/title-editor/title-editor.scss +1 -16
  57. package/src/object-model/layout-dimensions.js +4 -2
  58. package/src/palette/palette-flyout-content-category.jsx +73 -42
  59. package/src/palette/palette.scss +1 -1
  60. package/stats.html +1 -1
  61. package/dist/canvas-controller-8e2bb291.js +0 -2
  62. package/dist/canvas-controller-8e2bb291.js.map +0 -1
  63. package/dist/canvas-controller-bd0d8d59.js +0 -2
  64. package/dist/canvas-controller-bd0d8d59.js.map +0 -1
  65. package/dist/common-canvas-69fe4a67.js +0 -2
  66. package/dist/common-canvas-69fe4a67.js.map +0 -1
  67. package/dist/common-canvas-f5e4af65.js +0 -2
  68. package/dist/common-canvas-f5e4af65.js.map +0 -1
  69. package/dist/common-properties-40648163.js +0 -2
@@ -32,8 +32,7 @@ const markdownIt = require("markdown-it")({
32
32
  typographer: true
33
33
  });
34
34
 
35
- import { cloneDeep, escape as escapeText, forOwn, get,
36
- unescape as unescapeText } from "lodash";
35
+ import { cloneDeep, escape as escapeText, forOwn, get } from "lodash";
37
36
  import { ASSOC_RIGHT_SIDE_CURVE, ASSOCIATION_LINK, NODE_LINK, COMMENT_LINK,
38
37
  ASSOC_VAR_CURVE_LEFT, ASSOC_VAR_CURVE_RIGHT, ASSOC_VAR_DOUBLE_BACK_RIGHT,
39
38
  LINK_TYPE_CURVE, LINK_TYPE_ELBOW, LINK_TYPE_STRAIGHT,
@@ -56,33 +55,11 @@ import SvgCanvasNodes from "./svg-canvas-utils-nodes.js";
56
55
  import SvgCanvasComments from "./svg-canvas-utils-comments.js";
57
56
  import SvgCanvasLinks from "./svg-canvas-utils-links.js";
58
57
  import SvgCanvasDecs from "./svg-canvas-utils-decs.js";
59
- import SvgCanvasMarkdown from "./svg-canvas-utils-markdown.js";
58
+ import SvgCanvasTextArea from "./svg-canvas-utils-textarea.js";
60
59
  import SVGCanvasPipeline from "./svg-canvas-pipeline";
61
60
 
62
-
63
61
  const showLinksTime = false;
64
62
 
65
- const BACKSPACE_KEY = 8;
66
- const RETURN_KEY = 13;
67
- const ESC_KEY = 27;
68
- const LEFT_ARROW_KEY = 37;
69
- const UP_ARROW_KEY = 38;
70
- const RIGHT_ARROW_KEY = 39;
71
- const DOWN_ARROW_KEY = 40;
72
- const DELETE_KEY = 46;
73
- const A_KEY = 65;
74
- const B_KEY = 66;
75
- const E_KEY = 69;
76
- const I_KEY = 73;
77
- const K_KEY = 75;
78
- const X_KEY = 88;
79
- const LAB_KEY = 188; // Left angle bracket <
80
- const RAB_KEY = 190; // Right angle bracket >
81
- const SEVEN_KEY = 55;
82
- const EIGHT_KEY = 56;
83
-
84
- const SCROLL_PADDING = 12;
85
-
86
63
  const NINETY_DEGREES = 90;
87
64
 
88
65
  const INPUT_TYPE = "input_type";
@@ -116,6 +93,18 @@ export default class SVGCanvasRenderer {
116
93
  this.commentUtils = new SvgCanvasComments();
117
94
  this.linkUtils = new SvgCanvasLinks(this.config, this.canvasLayout, this.nodeUtils, this.commentUtils);
118
95
  this.decUtils = new SvgCanvasDecs(this.canvasLayout);
96
+ this.svgCanvasTextArea = new SvgCanvasTextArea(
97
+ this.config,
98
+ this.dispUtils,
99
+ this.nodeUtils,
100
+ this.decUtils,
101
+ this.canvasController,
102
+ this.canvasDiv,
103
+ this.activePipeline,
104
+ this.displayComments.bind(this), // Function
105
+ this.displayLinks.bind(this), // Function
106
+ this.getCommentToolbarPos.bind(this) // Function
107
+ );
119
108
 
120
109
  this.dispUtils.setDisplayState();
121
110
  this.logger.log(this.dispUtils.getDisplayStateMsg());
@@ -134,8 +123,8 @@ export default class SVGCanvasRenderer {
134
123
  // Allows us to track the sizing behavior of nodes
135
124
  this.nodeSizing = false;
136
125
  this.nodeSizingDirection = "";
137
- this.nodeSizingObjectsInfo = [];
138
- this.nodeSizingDetLinksInfo = [];
126
+ this.nodeSizingObjectsInfo = {};
127
+ this.nodeSizingDetLinksInfo = {};
139
128
 
140
129
  // Keeps track of the size and position, at the start of the sizing event,
141
130
  // of the object (node or comment) being sized.
@@ -148,10 +137,6 @@ export default class SVGCanvasRenderer {
148
137
  this.notSnappedWidth = 0;
149
138
  this.notSnappedHeight = 0;
150
139
 
151
- // Allows us to track the editing of text (either comments or node labels)
152
- this.editingText = false;
153
- this.editingTextId = "";
154
-
155
140
  // Allows us to record the drag behavior or nodes and comments.
156
141
  this.dragging = false;
157
142
  this.dragOffsetX = 0;
@@ -323,7 +308,7 @@ export default class SVGCanvasRenderer {
323
308
  setCanvasInfoRenderer(canvasInfo) {
324
309
  this.logger.logStartTimer("setCanvasInfoRenderer" + this.pipelineId.substring(0, 5));
325
310
  this.canvasInfo = canvasInfo;
326
- this.activePipeline = new SVGCanvasPipeline(this.pipelineId, canvasInfo);
311
+ this.activePipeline.initialize(this.pipelineId, canvasInfo);
327
312
  this.canvasLayout = this.objectModel.getCanvasLayout(); // Refresh the canvas layout info in case it changed.
328
313
 
329
314
  // Set the display state incase we changed from in-place to full-page
@@ -618,7 +603,7 @@ export default class SVGCanvasRenderer {
618
603
 
619
604
  // Returns true when we are editing text. Called by svg-canvas-d3.
620
605
  isEditingText() {
621
- if (this.editingText) {
606
+ if (this.svgCanvasTextArea.isEditingText()) {
622
607
  return true;
623
608
  }
624
609
  let state = false;
@@ -877,7 +862,7 @@ export default class SVGCanvasRenderer {
877
862
  .attr("y", this.nodeUtils.getNodeLabelPosY(node))
878
863
  .attr("width", this.nodeUtils.getNodeLabelWidth(node))
879
864
  .attr("height", this.nodeUtils.getNodeLabelHeight(node))
880
- .attr("class", this.nodeUtils.getNodeLabelForeignClass(node));
865
+ .attr("class", "d3-foreign-object-ghost-label");
881
866
 
882
867
  const fObjectDiv = fObject
883
868
  .append("xhtml:div")
@@ -1897,7 +1882,7 @@ export default class SVGCanvasRenderer {
1897
1882
  this.isSelecting = true;
1898
1883
 
1899
1884
  // Ensure the link objects in the active pipeline have their coordinate
1900
- // positions set. The coords might be set if the last object model
1885
+ // positions set. The coords might not be set if the last object model
1901
1886
  // update was a change in selections or some other operation that does
1902
1887
  // not redraw link lines.
1903
1888
  this.buildLinksArray();
@@ -1970,9 +1955,11 @@ export default class SVGCanvasRenderer {
1970
1955
  // Repositions the comment toolbar so it is always over the top of the
1971
1956
  // comment being edited.
1972
1957
  zoomCommentToolbar() {
1973
- if (this.config.enableMarkdownInComments && this.dispUtils.isDisplayingFullPage()) {
1958
+ if (this.config.enableMarkdownInComments &&
1959
+ this.dispUtils.isDisplayingFullPage() &&
1960
+ this.svgCanvasTextArea.isEditingText()) {
1974
1961
  // If a node label or text decoration is being edited com will be undefined.
1975
- const com = this.activePipeline.getComment(this.editingTextId);
1962
+ const com = this.activePipeline.getComment(this.svgCanvasTextArea.getEditingTextId());
1976
1963
  if (com) {
1977
1964
  const pos = this.getCommentToolbarPos(com);
1978
1965
  this.canvasController.moveTextToolbar(pos.x, pos.y);
@@ -2595,7 +2582,7 @@ export default class SVGCanvasRenderer {
2595
2582
  // Node Label
2596
2583
  newNodeGroups.filter((d) => !CanvasUtils.isSuperBindingNode(d))
2597
2584
  .append("foreignObject")
2598
- .attr("class", "d3-foreign-object")
2585
+ .attr("class", "d3-foreign-object-node-label")
2599
2586
  .call(this.attachNodeLabelListeners.bind(this))
2600
2587
  .append("xhtml:div") // Provide a namespace when div is inside foreignObject
2601
2588
  .append("xhtml:span") // Provide a namespace when span is inside foreignObject
@@ -2638,13 +2625,12 @@ export default class SVGCanvasRenderer {
2638
2625
  .attr("style", (d) => this.getNodeImageStyle(d, "default"));
2639
2626
 
2640
2627
  // Node Label
2641
- joinedNodeGrps.selectChildren(".d3-foreign-object")
2628
+ joinedNodeGrps.selectChildren(".d3-foreign-object-node-label")
2642
2629
  .datum((d) => this.activePipeline.getNode(d.id))
2643
2630
  .attr("x", (d) => this.nodeUtils.getNodeLabelPosX(d))
2644
2631
  .attr("y", (d) => this.nodeUtils.getNodeLabelPosY(d))
2645
2632
  .attr("width", (d) => this.nodeUtils.getNodeLabelWidth(d))
2646
2633
  .attr("height", (d) => this.nodeUtils.getNodeLabelHeight(d))
2647
- .attr("class", (d) => this.nodeUtils.getNodeLabelForeignClass(d))
2648
2634
  .select("div")
2649
2635
  .attr("class", (d) => this.nodeUtils.getNodeLabelClass(d))
2650
2636
  .attr("style", (d) => this.getNodeLabelStyle(d, "default"))
@@ -3382,7 +3368,7 @@ export default class SVGCanvasRenderer {
3382
3368
  if (labelSel.empty()) {
3383
3369
  labelSel = decSel
3384
3370
  .append("foreignObject")
3385
- .attr("class", this.decUtils.getDecLabelForeignClass(dec))
3371
+ .attr("class", "d3-foreign-object-dec-label")
3386
3372
  .attr("x", 0)
3387
3373
  .attr("y", 0)
3388
3374
  .call(this.attachDecLabelListeners.bind(this, d, objType));
@@ -4537,13 +4523,6 @@ export default class SVGCanvasRenderer {
4537
4523
  return this.getNodePortIdForElement(portElement);
4538
4524
  }
4539
4525
 
4540
- // Returns an element, with the class name passed in, if one exists, at the
4541
- // position defined by x,y.
4542
- getElementAtPoint(x, y, className) {
4543
- const elements = document.elementsFromPoint(x, y);
4544
- return elements.find((el) => this.isClassNameIncluded(el, className));
4545
- }
4546
-
4547
4526
  // Returns a DOM element which either has the classNames passed in or
4548
4527
  // has an ancestor with the className passed in, at the position
4549
4528
  // indicated by the clientX and clientY coordinates in the d3Event.
@@ -4560,44 +4539,12 @@ export default class SVGCanvasRenderer {
4560
4539
  let foundElement = null;
4561
4540
  let count = 0;
4562
4541
  while (!foundElement && count < elements.length) {
4563
- foundElement = this.getParentElementWithClass(elements[count], className);
4542
+ foundElement = CanvasUtils.getParentElementWithClass(elements[count], className);
4564
4543
  count++;
4565
4544
  }
4566
4545
  return foundElement;
4567
4546
  }
4568
4547
 
4569
- // Returns the element passed in, or an ancestor of the element, if either
4570
- // contains the classNames passed in. Otherwise it returns null if the
4571
- // className cannot be found. For example, if this element is a child of the
4572
- // node group object and "d3-node-group" is passed in, this function will
4573
- // find the group element.
4574
- getParentElementWithClass(element, className) {
4575
- let el = element;
4576
- let foundElement = null;
4577
-
4578
- while (el) {
4579
- // No need to proceed if we find either of these. Stopping at svg-area
4580
- // prevents the search transitioning from a sub-flow to a parent flow.
4581
- if (this.isClassNameIncluded(el, "d3-new-connection-guide") ||
4582
- this.isClassNameIncluded(el, "svg-area")) {
4583
- el = null;
4584
-
4585
- } else if (this.isClassNameIncluded(el, className)) {
4586
- foundElement = el;
4587
- el = null;
4588
- } else {
4589
- el = el.parentNode;
4590
- }
4591
- }
4592
- return foundElement;
4593
- }
4594
-
4595
- // Returns true if the class name passed in is one of the classes assigned
4596
- // to the element passed in.
4597
- isClassNameIncluded(el, className) {
4598
- return el.classList && el.classList.contains(className);
4599
- }
4600
-
4601
4548
  // Returns the node link object from the canvasInfo corresponding to the
4602
4549
  // element passed in provided it is a 'path' DOM object. Returns null if
4603
4550
  // a link cannot be found.
@@ -5114,7 +5061,7 @@ export default class SVGCanvasRenderer {
5114
5061
  // Comment Text
5115
5062
  newCommentGroups
5116
5063
  .append("foreignObject")
5117
- .attr("class", "d3-foreign-object")
5064
+ .attr("class", "d3-foreign-object-comment-text")
5118
5065
  .attr("x", 0)
5119
5066
  .attr("y", 0)
5120
5067
  .append("xhtml:div") // Provide a namespace when div is inside foreignObject
@@ -5156,7 +5103,7 @@ export default class SVGCanvasRenderer {
5156
5103
  .attr("style", (c) => this.getCommentBodyStyle(c, "default"));
5157
5104
 
5158
5105
  // Comment Text
5159
- joinedCommentGrps.selectChildren(".d3-foreign-object")
5106
+ joinedCommentGrps.selectChildren(".d3-foreign-object-comment-text")
5160
5107
  .datum((c) => this.activePipeline.getComment(c.id))
5161
5108
  .attr("width", (c) => c.width)
5162
5109
  .attr("height", (c) => c.height)
@@ -5173,7 +5120,7 @@ export default class SVGCanvasRenderer {
5173
5120
  commentGrps
5174
5121
  .on("mouseenter", (d3Event, d) => {
5175
5122
  this.setCommentStyles(d, "hover", d3.select(d3Event.currentTarget));
5176
- if (this.config.enableEditingActions && d.id !== this.editingTextId) {
5123
+ if (this.config.enableEditingActions && d.id !== this.svgCanvasTextArea.getEditingTextId()) {
5177
5124
  this.createCommentPort(d3Event.currentTarget, d);
5178
5125
  }
5179
5126
  })
@@ -5302,7 +5249,7 @@ export default class SVGCanvasRenderer {
5302
5249
 
5303
5250
  setCommentTextStyles(d, type, comGrp) {
5304
5251
  const style = this.getCommentTextStyle(d, type);
5305
- comGrp.selectChildren(".d3-foreign-object").select("div")
5252
+ comGrp.selectChildren(".d3-foreign-object-comment-text").select("div")
5306
5253
  .attr("style", style);
5307
5254
  }
5308
5255
 
@@ -5318,387 +5265,16 @@ export default class SVGCanvasRenderer {
5318
5265
  return CanvasUtils.getObjectStyle(d, "text", type);
5319
5266
  }
5320
5267
 
5321
- displayCommentTextArea(d, parentDomObj) {
5322
- this.editingTextData = {
5323
- id: d.id,
5324
- text: d.content,
5325
- singleLine: false,
5326
- maxCharacters: null,
5327
- allowReturnKey: true,
5328
- textCanBeEmpty: true,
5329
- xPos: 0,
5330
- yPos: 0,
5331
- width: d.width,
5332
- height: d.height,
5333
- className: "d3-comment-entry",
5334
- parentDomObj: parentDomObj,
5335
- keyboardInputCallback: this.config.enableMarkdownInComments ? this.commentKeyboardHandler.bind(this) : null,
5336
- autoSizeCallback: this.autoSizeComment.bind(this),
5337
- saveTextChangesCallback: this.saveCommentChanges.bind(this),
5338
- closeTextAreaCallback: this.closeCommentTextArea.bind(this)
5339
- };
5340
- this.displayTextArea(this.editingTextData);
5341
- if (this.config.enableMarkdownInComments && this.dispUtils.isDisplayingFullPage()) {
5342
- const pos = this.getCommentToolbarPos(d);
5343
- this.canvasController.openTextToolbar(pos.x, pos.y,
5344
- this.markdownActionHandler.bind(this),
5345
- this.blurInTextToolbar.bind(this));
5346
- }
5347
- }
5348
-
5349
- // Handles markdown actions initiated through the keyboard.
5350
- commentKeyboardHandler(d3Event) {
5351
- const action = this.getMarkdownAction(d3Event);
5352
- if (action) {
5353
- if (action !== "return") {
5354
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
5355
- }
5356
- this.markdownActionHandler(action, d3Event);
5357
- }
5358
- }
5359
-
5360
- // Called when the blur event occurs for the text toolbar.
5361
- blurInTextToolbar(evt) {
5362
- // When Cypress tests are running a call to focus() in addTextToTextArea()
5363
- // can cause an incorrect blur event to be generated for the text toolbar
5364
- // (where relatedTarget is null). This flag therefore allows us to avoid
5365
- // thus blue events that occur while addTextToTextArea() is executing.
5366
- if (this.addingTextToTextArea) {
5367
- return;
5368
- }
5369
-
5370
- // If there is a relatedTarget and it is set to one of the elements for the
5371
- // textarea, texttoolbar, etc we ignore the blur event.
5372
- if (evt.relatedTarget &&
5373
- (this.getParentElementWithClass(evt.relatedTarget, "d3-comment-entry") ||
5374
- this.getParentElementWithClass(evt.relatedTarget, "text-toolbar") ||
5375
- this.getParentElementWithClass(evt.relatedTarget, "bx--overflow-menu-options__btn"))) {
5376
- return;
5377
- }
5378
-
5379
- // If the blur event is ocurring for an object outside of the textarea and
5380
- // text toolbar we save the current text and close the textarea.
5381
- const commentParent = d3.select(this.editingTextData.parentDomObj);
5382
- const foreignObject = commentParent.selectAll(".d3-text-entry-fo");
5383
- const commentEntry = this.canvasDiv.selectAll(".d3-comment-entry");
5384
- const commentEntryElement = commentEntry.node();
5385
- this.saveAndCloseTextArea(foreignObject, this.editingTextData, commentEntryElement.value, evt);
5386
- }
5387
-
5388
- // Applies a markdown action to the comment text being edited using
5389
- // the same commands as the toolbar.
5390
- getMarkdownAction(d3Event) {
5391
- if (CanvasUtils.isCmndCtrlPressed(d3Event)) {
5392
- switch (d3Event.keyCode) {
5393
- case B_KEY: return "bold";
5394
- case I_KEY: return "italics";
5395
- case X_KEY: return d3Event.shiftKey ? "strikethrough" : null;
5396
- case SEVEN_KEY: return d3Event.shiftKey ? "numberedList" : null;
5397
- case EIGHT_KEY: return d3Event.shiftKey ? "bulletedList" : null;
5398
- case E_KEY: return "code";
5399
- case K_KEY: return "link";
5400
- case LAB_KEY: return "decreaseHashes";
5401
- case RAB_KEY: return d3Event.shiftKey ? "quote" : "increaseHashes";
5402
- default:
5403
- }
5404
- } else if (d3Event.keyCode === RETURN_KEY) {
5405
- return "return";
5406
- }
5407
-
5408
- return null;
5409
- }
5410
-
5411
- // Handles any actions requested on the comment text to add markdown
5412
- // characters to the text. evt can be either a d3Event object from D3 when
5413
- // this method is called from keyboard entry in the textarea or it can be
5414
- // a synthetic event object from React when called from the text toolbar.
5415
- markdownActionHandler(action, evt) {
5416
- this.logger.log("markdownActionHandler - action = " + action);
5417
-
5418
- const commentEntry = this.canvasDiv.selectAll(".d3-comment-entry");
5419
- const commentEntryElement = commentEntry.node();
5420
- const start = commentEntryElement.selectionStart;
5421
- const end = commentEntryElement.selectionEnd;
5422
- const text = commentEntryElement.value;
5423
-
5424
- const mdObj = SvgCanvasMarkdown.processMarkdownAction(action, text, start, end);
5425
- if (mdObj) {
5426
- CanvasUtils.stopPropagationAndPreventDefault(evt);
5427
- this.addTextToTextArea(mdObj, commentEntryElement);
5428
- }
5429
- }
5430
-
5431
- // Replaces the text in the currently displayed textarea with the text
5432
- // passed in. We use execCommand because this adds the inserted text to the
5433
- // textarea's undo/redo stack whereas setting the text directly into the
5434
- // textarea control does not.
5435
- addTextToTextArea(mdObj, commentEntryElement) {
5436
- this.addingTextToTextArea = true;
5437
- const text = unescapeText(mdObj.newText);
5438
- commentEntryElement.focus();
5439
- commentEntryElement.select();
5440
- document.execCommand("insertText", false, text);
5441
- commentEntryElement.setSelectionRange(mdObj.newStart, mdObj.newEnd);
5442
- this.addingTextToTextArea = false;
5443
- }
5444
-
5445
- autoSizeComment(textArea, foreignObject, data) {
5446
- this.logger.log("autoSizeComment - textAreaHt = " + this.textAreaHeight + " scroll ht = " + textArea.scrollHeight);
5447
-
5448
- const scrollHeight = textArea.scrollHeight + SCROLL_PADDING;
5449
- if (this.textAreaHeight < scrollHeight) {
5450
- this.textAreaHeight = scrollHeight;
5451
- foreignObject.style("height", this.textAreaHeight + "px");
5452
- this.activePipeline.getComment(data.id).height = this.textAreaHeight;
5453
- this.displayComments();
5454
- this.displayLinks();
5455
- }
5456
- }
5457
-
5458
- saveCommentChanges(id, newText, newHeight) {
5459
- const comment = this.activePipeline.getComment(id);
5460
- const data = {
5461
- editType: "editComment",
5462
- editSource: "canvas",
5463
- id: comment.id,
5464
- content: newText,
5465
- width: comment.width,
5466
- height: newHeight,
5467
- x_pos: comment.x_pos,
5468
- y_pos: comment.y_pos,
5469
- pipelineId: this.activePipeline.id
5470
- };
5471
- this.canvasController.editActionHandler(data);
5472
- }
5473
-
5474
- closeCommentTextArea() {
5475
- this.canvasController.closeTextToolbar();
5268
+ displayCommentTextArea(comment, parentDomObj) {
5269
+ this.svgCanvasTextArea.displayCommentTextArea(comment, parentDomObj);
5476
5270
  }
5477
5271
 
5478
5272
  displayNodeLabelTextArea(node, parentDomObj) {
5479
- d3.select(parentDomObj).selectAll("div")
5480
- .attr("style", "display:none;");
5481
- this.displayTextArea({
5482
- id: node.id,
5483
- text: node.label,
5484
- singleLine: node.layout.labelSingleLine,
5485
- maxCharacters: node.layout.labelMaxCharacters,
5486
- allowReturnKey: node.layout.labelAllowReturnKey,
5487
- textCanBeEmpty: false,
5488
- xPos: this.nodeUtils.getNodeLabelTextAreaPosX(node),
5489
- yPos: this.nodeUtils.getNodeLabelTextAreaPosY(node),
5490
- width: this.nodeUtils.getNodeLabelTextAreaWidth(node),
5491
- height: this.nodeUtils.getNodeLabelTextAreaHeight(node),
5492
- className: this.nodeUtils.getNodeLabelTextAreaClass(node),
5493
- parentDomObj: parentDomObj,
5494
- autoSizeCallback: this.autoSizeMultiLineLabel.bind(this),
5495
- saveTextChangesCallback: this.saveNodeLabelChanges.bind(this),
5496
- closeTextAreaCallback: this.closeNodeLabelTextArea.bind(this)
5497
- });
5498
- }
5499
-
5500
- // Increases the size of the editable multi-line text area for a label based
5501
- // on the characters entered, and also ensures the maximum number of
5502
- // characters for the label, if one is provided, is not exceeded.
5503
- // This callback works for editable multi-line node labels and also
5504
- // editable multi-line text decorations for either nodes or links.
5505
- autoSizeMultiLineLabel(textArea, foreignObject, data) {
5506
- this.logger.log("autoSizeNodeLabel - textAreaHt = " + this.textAreaHeight + " scroll ht = " + textArea.scrollHeight);
5507
-
5508
- // Restrict max characters in case text was pasted in to the text area.
5509
- if (data.maxCharacters &&
5510
- textArea.value.length > data.maxCharacters) {
5511
- textArea.value = textArea.value.substring(0, data.maxCharacters);
5512
- }
5513
- // Temporarily set the height to zero so the scrollHeight will get set to
5514
- // the full height of the text in the textarea. This allows us to close up
5515
- // the text area when the lines of text reduce.
5516
- foreignObject.style("height", 0);
5517
- const scrollHeight = textArea.scrollHeight + SCROLL_PADDING;
5518
- this.textAreaHeight = scrollHeight;
5519
- foreignObject.style("height", this.textAreaHeight + "px");
5273
+ this.svgCanvasTextArea.displayNodeLabelTextArea(node, parentDomObj);
5520
5274
  }
5521
5275
 
5522
- saveNodeLabelChanges(id, newText, newHeight, taData) {
5523
- const data = {
5524
- editType: "setNodeLabel",
5525
- editSource: "canvas",
5526
- nodeId: id,
5527
- label: newText,
5528
- pipelineId: this.activePipeline.id
5529
- };
5530
- this.canvasController.editActionHandler(data);
5531
- }
5532
-
5533
- // Called when the node label text area is closed. Sets the style of the
5534
- // div for the node label so the label is displayed (because it was hidden
5535
- // when the text area opened).
5536
- closeNodeLabelTextArea(nodeId) {
5537
- this.getNodeGroupSelectionById(nodeId)
5538
- .selectAll("div")
5539
- .attr("style", null);
5540
- }
5541
-
5542
- // Displays a text area for an editable text decoration on either a node
5543
- // or link.
5544
5276
  displayDecLabelTextArea(dec, obj, objType, parentDomObj) {
5545
- this.displayTextArea({
5546
- id: dec.id,
5547
- text: dec.label,
5548
- singleLine: dec.label_single_line || true,
5549
- maxCharacters: dec.label_max_characters || null,
5550
- allowReturnKey: dec.label_allow_return_key || false,
5551
- textCanBeEmpty: false,
5552
- xPos: this.decUtils.getDecLabelTextAreaPosX(),
5553
- yPos: this.decUtils.getDecLabelTextAreaPosY(),
5554
- width: this.decUtils.getDecLabelTextAreaWidth(dec, obj, objType),
5555
- height: this.decUtils.getDecLabelTextAreaHeight(dec, obj, objType),
5556
- className: this.decUtils.getDecLabelTextAreaClass(dec),
5557
- parentDomObj: parentDomObj,
5558
- objId: obj.id,
5559
- objType: objType,
5560
- autoSizeCallback: this.autoSizeMultiLineLabel.bind(this),
5561
- saveTextChangesCallback: this.saveDecLabelChanges.bind(this),
5562
- closeTextAreaCallback: null
5563
- });
5564
- }
5565
-
5566
- // Handles saved changes to editable text decorations.
5567
- saveDecLabelChanges(id, newText, newHeight, taData) {
5568
- const data = {
5569
- editType: "editDecorationLabel",
5570
- editSource: "canvas",
5571
- decId: id,
5572
- objId: taData.objId,
5573
- objType: taData.objType,
5574
- label: newText,
5575
- pipelineId: this.activePipeline.id
5576
- };
5577
- this.canvasController.editActionHandler(data);
5578
- }
5579
-
5580
- // Displays a text area to allow text entry and editing for: comments;
5581
- // node labels; or text decorations on either a node or link.
5582
- displayTextArea(data) {
5583
- const that = this;
5584
-
5585
- this.textAreaHeight = data.height; // Save for comparison during auto-resize
5586
- this.editingText = true;
5587
- this.editingTextId = data.id;
5588
-
5589
- const foreignObject = d3.select(data.parentDomObj)
5590
- .append("foreignObject")
5591
- .attr("class", "d3-foreign-object d3-text-entry-fo")
5592
- .attr("width", data.width)
5593
- .attr("height", data.height)
5594
- .attr("x", data.xPos)
5595
- .attr("y", data.yPos);
5596
-
5597
- const textArea = foreignObject
5598
- .append("xhtml:textarea")
5599
- .attr("class", data.className)
5600
- .text(unescapeText(data.text))
5601
- .on("keydown", function(d3Event) {
5602
- // Don't accept return key press when text is all on one line or
5603
- // if application doesn't want line feeds inserted in the label.
5604
- if ((data.singleLine || !data.allowReturnKey) &&
5605
- d3Event.keyCode === RETURN_KEY) {
5606
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
5607
- }
5608
- if (d3Event.keyCode === ESC_KEY) {
5609
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
5610
- that.textAreaEscKeyPressed = true;
5611
- that.closeTextArea(foreignObject, data);
5612
- }
5613
- if (data.maxCharacters &&
5614
- this.value.length >= data.maxCharacters &&
5615
- !that.textAreaAllowedKeys(d3Event)) {
5616
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
5617
- }
5618
- // Call any specific keyboard handler for the type of
5619
- // text being edited.
5620
- if (data.keyboardInputCallback) {
5621
- data.keyboardInputCallback(d3Event);
5622
- }
5623
- })
5624
- .on("keyup", function(d3Event) {
5625
- data.autoSizeCallback(this, foreignObject, data);
5626
- })
5627
- .on("paste", function() {
5628
- that.logger.log("Text area - Paste - Scroll Ht = " + this.scrollHeight);
5629
- // Allow some time for pasted text (from context menu) to be
5630
- // loaded into the text area. Otherwise the text is not there
5631
- // and the auto size does not increase the height correctly.
5632
- setTimeout(data.autoSizeCallback, 500, this, foreignObject, data);
5633
- })
5634
- .on("blur", function(d3Event, d) {
5635
- that.logger.log("Text area - blur");
5636
- // If the esc key was pressed to cause the blur event just return
5637
- // so label returns to what it was before editing started.
5638
- if (that.textAreaEscKeyPressed) {
5639
- that.textAreaEscKeyPressed = false;
5640
- return;
5641
- }
5642
-
5643
- // If the user clicked on an element in the text toolbar to cause the
5644
- // blur event, just return.
5645
- if (d3Event.relatedTarget && that.getParentElementWithClass(d3Event.relatedTarget, "text-toolbar")) {
5646
- return;
5647
- }
5648
-
5649
- that.saveAndCloseTextArea(foreignObject, data, this.value, d3Event);
5650
- })
5651
- .on("focus", function(d3Event, d) {
5652
- that.logger.log("Text area - focus");
5653
- data.autoSizeCallback(this, foreignObject, data);
5654
- })
5655
- .on("mousedown click dblclick contextmenu", (d3Event, d) => {
5656
- d3Event.stopPropagation(); // Allow default behavior to show system contenxt menu
5657
- });
5658
-
5659
- textArea.node().focus();
5660
-
5661
- // Set the cusrsor to the end of the text.
5662
- textArea.node().setSelectionRange(data.text.length, data.text.length);
5663
- }
5664
-
5665
- saveAndCloseTextArea(foreignObject, data, newValue, d3Event) {
5666
- // If there is no text for the label and textCanBeEmpty is false
5667
- // just return, so label returns to what it was before editing started.
5668
- if (!newValue && !data.textCanBeEmpty) {
5669
- CanvasUtils.stopPropagationAndPreventDefault(d3Event);
5670
- this.closeTextArea(foreignObject, data);
5671
- return;
5672
- }
5673
- const newText = newValue; // Save the text before closing the foreign object
5674
- this.closeTextArea(foreignObject, data);
5675
- if (data.text !== newText) {
5676
- this.isCommentBeingUpdated = true;
5677
- data.saveTextChangesCallback(data.id, newText, this.textAreaHeight, data);
5678
- this.isCommentBeingUpdatd = false;
5679
- }
5680
- }
5681
-
5682
- // Closes the text area and resets the flags.
5683
- closeTextArea(foreignObject, data) {
5684
- if (data.closeTextAreaCallback) {
5685
- data.closeTextAreaCallback(data.id);
5686
- }
5687
- foreignObject.remove();
5688
- this.editingText = false;
5689
- this.editingTextId = "";
5690
- }
5691
-
5692
- // Returns true if one of the keys that are allowed in the text area, when
5693
- // checking for maximum characters, has been pressed.
5694
- textAreaAllowedKeys(d3Event) {
5695
- return d3Event.keyCode === DELETE_KEY ||
5696
- d3Event.keyCode === BACKSPACE_KEY ||
5697
- d3Event.keyCode === LEFT_ARROW_KEY ||
5698
- d3Event.keyCode === RIGHT_ARROW_KEY ||
5699
- d3Event.keyCode === UP_ARROW_KEY ||
5700
- d3Event.keyCode === DOWN_ARROW_KEY ||
5701
- (d3Event.keyCode === A_KEY && CanvasUtils.isCmndCtrlPressed(d3Event));
5277
+ this.svgCanvasTextArea.displayDecLabelTextArea(dec, obj, objType, parentDomObj);
5702
5278
  }
5703
5279
 
5704
5280
  // Adds a rectangle over the top of the canvas which is used to display a
@@ -6018,8 +5594,8 @@ export default class SVGCanvasRenderer {
6018
5594
  });
6019
5595
  }
6020
5596
  this.nodeSizing = false;
6021
- this.nodeSizingObjectsInfo = [];
6022
- this.nodeSizingDetLinksInfo = [];
5597
+ this.nodeSizingObjectsInfo = {};
5598
+ this.nodeSizingDetLinksInfo = {};
6023
5599
  }
6024
5600
 
6025
5601
  // Finalises the sizing of a comment by calling editActionHandler
@@ -6448,9 +6024,7 @@ export default class SVGCanvasRenderer {
6448
6024
  return "d3-node-group" + supernodeClass + draggableClass + customClass;
6449
6025
  }
6450
6026
 
6451
- // Pushes the links to be below nodes and then pushes comments to be below
6452
- // nodes and links. This lets the user put a large comment underneath a set
6453
- // of nodes and links for annotation purposes.
6027
+ // Pushes the links to be below nodes within the nodesLinksGrp group.
6454
6028
  setDisplayOrder(linkGroup) {
6455
6029
  // Force those links without decorations to be behind those with decorations
6456
6030
  // in case the links overlap we don't want the decorations to be overwritten.
@@ -7099,16 +6673,16 @@ export default class SVGCanvasRenderer {
7099
6673
  // This is used when a new comment is created from the toolbar to make sure the
7100
6674
  // new comment always appears in the view port.
7101
6675
  getSvgViewportOffset() {
7102
- let xPos = this.canvasLayout.addCommentOffset;
7103
- let yPos = this.canvasLayout.addCommentOffset;
6676
+ let xPos = this.canvasLayout.addCommentOffsetX;
6677
+ let yPos = this.canvasLayout.addCommentOffsetY;
7104
6678
 
7105
6679
  if (this.zoomTransform) {
7106
6680
  xPos = this.zoomTransform.x / this.zoomTransform.k;
7107
6681
  yPos = this.zoomTransform.y / this.zoomTransform.k;
7108
6682
 
7109
6683
  // The window's viewport is in the opposite direction of zoomTransform
7110
- xPos = -xPos + this.canvasLayout.addCommentOffset;
7111
- yPos = -yPos + this.canvasLayout.addCommentOffset;
6684
+ xPos = -xPos + this.canvasLayout.addCommentOffsetX;
6685
+ yPos = -yPos + this.canvasLayout.addCommentOffsetY;
7112
6686
  }
7113
6687
 
7114
6688
  return {