@metadev/daga 4.2.4 → 4.2.5

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/Changelog.md CHANGED
@@ -6,6 +6,12 @@ List of releases and changes.
6
6
 
7
7
  ## Next release Joyeuse
8
8
 
9
+ ## v. 4.2.5
10
+
11
+ - Add methods `getZoomLevel()` and `getViewCoordinates()` in `canvas` to obtain the current zoom and pan level of the view [#317](https://github.com/metadevpro/daga/pull/317)
12
+ - Enable configuring the height of the palette and property editor [#319](https://github.com/metadevpro/daga/pull/319)
13
+ - Correctly update the connection point of ports when pasting [#321](https://github.com/metadevpro/daga/pull/321)
14
+
9
15
  ## v. 4.2.4
10
16
 
11
17
  - Enable configuring line style in shaped looks [#313](https://github.com/metadevpro/daga/pull/313)
package/index.cjs.js CHANGED
@@ -4518,7 +4518,7 @@ class DagaImporter {
4518
4518
  let portCounter = 0;
4519
4519
  for (const port of section.ports || []) {
4520
4520
  const newPortType = port.type !== undefined ? model.ports.types.get(port.type) : undefined;
4521
- const newPort = new DiagramPort(model, newPortType, newSection, port.coords, port.connectionPoint, port.direction, port.id);
4521
+ const newPort = new DiagramPort(model, newPortType, newSection, port.coords, port.connectionPoint || port.coords, port.direction, port.id);
4522
4522
  newSection.ports.push(newPort);
4523
4523
  model.ports.add(newPort);
4524
4524
  if (port.label) {
@@ -4565,7 +4565,7 @@ class DagaImporter {
4565
4565
  let portCounter = 0;
4566
4566
  for (const port of node.ports || []) {
4567
4567
  const newPortType = port.type !== undefined ? model.ports.types.get(port.type) : undefined;
4568
- const newPort = new DiagramPort(model, newPortType, newNode, port.coords, port.connectionPoint, port.direction, port.id);
4568
+ const newPort = new DiagramPort(model, newPortType, newNode, port.coords, port.connectionPoint || port.coords, port.direction, port.id);
4569
4569
  newNode.ports.push(newPort);
4570
4570
  model.ports.add(newPort);
4571
4571
  if (port.label) {
@@ -5800,6 +5800,9 @@ class PasteAction {
5800
5800
  idRefresh[oldPortId] = port.id;
5801
5801
  if (coordsDiff) {
5802
5802
  port.coords = [port.coords[0] + coordsDiff[0], port.coords[1] + coordsDiff[1]];
5803
+ if (port.connectionPoint) {
5804
+ port.connectionPoint = [port.connectionPoint[0] + coordsDiff[0], port.connectionPoint[1] + coordsDiff[1]];
5805
+ }
5803
5806
  }
5804
5807
  }
5805
5808
  }
@@ -5816,6 +5819,9 @@ class PasteAction {
5816
5819
  idRefresh[oldPortId] = port.id;
5817
5820
  if (coordsDiff) {
5818
5821
  port.coords = [port.coords[0] + coordsDiff[0], port.coords[1] + coordsDiff[1]];
5822
+ if (port.connectionPoint) {
5823
+ port.connectionPoint = [port.connectionPoint[0] + coordsDiff[0], port.connectionPoint[1] + coordsDiff[1]];
5824
+ }
5819
5825
  }
5820
5826
  }
5821
5827
  }
@@ -6589,7 +6595,7 @@ class DagaExporter {
6589
6595
  id: port.id,
6590
6596
  type: (_a = port.type) === null || _a === void 0 ? void 0 : _a.id,
6591
6597
  coords: roundPoint(port.coords),
6592
- connectionPoint: roundPoint(port.connectionPoint),
6598
+ connectionPoint: roundPoint(port.connectionPoint || port.coords),
6593
6599
  direction: port.direction,
6594
6600
  label: ((_b = port.label) === null || _b === void 0 ? void 0 : _b.text) || ''
6595
6601
  }, includeCollabMeta ? {
@@ -6623,7 +6629,7 @@ class DagaExporter {
6623
6629
  id: port.id,
6624
6630
  type: (_d = port.type) === null || _d === void 0 ? void 0 : _d.id,
6625
6631
  coords: roundPoint(port.coords),
6626
- connectionPoint: roundPoint(port.connectionPoint),
6632
+ connectionPoint: roundPoint(port.connectionPoint || port.coords),
6627
6633
  direction: port.direction,
6628
6634
  label: ((_e = port.label) === null || _e === void 0 ? void 0 : _e.text) || ''
6629
6635
  }, includeCollabMeta ? {
@@ -7301,6 +7307,9 @@ class DiagramCanvas {
7301
7307
  initializeGrid(this, canvasView, this.backgroundPatternId);
7302
7308
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7303
7309
  }
7310
+ getZoomLevel() {
7311
+ return this.zoomTransform.k;
7312
+ }
7304
7313
  zoomBy(factor) {
7305
7314
  if (!isNaN(factor)) {
7306
7315
  this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
@@ -7311,6 +7320,9 @@ class DiagramCanvas {
7311
7320
  this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
7312
7321
  }
7313
7322
  }
7323
+ getViewCoordinates() {
7324
+ return [this.zoomTransform.x, this.zoomTransform.y];
7325
+ }
7314
7326
  translateBy(x, y) {
7315
7327
  if (!isNaN(x) && !isNaN(y)) {
7316
7328
  this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
package/index.esm.js CHANGED
@@ -4497,7 +4497,7 @@ class DagaImporter {
4497
4497
  let portCounter = 0;
4498
4498
  for (const port of section.ports || []) {
4499
4499
  const newPortType = port.type !== undefined ? model.ports.types.get(port.type) : undefined;
4500
- const newPort = new DiagramPort(model, newPortType, newSection, port.coords, port.connectionPoint, port.direction, port.id);
4500
+ const newPort = new DiagramPort(model, newPortType, newSection, port.coords, port.connectionPoint || port.coords, port.direction, port.id);
4501
4501
  newSection.ports.push(newPort);
4502
4502
  model.ports.add(newPort);
4503
4503
  if (port.label) {
@@ -4544,7 +4544,7 @@ class DagaImporter {
4544
4544
  let portCounter = 0;
4545
4545
  for (const port of node.ports || []) {
4546
4546
  const newPortType = port.type !== undefined ? model.ports.types.get(port.type) : undefined;
4547
- const newPort = new DiagramPort(model, newPortType, newNode, port.coords, port.connectionPoint, port.direction, port.id);
4547
+ const newPort = new DiagramPort(model, newPortType, newNode, port.coords, port.connectionPoint || port.coords, port.direction, port.id);
4548
4548
  newNode.ports.push(newPort);
4549
4549
  model.ports.add(newPort);
4550
4550
  if (port.label) {
@@ -5779,6 +5779,9 @@ class PasteAction {
5779
5779
  idRefresh[oldPortId] = port.id;
5780
5780
  if (coordsDiff) {
5781
5781
  port.coords = [port.coords[0] + coordsDiff[0], port.coords[1] + coordsDiff[1]];
5782
+ if (port.connectionPoint) {
5783
+ port.connectionPoint = [port.connectionPoint[0] + coordsDiff[0], port.connectionPoint[1] + coordsDiff[1]];
5784
+ }
5782
5785
  }
5783
5786
  }
5784
5787
  }
@@ -5795,6 +5798,9 @@ class PasteAction {
5795
5798
  idRefresh[oldPortId] = port.id;
5796
5799
  if (coordsDiff) {
5797
5800
  port.coords = [port.coords[0] + coordsDiff[0], port.coords[1] + coordsDiff[1]];
5801
+ if (port.connectionPoint) {
5802
+ port.connectionPoint = [port.connectionPoint[0] + coordsDiff[0], port.connectionPoint[1] + coordsDiff[1]];
5803
+ }
5798
5804
  }
5799
5805
  }
5800
5806
  }
@@ -6568,7 +6574,7 @@ class DagaExporter {
6568
6574
  id: port.id,
6569
6575
  type: (_a = port.type) === null || _a === void 0 ? void 0 : _a.id,
6570
6576
  coords: roundPoint(port.coords),
6571
- connectionPoint: roundPoint(port.connectionPoint),
6577
+ connectionPoint: roundPoint(port.connectionPoint || port.coords),
6572
6578
  direction: port.direction,
6573
6579
  label: ((_b = port.label) === null || _b === void 0 ? void 0 : _b.text) || ''
6574
6580
  }, includeCollabMeta ? {
@@ -6602,7 +6608,7 @@ class DagaExporter {
6602
6608
  id: port.id,
6603
6609
  type: (_d = port.type) === null || _d === void 0 ? void 0 : _d.id,
6604
6610
  coords: roundPoint(port.coords),
6605
- connectionPoint: roundPoint(port.connectionPoint),
6611
+ connectionPoint: roundPoint(port.connectionPoint || port.coords),
6606
6612
  direction: port.direction,
6607
6613
  label: ((_e = port.label) === null || _e === void 0 ? void 0 : _e.text) || ''
6608
6614
  }, includeCollabMeta ? {
@@ -7280,6 +7286,9 @@ class DiagramCanvas {
7280
7286
  initializeGrid(this, canvasView, this.backgroundPatternId);
7281
7287
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7282
7288
  }
7289
+ getZoomLevel() {
7290
+ return this.zoomTransform.k;
7291
+ }
7283
7292
  zoomBy(factor) {
7284
7293
  if (!isNaN(factor)) {
7285
7294
  this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
@@ -7290,6 +7299,9 @@ class DiagramCanvas {
7290
7299
  this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
7291
7300
  }
7292
7301
  }
7302
+ getViewCoordinates() {
7303
+ return [this.zoomTransform.x, this.zoomTransform.y];
7304
+ }
7293
7305
  translateBy(x, y) {
7294
7306
  if (!isNaN(x) && !isNaN(y)) {
7295
7307
  this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "4.2.4",
3
+ "version": "4.2.5",
4
4
  "dependencies": {},
5
5
  "peerDependencies": {
6
6
  "d3": "^7.9.0",
@@ -99,8 +99,10 @@ export declare class DiagramCanvas implements Canvas {
99
99
  getPriorityThreshold(): number | undefined;
100
100
  setPriorityThreshold(priority: number): void;
101
101
  initView(appendTo: HTMLElement): void;
102
+ getZoomLevel(): number;
102
103
  zoomBy(factor: number): void;
103
104
  zoomTo(level: number): void;
105
+ getViewCoordinates(): Point;
104
106
  translateBy(x: number, y: number): void;
105
107
  translateTo(x: number, y: number): void;
106
108
  center(): void;
@@ -111,6 +111,11 @@ export interface PaletteComponentConfig {
111
111
  * @default 'bottom'
112
112
  */
113
113
  direction?: Side;
114
+ /**
115
+ * Dimension of this component in the direction that it extends towards. If undefined, it stretches as needed.
116
+ * @default undefined
117
+ */
118
+ height?: string;
114
119
  /**
115
120
  * Dimension of this component in the direction perpendicular to the direction that it extends towards.
116
121
  * @default '12rem'
@@ -153,6 +158,11 @@ export interface PropertyEditorComponentConfig {
153
158
  * @default '24rem'
154
159
  */
155
160
  width?: string;
161
+ /**
162
+ * Dimension of this component in the direction that it extends towards. If undefined, it stretches as needed.
163
+ * @default undefined
164
+ */
165
+ height?: string;
156
166
  }
157
167
  /**
158
168
  * Configuration for a palette.
@@ -177,6 +177,11 @@ export interface Canvas {
177
177
  * @private
178
178
  */
179
179
  initView(appendTo: HTMLElement): void;
180
+ /**
181
+ * Gets the current zoom level.
182
+ * @public
183
+ */
184
+ getZoomLevel(): number;
180
185
  /**
181
186
  * Increases the zoom level by the given factor.
182
187
  * @public
@@ -189,6 +194,11 @@ export interface Canvas {
189
194
  * @param level A level of zoom.
190
195
  */
191
196
  zoomTo(level: number): void;
197
+ /**
198
+ * Gets the current coordinates of the view.
199
+ * @public
200
+ */
201
+ getViewCoordinates(): Point;
192
202
  /**
193
203
  * Translates the view by the given amount.
194
204
  * @public