@metadev/daga 5.0.4 → 5.1.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.
package/index.cjs.js CHANGED
@@ -2687,6 +2687,11 @@ class DiagramConnectionSet extends DiagramElementSet {
2687
2687
  }
2688
2688
  }
2689
2689
 
2690
+ exports.ResizableMode = void 0;
2691
+ (function (ResizableMode) {
2692
+ ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
2693
+ })(exports.ResizableMode || (exports.ResizableMode = {}));
2694
+
2690
2695
  /**
2691
2696
  * Default values of the parameters of a diagram field.
2692
2697
  * @private
@@ -2694,19 +2699,22 @@ class DiagramConnectionSet extends DiagramElementSet {
2694
2699
  */
2695
2700
  const DIAGRAM_FIELD_DEFAULTS = {
2696
2701
  editable: true,
2697
- fontSize: 0,
2698
2702
  margin: 0,
2699
2703
  padding: 0,
2700
- fontFamily: "'Wonder Unit Sans', sans-serif",
2701
- color: '#000000',
2702
- selectedColor: '#000000',
2703
- backgroundColor: '#00000000',
2704
2704
  horizontalAlign: exports.HorizontalAlign.Center,
2705
2705
  verticalAlign: exports.VerticalAlign.Center,
2706
2706
  orientation: exports.Side.Top,
2707
2707
  multiline: false,
2708
2708
  fit: false,
2709
- shrink: true
2709
+ shrink: true,
2710
+ look: {
2711
+ lookType: 'field-look',
2712
+ fillColor: 'transparent',
2713
+ fontColor: '#000000',
2714
+ fontFamily: "'Wonder Unit Sans', sans-serif",
2715
+ fontSize: 10,
2716
+ fontWeight: 400
2717
+ }
2710
2718
  };
2711
2719
  /**
2712
2720
  * A field which displays text and is part of a diagram element.
@@ -2734,7 +2742,26 @@ class DiagramField extends DiagramElement {
2734
2742
  (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
2735
2743
  }
2736
2744
  }
2737
- constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink) {
2745
+ /**
2746
+ * Current look of this field.
2747
+ * @private
2748
+ */
2749
+ get look() {
2750
+ if (this.selected) {
2751
+ if (this.highlighted) {
2752
+ return this.selectedAndHighlightedLook;
2753
+ } else {
2754
+ return this.selectedLook;
2755
+ }
2756
+ } else {
2757
+ if (this.highlighted) {
2758
+ return this.highlightedLook;
2759
+ } else {
2760
+ return this.defaultLook;
2761
+ }
2762
+ }
2763
+ }
2764
+ constructor(model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
2738
2765
  const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
2739
2766
  if (model.fields.get(id) !== undefined) {
2740
2767
  throw new Error('DiagramField for rootElement already exists');
@@ -2749,12 +2776,9 @@ class DiagramField extends DiagramElement {
2749
2776
  this.coords = coords;
2750
2777
  this.width = width;
2751
2778
  this.height = height;
2752
- this.fontSize = fontSize;
2753
- this.fontFamily = fontFamily;
2754
- this.color = color;
2755
- this.selectedColor = selectedColor;
2756
2779
  this.horizontalAlign = horizontalAlign;
2757
2780
  this.verticalAlign = verticalAlign;
2781
+ this.multiline = multiline;
2758
2782
  if (!isNaN(Number(orientation))) {
2759
2783
  this.orientation = Number(orientation);
2760
2784
  } else {
@@ -2775,7 +2799,11 @@ class DiagramField extends DiagramElement {
2775
2799
  this.orientation = 0;
2776
2800
  }
2777
2801
  }
2778
- this.multiline = multiline;
2802
+ const looks = extractLooksFromConfig(look);
2803
+ this.defaultLook = looks.defaultLook;
2804
+ this.selectedLook = looks.selectedLook;
2805
+ this.highlightedLook = looks.highlightedLook;
2806
+ this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
2779
2807
  this.defaultText = text;
2780
2808
  this._text = text;
2781
2809
  this.editable = editable;
@@ -2820,8 +2848,8 @@ class DiagramFieldSet extends DiagramElementSet {
2820
2848
  * Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
2821
2849
  * @private
2822
2850
  */
2823
- new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink) {
2824
- const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, multiline, text, editable, fit, shrink);
2851
+ new(rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
2852
+ const field = new DiagramField(this.model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink);
2825
2853
  super.add(field);
2826
2854
  field.updateInView();
2827
2855
  // add this field to its root element
@@ -3000,11 +3028,6 @@ const getTopPadding$1 = config => {
3000
3028
  }
3001
3029
  };
3002
3030
 
3003
- exports.ResizableMode = void 0;
3004
- (function (ResizableMode) {
3005
- ResizableMode[ResizableMode["OnlyWhenSelected"] = 0] = "OnlyWhenSelected";
3006
- })(exports.ResizableMode || (exports.ResizableMode = {}));
3007
-
3008
3031
  /**
3009
3032
  * Default value of the default width of a diagram section.
3010
3033
  * @private
@@ -3445,8 +3468,9 @@ class DiagramSectionSet extends DiagramElementSet {
3445
3468
  const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
3446
3469
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3447
3470
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3448
- const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3449
- const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3471
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
3472
+ const labelWidth = 6 * (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3473
+ const labelHeight = (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3450
3474
  let labelCoords;
3451
3475
  switch (port.direction) {
3452
3476
  case exports.Side.Bottom:
@@ -3460,7 +3484,7 @@ class DiagramSectionSet extends DiagramElementSet {
3460
3484
  default:
3461
3485
  labelCoords = port.coords;
3462
3486
  }
3463
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3487
+ this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3464
3488
  }
3465
3489
  }
3466
3490
  }
@@ -3468,7 +3492,8 @@ class DiagramSectionSet extends DiagramElementSet {
3468
3492
  const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
3469
3493
  if (sectionLabel) {
3470
3494
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
3471
- this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3495
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
3496
+ this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3472
3497
  }
3473
3498
  return section;
3474
3499
  }
@@ -4373,8 +4398,9 @@ class DiagramNodeSet extends DiagramElementSet {
4373
4398
  const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
4374
4399
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
4375
4400
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
4376
- const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
4377
- const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
4401
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
4402
+ const labelWidth = 6 * (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
4403
+ const labelHeight = (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
4378
4404
  let labelCoords;
4379
4405
  switch (port.direction) {
4380
4406
  case exports.Side.Bottom:
@@ -4388,20 +4414,21 @@ class DiagramNodeSet extends DiagramElementSet {
4388
4414
  default:
4389
4415
  labelCoords = port.coords;
4390
4416
  }
4391
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4417
+ this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4392
4418
  }
4393
4419
  }
4394
4420
  }
4395
4421
  // add node label
4396
4422
  if (nodeType.label) {
4397
4423
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
4398
- this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4424
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
4425
+ this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4399
4426
  }
4400
4427
  // add node decorators
4401
4428
  if (nodeType.decorators.length > 0) {
4402
4429
  for (let i = 0; i < nodeType.decorators.length; ++i) {
4403
4430
  const decoratorConfig = nodeType.decorators[i];
4404
- this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
4431
+ this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.svg, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
4405
4432
  }
4406
4433
  }
4407
4434
  node.valueSet.resetValues();
@@ -4573,6 +4600,183 @@ const getTopPadding = config => {
4573
4600
  }
4574
4601
  };
4575
4602
 
4603
+ /**
4604
+ * A foreign object which is inserted with arbitrary SVG code into a diagram.
4605
+ * Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
4606
+ * Diagram decorators are not serialized with other diagram elements.
4607
+ * @public
4608
+ * @see DiagramNode
4609
+ * @see DiagramObject
4610
+ * @see DiagramSection
4611
+ */
4612
+ class DiagramDecorator extends DiagramElement {
4613
+ constructor(model, rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4614
+ if (model.objects.get(id) !== undefined) {
4615
+ throw new Error(`DiagramDecorator with id "${id}" already exists`);
4616
+ }
4617
+ if (!id) {
4618
+ throw new Error(`DiagramDecorator cannot have an empty or null id`);
4619
+ }
4620
+ super(model, id);
4621
+ this.rootElement = rootElement;
4622
+ this.coords = coords;
4623
+ this.width = width;
4624
+ this.height = height;
4625
+ this.priority = priority;
4626
+ this.svg = svg;
4627
+ this.anchorPointX = anchorPointX;
4628
+ this.anchorPointY = anchorPointY;
4629
+ }
4630
+ get removed() {
4631
+ return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
4632
+ }
4633
+ updateInView() {
4634
+ var _a;
4635
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
4636
+ }
4637
+ raise() {
4638
+ var _a;
4639
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4640
+ }
4641
+ /**
4642
+ * Change the coordinates of this decorator to the given coordinates.
4643
+ * @public
4644
+ * @param coords A point in the diagram.
4645
+ */
4646
+ move(coords) {
4647
+ this.coords = coords;
4648
+ this.updateInView();
4649
+ }
4650
+ getPriority() {
4651
+ return this.priority;
4652
+ }
4653
+ }
4654
+ class DiagramDecoratorSet extends DiagramElementSet {
4655
+ /**
4656
+ * Instance a set of decorators for the given model. This method is used internally.
4657
+ * @private
4658
+ */
4659
+ constructor(model) {
4660
+ super();
4661
+ this.model = model;
4662
+ }
4663
+ /**
4664
+ * Instance a new decorator and add it to this set.
4665
+ * @public
4666
+ * @param coords The coordinates of the top left corner of the decorator in the diagram.
4667
+ * @param width The dimension of the decorator along the x axis.
4668
+ * @param height The dimension of the decorator along the y axis.
4669
+ * @param priority The priority of the decorator. Used when filtering by priority.
4670
+ * @param svg The SVG contents of the decorator.
4671
+ * @param id The id of the decorator. Cannot be an empty string.
4672
+ * @returns The instanced decorator.
4673
+ */
4674
+ new(rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4675
+ const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, svg, id, anchorPointX, anchorPointY);
4676
+ super.add(decorator);
4677
+ decorator.updateInView();
4678
+ // add this port to its root element
4679
+ if (rootElement !== undefined) {
4680
+ rootElement.decorators.push(decorator);
4681
+ }
4682
+ return decorator;
4683
+ }
4684
+ remove(id) {
4685
+ const decorator = this.get(id, true);
4686
+ if (decorator) {
4687
+ // remove from root element
4688
+ if (decorator.rootElement instanceof DiagramNode || decorator.rootElement instanceof DiagramSection) {
4689
+ removeIfExists(decorator.rootElement.decorators, decorator);
4690
+ }
4691
+ // remove from set of objects
4692
+ super.remove(id);
4693
+ // remove from canvas
4694
+ decorator.updateInView();
4695
+ }
4696
+ }
4697
+ }
4698
+
4699
+ /**
4700
+ * A foreign object which is inserted with arbitrary SVG code into a diagram.
4701
+ * Diagram objects are not serialized with other diagram elements.
4702
+ * @public
4703
+ */
4704
+ class DiagramObject extends DiagramElement {
4705
+ constructor(model, coords, width, height, priority, svg, id) {
4706
+ if (model.objects.get(id) !== undefined) {
4707
+ throw new Error(`DiagramObject with id "${id}" already exists`);
4708
+ }
4709
+ if (!id) {
4710
+ throw new Error(`DiagramObject cannot have an empty or null id`);
4711
+ }
4712
+ super(model, id);
4713
+ this.coords = coords;
4714
+ this.width = width;
4715
+ this.height = height;
4716
+ this.priority = priority;
4717
+ this.svg = svg;
4718
+ }
4719
+ get removed() {
4720
+ return this.selfRemoved;
4721
+ }
4722
+ updateInView() {
4723
+ var _a;
4724
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
4725
+ }
4726
+ raise() {
4727
+ var _a;
4728
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4729
+ }
4730
+ /**
4731
+ * Change the coordinates of this object to the given coordinates.
4732
+ * @public
4733
+ * @param coords A point in the diagram.
4734
+ */
4735
+ move(coords) {
4736
+ this.coords = coords;
4737
+ this.updateInView();
4738
+ }
4739
+ getPriority() {
4740
+ return this.priority;
4741
+ }
4742
+ }
4743
+ class DiagramObjectSet extends DiagramElementSet {
4744
+ /**
4745
+ * Instance a set of objects for the given model. This method is used internally.
4746
+ * @private
4747
+ */
4748
+ constructor(model) {
4749
+ super();
4750
+ this.model = model;
4751
+ }
4752
+ /**
4753
+ * Instance a new object and add it to this set.
4754
+ * @public
4755
+ * @param coords The coordinates of the top left corner of the object in the diagram.
4756
+ * @param width The dimension of the object along the x axis.
4757
+ * @param height The dimension of the object along the y axis.
4758
+ * @param priority The priority of the object. Used when filtering by priority.
4759
+ * @param svg The SVG contents of the object.
4760
+ * @param id The id of the object. Cannot be an empty string.
4761
+ * @returns The instanced object.
4762
+ */
4763
+ new(coords, width, height, priority, svg, id) {
4764
+ const object = new DiagramObject(this.model, coords, width, height, priority, svg, id);
4765
+ super.add(object);
4766
+ object.updateInView();
4767
+ return object;
4768
+ }
4769
+ remove(id) {
4770
+ const object = this.get(id, true);
4771
+ if (object) {
4772
+ // remove from set of objects
4773
+ super.remove(id);
4774
+ // remove from canvas
4775
+ object.updateInView();
4776
+ }
4777
+ }
4778
+ }
4779
+
4576
4780
  /**
4577
4781
  * Default values of the look of a diagram port.
4578
4782
  * @private
@@ -4938,6 +5142,14 @@ class DagaImporter {
4938
5142
  for (const connection of data.connections || []) {
4939
5143
  this.importConnection(model, connection);
4940
5144
  }
5145
+ for (const object of data.objects || []) {
5146
+ const newObject = new DiagramObject(model, object.coords, object.width, object.height, object.priority, object.svg, object.id);
5147
+ if (object.collabMeta) {
5148
+ newObject.selfRemoved = object.collabMeta.selfRemoved;
5149
+ }
5150
+ model.objects.add(newObject);
5151
+ newObject.updateInView();
5152
+ }
4941
5153
  if (data.data) {
4942
5154
  model.valueSet.setValues(data.data);
4943
5155
  }
@@ -4955,17 +5167,11 @@ class DagaImporter {
4955
5167
  model.nodes.add(newNode);
4956
5168
  newNode.width = node.width;
4957
5169
  newNode.height = node.height;
4958
- // add node decorators
4959
- if (newNodeType.decorators) {
4960
- for (let i = 0; i < newNodeType.decorators.length; ++i) {
4961
- const decoratorConfig = newNodeType.decorators[i];
4962
- model.decorators.new(newNode, [newNode.coords[0] + decoratorConfig.coords[0], newNode.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, newNode.getPriority(), decoratorConfig.html, `${newNode.id}_decorator_${i}`);
4963
- }
4964
- }
4965
5170
  // add node label
4966
5171
  if (newNodeType.label) {
4967
5172
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
4968
- const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5173
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5174
+ const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4969
5175
  newField.text = node.label;
4970
5176
  newNode.label = newField;
4971
5177
  model.fields.add(newField);
@@ -4985,7 +5191,8 @@ class DagaImporter {
4985
5191
  // add section label
4986
5192
  if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
4987
5193
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
4988
- const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5194
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5195
+ const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4989
5196
  newField.text = section.label;
4990
5197
  newSection.label = newField;
4991
5198
  model.fields.add(newField);
@@ -5001,22 +5208,23 @@ class DagaImporter {
5001
5208
  // add port label
5002
5209
  if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
5003
5210
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
5211
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5004
5212
  let labelCoords;
5005
5213
  switch (newPort.direction) {
5006
5214
  case exports.Side.Top:
5007
5215
  case exports.Side.Left:
5008
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5216
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5009
5217
  break;
5010
5218
  case exports.Side.Bottom:
5011
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] + labelConfiguration.fontSize];
5219
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5012
5220
  break;
5013
5221
  case exports.Side.Right:
5014
- labelCoords = [newPort.coords[0] + labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5222
+ labelCoords = [newPort.coords[0] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5015
5223
  break;
5016
5224
  default:
5017
5225
  labelCoords = newPort.coords;
5018
5226
  }
5019
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5227
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5020
5228
  newField.text = port.label;
5021
5229
  newPort.label = newField;
5022
5230
  model.fields.add(newField);
@@ -5031,6 +5239,15 @@ class DagaImporter {
5031
5239
  }
5032
5240
  newPort.updateInView();
5033
5241
  }
5242
+ for (const decorator of section.decorators || []) {
5243
+ const newDecorator = new DiagramDecorator(model, newSection, decorator.coords, decorator.width, decorator.height, decorator.priority, decorator.svg, decorator.id, decorator.anchorPoints[0], decorator.anchorPoints[1]);
5244
+ if (decorator.collabMeta) {
5245
+ newDecorator.selfRemoved = decorator.collabMeta.selfRemoved;
5246
+ }
5247
+ newNode.decorators.push(newDecorator);
5248
+ model.decorators.add(newDecorator);
5249
+ newDecorator.updateInView();
5250
+ }
5034
5251
  if (section.collabMeta) {
5035
5252
  newSection.selfRemoved = section.collabMeta.selfRemoved;
5036
5253
  newSection.selfRemovedTimestamp = section.collabMeta.selfRemovedTimestamp;
@@ -5048,22 +5265,23 @@ class DagaImporter {
5048
5265
  // add port label
5049
5266
  if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
5050
5267
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
5268
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
5051
5269
  let labelCoords;
5052
5270
  switch (newPort.direction) {
5053
5271
  case exports.Side.Top:
5054
5272
  case exports.Side.Left:
5055
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5273
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5056
5274
  break;
5057
5275
  case exports.Side.Bottom:
5058
- labelCoords = [newPort.coords[0] - labelConfiguration.fontSize, newPort.coords[1] + labelConfiguration.fontSize];
5276
+ labelCoords = [newPort.coords[0] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5059
5277
  break;
5060
5278
  case exports.Side.Right:
5061
- labelCoords = [newPort.coords[0] + labelConfiguration.fontSize, newPort.coords[1] - labelConfiguration.fontSize];
5279
+ labelCoords = [newPort.coords[0] + (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize), newPort.coords[1] - (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)];
5062
5280
  break;
5063
5281
  default:
5064
5282
  labelCoords = newPort.coords;
5065
5283
  }
5066
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5284
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
5067
5285
  newField.text = port.label;
5068
5286
  newPort.label = newField;
5069
5287
  model.fields.add(newField);
@@ -5078,6 +5296,15 @@ class DagaImporter {
5078
5296
  }
5079
5297
  newPort.updateInView();
5080
5298
  }
5299
+ for (const decorator of node.decorators || []) {
5300
+ const newDecorator = new DiagramDecorator(model, newNode, decorator.coords, decorator.width, decorator.height, decorator.priority, decorator.svg, decorator.id, decorator.anchorPoints[0], decorator.anchorPoints[1]);
5301
+ if (decorator.collabMeta) {
5302
+ newDecorator.selfRemoved = decorator.collabMeta.selfRemoved;
5303
+ }
5304
+ newNode.decorators.push(newDecorator);
5305
+ model.decorators.add(newDecorator);
5306
+ newDecorator.updateInView();
5307
+ }
5081
5308
  if (node.data) {
5082
5309
  newNode.valueSet.setValues(node.data);
5083
5310
  }
@@ -6369,7 +6596,8 @@ class DiagramZoomEvent extends DiagramEvent {
6369
6596
  /**
6370
6597
  * Create a diagram zoom event.
6371
6598
  *
6372
- * @param coords .
6599
+ * @param coords Coordinates to which the user panned. Calling the method `canvas.translateTo()` with these coordinates after this event should cause no changes.
6600
+ * @param zoom Zoom level to which the user zoomed. Calling the method `canvas.zoomTo()` with this zoom level after this event should cause no changes.
6373
6601
  */
6374
6602
  constructor(coords, zoom) {
6375
6603
  super(exports.DiagramEvents.Zoom);
@@ -6459,183 +6687,6 @@ class DiagramDraggingNodeEvent extends DiagramEvent {
6459
6687
  }
6460
6688
  }
6461
6689
 
6462
- /**
6463
- * A foreign object which is inserted with arbitrary html into a diagram.
6464
- * Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
6465
- * Diagram decorators are not serialized with other diagram elements.
6466
- * @public
6467
- * @see DiagramNode
6468
- * @see DiagramObject
6469
- * @see DiagramSection
6470
- */
6471
- class DiagramDecorator extends DiagramElement {
6472
- constructor(model, rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
6473
- if (model.objects.get(id) !== undefined) {
6474
- throw new Error(`DiagramDecorator with id "${id}" already exists`);
6475
- }
6476
- if (!id) {
6477
- throw new Error(`DiagramDecorator cannot have an empty or null id`);
6478
- }
6479
- super(model, id);
6480
- this.rootElement = rootElement;
6481
- this.coords = coords;
6482
- this.width = width;
6483
- this.height = height;
6484
- this.priority = priority;
6485
- this.html = html;
6486
- this.anchorPointX = anchorPointX;
6487
- this.anchorPointY = anchorPointY;
6488
- }
6489
- get removed() {
6490
- return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
6491
- }
6492
- updateInView() {
6493
- var _a;
6494
- (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
6495
- }
6496
- raise() {
6497
- var _a;
6498
- (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
6499
- }
6500
- /**
6501
- * Change the coordinates of this decorator to the given coordinates.
6502
- * @public
6503
- * @param coords A point in the diagram.
6504
- */
6505
- move(coords) {
6506
- this.coords = coords;
6507
- this.updateInView();
6508
- }
6509
- getPriority() {
6510
- return this.priority;
6511
- }
6512
- }
6513
- class DiagramDecoratorSet extends DiagramElementSet {
6514
- /**
6515
- * Instance a set of decorators for the given model. This method is used internally.
6516
- * @private
6517
- */
6518
- constructor(model) {
6519
- super();
6520
- this.model = model;
6521
- }
6522
- /**
6523
- * Instance a new decorator and add it to this set.
6524
- * @public
6525
- * @param coords The coordinates of the top left corner of the decorator in the diagram.
6526
- * @param width The dimension of the decorator along the x axis.
6527
- * @param height The dimension of the decorator along the y axis.
6528
- * @param priority The priority of the decorator. Used when filtering by priority.
6529
- * @param html The html contents of the decorator.
6530
- * @param id The id of the decorator. Cannot be an empty string.
6531
- * @returns The instanced decorator.
6532
- */
6533
- new(rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
6534
- const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id, anchorPointX, anchorPointY);
6535
- super.add(decorator);
6536
- decorator.updateInView();
6537
- // add this port to its root element
6538
- if (rootElement !== undefined) {
6539
- rootElement.decorators.push(decorator);
6540
- }
6541
- return decorator;
6542
- }
6543
- remove(id) {
6544
- const decorator = this.get(id, true);
6545
- if (decorator) {
6546
- // remove from root element
6547
- if (decorator.rootElement instanceof DiagramNode || decorator.rootElement instanceof DiagramSection) {
6548
- removeIfExists(decorator.rootElement.decorators, decorator);
6549
- }
6550
- // remove from set of objects
6551
- super.remove(id);
6552
- // remove from canvas
6553
- decorator.updateInView();
6554
- }
6555
- }
6556
- }
6557
-
6558
- /**
6559
- * A foreign object which is inserted with arbitrary html into a diagram.
6560
- * Diagram objects are not serialized with other diagram elements.
6561
- * @public
6562
- */
6563
- class DiagramObject extends DiagramElement {
6564
- constructor(model, coords, width, height, priority, html, id) {
6565
- if (model.objects.get(id) !== undefined) {
6566
- throw new Error(`DiagramObject with id "${id}" already exists`);
6567
- }
6568
- if (!id) {
6569
- throw new Error(`DiagramObject cannot have an empty or null id`);
6570
- }
6571
- super(model, id);
6572
- this.coords = coords;
6573
- this.width = width;
6574
- this.height = height;
6575
- this.priority = priority;
6576
- this.html = html;
6577
- }
6578
- get removed() {
6579
- return this.selfRemoved;
6580
- }
6581
- updateInView() {
6582
- var _a;
6583
- (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
6584
- }
6585
- raise() {
6586
- var _a;
6587
- (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
6588
- }
6589
- /**
6590
- * Change the coordinates of this object to the given coordinates.
6591
- * @public
6592
- * @param coords A point in the diagram.
6593
- */
6594
- move(coords) {
6595
- this.coords = coords;
6596
- this.updateInView();
6597
- }
6598
- getPriority() {
6599
- return this.priority;
6600
- }
6601
- }
6602
- class DiagramObjectSet extends DiagramElementSet {
6603
- /**
6604
- * Instance a set of objects for the given model. This method is used internally.
6605
- * @private
6606
- */
6607
- constructor(model) {
6608
- super();
6609
- this.model = model;
6610
- }
6611
- /**
6612
- * Instance a new object and add it to this set.
6613
- * @public
6614
- * @param coords The coordinates of the top left corner of the object in the diagram.
6615
- * @param width The dimension of the object along the x axis.
6616
- * @param height The dimension of the object along the y axis.
6617
- * @param priority The priority of the object. Used when filtering by priority.
6618
- * @param html The html contents of the object.
6619
- * @param id The id of the object. Cannot be an empty string.
6620
- * @returns The instanced object.
6621
- */
6622
- new(coords, width, height, priority, html, id) {
6623
- const object = new DiagramObject(this.model, coords, width, height, priority, html, id);
6624
- super.add(object);
6625
- object.updateInView();
6626
- return object;
6627
- }
6628
- remove(id) {
6629
- const object = this.get(id, true);
6630
- if (object) {
6631
- // remove from set of objects
6632
- super.remove(id);
6633
- // remove from canvas
6634
- object.updateInView();
6635
- }
6636
- }
6637
- }
6638
-
6639
6690
  /**
6640
6691
  * Stores the data of a diagram.
6641
6692
  * Represents the state of the diagram.
@@ -6737,7 +6788,7 @@ const isSecondaryButton = event => {
6737
6788
  const getConnectionPath = (shape, startCoords, endCoords, startDirection, endDirection, points, width, startMarkerWidth, endMarkerWidth) => {
6738
6789
  return linePath(shape, [startCoords, ...points, endCoords], startDirection, endDirection, Math.max(
6739
6790
  // reasonable value for the minimumDistanceBeforeTurn relative to the line width
6740
- 10, startMarkerWidth || 0, endMarkerWidth || 0) * width);
6791
+ 10, startMarkerWidth !== null && startMarkerWidth !== void 0 ? startMarkerWidth : 0, endMarkerWidth !== null && endMarkerWidth !== void 0 ? endMarkerWidth : 0) * width);
6741
6792
  };
6742
6793
  const setCursorStyle = style => {
6743
6794
  if (!style) {
@@ -6747,11 +6798,12 @@ const setCursorStyle = style => {
6747
6798
  }
6748
6799
  };
6749
6800
  const getRelatedNodeOrItself = element => {
6801
+ var _a;
6750
6802
  if (element instanceof DiagramNode) {
6751
6803
  return element;
6752
6804
  }
6753
6805
  if (element instanceof DiagramSection) {
6754
- return element.node || element;
6806
+ return (_a = element.node) !== null && _a !== void 0 ? _a : element;
6755
6807
  }
6756
6808
  return element.rootElement instanceof DiagramNode || element.rootElement instanceof DiagramSection || element.rootElement instanceof DiagramPort ? getRelatedNodeOrItself(element.rootElement) : element;
6757
6809
  };
@@ -6803,9 +6855,21 @@ const SHAPED_LOOK_DEFAULTS = {
6803
6855
  borderStyle: exports.LineStyle.Solid
6804
6856
  };
6805
6857
  const updateLook = selection => {
6806
- selection.filter('.shaped-look').select('path').attr('d', d => generalClosedPath(d.look.shape || exports.ClosedShape.Rectangle, 0, 0, d.width, d.height)).attr('fill', d => d.look.fillColor || SHAPED_LOOK_DEFAULTS.fillColor).attr('stroke', d => d.look.borderColor || SHAPED_LOOK_DEFAULTS.borderColor).attr('stroke-width', d => `${d.look.borderThickness || SHAPED_LOOK_DEFAULTS.borderThickness}px`).attr('stroke-dasharray', d => {
6807
- var _a, _b, _c;
6808
- return lineStyleDasharray(d.look.borderStyle || SHAPED_LOOK_DEFAULTS.borderStyle, ((_b = (_a = d.type) === null || _a === void 0 ? void 0 : _a.defaultLook) === null || _b === void 0 ? void 0 : _b.borderThickness) || ((_c = d.look) === null || _c === void 0 ? void 0 : _c.borderThickness) || SHAPED_LOOK_DEFAULTS.borderThickness);
6858
+ selection.filter('.shaped-look').select('path').attr('d', d => {
6859
+ var _a;
6860
+ return generalClosedPath((_a = d.look.shape) !== null && _a !== void 0 ? _a : exports.ClosedShape.Rectangle, 0, 0, d.width, d.height);
6861
+ }).attr('fill', d => {
6862
+ var _a;
6863
+ return (_a = d.look.fillColor) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.fillColor;
6864
+ }).attr('stroke', d => {
6865
+ var _a;
6866
+ return (_a = d.look.borderColor) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderColor;
6867
+ }).attr('stroke-width', d => {
6868
+ var _a;
6869
+ return `${(_a = d.look.borderThickness) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderThickness}px`;
6870
+ }).attr('stroke-dasharray', d => {
6871
+ var _a, _b, _c, _d, _e, _f;
6872
+ return lineStyleDasharray((_a = d.look.borderStyle) !== null && _a !== void 0 ? _a : SHAPED_LOOK_DEFAULTS.borderStyle, (_f = (_d = (_c = (_b = d.type) === null || _b === void 0 ? void 0 : _b.defaultLook) === null || _c === void 0 ? void 0 : _c.borderThickness) !== null && _d !== void 0 ? _d : (_e = d.look) === null || _e === void 0 ? void 0 : _e.borderThickness) !== null && _f !== void 0 ? _f : SHAPED_LOOK_DEFAULTS.borderThickness);
6809
6873
  });
6810
6874
  selection.filter('.image-look').select('image').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('href', d => d.look.backgroundImage);
6811
6875
  selection.filter('.stretchable-image-look').select('image.top-left-image').attr('x', 0).attr('y', 0).attr('width', d => d.look.leftMargin).attr('height', d => d.look.topMargin).attr('href', d => d.look.backgroundImageTopLeft);
@@ -6818,30 +6882,91 @@ const updateLook = selection => {
6818
6882
  selection.filter('.stretchable-image-look').select('image.bottom-image').attr('x', d => d.look.leftMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.width - d.look.rightMargin - d.look.leftMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottom);
6819
6883
  selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
6820
6884
  };
6885
+ const BACKGROUND_DEFAULTS = {
6886
+ style: 'solid',
6887
+ color: '#FFFFFF'
6888
+ };
6821
6889
  const GRID_DEFAULTS = {
6890
+ enabled: true,
6891
+ style: 'none',
6892
+ snap: false,
6893
+ spacing: 1
6894
+ };
6895
+ const DOTS_GRID_DEFAULTS = Object.assign(Object.assign({}, GRID_DEFAULTS), {
6822
6896
  style: 'dots',
6823
- color: 'rgba(0, 0, 0, 0.1)',
6824
6897
  snap: false,
6825
6898
  spacing: 10,
6826
- thickness: 0.05
6899
+ thickness: 0.05,
6900
+ color: 'rgba(0, 0, 0, 0.1)'
6901
+ });
6902
+ const initializeBackground = (canvas, canvasView, backgroundConfig) => {
6903
+ var _a, _b;
6904
+ switch ((_a = backgroundConfig === null || backgroundConfig === void 0 ? void 0 : backgroundConfig.style) !== null && _a !== void 0 ? _a : '') {
6905
+ case 'image':
6906
+ return canvasView.append('image').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('href', backgroundConfig.image).attr('preserveAspectRatio', 'none');
6907
+ case 'solid':
6908
+ default:
6909
+ return canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', (_b = backgroundConfig.color) !== null && _b !== void 0 ? _b : '#FFFFFF').attr('stroke-width', '0');
6910
+ }
6911
+ };
6912
+ const applyGridDefaults = gridConfig => {
6913
+ if (!gridConfig) {
6914
+ return DOTS_GRID_DEFAULTS;
6915
+ }
6916
+ switch (gridConfig.style) {
6917
+ case 'dots':
6918
+ case 'lines':
6919
+ // lines has the same parameters as dots
6920
+ return Object.assign(Object.assign({}, DOTS_GRID_DEFAULTS), gridConfig);
6921
+ default:
6922
+ return Object.assign(Object.assign({}, GRID_DEFAULTS), gridConfig);
6923
+ }
6827
6924
  };
6828
- const initializeGrid = (canvas, canvasView, backgroundPatternId) => {
6829
- const canvasDefs = canvasView.append('defs');
6830
- if (canvas.gridSize > 0 && isFinite(canvas.gridSize)) {
6831
- const canvasBackgroundPattern = canvasDefs.append('pattern').attr('id', backgroundPatternId).attr('x', -canvas.gridSize / 2).attr('y', -canvas.gridSize / 2).attr('width', canvas.gridSize).attr('height', canvas.gridSize).attr('patternUnits', 'userSpaceOnUse');
6832
- canvasBackgroundPattern.append('rect').attr('x', 0).attr('y', 0).attr('width', canvas.gridSize).attr('height', canvas.gridSize).attr('fill', canvas.backgroundColor);
6833
- switch (canvas.gridStyle) {
6925
+ const initializeGrid = (canvas, canvasView, canvasDefs, gridPatternId, gridConfig) => {
6926
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6927
+ if (getGridSpacingX(gridConfig) !== 0 && getGridSpacingY(gridConfig) !== 0) {
6928
+ const canvasBackgroundPattern = canvasDefs.append('pattern').attr('id', gridPatternId).attr('x', -getGridSpacingX(gridConfig) / 2).attr('y', -getGridSpacingY(gridConfig) / 2).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('patternUnits', 'userSpaceOnUse');
6929
+ canvasBackgroundPattern.append('rect').attr('x', 0).attr('y', 0).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('fill', 'transparent');
6930
+ switch (gridConfig.style) {
6834
6931
  case 'dots':
6835
- canvasBackgroundPattern.append('circle').attr('cx', canvas.gridSize / 2).attr('cy', canvas.gridSize / 2).attr('r', canvas.gridSize * canvas.gridThickness).attr('fill', canvas.gridColor);
6932
+ canvasBackgroundPattern.append('circle').attr('cx', getGridSpacingX(gridConfig) / 2).attr('cy', getGridSpacingY(gridConfig) / 2).attr('r', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_a = gridConfig.thickness) !== null && _a !== void 0 ? _a : 0)).attr('fill', (_b = gridConfig.color) !== null && _b !== void 0 ? _b : '');
6836
6933
  break;
6837
6934
  case 'lines':
6838
- canvasBackgroundPattern.append('line').attr('x1', canvas.gridSize / 2).attr('x2', canvas.gridSize / 2).attr('y1', 0).attr('y2', canvas.gridSize).attr('stroke-width', canvas.gridSize * canvas.gridThickness).attr('stroke', canvas.gridColor);
6839
- canvasBackgroundPattern.append('line').attr('x1', 0).attr('x2', (canvas.gridSize - canvas.gridSize * canvas.gridThickness) / 2).attr('y1', canvas.gridSize / 2).attr('y2', canvas.gridSize / 2).attr('stroke-width', canvas.gridSize * canvas.gridThickness).attr('stroke', canvas.gridColor);
6840
- canvasBackgroundPattern.append('line').attr('x1', (canvas.gridSize + canvas.gridSize * canvas.gridThickness) / 2).attr('x2', canvas.gridSize).attr('y1', canvas.gridSize / 2).attr('y2', canvas.gridSize / 2).attr('stroke-width', canvas.gridSize * canvas.gridThickness).attr('stroke', canvas.gridColor);
6935
+ canvasBackgroundPattern.append('line').attr('x1', getGridSpacingX(gridConfig) / 2).attr('x2', getGridSpacingX(gridConfig) / 2).attr('y1', 0).attr('y2', getGridSpacingY(gridConfig)).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_c = gridConfig.thickness) !== null && _c !== void 0 ? _c : 0)).attr('stroke', (_d = gridConfig.color) !== null && _d !== void 0 ? _d : '');
6936
+ canvasBackgroundPattern.append('line').attr('x1', 0).attr('x2', (getGridSpacingX(gridConfig) - getGridSpacingX(gridConfig) * ((_e = gridConfig.thickness) !== null && _e !== void 0 ? _e : 0)) / 2).attr('y1', getGridSpacingY(gridConfig) / 2).attr('y2', getGridSpacingY(gridConfig) / 2).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_f = gridConfig.thickness) !== null && _f !== void 0 ? _f : 0)).attr('stroke', (_g = gridConfig.color) !== null && _g !== void 0 ? _g : '');
6937
+ canvasBackgroundPattern.append('line').attr('x1', (getGridSpacingX(gridConfig) + getGridSpacingX(gridConfig) * ((_h = gridConfig.thickness) !== null && _h !== void 0 ? _h : 0)) / 2).attr('x2', getGridSpacingX(gridConfig)).attr('y1', getGridSpacingY(gridConfig) / 2).attr('y2', getGridSpacingY(gridConfig) / 2).attr('stroke-width', Math.min(getGridSpacingX(gridConfig), getGridSpacingY(gridConfig)) * ((_j = gridConfig.thickness) !== null && _j !== void 0 ? _j : 0)).attr('stroke', (_k = gridConfig.color) !== null && _k !== void 0 ? _k : '');
6938
+ break;
6939
+ case 'image':
6940
+ canvasBackgroundPattern.append('image').attr('x', 0).attr('y', 0).attr('width', getGridSpacingX(gridConfig)).attr('height', getGridSpacingY(gridConfig)).attr('href', gridConfig.image).attr('preserveAspectRatio', 'none');
6841
6941
  break;
6842
6942
  }
6843
- canvasView.select('rect').attr('fill', `url(#${backgroundPatternId})`);
6943
+ return canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', `url(#${gridPatternId})`).attr('stroke-width', '0');
6944
+ }
6945
+ return undefined;
6946
+ };
6947
+ const getGridSpacingX = gridConfig => {
6948
+ let value = 0;
6949
+ if (typeof gridConfig.spacing === 'number') {
6950
+ value = gridConfig.spacing;
6951
+ } else if (Array.isArray(gridConfig.spacing) && typeof gridConfig.spacing[0] === 'number') {
6952
+ value = gridConfig.spacing[0];
6844
6953
  }
6954
+ if (!isFinite(value)) {
6955
+ return 0;
6956
+ }
6957
+ return value;
6958
+ };
6959
+ const getGridSpacingY = gridConfig => {
6960
+ let value = 0;
6961
+ if (typeof gridConfig.spacing === 'number') {
6962
+ value = gridConfig.spacing;
6963
+ } else if (Array.isArray(gridConfig.spacing) && typeof gridConfig.spacing[1] === 'number') {
6964
+ value = gridConfig.spacing[1];
6965
+ }
6966
+ if (!isFinite(value)) {
6967
+ return 0;
6968
+ }
6969
+ return value;
6845
6970
  };
6846
6971
 
6847
6972
  const CONTEXT_MENU_MENU_RADIUS = 96;
@@ -7087,6 +7212,7 @@ const DAGA_FILE_VERSION = 1;
7087
7212
  */
7088
7213
  class DagaExporter {
7089
7214
  export(model, includeCollabMeta = false) {
7215
+ var _a;
7090
7216
  const result = Object.assign({
7091
7217
  name: model.name,
7092
7218
  type: model.type,
@@ -7095,6 +7221,7 @@ class DagaExporter {
7095
7221
  updatedAt: model.updatedAt,
7096
7222
  nodes: [],
7097
7223
  connections: [],
7224
+ objects: [],
7098
7225
  data: model.valueSet.getValues()
7099
7226
  }, includeCollabMeta ? {
7100
7227
  collabMeta: {
@@ -7117,6 +7244,21 @@ class DagaExporter {
7117
7244
  if (!includeCollabMeta && connection.removed) continue;
7118
7245
  result.connections.push(this.exportConnection(connection, includeCollabMeta));
7119
7246
  }
7247
+ for (const object of model.objects.all(true)) {
7248
+ (_a = result.objects) === null || _a === void 0 ? void 0 : _a.push(Object.assign({
7249
+ id: object.id,
7250
+ coords: roundPoint(object.coords),
7251
+ width: object.width,
7252
+ height: object.height,
7253
+ priority: object.priority,
7254
+ svg: object.svg
7255
+ }, includeCollabMeta ? {
7256
+ collabMeta: {
7257
+ removed: object.removed,
7258
+ selfRemoved: object.selfRemoved
7259
+ }
7260
+ } : {}));
7261
+ }
7120
7262
  return result;
7121
7263
  }
7122
7264
  exportNode(node, includeCollabMeta = false) {
@@ -7144,9 +7286,27 @@ class DagaExporter {
7144
7286
  }, this.exportLabelCollabMeta(port))
7145
7287
  } : {}));
7146
7288
  }
7289
+ const decorators = [];
7290
+ for (const decorator of section.decorators) {
7291
+ decorators.push(Object.assign({
7292
+ id: decorator.id,
7293
+ coords: roundPoint(decorator.coords),
7294
+ width: decorator.width,
7295
+ height: decorator.height,
7296
+ priority: decorator.priority,
7297
+ svg: decorator.svg,
7298
+ anchorPoints: [decorator.anchorPointX, decorator.anchorPointY]
7299
+ }, includeCollabMeta ? {
7300
+ collabMeta: {
7301
+ removed: decorator.removed,
7302
+ selfRemoved: decorator.selfRemoved
7303
+ }
7304
+ } : {}));
7305
+ }
7147
7306
  sections.push(Object.assign({
7148
7307
  id: section.id,
7149
7308
  ports,
7309
+ decorators,
7150
7310
  label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
7151
7311
  indexXInNode: section.indexXInNode,
7152
7312
  indexYInNode: section.indexYInNode,
@@ -7178,12 +7338,30 @@ class DagaExporter {
7178
7338
  }, this.exportLabelCollabMeta(port))
7179
7339
  } : {}));
7180
7340
  }
7341
+ const decorators = [];
7342
+ for (const decorator of node.decorators) {
7343
+ decorators.push(Object.assign({
7344
+ id: decorator.id,
7345
+ coords: roundPoint(decorator.coords),
7346
+ width: decorator.width,
7347
+ height: decorator.height,
7348
+ priority: decorator.priority,
7349
+ svg: decorator.svg,
7350
+ anchorPoints: [decorator.anchorPointX, decorator.anchorPointY]
7351
+ }, includeCollabMeta ? {
7352
+ collabMeta: {
7353
+ removed: decorator.removed,
7354
+ selfRemoved: decorator.selfRemoved
7355
+ }
7356
+ } : {}));
7357
+ }
7181
7358
  return Object.assign({
7182
7359
  id: node.id,
7183
7360
  type: node.type.id,
7184
7361
  children,
7185
7362
  sections,
7186
7363
  ports,
7364
+ decorators,
7187
7365
  label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
7188
7366
  coords: roundPoint(node.coords),
7189
7367
  width: node.width,
@@ -7526,8 +7704,9 @@ class DiagramCanvas {
7526
7704
  * @param config The configuration object used to set the parameters of this canvas.
7527
7705
  */
7528
7706
  constructor(parentComponent, config) {
7529
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
7530
- this.backgroundPatternId = `daga-background-pattern-id-${DiagramCanvas.canvasCount++}`;
7707
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
7708
+ this.gridPatternId = `daga-grid-pattern-id-${++DiagramCanvas.canvasCount}`;
7709
+ this.ancillaryGridPatternIds = [];
7531
7710
  this.zoomTransform = d3__namespace.zoomIdentity;
7532
7711
  // used to distinguish drags from clicks when dragging elements and during multiple selection
7533
7712
  this.draggingFrom = [0, 0];
@@ -7544,23 +7723,25 @@ class DiagramCanvas {
7544
7723
  this.userSelection = new DiagramUserSelection(this, (_b = (_a = config.components) === null || _a === void 0 ? void 0 : _a.propertyEditor) === null || _b === void 0 ? void 0 : _b.title);
7545
7724
  this.userHighlight = new DiagramUserHighlight(this, ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.highlightSections) !== false);
7546
7725
  this.contextMenu = new DiagramContextMenu(this, (_d = config.canvas) === null || _d === void 0 ? void 0 : _d.contextMenu);
7547
- this.backgroundColor = ((_e = config.canvas) === null || _e === void 0 ? void 0 : _e.backgroundColor) || '#FFFFFF';
7548
- this.gridStyle = (_h = (_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.grid) === null || _g === void 0 ? void 0 : _g.style) !== null && _h !== void 0 ? _h : GRID_DEFAULTS.style;
7549
- this.gridSize = ((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === null || _k === void 0 ? void 0 : _k.enabled) === false || ((_l = config.canvas) === null || _l === void 0 ? void 0 : _l.grid) === undefined ? 0 : Math.abs(((_o = (_m = config.canvas) === null || _m === void 0 ? void 0 : _m.grid) === null || _o === void 0 ? void 0 : _o.spacing) || GRID_DEFAULTS.spacing);
7550
- this.gridThickness = Math.abs(((_q = (_p = config.canvas) === null || _p === void 0 ? void 0 : _p.grid) === null || _q === void 0 ? void 0 : _q.thickness) || GRID_DEFAULTS.thickness);
7551
- this.gridColor = ((_s = (_r = config.canvas) === null || _r === void 0 ? void 0 : _r.grid) === null || _s === void 0 ? void 0 : _s.color) || GRID_DEFAULTS.color;
7552
- this.snapToGrid = ((_u = (_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === null || _u === void 0 ? void 0 : _u.enabled) === false || ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.grid) === undefined ? false : ((_x = (_w = config.canvas) === null || _w === void 0 ? void 0 : _w.grid) === null || _x === void 0 ? void 0 : _x.snap) || GRID_DEFAULTS.snap;
7553
- this.zoomFactor = ((_y = config.canvas) === null || _y === void 0 ? void 0 : _y.zoomFactor) || 2;
7554
- this.panRate = ((_z = config.canvas) === null || _z === void 0 ? void 0 : _z.panRate) || 100;
7555
- this.inferConnectionType = ((_0 = config.connectionSettings) === null || _0 === void 0 ? void 0 : _0.inferConnectionType) || false;
7556
- this.autoTightenConnections = ((_1 = config.connectionSettings) === null || _1 === void 0 ? void 0 : _1.autoTighten) !== false;
7557
- this.tightenConnectionsAcrossPortTypes = ((_2 = config.connectionSettings) === null || _2 === void 0 ? void 0 : _2.tightenAcrossPortTypes) || false;
7558
- this.allowConnectionLoops = ((_3 = config.connectionSettings) === null || _3 === void 0 ? void 0 : _3.allowLoops) || false;
7559
- this.allowSharingPorts = ((_4 = config.connectionSettings) === null || _4 === void 0 ? void 0 : _4.sharePorts) !== false;
7560
- this.allowSharingBothPorts = ((_5 = config.connectionSettings) === null || _5 === void 0 ? void 0 : _5.shareBothPorts) || false;
7561
- this.portHighlightRadius = ((_6 = config.connectionSettings) === null || _6 === void 0 ? void 0 : _6.portHighlightRadius) || 100;
7726
+ // TODO
7727
+ this.backgroundConfig = (_f = (_e = config.canvas) === null || _e === void 0 ? void 0 : _e.background) !== null && _f !== void 0 ? _f : BACKGROUND_DEFAULTS;
7728
+ this.gridConfig = applyGridDefaults((_g = config.canvas) === null || _g === void 0 ? void 0 : _g.grid);
7729
+ this.ancillaryGridsConfig = [];
7730
+ for (let i = 0; i < (((_j = (_h = config.canvas) === null || _h === void 0 ? void 0 : _h.ancillaryGrids) === null || _j === void 0 ? void 0 : _j.length) || 0); ++i) {
7731
+ this.ancillaryGridsConfig.push(applyGridDefaults((_l = (_k = config.canvas) === null || _k === void 0 ? void 0 : _k.ancillaryGrids) === null || _l === void 0 ? void 0 : _l[i]));
7732
+ this.ancillaryGridPatternIds.push(`${this.gridPatternId}-ancillary-${i}`);
7733
+ }
7734
+ this.zoomFactor = ((_m = config.canvas) === null || _m === void 0 ? void 0 : _m.zoomFactor) || 2;
7735
+ this.panRate = ((_o = config.canvas) === null || _o === void 0 ? void 0 : _o.panRate) || 100;
7736
+ this.inferConnectionType = ((_p = config.connectionSettings) === null || _p === void 0 ? void 0 : _p.inferConnectionType) || false;
7737
+ this.autoTightenConnections = ((_q = config.connectionSettings) === null || _q === void 0 ? void 0 : _q.autoTighten) !== false;
7738
+ this.tightenConnectionsAcrossPortTypes = ((_r = config.connectionSettings) === null || _r === void 0 ? void 0 : _r.tightenAcrossPortTypes) || false;
7739
+ this.allowConnectionLoops = ((_s = config.connectionSettings) === null || _s === void 0 ? void 0 : _s.allowLoops) || false;
7740
+ this.allowSharingPorts = ((_t = config.connectionSettings) === null || _t === void 0 ? void 0 : _t.sharePorts) !== false;
7741
+ this.allowSharingBothPorts = ((_u = config.connectionSettings) === null || _u === void 0 ? void 0 : _u.shareBothPorts) || false;
7742
+ this.portHighlightRadius = ((_v = config.connectionSettings) === null || _v === void 0 ? void 0 : _v.portHighlightRadius) || 100;
7562
7743
  this.multipleSelectionOn = false;
7563
- this.priorityThresholds = ((_7 = config.canvas) === null || _7 === void 0 ? void 0 : _7.priorityThresholds) || [];
7744
+ this.priorityThresholds = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.priorityThresholds) || [];
7564
7745
  this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
7565
7746
  this.layoutFormat = config.layoutFormat;
7566
7747
  this.userActions = config.userActions || {};
@@ -7587,7 +7768,7 @@ class DiagramCanvas {
7587
7768
  const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
7588
7769
  this.model.connections.types.add(connectionType);
7589
7770
  }
7590
- this._connectionType = ((_8 = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _8 === void 0 ? void 0 : _8.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
7771
+ this._connectionType = ((_x = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _x === void 0 ? void 0 : _x.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
7591
7772
  }
7592
7773
  }
7593
7774
  addValidator(validator) {
@@ -7619,13 +7800,13 @@ class DiagramCanvas {
7619
7800
  // remove all children
7620
7801
  appendToSelection.html('');
7621
7802
  this.diagramRoot = appendToSelection.append('div').node();
7622
- d3__namespace.select(this.diagramRoot).attr('tabindex', 0) // make element focusable
7803
+ this.selectRoot().attr('tabindex', 0) // make element focusable
7623
7804
  .style('width', '100%').style('height', '100%').append('svg').style('width', '100%').style('height', '100%');
7624
- d3__namespace.select(this.diagramRoot).on(exports.Events.Click, () => {
7805
+ this.selectRoot().on(exports.Events.Click, () => {
7625
7806
  var _a;
7626
7807
  // focus on the diagram when clicking so that we can focus on the diagram
7627
7808
  // keyboard events only work if we're focusing on the diagram
7628
- (_a = d3__namespace.select(this.diagramRoot).node()) === null || _a === void 0 ? void 0 : _a.focus();
7809
+ (_a = this.selectRoot().node()) === null || _a === void 0 ? void 0 : _a.focus();
7629
7810
  }).on(exports.Events.ContextMenu, event => {
7630
7811
  if (this.dragging) {
7631
7812
  event.preventDefault();
@@ -7789,44 +7970,57 @@ class DiagramCanvas {
7789
7970
  this.zoomTransform = event.transform;
7790
7971
  const transformAttribute = event.transform.toString();
7791
7972
  this.selectCanvasElements().attr('transform', transformAttribute);
7792
- d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7973
+ for (const gridPatternId of [this.gridPatternId, ...this.ancillaryGridPatternIds]) {
7974
+ this.selectCanvasView().select(`#${gridPatternId}`).attr('patternTransform', transformAttribute);
7975
+ }
7793
7976
  this.contextMenu.close();
7794
7977
  this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
7795
7978
  }).on(exports.ZoomEvents.End, () => {
7796
7979
  setCursorStyle();
7797
7980
  }));
7798
- canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', this.backgroundColor).attr('stroke-width', '0').on(exports.Events.MouseMove, event => {
7799
- if (this.unfinishedConnection !== undefined) {
7800
- const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7801
- this.unfinishedConnection.endCoords = pointerCoords;
7802
- }
7803
- }).on(exports.Events.MouseOver, () => {
7804
- if (this.userHighlight.size() > 0) {
7805
- this.userHighlight.clear();
7806
- this.diagramEvent$.next(new DiagramHighlightedEvent(null));
7807
- }
7808
- }).on(exports.Events.Click, () => {
7809
- if (this.userHighlight.size() > 0) {
7810
- this.userHighlight.clear();
7811
- this.diagramEvent$.next(new DiagramHighlightedEvent(null));
7812
- }
7813
- this.contextMenu.close();
7814
- if (this.userSelection.size() > 0) {
7815
- const deselectedElements = this.userSelection.all();
7816
- this.userSelection.clear();
7817
- this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
7818
- }
7819
- this.userSelection.openInPropertyEditor(this.model);
7820
- }).call(d3__namespace.drag().filter(event => {
7821
- return this.multipleSelectionOn || isSecondaryButton(event);
7822
- }).on(exports.DragEvents.Start, event => {
7823
- this.startMultipleSelection(event);
7824
- }).on(exports.DragEvents.Drag, event => {
7825
- this.continueMultipleSelection(event);
7826
- }).on(exports.DragEvents.End, event => {
7827
- this.finishMultipleSelection(event);
7828
- }));
7829
- initializeGrid(this, canvasView, this.backgroundPatternId);
7981
+ const canvasDefs = canvasView.append('defs');
7982
+ const canvasBackground = [];
7983
+ canvasBackground.push(initializeBackground(this, canvasView, this.backgroundConfig));
7984
+ for (let i = 0; i < this.ancillaryGridsConfig.length; ++i) {
7985
+ canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.ancillaryGridPatternIds[i], this.ancillaryGridsConfig[i]));
7986
+ }
7987
+ canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.gridPatternId, this.gridConfig));
7988
+ for (const canvasBackgroundElement of canvasBackground) {
7989
+ canvasBackgroundElement.on(exports.Events.MouseMove, event => {
7990
+ if (this.unfinishedConnection !== undefined) {
7991
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7992
+ this.unfinishedConnection.endCoords = pointerCoords;
7993
+ }
7994
+ });
7995
+ canvasBackgroundElement.on(exports.Events.MouseOver, () => {
7996
+ if (this.userHighlight.size() > 0) {
7997
+ this.userHighlight.clear();
7998
+ this.diagramEvent$.next(new DiagramHighlightedEvent(null));
7999
+ }
8000
+ });
8001
+ canvasBackgroundElement.on(exports.Events.Click, () => {
8002
+ if (this.userHighlight.size() > 0) {
8003
+ this.userHighlight.clear();
8004
+ this.diagramEvent$.next(new DiagramHighlightedEvent(null));
8005
+ }
8006
+ this.contextMenu.close();
8007
+ if (this.userSelection.size() > 0) {
8008
+ const deselectedElements = this.userSelection.all();
8009
+ this.userSelection.clear();
8010
+ this.diagramEvent$.next(new DiagramSelectionEvent(deselectedElements, false));
8011
+ }
8012
+ this.userSelection.openInPropertyEditor(this.model);
8013
+ });
8014
+ canvasBackgroundElement.call(d3__namespace.drag().filter(event => {
8015
+ return this.multipleSelectionOn || isSecondaryButton(event);
8016
+ }).on(exports.DragEvents.Start, event => {
8017
+ this.startMultipleSelection(event);
8018
+ }).on(exports.DragEvents.Drag, event => {
8019
+ this.continueMultipleSelection(event);
8020
+ }).on(exports.DragEvents.End, event => {
8021
+ this.finishMultipleSelection(event);
8022
+ }));
8023
+ }
7830
8024
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7831
8025
  }
7832
8026
  getZoomLevel() {
@@ -7886,7 +8080,7 @@ class DiagramCanvas {
7886
8080
  this.zoomBehavior.translateTo(this.selectCanvasView(), currentX, currentY);
7887
8081
  }
7888
8082
  } catch (e) {
7889
- console.warn('Animation has been interrupted');
8083
+ console.warn('Animation has been interrupted.', e);
7890
8084
  animationInterrupted = true;
7891
8085
  }
7892
8086
  };
@@ -7921,10 +8115,17 @@ class DiagramCanvas {
7921
8115
  }
7922
8116
  }
7923
8117
  getClosestGridPoint(point) {
7924
- if (this.gridSize === 0 || !isFinite(this.gridSize)) {
7925
- return point;
8118
+ let pointX = point[0];
8119
+ const spacingX = getGridSpacingX(this.gridConfig);
8120
+ if (spacingX !== 0) {
8121
+ pointX = Math.round(pointX / spacingX) * spacingX;
8122
+ }
8123
+ let pointY = point[1];
8124
+ const spacingY = getGridSpacingY(this.gridConfig);
8125
+ if (spacingY !== 0) {
8126
+ pointY = Math.round(pointY / spacingY) * spacingY;
7926
8127
  }
7927
- return [Math.round(point[0] / this.gridSize) * this.gridSize, Math.round(point[1] / this.gridSize) * this.gridSize];
8128
+ return [pointX, pointY];
7928
8129
  }
7929
8130
  getCoordinatesOnScreen() {
7930
8131
  var _a;
@@ -8059,7 +8260,7 @@ class DiagramCanvas {
8059
8260
  }).on(exports.DragEvents.End, (event, d) => {
8060
8261
  if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8061
8262
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8062
- if (this.snapToGrid) {
8263
+ if (this.gridConfig.snap) {
8063
8264
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8064
8265
  pointerCoords[0] += d.type.snapToGridOffset[0];
8065
8266
  pointerCoords[1] += d.type.snapToGridOffset[1];
@@ -8095,7 +8296,7 @@ class DiagramCanvas {
8095
8296
  }).on(exports.DragEvents.End, (event, d) => {
8096
8297
  if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8097
8298
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8098
- if (this.snapToGrid) {
8299
+ if (this.gridConfig.snap) {
8099
8300
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
8100
8301
  pointerCoords[0] += d.type.snapToGridOffset[0];
8101
8302
  pointerCoords[1] += d.type.snapToGridOffset[1];
@@ -8131,7 +8332,7 @@ class DiagramCanvas {
8131
8332
  }).on(exports.DragEvents.End, (event, d) => {
8132
8333
  if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8133
8334
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8134
- if (this.snapToGrid) {
8335
+ if (this.gridConfig.snap) {
8135
8336
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8136
8337
  pointerCoords[0] += d.type.snapToGridOffset[2];
8137
8338
  pointerCoords[1] += d.type.snapToGridOffset[3];
@@ -8167,12 +8368,10 @@ class DiagramCanvas {
8167
8368
  }).on(exports.DragEvents.End, (event, d) => {
8168
8369
  if (this.canUserPerformAction(exports.DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchNode) {
8169
8370
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8170
- if (this.snapToGrid) {
8171
- if (this.snapToGrid) {
8172
- pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8173
- pointerCoords[0] += d.type.snapToGridOffset[2];
8174
- pointerCoords[1] += d.type.snapToGridOffset[3];
8175
- }
8371
+ if (this.gridConfig.snap) {
8372
+ pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
8373
+ pointerCoords[0] += d.type.snapToGridOffset[2];
8374
+ pointerCoords[1] += d.type.snapToGridOffset[3];
8176
8375
  }
8177
8376
  d.stretch(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8178
8377
  this.currentAction.to = d.getGeometry();
@@ -8298,7 +8497,7 @@ class DiagramCanvas {
8298
8497
  }).on(exports.DragEvents.End, (event, d) => {
8299
8498
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8300
8499
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8301
- if (this.snapToGrid) {
8500
+ if (this.gridConfig.snap) {
8302
8501
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8303
8502
  }
8304
8503
  d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
@@ -8332,7 +8531,7 @@ class DiagramCanvas {
8332
8531
  }).on(exports.DragEvents.End, (event, d) => {
8333
8532
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8334
8533
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8335
- if (this.snapToGrid) {
8534
+ if (this.gridConfig.snap) {
8336
8535
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8337
8536
  }
8338
8537
  d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
@@ -8366,7 +8565,7 @@ class DiagramCanvas {
8366
8565
  }).on(exports.DragEvents.End, (event, d) => {
8367
8566
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8368
8567
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8369
- if (this.snapToGrid) {
8568
+ if (this.gridConfig.snap) {
8370
8569
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8371
8570
  }
8372
8571
  d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
@@ -8400,7 +8599,7 @@ class DiagramCanvas {
8400
8599
  }).on(exports.DragEvents.End, (event, d) => {
8401
8600
  if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
8402
8601
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8403
- if (this.snapToGrid) {
8602
+ if (this.gridConfig.snap) {
8404
8603
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8405
8604
  }
8406
8605
  d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
@@ -8771,9 +8970,9 @@ class DiagramCanvas {
8771
8970
  }
8772
8971
  this.secondaryButton = false;
8773
8972
  }));
8774
- enterSelection.append('text');
8973
+ enterSelection.append('text').style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
8775
8974
  enterSelection.append('rect');
8776
- mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === exports.HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === exports.HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'middle' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === exports.VerticalAlign.Center ? d.height / 2 : d.verticalAlign === exports.VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === exports.VerticalAlign.Center ? 'middle' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.fontSize).attr('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.highlighted ? 600 : 400).attr('fill', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').each(d => {
8975
+ mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === exports.HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === exports.HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'middle' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === exports.VerticalAlign.Center ? d.height / 2 : d.verticalAlign === exports.VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === exports.VerticalAlign.Center ? 'middle' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('font-family', d => d.look.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.look.fontWeight || DIAGRAM_FIELD_DEFAULTS.look.fontWeight).attr('fill', d => d.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').each(d => {
8777
8976
  this.setFieldTextAndWrap(d);
8778
8977
  });
8779
8978
  mergeSelection
@@ -8788,7 +8987,7 @@ class DiagramCanvas {
8788
8987
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8789
8988
  }
8790
8989
  const mergeSelection = enterSelection.merge(updateSelection);
8791
- mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
8990
+ mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
8792
8991
  exitSelection.remove();
8793
8992
  enterSelection.on(exports.Events.ContextMenu, (event, d) => {
8794
8993
  if (this.dragging) {
@@ -8831,7 +9030,7 @@ class DiagramCanvas {
8831
9030
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8832
9031
  }
8833
9032
  const mergeSelection = enterSelection.merge(updateSelection);
8834
- mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.html);
9033
+ mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
8835
9034
  exitSelection.remove();
8836
9035
  enterSelection.on(exports.Events.MouseOver, (_event, d) => {
8837
9036
  if (!this.dragging) {
@@ -8932,6 +9131,7 @@ class DiagramCanvas {
8932
9131
  const pathSelection = connectionSelection.select('path');
8933
9132
  const pathNode = pathSelection.node();
8934
9133
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
9134
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
8935
9135
  if (pathNode) {
8936
9136
  const pathLength = pathNode.getTotalLength();
8937
9137
  let startLabelShiftX = 0;
@@ -8940,7 +9140,7 @@ class DiagramCanvas {
8940
9140
  let middleLabelShiftY = 0;
8941
9141
  let endLabelShiftX = 0;
8942
9142
  let endLabelShiftY = 0;
8943
- if (labelConfiguration.backgroundColor === '#00000000') {
9143
+ if (labelConfiguration.look.fillColor === 'transparent') {
8944
9144
  // background color is transparent / not set, so we find an alternative position for the label
8945
9145
  const deltaX = connection.endCoords[0] - connection.startCoords[0];
8946
9146
  const deltaY = connection.endCoords[1] - connection.startCoords[1];
@@ -8995,7 +9195,7 @@ class DiagramCanvas {
8995
9195
  }
8996
9196
  }
8997
9197
  // bind start labels
8998
- connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.startLabel);
9198
+ connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).text(connection.startLabel);
8999
9199
  const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
9000
9200
  if (startLabelBoundingRect) {
9001
9201
  // don't create space for the label if the label is empty
@@ -9018,22 +9218,22 @@ class DiagramCanvas {
9018
9218
  default:
9019
9219
  pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
9020
9220
  }
9021
- connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
9221
+ connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9022
9222
  connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
9023
9223
  }
9024
9224
  // bind middle labels
9025
- connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.middleLabel);
9225
+ connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).style('font-kerning', 'none').text(connection.middleLabel);
9026
9226
  const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
9027
9227
  if (middleLabelBoundingRect) {
9028
9228
  // don't create space for the label if the label is empty
9029
9229
  const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
9030
9230
  const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
9031
9231
  const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
9032
- connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
9232
+ connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9033
9233
  connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
9034
9234
  }
9035
9235
  // bind end labels
9036
- connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.endLabel);
9236
+ connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').text(connection.endLabel);
9037
9237
  const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
9038
9238
  if (endLabelBoundingRect) {
9039
9239
  // don't create space for the label if the label is empty
@@ -9056,7 +9256,7 @@ class DiagramCanvas {
9056
9256
  default:
9057
9257
  pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
9058
9258
  }
9059
- connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.backgroundColor).attr('stroke', 'none');
9259
+ connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9060
9260
  connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
9061
9261
  }
9062
9262
  }
@@ -9100,9 +9300,13 @@ class DiagramCanvas {
9100
9300
  const fieldDimensions = this.minimumSizeOfField(field);
9101
9301
  let stretchX = fieldDimensions[0] + getLeftMargin(field.rootElement.type.label) + getRightMargin(field.rootElement.type.label) - field.rootElement.width;
9102
9302
  let stretchY = fieldDimensions[1] + getTopMargin(field.rootElement.type.label) + getBottomMargin(field.rootElement.type.label) - field.rootElement.height;
9103
- if (this.snapToGrid) {
9104
- stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
9105
- stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
9303
+ const spacingX = getGridSpacingX(this.gridConfig);
9304
+ const spacingY = getGridSpacingY(this.gridConfig);
9305
+ if (this.gridConfig.snap && spacingX !== 0) {
9306
+ stretchX = Math.ceil(stretchX / spacingX) * spacingX;
9307
+ }
9308
+ if (this.gridConfig.snap && spacingY !== 0) {
9309
+ stretchY = Math.ceil(stretchY / spacingY) * spacingY;
9106
9310
  }
9107
9311
  // ensure node is not stretched under its minimum dimensions
9108
9312
  if (field.rootElement.width + stretchX < field.rootElement.type.minWidth) {
@@ -9140,9 +9344,13 @@ class DiagramCanvas {
9140
9344
  const type = field.rootElement.type;
9141
9345
  let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label) + getRightMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.width;
9142
9346
  let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label) + getBottomMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.height;
9143
- if (this.snapToGrid) {
9144
- stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
9145
- stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
9347
+ const spacingX = getGridSpacingX(this.gridConfig);
9348
+ const spacingY = getGridSpacingY(this.gridConfig);
9349
+ if (this.gridConfig.snap && spacingX !== 0) {
9350
+ stretchX = Math.ceil(stretchX / spacingX) * spacingX;
9351
+ }
9352
+ if (this.gridConfig.snap && spacingY !== 0) {
9353
+ stretchY = Math.ceil(stretchY / spacingY) * spacingY;
9146
9354
  }
9147
9355
  // ensure section is not stretched under its minimum dimensions
9148
9356
  if (field.rootElement.width + stretchX < (field.rootElement.getMinWidth() || 0)) {
@@ -9192,13 +9400,13 @@ class DiagramCanvas {
9192
9400
  return d3__namespace.select(this.diagramRoot);
9193
9401
  }
9194
9402
  selectSVGElement() {
9195
- return d3__namespace.select(this.diagramRoot).select('svg');
9403
+ return this.selectRoot().select('svg');
9196
9404
  }
9197
9405
  selectCanvasView() {
9198
9406
  return this.selectSVGElement().select(`.daga-canvas-view`);
9199
9407
  }
9200
9408
  selectCanvasElements() {
9201
- return this.selectSVGElement().select(`.daga-canvas-elements`);
9409
+ return this.selectCanvasView().select(`.daga-canvas-elements`);
9202
9410
  }
9203
9411
  // User actions
9204
9412
  startConnection(port) {
@@ -9310,7 +9518,7 @@ class DiagramCanvas {
9310
9518
  openTextInput(id) {
9311
9519
  const field = this.model.fields.get(id);
9312
9520
  if (field) {
9313
- this.createInputField(field.text, field.coords, field.width, field.height, field.fontSize, field.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, field.orientation, field.multiline, () => {
9521
+ this.createInputField(field.text, field.coords, field.width, field.height, field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, field.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily, field.orientation, field.multiline, () => {
9314
9522
  // (_text)
9315
9523
  /*
9316
9524
  Empty for now
@@ -9347,7 +9555,7 @@ class DiagramCanvas {
9347
9555
  }
9348
9556
  }).on(exports.Events.KeyUp, event => {
9349
9557
  event.stopPropagation();
9350
- }).on(exports.Events.Input, event => {
9558
+ }).on(exports.Events.Input, () => {
9351
9559
  const value = inputField.property('value');
9352
9560
  inputField.attr('cols', numberOfColumns(value) + 1);
9353
9561
  inputField.attr('rows', numberOfRows(value) + 1);
@@ -9436,7 +9644,7 @@ class DiagramCanvas {
9436
9644
  const lines = text.split('\n');
9437
9645
  textSelection.html('');
9438
9646
  for (let i = 0; i < lines.length; ++i) {
9439
- textSelection.append('tspan').attr('x', field.horizontalAlign === exports.HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === exports.HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === exports.VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * field.fontSize + field.height / 2 : field.verticalAlign === exports.VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * field.fontSize : i * field.fontSize).text(lines[i]);
9647
+ textSelection.append('tspan').attr('x', field.horizontalAlign === exports.HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === exports.HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === exports.VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + field.height / 2 : field.verticalAlign === exports.VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) : i * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)).text(lines[i]);
9440
9648
  }
9441
9649
  }
9442
9650
  /**
@@ -9476,12 +9684,12 @@ class DiagramCanvas {
9476
9684
  * Method to call to finish the moving of a node triggered by a user drag event.
9477
9685
  */
9478
9686
  finishMovingNode(event, d) {
9479
- var _a, _b, _c;
9687
+ var _a, _b, _c, _d;
9480
9688
  if (this.canUserPerformAction(exports.DiagramActions.MoveNode) && !d.removed) {
9481
9689
  // prevent drag behavior if mouse hasn't moved
9482
9690
  if (this.draggingFrom[0] !== event.x || this.draggingFrom[1] !== event.y) {
9483
9691
  let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
9484
- if (this.snapToGrid) {
9692
+ if ((_a = this.gridConfig) === null || _a === void 0 ? void 0 : _a.snap) {
9485
9693
  newNodeCoords = this.getClosestGridPoint([newNodeCoords[0] - d.type.snapToGridOffset[0], newNodeCoords[1] - d.type.snapToGridOffset[1]]);
9486
9694
  newNodeCoords[0] += d.type.snapToGridOffset[0];
9487
9695
  newNodeCoords[1] += d.type.snapToGridOffset[1];
@@ -9508,8 +9716,8 @@ class DiagramCanvas {
9508
9716
  if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
9509
9717
  const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
9510
9718
  const fromChildGeometry = this.currentAction.from;
9511
- const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === void 0 ? void 0 : _a.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
9512
- (_b = d.parent) === null || _b === void 0 ? void 0 : _b.removeChild(d);
9719
+ const setParentAction = new SetParentAction(this, d.id, (_b = d.parent) === null || _b === void 0 ? void 0 : _b.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
9720
+ (_c = d.parent) === null || _c === void 0 ? void 0 : _c.removeChild(d);
9513
9721
  if (droppedOn !== undefined) {
9514
9722
  droppedOn.addChild(d);
9515
9723
  }
@@ -9520,7 +9728,7 @@ class DiagramCanvas {
9520
9728
  const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
9521
9729
  this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
9522
9730
  this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
9523
- (_c = d.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(d);
9731
+ (_d = d.parent) === null || _d === void 0 ? void 0 : _d.fitToChild(d);
9524
9732
  this.currentAction.to = d.getGeometry(d.id);
9525
9733
  this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
9526
9734
  }
@@ -9931,7 +10139,7 @@ class AdjacencyLayout {
9931
10139
  this.gapSize = gapSize;
9932
10140
  }
9933
10141
  apply(model) {
9934
- var _a;
10142
+ var _a, _b, _c, _d;
9935
10143
  if (model.nodes.length === 0) {
9936
10144
  // nothing to arrange...
9937
10145
  return model;
@@ -9945,12 +10153,13 @@ class AdjacencyLayout {
9945
10153
  // place nodes according to arrangement
9946
10154
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
9947
10155
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
9948
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10156
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10157
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
9949
10158
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
9950
10159
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
9951
10160
  const node = nodeArrangement.get([x, y]);
9952
10161
  if (node !== undefined) {
9953
- node.move([x * (maximumWidth + gapSize), y * (maximumHeight + gapSize)]);
10162
+ node.move([x * (maximumWidth + gapSizeX), y * (maximumHeight + gapSizeY)]);
9954
10163
  }
9955
10164
  }
9956
10165
  }
@@ -9977,7 +10186,7 @@ class BreadthAdjacencyLayout {
9977
10186
  this.gapSize = gapSize;
9978
10187
  }
9979
10188
  apply(model) {
9980
- var _a;
10189
+ var _a, _b, _c, _d;
9981
10190
  if (model.nodes.length === 0) {
9982
10191
  // nothing to arrange...
9983
10192
  return model;
@@ -10013,12 +10222,13 @@ class BreadthAdjacencyLayout {
10013
10222
  // place nodes according to arrangement
10014
10223
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
10015
10224
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
10016
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10225
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10226
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10017
10227
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
10018
10228
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
10019
10229
  const node = nodeArrangement.get([x, y]);
10020
10230
  if (node !== undefined) {
10021
- node.move([x * (maximumWidth + gapSize), y * (maximumHeight + gapSize)]);
10231
+ node.move([x * (maximumWidth + gapSizeX), y * (maximumHeight + gapSizeY)]);
10022
10232
  }
10023
10233
  }
10024
10234
  }
@@ -10035,12 +10245,13 @@ class BreadthLayout {
10035
10245
  this.gapSize = gapSize;
10036
10246
  }
10037
10247
  apply(model) {
10038
- var _a;
10248
+ var _a, _b, _c, _d;
10039
10249
  if (model.nodes.length === 0) {
10040
10250
  // nothing to arrange...
10041
10251
  return model;
10042
10252
  }
10043
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10253
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10254
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10044
10255
  let nodesToBeArranged = model.nodes.filter(n => !n.parent);
10045
10256
  // Arrange nodes by a breadth first search
10046
10257
  const firstNode = nodesToBeArranged[0];
@@ -10079,10 +10290,10 @@ class BreadthLayout {
10079
10290
  let heightAccumulator = 0;
10080
10291
  for (const node of nodeArrangementRow) {
10081
10292
  node.move([widthAccumulator, heightAccumulator]);
10082
- heightAccumulator += gapSize + node.height;
10293
+ heightAccumulator += gapSizeY + node.height;
10083
10294
  }
10084
10295
  const maximumWidth = Math.max(...nodeArrangementRow.map(n => n.width));
10085
- widthAccumulator += gapSize + maximumWidth;
10296
+ widthAccumulator += gapSizeX + maximumWidth;
10086
10297
  }
10087
10298
  for (const connection of model.connections) {
10088
10299
  connection.tighten();
@@ -10100,14 +10311,16 @@ class ForceLayout {
10100
10311
  this.gapSize = gapSize;
10101
10312
  }
10102
10313
  apply(model) {
10103
- var _a;
10314
+ var _a, _b, _c, _d;
10104
10315
  if (model.nodes.length === 0) {
10105
10316
  // nothing to arrange...
10106
10317
  return model;
10107
10318
  }
10108
10319
  // as a starting point, we apply a simple layout
10109
10320
  new BreadthLayout(this.gapSize).apply(model);
10110
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10321
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10322
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10323
+ const gapSize = Math.max(gapSizeX, gapSizeY);
10111
10324
  const coolingFactor = 0.99;
10112
10325
  const minimumTemperature = 1;
10113
10326
  const attractionFactor = 0.1;
@@ -10176,7 +10389,7 @@ class ForceLayout {
10176
10389
  }
10177
10390
  }
10178
10391
  }
10179
- if (model.canvas && model.canvas.snapToGrid) {
10392
+ if (model.canvas && model.canvas.gridConfig.snap) {
10180
10393
  for (const node of model.nodes) {
10181
10394
  const snappedCoords = model.canvas.getClosestGridPoint([node.coords[0] - node.type.snapToGridOffset[0], node.coords[1] - node.type.snapToGridOffset[1]]);
10182
10395
  snappedCoords[0] += node.type.snapToGridOffset[0];
@@ -10200,18 +10413,18 @@ class HorizontalLayout {
10200
10413
  this.gapSize = gapSize;
10201
10414
  }
10202
10415
  apply(model) {
10203
- var _a;
10416
+ var _a, _b;
10204
10417
  if (model.nodes.length === 0) {
10205
10418
  // nothing to arrange...
10206
10419
  return model;
10207
10420
  }
10208
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10421
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10209
10422
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
10210
10423
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
10211
10424
  let widthAccumulator = 0;
10212
10425
  for (const node of nodesToBeArranged) {
10213
10426
  node.move([widthAccumulator, 0]);
10214
- widthAccumulator += node.width + gapSize;
10427
+ widthAccumulator += node.width + gapSizeX;
10215
10428
  }
10216
10429
  return model;
10217
10430
  }
@@ -10226,7 +10439,7 @@ class PriorityLayout {
10226
10439
  this.gapSize = gapSize;
10227
10440
  }
10228
10441
  apply(model) {
10229
- var _a;
10442
+ var _a, _b, _c, _d;
10230
10443
  if (model.nodes.length === 0) {
10231
10444
  // nothing to arrange...
10232
10445
  return model;
@@ -10238,7 +10451,8 @@ class PriorityLayout {
10238
10451
  new BreadthLayout(this.gapSize).apply(model);
10239
10452
  return model;
10240
10453
  }
10241
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10454
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10455
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10242
10456
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
10243
10457
  const nodeArrangement = [];
10244
10458
  const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
@@ -10315,10 +10529,10 @@ class PriorityLayout {
10315
10529
  for (let j = 0; j < nodeArrangement[i].length; ++j) {
10316
10530
  const node = nodeArrangement[i][j];
10317
10531
  node.move([widthAccumulator, heightAccumulator]);
10318
- heightAccumulator += gapSize + node.height;
10532
+ heightAccumulator += gapSizeY + node.height;
10319
10533
  }
10320
10534
  const maximumWidth = Math.max(...nodeArrangement[i].map(n => n.width));
10321
- widthAccumulator += gapSize + maximumWidth;
10535
+ widthAccumulator += gapSizeX + maximumWidth;
10322
10536
  }
10323
10537
  for (const connection of model.connections) {
10324
10538
  connection.tighten();
@@ -10336,7 +10550,7 @@ class TreeLayout {
10336
10550
  this.gapSize = gapSize;
10337
10551
  }
10338
10552
  apply(model) {
10339
- var _a;
10553
+ var _a, _b, _c, _d;
10340
10554
  if (model.nodes.length === 0) {
10341
10555
  // nothing to arrange...
10342
10556
  return model;
@@ -10348,7 +10562,8 @@ class TreeLayout {
10348
10562
  new BreadthLayout(this.gapSize).apply(model);
10349
10563
  return model;
10350
10564
  }
10351
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10565
+ const gapSizeX = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingX((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10566
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_c = model.canvas) === null || _c === void 0 ? void 0 : _c.gridConfig) ? getGridSpacingY((_d = model.canvas) === null || _d === void 0 ? void 0 : _d.gridConfig) * 2 : 0;
10352
10567
  const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
10353
10568
  const branches = [];
10354
10569
  while (nodesToBeArranged.length > 0) {
@@ -10370,10 +10585,10 @@ class TreeLayout {
10370
10585
  for (let j = 0; j < branchArrangement[i].length; ++j) {
10371
10586
  const branch = branchArrangement[i][j];
10372
10587
  branch.node.move([widthAccumulator, heightAccumulator]);
10373
- heightAccumulator += (gapSize + maximumHeight) * branch.countBranchHeight();
10588
+ heightAccumulator += (gapSizeY + maximumHeight) * branch.countBranchHeight();
10374
10589
  }
10375
10590
  const maximumWidth = Math.max(...branchArrangement[i].map(b => b.node.width));
10376
- widthAccumulator += gapSize + maximumWidth;
10591
+ widthAccumulator += gapSizeX + maximumWidth;
10377
10592
  }
10378
10593
  for (const connection of model.connections) {
10379
10594
  connection.tighten();
@@ -10437,18 +10652,18 @@ class VerticalLayout {
10437
10652
  this.gapSize = gapSize;
10438
10653
  }
10439
10654
  apply(model) {
10440
- var _a;
10655
+ var _a, _b;
10441
10656
  if (model.nodes.length === 0) {
10442
10657
  // nothing to arrange...
10443
10658
  return model;
10444
10659
  }
10445
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
10660
+ const gapSizeY = this.gapSize !== undefined ? this.gapSize : ((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridConfig) ? getGridSpacingY((_b = model.canvas) === null || _b === void 0 ? void 0 : _b.gridConfig) * 2 : 0;
10446
10661
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
10447
10662
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
10448
10663
  let heightAccumulator = 0;
10449
10664
  for (const node of nodesToBeArranged) {
10450
10665
  node.move([0, heightAccumulator]);
10451
- heightAccumulator += node.height + gapSize;
10666
+ heightAccumulator += node.height + gapSizeY;
10452
10667
  }
10453
10668
  return model;
10454
10669
  }