@metadev/daga 4.2.11 → 4.2.12

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,11 @@ List of releases and changes.
6
6
 
7
7
  ## Next release Joyeuse
8
8
 
9
+ ## v. 4.2.12
10
+
11
+ - Force location of field `<foreignObject>` tags in webkit browsers [#356](https://github.com/metadevpro/daga/pull/356)
12
+ - Use `<g>` instead of `<foreignObject>` for containers of diagram decorators and objects [#357](https://github.com/metadevpro/daga/pull/357)
13
+
9
14
  ## v. 4.2.11
10
15
 
11
16
  - Version branch to avoid error in ng-packagr
package/index.cjs.js CHANGED
@@ -231,7 +231,7 @@ const distanceBetweenPoints = (point1, point2) => {
231
231
  return Math.pow(Math.pow(point1[0] - point2[0], 2) + Math.pow(point1[1] - point2[1], 2), 0.5);
232
232
  };
233
233
  /**
234
- * Checks whether the two given reactangles share at least one point.
234
+ * Checks whether the two given rectangles share at least one point.
235
235
  * @public
236
236
  * @param rectangle1 A rectangle.
237
237
  * @param rectangle2 A rectangle.
@@ -7163,7 +7163,6 @@ class DiagramUserSelection extends DiagramElementSet {
7163
7163
  this.canvas.propertyEditorChanges$.pipe(rxjs.debounceTime(2000)).subscribe(() => {
7164
7164
  this.makeUpdateValuesAction();
7165
7165
  });
7166
- console.log(diagramPropertiesText);
7167
7166
  this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
7168
7167
  }
7169
7168
  add(element) {
@@ -7415,6 +7414,9 @@ const unrotate = (width, height, orientation) => {
7415
7414
  return [oldWidth, oldHeight];
7416
7415
  };
7417
7416
 
7417
+ var _a;
7418
+ const isWebkit = ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.indexOf('AppleWebKit')) >= 0;
7419
+
7418
7420
  /**
7419
7421
  * Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
7420
7422
  * @private
@@ -7712,6 +7714,10 @@ class DiagramCanvas {
7712
7714
  const transformAttribute = event.transform.toString();
7713
7715
  this.selectCanvasElements().attr('transform', transformAttribute);
7714
7716
  d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7717
+ if (isWebkit) {
7718
+ // force update fields to compensate for a rendering bug in webkit
7719
+ this.updateFieldsInView();
7720
+ }
7715
7721
  this.contextMenu.close();
7716
7722
  this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
7717
7723
  }).on(exports.ZoomEvents.End, () => {
@@ -8670,11 +8676,15 @@ class DiagramCanvas {
8670
8676
  this.secondaryButton = false;
8671
8677
  })).append('xhtml:div').style('width', '100%').style('height', '100%').style('display', 'flex').append('xhtml:p').style('box-sizing', 'border-box').style('outline', 0).style('margin', 0).style('border', 0).style('padding', 0).style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
8672
8678
  mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[0]}px`).style('max-height', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[1]}px`).style('overflow', d => d.fit ? 'default' : 'clip').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').style('transform', d => `rotate(${d.orientation}deg)`).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
8679
+ if (isWebkit) {
8680
+ const zoomFactor = this.zoomTransform.k;
8681
+ mergeSelection.attr('width', d => `${d.width * zoomFactor}px`).attr('height', d => `${d.height * zoomFactor}px`).select('div').style('position', 'absolute').style('left', d => `${d.coords[0] * zoomFactor + this.zoomTransform.x}px`).style('top', d => `${d.coords[1] * zoomFactor + this.zoomTransform.y}px`).select('p').style('font-size', d => `${d.fontSize * zoomFactor}px`);
8682
+ }
8673
8683
  }
8674
8684
  updateObjectsInView(...ids) {
8675
- let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8685
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8676
8686
  const exitSelection = updateSelection.exit();
8677
- const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-object');
8687
+ const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-object');
8678
8688
  if (ids && ids.length > 0) {
8679
8689
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8680
8690
  }
@@ -8715,9 +8725,9 @@ class DiagramCanvas {
8715
8725
  }));
8716
8726
  }
8717
8727
  updateDecoratorsInView(...ids) {
8718
- let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8728
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8719
8729
  const exitSelection = updateSelection.exit();
8720
- const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-decorator');
8730
+ const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-decorator');
8721
8731
  if (ids && ids.length > 0) {
8722
8732
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8723
8733
  }
package/index.esm.js CHANGED
@@ -210,7 +210,7 @@ const distanceBetweenPoints = (point1, point2) => {
210
210
  return Math.pow(Math.pow(point1[0] - point2[0], 2) + Math.pow(point1[1] - point2[1], 2), 0.5);
211
211
  };
212
212
  /**
213
- * Checks whether the two given reactangles share at least one point.
213
+ * Checks whether the two given rectangles share at least one point.
214
214
  * @public
215
215
  * @param rectangle1 A rectangle.
216
216
  * @param rectangle2 A rectangle.
@@ -7142,7 +7142,6 @@ class DiagramUserSelection extends DiagramElementSet {
7142
7142
  this.canvas.propertyEditorChanges$.pipe(debounceTime(2000)).subscribe(() => {
7143
7143
  this.makeUpdateValuesAction();
7144
7144
  });
7145
- console.log(diagramPropertiesText);
7146
7145
  this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
7147
7146
  }
7148
7147
  add(element) {
@@ -7394,6 +7393,9 @@ const unrotate = (width, height, orientation) => {
7394
7393
  return [oldWidth, oldHeight];
7395
7394
  };
7396
7395
 
7396
+ var _a;
7397
+ const isWebkit = ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.indexOf('AppleWebKit')) >= 0;
7398
+
7397
7399
  /**
7398
7400
  * Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
7399
7401
  * @private
@@ -7691,6 +7693,10 @@ class DiagramCanvas {
7691
7693
  const transformAttribute = event.transform.toString();
7692
7694
  this.selectCanvasElements().attr('transform', transformAttribute);
7693
7695
  d3.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7696
+ if (isWebkit) {
7697
+ // force update fields to compensate for a rendering bug in webkit
7698
+ this.updateFieldsInView();
7699
+ }
7694
7700
  this.contextMenu.close();
7695
7701
  this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
7696
7702
  }).on(ZoomEvents.End, () => {
@@ -8649,11 +8655,15 @@ class DiagramCanvas {
8649
8655
  this.secondaryButton = false;
8650
8656
  })).append('xhtml:div').style('width', '100%').style('height', '100%').style('display', 'flex').append('xhtml:p').style('box-sizing', 'border-box').style('outline', 0).style('margin', 0).style('border', 0).style('padding', 0).style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
8651
8657
  mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === VerticalAlign.Center ? 'center' : d.verticalAlign === VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[0]}px`).style('max-height', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[1]}px`).style('overflow', d => d.fit ? 'default' : 'clip').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').style('transform', d => `rotate(${d.orientation}deg)`).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
8658
+ if (isWebkit) {
8659
+ const zoomFactor = this.zoomTransform.k;
8660
+ mergeSelection.attr('width', d => `${d.width * zoomFactor}px`).attr('height', d => `${d.height * zoomFactor}px`).select('div').style('position', 'absolute').style('left', d => `${d.coords[0] * zoomFactor + this.zoomTransform.x}px`).style('top', d => `${d.coords[1] * zoomFactor + this.zoomTransform.y}px`).select('p').style('font-size', d => `${d.fontSize * zoomFactor}px`);
8661
+ }
8652
8662
  }
8653
8663
  updateObjectsInView(...ids) {
8654
- let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8664
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8655
8665
  const exitSelection = updateSelection.exit();
8656
- const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-object');
8666
+ const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-object');
8657
8667
  if (ids && ids.length > 0) {
8658
8668
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8659
8669
  }
@@ -8694,9 +8704,9 @@ class DiagramCanvas {
8694
8704
  }));
8695
8705
  }
8696
8706
  updateDecoratorsInView(...ids) {
8697
- let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8707
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8698
8708
  const exitSelection = updateSelection.exit();
8699
- const enterSelection = updateSelection.enter().append('foreignObject').attr('id', d => d.id).attr('class', 'diagram-decorator');
8709
+ const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-decorator');
8700
8710
  if (ids && ids.length > 0) {
8701
8711
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
8702
8712
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "4.2.11",
3
+ "version": "4.2.12",
4
4
  "dependencies": {},
5
5
  "peerDependencies": {
6
6
  "d3": "^7.9.0",
@@ -0,0 +1 @@
1
+ export declare const isWebkit: boolean;
@@ -144,7 +144,7 @@ export declare const linesOverlap: (line1: Line, line2: Line) => boolean;
144
144
  */
145
145
  export declare const lineIntersectsRectangle: (line: Line, rectangle: Rectangle) => boolean;
146
146
  /**
147
- * Checks whether the two given reactangles share at least one point.
147
+ * Checks whether the two given rectangles share at least one point.
148
148
  * @public
149
149
  * @param rectangle1 A rectangle.
150
150
  * @param rectangle2 A rectangle.