@genexus/diagram-editors 0.5.27 → 0.8.27

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 (46) hide show
  1. package/dist/cjs/{editor-27988eb7.js → editor-386996a2.js} +248 -248
  2. package/dist/cjs/gx-bpmn-editor.cjs.entry.js +69 -124
  3. package/dist/cjs/gx-report-layout-editor.cjs.entry.js +3 -18
  4. package/dist/collection/components/bpmn/bpmn-editor-component.js +1 -3
  5. package/dist/collection/components/bpmn/bpmn-editor.js +10 -27
  6. package/dist/collection/components/bpmn/bpmn-graph.js +19 -35
  7. package/dist/collection/components/bpmn/layout.js +0 -2
  8. package/dist/collection/components/bpmn/shapes/activity-shape.js +0 -21
  9. package/dist/collection/components/bpmn/shapes/connector-shape.js +0 -1
  10. package/dist/collection/components/bpmn/shapes/event-shape.js +4 -3
  11. package/dist/collection/components/bpmn/shapes/gateway-shape.js +2 -1
  12. package/dist/collection/components/bpmn/style-tokens.js +4 -0
  13. package/dist/collection/components/common/cell.js +1 -1
  14. package/dist/collection/components/common/common-style-tokens.js +1 -1
  15. package/dist/collection/components/common/connection-handler.js +3 -33
  16. package/dist/collection/components/common/editor.js +7 -55
  17. package/dist/collection/components/common/event-converter.js +3 -3
  18. package/dist/collection/components/common/graph-handler.js +0 -14
  19. package/dist/collection/components/common/graph.js +235 -90
  20. package/dist/collection/components/common/mx.js +0 -51
  21. package/dist/collection/components/common/panning-handler.js +0 -2
  22. package/dist/collection/components/report/report-editor-component.js +1 -1
  23. package/dist/collection/components/report/report-editor.js +1 -12
  24. package/dist/collection/components/report/report-graph.js +0 -2
  25. package/dist/collection/components/report/shapes/rectangle-shape.js +0 -2
  26. package/dist/diagram-editors/diagram-editors.esm.js +1 -1
  27. package/dist/diagram-editors/{p-dc5159a2.system.entry.js → p-009a6590.system.entry.js} +1 -1
  28. package/dist/diagram-editors/{p-534c30c2.entry.js → p-0cbf75ed.entry.js} +1 -1
  29. package/dist/diagram-editors/{p-a5f6012d.js → p-52c75d65.js} +1 -1
  30. package/dist/diagram-editors/p-60b39e5b.system.entry.js +1 -0
  31. package/dist/diagram-editors/{p-99c06652.system.js → p-80e1f1a5.system.js} +1 -1
  32. package/dist/diagram-editors/p-e435d3dc.system.js +1 -1
  33. package/dist/diagram-editors/p-f022f8f7.entry.js +1 -0
  34. package/dist/esm/{editor-786b0cd7.js → editor-4d1ececd.js} +248 -248
  35. package/dist/esm/gx-bpmn-editor.entry.js +69 -124
  36. package/dist/esm/gx-report-layout-editor.entry.js +3 -18
  37. package/dist/esm-es5/{editor-786b0cd7.js → editor-4d1ececd.js} +250 -245
  38. package/dist/esm-es5/gx-bpmn-editor.entry.js +67 -122
  39. package/dist/esm-es5/gx-report-layout-editor.entry.js +3 -18
  40. package/dist/types/components/bpmn/bpmn-graph.d.ts +1 -0
  41. package/dist/types/components/bpmn/style-tokens.d.ts +5 -0
  42. package/dist/types/components/common/graph.d.ts +7 -0
  43. package/dist/types/components/common/interop-types.d.ts +6 -0
  44. package/package.json +3 -3
  45. package/dist/diagram-editors/p-1ed04dc8.system.entry.js +0 -1
  46. package/dist/diagram-editors/p-5d0e2e7a.entry.js +0 -1
@@ -92532,7 +92532,7 @@ var CommonStyleTokens;
92532
92532
  CommonStyleTokens.PREVIEW_COLOR = '#5bb2ff';
92533
92533
  CommonStyleTokens.EDGE_SELECTION_COLOR = 'red';
92534
92534
  CommonStyleTokens.HIGHLIGHT_CONNECTION_COLOR = '#ffb754';
92535
- CommonStyleTokens.GUIDE_COLOR = CommonStyleTokens.PREVIEW_COLOR; // '#ffb754';
92535
+ CommonStyleTokens.GUIDE_COLOR = CommonStyleTokens.PREVIEW_COLOR;
92536
92536
  CommonStyleTokens.GUIDE_STROKE_WIDTH = 2;
92537
92537
  CommonStyleTokens.DROP_TARGET_COLOR = CommonStyleTokens.GUIDE_COLOR;
92538
92538
  })(CommonStyleTokens || (CommonStyleTokens = {}));
@@ -92575,9 +92575,7 @@ mx.mxMarker.addMarker('oval', function (canvas, shape, type, pe, unitX, unitY, s
92575
92575
  }
92576
92576
  };
92577
92577
  });
92578
- // Enables snapping waypoints to terminals (this is useful when managing orthogonal edge segments)
92579
92578
  mx.mxEdgeHandler.prototype.snapToTerminals = true;
92580
- /// Custom functions for SVG direct manipulation
92581
92579
  const _SYM_SVG_GROUPS = Symbol('svgGrpups');
92582
92580
  const svgCanvas = mx.mxSvgCanvas2D.prototype;
92583
92581
  svgCanvas[_SYM_SVG_GROUPS] = [];
@@ -92614,55 +92612,6 @@ svgCanvas.addSvgElement = function (name, attrs = {}) {
92614
92612
  }
92615
92613
  return e;
92616
92614
  };
92617
- //mx.mxCellHighlight.prototype.drawHighlight = () => {};
92618
- // mx.mxMarker.addMarker('classic', function (canvas, shape, type, pe, unitX, unitY, size, source, sw, filled) {
92619
- // let widthFactor = 2;
92620
- // // The angle of the forward facing arrow sides against the x axis is
92621
- // // 26.565 degrees, 1/sin(26.565) = 2.236 / 2 = 1.118 ( / 2 allows for
92622
- // // only half the strokewidth is processed ).
92623
- // var endOffsetX = unitX * sw * 1.118;
92624
- // var endOffsetY = unitY * sw * 1.118;
92625
- // unitX = unitX * (size + sw);
92626
- // unitY = unitY * (size + sw);
92627
- // var pt = pe.clone();
92628
- // pt.x -= endOffsetX;
92629
- // pt.y -= endOffsetY;
92630
- // var f = (type != mx.mxConstants.ARROW_CLASSIC && type != mx.mxConstants.ARROW_CLASSIC_THIN) ? 1 : 3 / 4;
92631
- // pe.x += -unitX * f - endOffsetX;
92632
- // pe.y += -unitY * f - endOffsetY;
92633
- // return function () {
92634
- // canvas.begin();
92635
- // canvas.moveTo(pt.x, pt.y);
92636
- // canvas.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
92637
- // if (type == mx.mxConstants.ARROW_CLASSIC || type == mx.mxConstants.ARROW_CLASSIC_THIN) {
92638
- // canvas.lineTo(pt.x - unitX * 3 / 4, pt.y - unitY * 3 / 4);
92639
- // }
92640
- // canvas.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
92641
- // canvas.close();
92642
- // if (filled) {
92643
- // canvas.fillAndStroke();
92644
- // }
92645
- // else {
92646
- // canvas.stroke();
92647
- // }
92648
- // pt.x -= endOffsetX * 5;
92649
- // pt.y -= endOffsetY * 5;
92650
- // canvas.begin();
92651
- // canvas.moveTo(pt.x, pt.y);
92652
- // canvas.lineTo(pt.x - unitX - unitY / widthFactor, pt.y - unitY + unitX / widthFactor);
92653
- // if (type == mx.mxConstants.ARROW_CLASSIC || type == mx.mxConstants.ARROW_CLASSIC_THIN) {
92654
- // canvas.lineTo(pt.x - unitX * 3 / 4, pt.y - unitY * 3 / 4);
92655
- // }
92656
- // canvas.lineTo(pt.x + unitY / widthFactor - unitX, pt.y - unitY - unitX / widthFactor);
92657
- // canvas.close();
92658
- // if (filled) {
92659
- // canvas.fillAndStroke();
92660
- // }
92661
- // else {
92662
- // canvas.stroke();
92663
- // }
92664
- // };
92665
- // });
92666
92615
 
92667
92616
  class Cell extends mx.mxCell {
92668
92617
  constructor(descriptor, value, geometry) {
@@ -92721,7 +92670,7 @@ class Cell extends mx.mxCell {
92721
92670
  return Object.assign({}, value);
92722
92671
  }
92723
92672
  }
92724
- Cell.prototype.mxTransient = [...Cell.prototype.mxTransient, '_descriptor']; // We avoid descriptor being deep cloned if the cell clone is deep.
92673
+ Cell.prototype.mxTransient = [...Cell.prototype.mxTransient, '_descriptor'];
92725
92674
 
92726
92675
  const _LABEL_ATTR = 'label';
92727
92676
  class CellDescriptor {
@@ -92861,12 +92810,12 @@ class EventConverter {
92861
92810
  let parentGuid = null, slotId;
92862
92811
  if (change.parent) {
92863
92812
  if (change.parent instanceof Cell) {
92864
- let parentElement = change.child.getParentDiagramElement(); // Must always be different than null
92813
+ let parentElement = change.child.getParentDiagramElement();
92865
92814
  parentGuid = parentElement.id;
92866
92815
  slotId = change.parent.descriptor.slotId;
92867
92816
  }
92868
92817
  else
92869
- parentGuid = Guid.EMPTY.toString(); // Empty Guid means root default layer (for now only one layer supported)
92818
+ parentGuid = Guid.EMPTY.toString();
92870
92819
  }
92871
92820
  return {
92872
92821
  type: EventType.ChildChange,
@@ -92954,14 +92903,11 @@ class ConnectionHandler extends mx.mxConnectionHandler {
92954
92903
  }
92955
92904
  createMarker() {
92956
92905
  let marker = super.createMarker();
92957
- // This is to disable the creation of new edges by clicking on potential source vertexes.
92958
- // let intersects = marker.intersects;
92959
92906
  marker.intersects = mx.mxUtils.bind(this, function (state, evt) {
92960
92907
  if (this.connectImage != null || this.isConnecting()) {
92961
92908
  return true;
92962
92909
  }
92963
92910
  return false;
92964
- //return intersects.call(marker, state, evt);
92965
92911
  });
92966
92912
  return marker;
92967
92913
  }
@@ -92984,23 +92930,8 @@ class ConnectionHandler extends mx.mxConnectionHandler {
92984
92930
  let t = this.graph.view.translate;
92985
92931
  let s = this.graph.view.scale;
92986
92932
  let point = new mx.mxPoint(this.currentPoint.x / s - t.x, this.currentPoint.y / s - t.y);
92987
- geo.x = Math.round(point.x - geo.width / 2); // <GX> This was wrong (panDx should not be substracted because it messes with autopan): geo.x = Math.round(point.x - geo.width / 2 - this.graph.panDx / s);
92988
- geo.y = Math.round(point.y - geo.height / 2); // <GX> Same as above but with panDy
92989
- // // Aligns with source if within certain tolerance
92990
- // let tol = (this as any).getAlignmentTolerance();
92991
- // if (tol > 0) {
92992
- // let sourceState = this.graph.view.getState(source);
92993
- // if (sourceState != null) {
92994
- // let x = sourceState.x / s - t.x;
92995
- // let y = sourceState.y / s - t.y;
92996
- // if (Math.abs(x - geo.x) <= tol) {
92997
- // geo.x = Math.round(x);
92998
- // }
92999
- // if (Math.abs(y - geo.y) <= tol) {
93000
- // geo.y = Math.round(y);
93001
- // }
93002
- // }
93003
- // }
92933
+ geo.x = Math.round(point.x - geo.width / 2);
92934
+ geo.y = Math.round(point.y - geo.height / 2);
93004
92935
  }
93005
92936
  this.currentVertexType = null;
93006
92937
  return clone;
@@ -93037,8 +92968,6 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93037
92968
  }
93038
92969
  connect(source, target, evt, dropTarget) {
93039
92970
  if (target != null || this.isCreateTarget(evt) || this.graph.allowDanglingEdges) {
93040
- // Uses the common parent of source and target or
93041
- // the default parent to insert the edge
93042
92971
  var model = this.graph.getModel();
93043
92972
  var terminalInserted = false;
93044
92973
  var edge = null;
@@ -93049,8 +92978,6 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93049
92978
  if (target != null) {
93050
92979
  dropTarget = this.graph.getDropTarget([target], evt, dropTarget);
93051
92980
  terminalInserted = true;
93052
- // Disables edges as drop targets if the target cell was created
93053
- // FIXME: Should not shift if vertex was aligned (same in Java)
93054
92981
  if (dropTarget == null || !this.graph.getModel().isEdge(dropTarget)) {
93055
92982
  var pstate = this.graph.getView().getState(dropTarget);
93056
92983
  if (pstate != null) {
@@ -93064,7 +92991,7 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93064
92991
  }
93065
92992
  this.graph.addCell(target, dropTarget);
93066
92993
  }
93067
- else if (!this.graph.allowDanglingEdges) { // <GX> Minor fix: do not create links if there is no target and allowDanglingEdges is false
92994
+ else if (!this.graph.allowDanglingEdges) {
93068
92995
  return;
93069
92996
  }
93070
92997
  }
@@ -93078,8 +93005,6 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93078
93005
  parent = model.getParent(parent);
93079
93006
  }
93080
93007
  }
93081
- // Uses the value of the preview edge state for inserting
93082
- // the new edge into the graph
93083
93008
  var value = null;
93084
93009
  var style = null;
93085
93010
  if (this.edgeState != null) {
@@ -93088,15 +93013,12 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93088
93013
  }
93089
93014
  edge = this.insertEdge(parent, null, value, source, target, style);
93090
93015
  if (edge != null) {
93091
- // Updates the connection constraints
93092
93016
  this.graph.setConnectionConstraint(edge, source, true, this.sourceConstraint);
93093
93017
  this.graph.setConnectionConstraint(edge, target, false, this.constraintHandler.currentConstraint);
93094
- // Uses geometry of the preview edge state
93095
93018
  if (this.edgeState != null) {
93096
93019
  model.setGeometry(edge, this.edgeState.cell.geometry);
93097
93020
  }
93098
93021
  var parent = model.getParent(source);
93099
- // Inserts edge before source
93100
93022
  if (this.isInsertBefore(edge, source, target, evt, dropTarget)) {
93101
93023
  var tmp = source;
93102
93024
  while (tmp.parent != null && tmp.geometry != null &&
@@ -93107,14 +93029,12 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93107
93029
  model.add(parent, edge, tmp.parent.getIndex(tmp));
93108
93030
  }
93109
93031
  }
93110
- // Makes sure the edge has a non-null, relative geometry
93111
93032
  var geo = model.getGeometry(edge);
93112
93033
  if (geo == null) {
93113
93034
  geo = new mx.mxGeometry();
93114
93035
  geo.relative = true;
93115
93036
  model.setGeometry(edge, geo);
93116
93037
  }
93117
- // Uses scaled waypoints in geometry
93118
93038
  if (this.waypoints != null && this.waypoints.length > 0) {
93119
93039
  var s = this.graph.view.scale;
93120
93040
  var tr = this.graph.view.translate;
@@ -93139,7 +93059,6 @@ class ConnectionHandler extends mx.mxConnectionHandler {
93139
93059
  }
93140
93060
  catch (e) {
93141
93061
  mx.mxLog.show();
93142
- //mx.mxLog.debug(e.message);
93143
93062
  }
93144
93063
  finally {
93145
93064
  model.endUpdate();
@@ -93235,8 +93154,6 @@ class GraphHandler extends mx.mxGraphHandler {
93235
93154
  shouldRemoveCellsFromParent(parent, cells, evt) {
93236
93155
  return false;
93237
93156
  }
93238
- // Modify mouseDown and mouseUp event handlers to use Right button clicks only for selction if current target node is not selected.
93239
- // This is to avoid inteference with context menu management which is done in the host of this component.
93240
93157
  mouseDown(sender, me) {
93241
93158
  let graph = this.graph;
93242
93159
  if (me.getEvent().button === 2) {
@@ -93275,9 +93192,6 @@ class GraphHandler extends mx.mxGraphHandler {
93275
93192
  mouseUp(sender, me) {
93276
93193
  if (me.getEvent().button === 2)
93277
93194
  return;
93278
- // Some computations for the case when some element is dropped over an edge (only valid for orthogonal edges). Default edge spliting algorithm do not try to align the dropped
93279
- // element with the source nor the target element. This tries to fix some of this issue. Basically we check if the drop is on the first or last segment.
93280
- // If this condition is met and depending on the case, we align the dropped element with the source or the target element of the edge.
93281
93195
  let self = this;
93282
93196
  let cell = self.cell;
93283
93197
  if (!cell)
@@ -93335,7 +93249,6 @@ class GraphHandler extends mx.mxGraphHandler {
93335
93249
  var graph = self.graph;
93336
93250
  if (!me.isConsumed() && graph.isMouseDown && self.cell != null &&
93337
93251
  self.first != null && self.bounds != null && !self.suspended) {
93338
- // Stops moving if a multi touch event is received
93339
93252
  if (mx.mxEvent.isMultiTouchEvent(me.getEvent())) {
93340
93253
  this.reset();
93341
93254
  return;
@@ -93343,7 +93256,6 @@ class GraphHandler extends mx.mxGraphHandler {
93343
93256
  var delta = this.getDelta(me);
93344
93257
  var tol = graph.tolerance;
93345
93258
  if (self.shape != null || self.livePreviewActive || Math.abs(delta.x) > tol || Math.abs(delta.y) > tol) {
93346
- // Highlight is used for highlighting drop targets
93347
93259
  if (self.highlight == null) {
93348
93260
  self.highlight = new mx.mxCellHighlight(graph, mx.mxConstants.DROP_TARGET_COLOR, 3, undefined);
93349
93261
  }
@@ -93354,7 +93266,6 @@ class GraphHandler extends mx.mxGraphHandler {
93354
93266
  var target = null;
93355
93267
  self.cloning = clone;
93356
93268
  if (graph.isDropEnabled() && self.highlightEnabled && self.cells.indexOf(cell) < 0) {
93357
- // Contains a call to getCellAt to find the cell under the mouse
93358
93269
  target = graph.getDropTarget(self.cells, me.getEvent(), cell, clone);
93359
93270
  }
93360
93271
  var state = graph.getView().getState(target);
@@ -93411,7 +93322,6 @@ class GraphHandler extends mx.mxGraphHandler {
93411
93322
  if (self.guide != null && hideGuide) {
93412
93323
  self.guide.hide();
93413
93324
  }
93414
- // Constrained movement if shift key is pressed
93415
93325
  if (graph.isConstrainedEvent(me.getEvent())) {
93416
93326
  if (Math.abs(delta.x) > Math.abs(delta.y)) {
93417
93327
  delta.y = 0;
@@ -93428,9 +93338,6 @@ class GraphHandler extends mx.mxGraphHandler {
93428
93338
  }
93429
93339
  this.updateHint(me);
93430
93340
  this.consumeMouseEvent(mx.mxEvent.MOUSE_MOVE, me);
93431
- // Cancels the bubbling of events to the container so
93432
- // that the droptarget is not reset due to an mouseMove
93433
- // fired on the container with no associated state.
93434
93341
  mx.mxEvent.consume(me.getEvent());
93435
93342
  }
93436
93343
  else if ((this.isMoveEnabled() || this.isCloneEnabled()) && self.updateCursor && !me.isConsumed() &&
@@ -93444,8 +93351,6 @@ class GraphHandler extends mx.mxGraphHandler {
93444
93351
  cursor = mx.mxConstants.CURSOR_MOVABLE_VERTEX;
93445
93352
  }
93446
93353
  }
93447
- // Sets the cursor on the original source state under the mouse
93448
- // instead of the event source state which can be the parent
93449
93354
  if (cursor != null && me.sourceState != null) {
93450
93355
  me.sourceState.setCursor(cursor);
93451
93356
  }
@@ -93459,8 +93364,6 @@ class PanningHandler extends mx.mxPanningHandler {
93459
93364
  let ctrlDown = navigator.platform === 'MacIntel' ? mx.mxEvent.isMetaDown(evt) : mx.mxEvent.isControlDown(evt);
93460
93365
  return (this.useLeftButtonForPanning && me.getState() == null &&
93461
93366
  mx.mxEvent.isLeftMouseButton(evt)) || (ctrlDown && !mx.mxEvent.isShiftDown(evt));
93462
- //((mx.mxEvent.isControlDown(evt) || mx.mxEvent.isMetaDown(evt))
93463
- // || (this.usePopupTrigger && mx.mxEvent.isPopupTrigger(evt))
93464
93367
  }
93465
93368
  ;
93466
93369
  }
@@ -93693,6 +93596,7 @@ const _NAME_REGEX = /([^\d]*)([\d]*)/g;
93693
93596
  class Graph extends mx.mxGraph {
93694
93597
  constructor(options) {
93695
93598
  super(options.container);
93599
+ this.resetEdgesOnMove = true;
93696
93600
  this._editorHelper = options.editorHelper;
93697
93601
  this.dropEnabled = true;
93698
93602
  this.installCellDescriptors(options.cellDescriptors);
@@ -93706,21 +93610,7 @@ class Graph extends mx.mxGraph {
93706
93610
  this.installGlobalStyles(options.globalStyles);
93707
93611
  if (options.bottomPad)
93708
93612
  this.createBottomPad(options.bottomPad);
93709
- // let createLabel = (<any>mx.mxCellRenderer).prototype.createLabel;
93710
- // console.log('MXGRAPH COLOC', createLabel, mx.mxCellRenderer.prototype);
93711
- // (<any>mx.mxCellRenderer).prototype.createLabel = (state, value) => {
93712
- // console.log('MXGRAPG label state', state, value);
93713
- // let color = mx.mxConstants.STYLE_FONTCOLOR;
93714
- // if (color === 'blue')
93715
- // mx.mxConstants.STYLE_FONTCOLOR = 'green';
93716
- // else
93717
- // mx.mxConstants.STYLE_FONTCOLOR = 'blue';
93718
- // createLabel.call(mx.mxCellRenderer.prototype, state, value);
93719
- // if (state.text)
93720
- // console.log('LABEL', state.text, state.text.color);
93721
- // }
93722
93613
  }
93723
- //#region Initialization
93724
93614
  installCellDescriptors(descriptors) {
93725
93615
  this._cellDescriptors = new Map();
93726
93616
  if (!descriptors)
@@ -93775,8 +93665,6 @@ class Graph extends mx.mxGraph {
93775
93665
  createCellEditor() {
93776
93666
  return new CellEditor(this);
93777
93667
  }
93778
- //#endregion
93779
- //#region Utility Members
93780
93668
  get editorHelper() {
93781
93669
  return this._editorHelper;
93782
93670
  }
@@ -93823,7 +93711,7 @@ class Graph extends mx.mxGraph {
93823
93711
  cell.setVertex(descriptor.isVertex);
93824
93712
  cell.setEdge(descriptor.isEdge);
93825
93713
  cell.setStyle(descriptor.getDefaultStyle());
93826
- this.setCellValue(cell, (_b = options.value) !== null && _b !== void 0 ? _b : {}); // Set cell value this way so Graph can preprocess value to set other properties like style
93714
+ this.setCellValue(cell, (_b = options.value) !== null && _b !== void 0 ? _b : {});
93827
93715
  if (options.assignName &&
93828
93716
  descriptor.nameAttribute &&
93829
93717
  descriptor.baseName &&
@@ -93837,8 +93725,25 @@ class Graph extends mx.mxGraph {
93837
93725
  this.getModel().setValue(cell, value);
93838
93726
  }
93839
93727
  setCellGraphicalProperties(cell, props, redraw = true) {
93728
+ var _a;
93729
+ if (cell.isEdge() && (!cell.source || !cell.target))
93730
+ return;
93840
93731
  let pos = this.convertLogicalPointToPixels(cell, { x: props.x, y: props.y });
93841
- let geo = new mx.mxGeometry(pos.x, pos.y, this.convertLogicalToPixels(cell, props.width), this.convertLogicalToPixels(cell, props.height));
93732
+ let geo = cell.isEdge() ? new mx.mxGeometry() : new mx.mxGeometry(pos.x, pos.y, this.convertLogicalToPixels(cell, props.width), this.convertLogicalToPixels(cell, props.height));
93733
+ let style = cell.getStyle();
93734
+ if (props.fromPoint) {
93735
+ let fromGeo = cell.source.geometry;
93736
+ let fromPos = this.convertPixelsPointToLogical(cell.source, { x: fromGeo.x, y: fromGeo.y });
93737
+ style = mx.mxUtils.setStyle(style, mx.mxConstants.STYLE_EXIT_X, (props.fromPoint.x - fromPos.x) / fromGeo.width);
93738
+ style = mx.mxUtils.setStyle(style, mx.mxConstants.STYLE_EXIT_Y, (props.fromPoint.y - fromPos.y) / fromGeo.height);
93739
+ }
93740
+ if (props.toPoint) {
93741
+ let toGeo = cell.target.geometry;
93742
+ let toPos = this.convertPixelsPointToLogical(cell.source, { x: toGeo.x, y: toGeo.y });
93743
+ style = mx.mxUtils.setStyle(style, mx.mxConstants.STYLE_ENTRY_X, (props.toPoint.x - toPos.x) / toGeo.width);
93744
+ style = mx.mxUtils.setStyle(style, mx.mxConstants.STYLE_ENTRY_Y, (props.toPoint.y - toPos.y) / toGeo.height);
93745
+ }
93746
+ cell.setStyle(style);
93842
93747
  geo.relative = false;
93843
93748
  if (props.points && props.points.length > 0) {
93844
93749
  geo.points = props.points.map(p => {
@@ -93847,8 +93752,19 @@ class Graph extends mx.mxGraph {
93847
93752
  });
93848
93753
  }
93849
93754
  if (props.labelPosition) {
93850
- let offset = this.convertLogicalPointToPixels(cell, props.labelPosition); //this.convertLogicalOffsetToPixels(cell, props.labelPosition);
93851
- geo.offset = new mx.mxPoint(offset.x, offset.y);
93755
+ let center;
93756
+ if (cell.isEdge() && cell.source && cell.target) {
93757
+ if (((_a = props.points) === null || _a === void 0 ? void 0 : _a.length) > 0)
93758
+ center = this._getPointListCenter(props.points);
93759
+ else {
93760
+ let fromPoint = this._getTerminalLogicalPointFromStyle(cell, true);
93761
+ let toPoint = this._getTerminalLogicalPointFromStyle(cell, false);
93762
+ center = this._getPointListCenter([fromPoint, toPoint]);
93763
+ }
93764
+ }
93765
+ else
93766
+ center = { x: props.x + props.width / 2, y: props.y + props.height / 2 };
93767
+ geo.offset = new mx.mxPoint(props.labelPosition.x - center.x, props.labelPosition.y - center.y);
93852
93768
  }
93853
93769
  this.model.setGeometry(cell, geo);
93854
93770
  if (redraw) {
@@ -93861,21 +93777,210 @@ class Graph extends mx.mxGraph {
93861
93777
  let geo = cell.getGeometry();
93862
93778
  let position = geo.x !== undefined && geo.y !== undefined
93863
93779
  ? this.convertPixelsPointToLogical(cell, { x: geo.x, y: geo.y })
93780
+ : undefined;
93781
+ let size = geo.width !== undefined && geo.height !== undefined
93782
+ ? { width: this.convertPixelsToLogical(cell, geo.width), height: this.convertPixelsToLogical(cell, geo.height) }
93783
+ : undefined;
93784
+ let offset = geo.offset && !isNaN(geo.offset.x) && !isNaN(geo.offset.y)
93785
+ ? { x: geo.offset.x, y: geo.offset.y }
93786
+ : undefined;
93787
+ let labelPosition = position && size && offset
93788
+ ? { x: position.x + size.width / 2 + offset.x, y: position.y + size.height / 2 + offset.y }
93789
+ : undefined;
93790
+ let points = geo.points
93791
+ ? geo.points.map(p => this.convertPixelsPointToLogical(cell, p))
93864
93792
  : null;
93865
- let labelPosition;
93866
- if (geo.offset && !isNaN(geo.offset.x) && !isNaN(geo.offset.y))
93867
- labelPosition = this.convertPixelsPointToLogical(cell, geo.offset); //this.convertPixelsOffsetToLogical(cell, geo.offset);
93793
+ let fromPoint, toPoint;
93794
+ let from = cell.source;
93795
+ let to = cell.target;
93796
+ if (cell.isEdge() && from && to) {
93797
+ let edgeCenter;
93798
+ if ((points === null || points === void 0 ? void 0 : points.length) > 0) {
93799
+ let first = this._getTerminalLogicalPoint(from, points[0], true, true);
93800
+ if (first && (first.x !== points[0].x || first.y !== points[0].y)) {
93801
+ points.unshift(first);
93802
+ }
93803
+ let last = this._getTerminalLogicalPoint(to, points[points.length - 1], true, false);
93804
+ if (last && (last.x !== points[points.length - 1].x || last.y !== points[points.length - 1].y)) {
93805
+ points.push(last);
93806
+ }
93807
+ this._insertExtraPointsInEdgeForCompatibiityWithGXWin(points);
93808
+ edgeCenter = this._getPointListCenter(points);
93809
+ }
93810
+ else {
93811
+ fromPoint = this._getTerminalLogicalPointFromStyle(cell, true);
93812
+ toPoint = this._getTerminalLogicalPointFromStyle(cell, false);
93813
+ edgeCenter = this._getPointListCenter([fromPoint, toPoint]);
93814
+ }
93815
+ if (offset && edgeCenter)
93816
+ labelPosition = { x: edgeCenter.x + offset.x, y: edgeCenter.y + offset.y };
93817
+ }
93868
93818
  return {
93869
- x: position.x,
93870
- y: position.y,
93871
- width: this.convertPixelsToLogical(cell, geo.width),
93872
- height: this.convertPixelsToLogical(cell, geo.height),
93873
- points: geo.points
93874
- ? geo.points.map(p => this.convertPixelsPointToLogical(cell, p))
93875
- : null,
93876
- labelPosition
93819
+ x: position === null || position === void 0 ? void 0 : position.x,
93820
+ y: position === null || position === void 0 ? void 0 : position.y,
93821
+ width: size === null || size === void 0 ? void 0 : size.width,
93822
+ height: size === null || size === void 0 ? void 0 : size.height,
93823
+ points,
93824
+ labelPosition,
93825
+ fromPoint: fromPoint,
93826
+ toPoint: toPoint
93877
93827
  };
93878
93828
  }
93829
+ _insertExtraPointsInEdgeForCompatibiityWithGXWin(points) {
93830
+ if (points.length >= 2) {
93831
+ if (Math.abs(points[0].x - points[1].x) > 10) {
93832
+ if (points[0].x < points[1].x)
93833
+ points.splice(1, 0, { x: points[0].x + 10, y: points[0].y });
93834
+ else
93835
+ points.splice(1, 0, { x: points[0].x - 10, y: points[0].y });
93836
+ }
93837
+ if (Math.abs(points[0].y - points[1].y) > 10) {
93838
+ if (points[0].y < points[1].y)
93839
+ points.splice(1, 0, { x: points[0].x, y: points[0].y + 10 });
93840
+ else
93841
+ points.splice(1, 0, { x: points[0].x, y: points[0].y - 10 });
93842
+ }
93843
+ let pre = points[points.length - 2];
93844
+ let last = points[points.length - 1];
93845
+ if (Math.abs(pre.x - last.x) > 10) {
93846
+ if (pre.x < last.x)
93847
+ points.splice(points.length - 1, 0, { x: last.x - 10, y: pre.y });
93848
+ else
93849
+ points.splice(points.length - 1, 0, { x: last.x + 10, y: pre.y });
93850
+ }
93851
+ if (Math.abs(pre.y - last.y) > 10) {
93852
+ if (pre.y < last.y)
93853
+ points.splice(points.length - 1, 0, { x: pre.x, y: last.y - 10 });
93854
+ else
93855
+ points.splice(points.length - 1, 0, { x: pre.x, y: last.y + 10 });
93856
+ }
93857
+ }
93858
+ }
93859
+ _getTerminalLogicalPointFromStyle(edge, from) {
93860
+ let style = this.getCellStyle(edge);
93861
+ let delta;
93862
+ if (from && style[mx.mxConstants.STYLE_EXIT_X] && style[mx.mxConstants.STYLE_EXIT_Y]) {
93863
+ delta = {
93864
+ x: Number.parseFloat(style[mx.mxConstants.STYLE_EXIT_X]),
93865
+ y: Number.parseFloat(style[mx.mxConstants.STYLE_EXIT_Y])
93866
+ };
93867
+ }
93868
+ else if (!from && style[mx.mxConstants.STYLE_ENTRY_X] && style[mx.mxConstants.STYLE_ENTRY_Y]) {
93869
+ delta = {
93870
+ x: Number.parseFloat(style[mx.mxConstants.STYLE_ENTRY_X]),
93871
+ y: Number.parseFloat(style[mx.mxConstants.STYLE_ENTRY_Y])
93872
+ };
93873
+ }
93874
+ let fromGeo = edge.source.getGeometry();
93875
+ let fromBounds = {
93876
+ position: this.convertPixelsPointToLogical(edge.source, { x: fromGeo.x, y: fromGeo.y }),
93877
+ size: { width: this.convertPixelsToLogical(edge.source, fromGeo.width), height: this.convertPixelsToLogical(edge, fromGeo.height) }
93878
+ };
93879
+ let toGeo = edge.target.getGeometry();
93880
+ let toBounds = {
93881
+ position: this.convertPixelsPointToLogical(edge.target, { x: toGeo.x, y: toGeo.y }),
93882
+ size: { width: this.convertPixelsToLogical(edge.target, toGeo.width), height: this.convertPixelsToLogical(edge, toGeo.height) }
93883
+ };
93884
+ if (delta) {
93885
+ let bounds = from ? fromBounds : toBounds;
93886
+ return {
93887
+ x: bounds.position.x + delta.x * bounds.size.width,
93888
+ y: bounds.position.y + delta.y * bounds.size.height
93889
+ };
93890
+ }
93891
+ if (from)
93892
+ return this._getAutoTerminalPoint(fromBounds, toBounds, from);
93893
+ return this._getAutoTerminalPoint(toBounds, fromBounds, from);
93894
+ }
93895
+ _getPointListCenter(points) {
93896
+ let top = { x: Number.POSITIVE_INFINITY, y: Number.POSITIVE_INFINITY };
93897
+ let bottom = { x: Number.NEGATIVE_INFINITY, y: Number.NEGATIVE_INFINITY };
93898
+ for (let point of points) {
93899
+ if (top.x > point.x)
93900
+ top.x = point.x;
93901
+ if (top.y > point.y)
93902
+ top.y = point.y;
93903
+ if (bottom.x < point.x)
93904
+ bottom.x = point.x;
93905
+ if (bottom.y < point.y)
93906
+ bottom.y = point.y;
93907
+ }
93908
+ return {
93909
+ x: top.x + (bottom.x - top.x) / 2,
93910
+ y: top.y + (bottom.y - top.y) / 2,
93911
+ };
93912
+ }
93913
+ _getAutoTerminalPoint(bounds, otherBounds, from) {
93914
+ if (from) {
93915
+ if (bounds.position.y > otherBounds.position.y + otherBounds.size.height) {
93916
+ if (bounds.position.x + bounds.size.width < otherBounds.position.x)
93917
+ return this._getMiddlePoint(bounds, 'middleRight');
93918
+ if (bounds.position.x > otherBounds.position.x + otherBounds.size.width)
93919
+ return this._getMiddlePoint(bounds, 'middleLeft');
93920
+ return this._getMiddlePoint(bounds, 'middleTop');
93921
+ }
93922
+ if (bounds.position.x + bounds.size.width < otherBounds.position.x)
93923
+ return this._getMiddlePoint(bounds, 'middleRight');
93924
+ if (bounds.position.x > otherBounds.position.x + otherBounds.size.width)
93925
+ return this._getMiddlePoint(bounds, 'middleLeft');
93926
+ return this._getMiddlePoint(bounds, 'middleBottom');
93927
+ }
93928
+ if (bounds.position.y > otherBounds.position.y + otherBounds.size.height)
93929
+ return this._getMiddlePoint(bounds, 'middleTop');
93930
+ if (bounds.position.y + bounds.size.height < otherBounds.position.y)
93931
+ return this._getMiddlePoint(bounds, 'middleBottom');
93932
+ if (bounds.position.x > otherBounds.position.x + otherBounds.size.width)
93933
+ return this._getMiddlePoint(bounds, 'middleLeft');
93934
+ return this._getMiddlePoint(bounds, 'middleRight');
93935
+ }
93936
+ _getMiddlePoint(bounds, position) {
93937
+ switch (position) {
93938
+ case 'middleTop':
93939
+ return {
93940
+ x: bounds.position.x + bounds.size.width / 2,
93941
+ y: bounds.position.y
93942
+ };
93943
+ case 'middleBottom':
93944
+ return {
93945
+ x: bounds.position.x + bounds.size.width / 2,
93946
+ y: bounds.position.y + bounds.size.height
93947
+ };
93948
+ case 'middleLeft':
93949
+ return {
93950
+ x: bounds.position.x,
93951
+ y: bounds.position.y + bounds.size.height / 2
93952
+ };
93953
+ case 'middleRight':
93954
+ return {
93955
+ x: bounds.position.x + bounds.size.width,
93956
+ y: bounds.position.y + bounds.size.height / 2
93957
+ };
93958
+ }
93959
+ }
93960
+ _getTerminalLogicalPoint(terminal, next, orthogonal, from) {
93961
+ let perimeter = this._getPerimeter(terminal);
93962
+ let geo = terminal.getGeometry();
93963
+ if (perimeter && geo) {
93964
+ let mxNext = new mx.mxPoint(next.x, next.y);
93965
+ let location = this.convertPixelsPointToLogical(terminal, { x: geo.x, y: geo.y });
93966
+ let bounds = new mx.mxRectangle(location.x, location.y, geo.width, geo.height);
93967
+ let point = perimeter(bounds, { style: this.getCellStyle(terminal) }, mxNext, orthogonal);
93968
+ if (orthogonal) {
93969
+ let EPSILON = 3;
93970
+ if (Math.abs(next.x - point.x) < EPSILON && Math.abs(next.y - point.y) < EPSILON)
93971
+ return next;
93972
+ }
93973
+ return point;
93974
+ }
93975
+ }
93976
+ _getPerimeter(cell) {
93977
+ let style = this.getCellStyle(cell);
93978
+ let perimeter = style[mx.mxConstants.STYLE_PERIMETER];
93979
+ if (typeof perimeter === "function")
93980
+ return perimeter;
93981
+ if (typeof perimeter === "string")
93982
+ return mx.mxStyleRegistry.getValue(perimeter);
93983
+ }
93879
93984
  convertLogicalPointToPixels(cell, point) {
93880
93985
  return {
93881
93986
  x: this.convertLogicalToPixels(cell, point.x),
@@ -93946,49 +94051,32 @@ class Graph extends mx.mxGraph {
93946
94051
  }
93947
94052
  return result;
93948
94053
  }
93949
- //#endregion
93950
- //#region Customization
93951
94054
  selectCellForEvent(cell, evt) {
93952
94055
  if (cell instanceof Cell && !cell.descriptor.isDiagramElement)
93953
94056
  cell = cell.getParentDiagramElement();
93954
94057
  return super.selectCellForEvent(cell, evt);
93955
94058
  }
93956
- // isLabelMovable(cell) {
93957
- // return super.isLabelMovable(cell);
93958
- // }
93959
94059
  getDropTarget(cells, evt, cell, clone) {
93960
94060
  let target = super.getDropTarget(cells, evt, cell, clone);
93961
94061
  if (!target)
93962
94062
  target = this.getDefaultParent();
93963
94063
  return target;
93964
94064
  }
93965
- // isSwimlane(cell) {
93966
- // return true;
93967
- // }
93968
94065
  isExtendParentsOnAdd(cell) {
93969
94066
  return false;
93970
94067
  }
93971
94068
  isExtendParent(cell) {
93972
94069
  return true;
93973
94070
  }
93974
- // isExtendParentsOnMove() {
93975
- // return true;
93976
- // }
93977
94071
  isConstrainChild(cell) {
93978
94072
  return true;
93979
94073
  }
93980
- // isCellFoldable(cell: mxgraph.mxCell, collapse: boolean) {
93981
- // return false;
93982
- // }
93983
94074
  isCellLocked(cell) {
93984
94075
  return false;
93985
94076
  }
93986
94077
  isCellDisconnectable(cell, terminal, source) {
93987
94078
  return true;
93988
94079
  }
93989
- // isCellMovable(cell: mxgraph.mxCell) {
93990
- // return !cell.isEdge();
93991
- // }
93992
94080
  isCellResizable(cell) {
93993
94081
  if (cell instanceof Cell) {
93994
94082
  let descriptor = cell.descriptor;
@@ -94001,15 +94089,6 @@ class Graph extends mx.mxGraph {
94001
94089
  return true;
94002
94090
  return false;
94003
94091
  }
94004
- // translateCell(cell, dx, dy) {
94005
- // super.translateCell(cell, dx, dy);
94006
- // }
94007
- // moveCells(cells: mxgraph.mxCell[], dx?: number, dy?: number, clone?: boolean, target?: mxgraph.mxCell, evt?: Event, mapping?): mxgraph.mxCell[] {
94008
- // return super.moveCells(cells, dx, dy, clone, target, evt, mapping);
94009
- // }
94010
- // isAllowOverlapParent(cell) {
94011
- // return true;
94012
- // }
94013
94092
  convertValueToString(cell) {
94014
94093
  if (cell instanceof Cell) {
94015
94094
  let value = cell.getValue();
@@ -94023,13 +94102,9 @@ class Graph extends mx.mxGraph {
94023
94102
  }
94024
94103
  cellLabelChanged(cell, newValue, autoSize) {
94025
94104
  if (cell instanceof Cell && cell.value && typeof cell.value === 'object') {
94026
- // Clones the value for correct undo/redo
94027
94105
  let clone = cell.cloneValue();
94028
94106
  clone[cell.descriptor.labelAttribute] = newValue;
94029
94107
  newValue = clone;
94030
- // let style = cell.getStyle();
94031
- // mx.mxUtils.setCellStyles(this.getModel(), [cell], mx.mxConstants.STYLE_NOLABEL, 0);
94032
- //console.log('LABVEL changed', label)
94033
94108
  }
94034
94109
  super.cellLabelChanged(cell, newValue, autoSize);
94035
94110
  }
@@ -94046,8 +94121,6 @@ class Graph extends mx.mxGraph {
94046
94121
  }
94047
94122
  return null;
94048
94123
  }
94049
- //#endregion
94050
- //#region Memento state
94051
94124
  getState() {
94052
94125
  return {
94053
94126
  elements: this.getElementsState(this.getDefaultParent().children)
@@ -94128,22 +94201,6 @@ class Graph extends mx.mxGraph {
94128
94201
  }
94129
94202
  }
94130
94203
  });
94131
- // setTimeout(() => {
94132
- // let queue = states.slice(0);
94133
- // while (queue.length > 0) {
94134
- // let elementState = queue.shift();
94135
- // let element = <Cell>this.model.getCell(elementState.guid);
94136
- // if (element.isEdge()) {
94137
- // this.setCellGraphicalProperties(element, elementState.graphicalProperties);
94138
- // }
94139
- // if (elementState.slots) {
94140
- // for (let slotState of elementState.slots) {
94141
- // for (let childState of slotState.elements)
94142
- // queue.push(childState);
94143
- // }
94144
- // }
94145
- // }
94146
- // });
94147
94204
  }
94148
94205
  addElementFromState(state, parent) {
94149
94206
  var _a;
@@ -94171,10 +94228,6 @@ class Graph extends mx.mxGraph {
94171
94228
  gp.x += offset.width;
94172
94229
  if (gp.y !== undefined)
94173
94230
  gp.y += offset.height;
94174
- // if (gp.labelPosition) {
94175
- // gp.labelPosition.x += offset.width;
94176
- // gp.labelPosition.y += offset.height;
94177
- // }
94178
94231
  if (gp.points) {
94179
94232
  for (let point of gp.points) {
94180
94233
  point.x += offset.width;
@@ -94201,19 +94254,14 @@ class Graph extends mx.mxGraph {
94201
94254
  let newGuid = Guid.newInstance().toString();
94202
94255
  guidMap.set(state.guid, newGuid);
94203
94256
  state.guid = newGuid;
94204
- // let descriptor = this.getCellDescriptor(state.type);
94205
- // if (descriptor && descriptor.nameAttribute) {
94206
- // let name = state.properties[descriptor.nameAttribute];
94207
- // state.properties[descriptor.nameAttribute] = this.getNewCellName(name);
94208
- // }
94209
94257
  }
94210
94258
  setElementDelayedState(cell, state) {
94211
- // Second pass to allow finishing the construction of the diagram element, setting for example terminal connections
94212
94259
  if (cell.isEdge()) {
94213
94260
  let from = this.model.getCell(state.fromGuid.toString());
94214
94261
  this.model.setTerminal(cell, from, true);
94215
94262
  let to = this.model.getCell(state.toGuid.toString());
94216
94263
  this.model.setTerminal(cell, to, false);
94264
+ this.setCellGraphicalProperties(cell, state.graphicalProperties);
94217
94265
  }
94218
94266
  }
94219
94267
  setSlotState(cell, state) {
@@ -94286,7 +94334,6 @@ class Editor extends mx.mxEventSource {
94286
94334
  mx.mxEvent.disableContextMenu(this.container);
94287
94335
  this.initialize(options);
94288
94336
  }
94289
- //#region Initialization
94290
94337
  createGraph(options) {
94291
94338
  return new Graph(options);
94292
94339
  }
@@ -94294,11 +94341,6 @@ class Editor extends mx.mxEventSource {
94294
94341
  this.graph.setAllowDanglingEdges(false);
94295
94342
  this.graph.vertexLabelsMovable = true;
94296
94343
  this.graph.resizeContainer = false;
94297
- // this.graph.ignoreScrollbars = true;
94298
- // this.graph.translateToScrollPosition = true;
94299
- // this.graph.extendParents = false;
94300
- // this.graph.constrainChildren = false;
94301
- // this.graph.extendParentsOnAdd = false;
94302
94344
  if (options.guides)
94303
94345
  this.installGuides();
94304
94346
  if (options.undoManager)
@@ -94309,7 +94351,6 @@ class Editor extends mx.mxEventSource {
94309
94351
  mx.mxEvent.addListener(this.container, 'dragover', (e) => this.onDragOver(e));
94310
94352
  mx.mxEvent.addListener(this.container, 'drop', (e) => this.onDropOver(e));
94311
94353
  }
94312
- // Config graph after installing key handler, because otherwise panning conflicts with custom key strokes for Undo/Redo and selection moving
94313
94354
  this.graph.graphHandler.scrollOnMove = !!options.scrollOnMove;
94314
94355
  this.graph.setResizeContainer(!!options.resizeContainer);
94315
94356
  this.graph.setGridEnabled(!!options.grid);
@@ -94334,7 +94375,6 @@ class Editor extends mx.mxEventSource {
94334
94375
  let listener = (_, evt) => this.undoManager.undoableEditHappened(evt.getProperty('edit'));
94335
94376
  this.graph.getModel().addListener(mx.mxEvent.UNDO, listener);
94336
94377
  this.graph.getView().addListener(mx.mxEvent.UNDO, listener);
94337
- // Keeps the selection state in sync
94338
94378
  let undoHandler = (_, evt) => {
94339
94379
  let changes = evt.getProperty('edit').changes;
94340
94380
  this.graph.setSelectionCells(this.graph.getSelectionCellsForChanges(changes));
@@ -94364,7 +94404,6 @@ class Editor extends mx.mxEventSource {
94364
94404
  }
94365
94405
  installRubberBand() {
94366
94406
  this.rubberBand = new mx.mxRubberband(this.graph);
94367
- // Modify mouseDown event handlers to ignore Right button clicks to avoid inteference with context menu management which is done in the host of this component.
94368
94407
  const mouseDown = this.rubberBand.mouseDown;
94369
94408
  this.rubberBand.mouseDown = (sender, me) => {
94370
94409
  if (me.getEvent().button === 2) {
@@ -94375,8 +94414,6 @@ class Editor extends mx.mxEventSource {
94375
94414
  mouseDown.call(this.rubberBand, sender, me);
94376
94415
  };
94377
94416
  }
94378
- //#endregion
94379
- //#region Utility Methods
94380
94417
  setProperties(id, props, graphicalProps) {
94381
94418
  this._pauseGraphChangeEvents = true;
94382
94419
  this.undoManager.enabled = false;
@@ -94424,11 +94461,10 @@ class Editor extends mx.mxEventSource {
94424
94461
  if (json.format === this.clipboardFormat) {
94425
94462
  let editorGuid = new Guid(json.editorGuid);
94426
94463
  if (Guid.equals(editorGuid, this._guid)) {
94427
- this.graph.addElementsFromState(json.content, this.getParentForPaste(), false, COPY_OFFSET); // If it is a paste in the same editor, apply an offset to positions but do not reassign unique
94428
- // IDs unless an element with the same ID already exists.
94464
+ this.graph.addElementsFromState(json.content, this.getParentForPaste(), false, COPY_OFFSET);
94429
94465
  }
94430
94466
  else
94431
- this.graph.addElementsFromState(json.content, this.getParentForPaste(), true); // If it is a paste from another editor, always reassign unique IDs but do not apply any offset to positions.
94467
+ this.graph.addElementsFromState(json.content, this.getParentForPaste(), true);
94432
94468
  }
94433
94469
  }
94434
94470
  }
@@ -94457,15 +94493,14 @@ class Editor extends mx.mxEventSource {
94457
94493
  }
94458
94494
  });
94459
94495
  }
94460
- //#endregion
94461
- //#region Event Handling
94462
94496
  onGraphChange(evt) {
94463
94497
  if (this._pauseGraphChangeEvents)
94464
94498
  return;
94465
- //console.log('Model change', evt);
94466
- let events = EventConverter.convert(evt, this.graph);
94467
- if (events.length > 0)
94468
- this.fireEvent(new mx.mxEventObject(Editor.EVENT_MODEL_CHANGED, 'data', events), this);
94499
+ setTimeout(() => {
94500
+ let events = EventConverter.convert(evt, this.graph);
94501
+ if (events.length > 0)
94502
+ this.fireEvent(new mx.mxEventObject(Editor.EVENT_MODEL_CHANGED, 'data', events), this);
94503
+ }, 100);
94469
94504
  }
94470
94505
  onGraphSelectionChange() {
94471
94506
  let selection = this.graph.getSelectionCells();
@@ -94474,7 +94509,6 @@ class Editor extends mx.mxEventSource {
94474
94509
  if (cell instanceof Cell)
94475
94510
  data.push(cell.id);
94476
94511
  }
94477
- //console.log('SEL', selection);
94478
94512
  this.fireEvent(new mx.mxEventObject(Editor.EVENT_SELECTION_CHANGED, 'data', data)), this;
94479
94513
  }
94480
94514
  onUndoRedo(evt) {
@@ -94513,9 +94547,6 @@ class Editor extends mx.mxEventSource {
94513
94547
  }
94514
94548
  }
94515
94549
  async onDropOver(evt) {
94516
- // console.log('Dop Evt', evt);
94517
- // console.log(evt.dataTransfer.getData('text'));
94518
- // console.log(evt.dataTransfer.getData('text2'));
94519
94550
  let type = evt.dataTransfer.getData('text');
94520
94551
  let state = {};
94521
94552
  if (this.graph.editorHelper) {
@@ -94528,7 +94559,6 @@ class Editor extends mx.mxEventSource {
94528
94559
  let cellDescriptor = this.graph.getCellDescriptor(type);
94529
94560
  evt.stopPropagation();
94530
94561
  evt.preventDefault();
94531
- // Gets drop location point for vertex
94532
94562
  let size = cellDescriptor.size;
94533
94563
  let pt = mx.mxUtils.convertPoint(this.graph.container, mx.mxEvent.getClientX(evt), mx.mxEvent.getClientY(evt));
94534
94564
  let tr = this.graph.view.translate;
@@ -94565,8 +94595,6 @@ class Editor extends mx.mxEventSource {
94565
94595
  getDropTarget(x, y) {
94566
94596
  return null;
94567
94597
  }
94568
- //#endregion
94569
- //#region Memento state
94570
94598
  async setState(state) {
94571
94599
  this._pauseGraphChangeEvents = true;
94572
94600
  this.undoManager.enabled = false;
@@ -94587,34 +94615,6 @@ class Editor extends mx.mxEventSource {
94587
94615
  }
94588
94616
  Editor.EVENT_MODEL_CHANGED = 'modelChanged';
94589
94617
  Editor.EVENT_SELECTION_CHANGED = 'selectionChanged';
94590
- // Some ideas for panning with mousewheel (THIS IS NOT WORKING)
94591
- // startX: number;
94592
- // startY: number;
94593
- // protected subscribeToEvents() {
94594
- // mx.mxEvent.addListener(this.container, 'mousewheel', ((evt) => {
94595
- // this.container.addEventListener('mousewheel', (evt: any) => {
94596
- // // let pt = mx.mxUtils.convertPoint(this.graph.container, mx.mxEvent.getClientX(evt), mx.mxEvent.getClientY(evt));
94597
- // // let tr = this.graph.view.translate;
94598
- // // let scale = this.graph.view.scale;
94599
- // // let x = pt.x / scale - tr.x;
94600
- // // let y = pt.y / scale - tr.y;
94601
- // // if (!this.startX)
94602
- // // this.startX = x;
94603
- // // if (!this.startY)
94604
- // // this.startY = y;
94605
- // //this.graph.panGraph(evt.wheelDeltaX, evt.wheelDeltaY);
94606
- // this.graph.panGraph(20, 20);
94607
- // console.log('PAN', evt);
94608
- // if (evt.stopPropagation) evt.stopPropagation();
94609
- // if (evt.preventDefault) evt.preventDefault();
94610
- // if (evt.stopImmediatePropagation) evt.stopImmediatePropagation();
94611
- // evt.cancelBubble = true;
94612
- // evt.returnValue = false;
94613
- // //this.graph.panningManager.panTo(x + evt.deltaX , y + evt.deltaY);
94614
- // //this.graph.panningHandler.start(new mx.mxMouseEvent(evt, null));
94615
- // //mx.mxEvent.consume(evt);
94616
- // });
94617
- // }
94618
94618
 
94619
94619
  exports.Cell = Cell;
94620
94620
  exports.CellDescriptor = CellDescriptor;