@inweb/markup 26.3.3 → 26.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/markup.js +698 -285
  2. package/dist/markup.js.map +1 -1
  3. package/dist/markup.min.js +1 -1
  4. package/dist/markup.module.js +709 -175
  5. package/dist/markup.module.js.map +1 -1
  6. package/lib/markup/IMarkupArrow.d.ts +8 -8
  7. package/lib/markup/IMarkupCloud.d.ts +12 -5
  8. package/lib/markup/IMarkupEllipse.d.ts +4 -4
  9. package/lib/markup/IMarkupImage.d.ts +3 -3
  10. package/lib/markup/IMarkupLine.d.ts +2 -2
  11. package/lib/markup/IMarkupObject.d.ts +4 -0
  12. package/lib/markup/IMarkupRectangle.d.ts +10 -3
  13. package/lib/markup/IMarkupText.d.ts +3 -3
  14. package/lib/markup/Konva/KonvaArrow.d.ts +4 -1
  15. package/lib/markup/Konva/KonvaCloud.d.ts +4 -1
  16. package/lib/markup/Konva/KonvaEllipse.d.ts +4 -1
  17. package/lib/markup/Konva/KonvaImage.d.ts +4 -1
  18. package/lib/markup/Konva/KonvaLine.d.ts +4 -1
  19. package/lib/markup/Konva/KonvaMarkup.d.ts +2 -2
  20. package/lib/markup/Konva/KonvaRectangle.d.ts +4 -1
  21. package/lib/markup/Konva/KonvaText.d.ts +4 -1
  22. package/package.json +3 -3
  23. package/src/markup/IMarkupArrow.ts +8 -8
  24. package/src/markup/IMarkupCloud.ts +10 -5
  25. package/src/markup/IMarkupEllipse.ts +4 -4
  26. package/src/markup/IMarkupImage.ts +3 -3
  27. package/src/markup/IMarkupLine.ts +2 -2
  28. package/src/markup/IMarkupObject.ts +5 -0
  29. package/src/markup/IMarkupRectangle.ts +8 -3
  30. package/src/markup/IMarkupText.ts +3 -3
  31. package/src/markup/Konva/KonvaArrow.ts +49 -4
  32. package/src/markup/Konva/KonvaCloud.ts +110 -11
  33. package/src/markup/Konva/KonvaEllipse.ts +102 -2
  34. package/src/markup/Konva/KonvaImage.ts +60 -2
  35. package/src/markup/Konva/KonvaLine.ts +97 -3
  36. package/src/markup/Konva/KonvaMarkup.ts +182 -166
  37. package/src/markup/Konva/KonvaRectangle.ts +103 -4
  38. package/src/markup/Konva/KonvaText.ts +61 -2
package/dist/markup.js CHANGED
@@ -25,7 +25,7 @@
25
25
  hasRequiredGlobal = 1;
26
26
  (function (exports) {
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports._registerNode = exports.Konva = exports.glob = void 0;
28
+ exports._registerNode = exports.Konva = exports.glob = undefined;
29
29
  const PI_OVER_180 = Math.PI / 180;
30
30
  function detectBrowser() {
31
31
  return (typeof window !== 'undefined' &&
@@ -41,7 +41,7 @@
41
41
  : {};
42
42
  exports.Konva = {
43
43
  _global: exports.glob,
44
- version: '9.3.20',
44
+ version: '9.3.18',
45
45
  isBrowser: detectBrowser(),
46
46
  isUnminified: /param/.test(function (param) { }.toString()),
47
47
  dblClickWindow: 400,
@@ -73,7 +73,7 @@
73
73
  },
74
74
  isTransforming() {
75
75
  var _a;
76
- return (_a = exports.Konva['Transformer']) === null || _a === void 0 ? void 0 : _a.isTransforming();
76
+ return (_a = exports.Konva['Transformer']) === null || _a === undefined ? undefined : _a.isTransforming();
77
77
  },
78
78
  isDragReady() {
79
79
  return !!exports.Konva['DD'].node;
@@ -102,7 +102,7 @@
102
102
  hasRequiredUtil = 1;
103
103
  (function (exports) {
104
104
  Object.defineProperty(exports, "__esModule", { value: true });
105
- exports.Util = exports.Transform = void 0;
105
+ exports.Util = exports.Transform = undefined;
106
106
  const Global_1 = requireGlobal();
107
107
  class Transform {
108
108
  constructor(m = [1, 0, 0, 1, 0, 0]) {
@@ -1120,7 +1120,7 @@
1120
1120
  hasRequiredFactory = 1;
1121
1121
  (function (exports) {
1122
1122
  Object.defineProperty(exports, "__esModule", { value: true });
1123
- exports.Factory = void 0;
1123
+ exports.Factory = undefined;
1124
1124
  const Util_1 = requireUtil();
1125
1125
  const Validators_1 = requireValidators();
1126
1126
  const GET = 'get';
@@ -1258,7 +1258,7 @@
1258
1258
  if (hasRequiredContext) return Context;
1259
1259
  hasRequiredContext = 1;
1260
1260
  Object.defineProperty(Context, "__esModule", { value: true });
1261
- Context.HitContext = Context.SceneContext = Context.Context = void 0;
1261
+ Context.HitContext = Context.SceneContext = Context.Context = undefined;
1262
1262
  const Util_1 = requireUtil();
1263
1263
  const Global_1 = requireGlobal();
1264
1264
  function simplifyArray(arr) {
@@ -1747,7 +1747,7 @@
1747
1747
  }
1748
1748
  _applyShadow(shape) {
1749
1749
  var _a, _b, _c;
1750
- const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
1750
+ const color = (_a = shape.getShadowRGBA()) !== null && _a !== undefined ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== undefined ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== undefined ? _c : {
1751
1751
  x: 0,
1752
1752
  y: 0,
1753
1753
  }, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
@@ -1806,10 +1806,12 @@
1806
1806
  if (hasRequiredCanvas) return Canvas;
1807
1807
  hasRequiredCanvas = 1;
1808
1808
  Object.defineProperty(Canvas, "__esModule", { value: true });
1809
- Canvas.HitCanvas = Canvas.SceneCanvas = Canvas.Canvas = void 0;
1809
+ Canvas.HitCanvas = Canvas.SceneCanvas = Canvas.Canvas = undefined;
1810
1810
  const Util_1 = requireUtil();
1811
1811
  const Context_1 = requireContext();
1812
1812
  const Global_1 = requireGlobal();
1813
+ const Factory_1 = requireFactory();
1814
+ const Validators_1 = requireValidators();
1813
1815
  let _pixelRatio;
1814
1816
  function getDevicePixelRatio() {
1815
1817
  if (_pixelRatio) {
@@ -1898,6 +1900,7 @@
1898
1900
  }
1899
1901
  };
1900
1902
  Canvas.Canvas = Canvas$1;
1903
+ Factory_1.Factory.addGetterSetter(Canvas$1, 'pixelRatio', undefined, (0, Validators_1.getNumberValidator)());
1901
1904
  class SceneCanvas extends Canvas$1 {
1902
1905
  constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
1903
1906
  super(config);
@@ -1929,7 +1932,7 @@
1929
1932
  hasRequiredDragAndDrop = 1;
1930
1933
  (function (exports) {
1931
1934
  Object.defineProperty(exports, "__esModule", { value: true });
1932
- exports.DD = void 0;
1935
+ exports.DD = undefined;
1933
1936
  const Global_1 = requireGlobal();
1934
1937
  const Util_1 = requireUtil();
1935
1938
  exports.DD = {
@@ -2050,7 +2053,7 @@
2050
2053
  if (hasRequiredNode) return Node;
2051
2054
  hasRequiredNode = 1;
2052
2055
  Object.defineProperty(Node, "__esModule", { value: true });
2053
- Node.Node = void 0;
2056
+ Node.Node = undefined;
2054
2057
  const Util_1 = requireUtil();
2055
2058
  const Factory_1 = requireFactory();
2056
2059
  const Canvas_1 = requireCanvas();
@@ -2955,7 +2958,7 @@
2955
2958
  var _a, _b;
2956
2959
  const m = this._cache.get(TRANSFORM) || new Util_1.Transform();
2957
2960
  m.reset();
2958
- const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== void 0 ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== void 0 ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
2961
+ const x = this.x(), y = this.y(), rotation = Global_1.Konva.getAngle(this.rotation()), scaleX = (_a = this.attrs.scaleX) !== null && _a !== undefined ? _a : 1, scaleY = (_b = this.attrs.scaleY) !== null && _b !== undefined ? _b : 1, skewX = this.attrs.skewX || 0, skewY = this.attrs.skewY || 0, offsetX = this.attrs.offsetX || 0, offsetY = this.attrs.offsetY || 0;
2959
2962
  if (x !== 0 || y !== 0) {
2960
2963
  m.translate(x, y);
2961
2964
  }
@@ -3157,7 +3160,7 @@
3157
3160
  _requestDraw() {
3158
3161
  if (Global_1.Konva.autoDrawEnabled) {
3159
3162
  const drawNode = this.getLayer() || this.getStage();
3160
- drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();
3163
+ drawNode === null || drawNode === undefined ? undefined : drawNode.batchDraw();
3161
3164
  }
3162
3165
  }
3163
3166
  _setAttr(key, val) {
@@ -3218,13 +3221,13 @@
3218
3221
  }
3219
3222
  _getProtoListeners(eventType) {
3220
3223
  var _a, _b, _c;
3221
- const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== void 0 ? _a : {};
3222
- let events = allListeners === null || allListeners === void 0 ? void 0 : allListeners[eventType];
3224
+ const allListeners = (_a = this._cache.get(ALL_LISTENERS)) !== null && _a !== undefined ? _a : {};
3225
+ let events = allListeners === null || allListeners === undefined ? undefined : allListeners[eventType];
3223
3226
  if (events === undefined) {
3224
3227
  events = [];
3225
3228
  let obj = Object.getPrototypeOf(this);
3226
3229
  while (obj) {
3227
- const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === void 0 ? void 0 : _b[eventType]) !== null && _c !== void 0 ? _c : [];
3230
+ const hierarchyEvents = (_c = (_b = obj.eventListeners) === null || _b === undefined ? undefined : _b[eventType]) !== null && _c !== undefined ? _c : [];
3228
3231
  events.push(...hierarchyEvents);
3229
3232
  obj = Object.getPrototypeOf(obj);
3230
3233
  }
@@ -3490,7 +3493,7 @@
3490
3493
  if (hasRequiredContainer) return Container;
3491
3494
  hasRequiredContainer = 1;
3492
3495
  Object.defineProperty(Container, "__esModule", { value: true });
3493
- Container.Container = void 0;
3496
+ Container.Container = undefined;
3494
3497
  const Factory_1 = requireFactory();
3495
3498
  const Node_1 = requireNode();
3496
3499
  const Validators_1 = requireValidators();
@@ -3647,13 +3650,13 @@
3647
3650
  if (this.isCached()) {
3648
3651
  return;
3649
3652
  }
3650
- (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
3653
+ (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (node) {
3651
3654
  node._clearSelfAndDescendantCache(attr);
3652
3655
  });
3653
3656
  }
3654
3657
  _setChildrenIndices() {
3655
3658
  var _a;
3656
- (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
3659
+ (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child, n) {
3657
3660
  child.index = n;
3658
3661
  });
3659
3662
  this._requestDraw();
@@ -3724,7 +3727,7 @@
3724
3727
  context.save();
3725
3728
  context._applyGlobalCompositeOperation(this);
3726
3729
  }
3727
- (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
3730
+ (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child) {
3728
3731
  child[drawMethod](canvas, top, bufferCanvas);
3729
3732
  });
3730
3733
  if (hasComposition) {
@@ -3746,7 +3749,7 @@
3746
3749
  height: 0,
3747
3750
  };
3748
3751
  const that = this;
3749
- (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
3752
+ (_a = this.children) === null || _a === undefined ? undefined : _a.forEach(function (child) {
3750
3753
  if (!child.visible()) {
3751
3754
  return;
3752
3755
  }
@@ -3878,7 +3881,7 @@
3878
3881
  hasRequiredStage = 1;
3879
3882
  (function (exports) {
3880
3883
  Object.defineProperty(exports, "__esModule", { value: true });
3881
- exports.Stage = exports.stages = void 0;
3884
+ exports.Stage = exports.stages = undefined;
3882
3885
  const Util_1 = requireUtil();
3883
3886
  const Factory_1 = requireFactory();
3884
3887
  const Container_1 = requireContainer();
@@ -4595,7 +4598,7 @@
4595
4598
  hasRequiredShape = 1;
4596
4599
  (function (exports) {
4597
4600
  Object.defineProperty(exports, "__esModule", { value: true });
4598
- exports.Shape = exports.shapes = void 0;
4601
+ exports.Shape = exports.shapes = undefined;
4599
4602
  const Global_1 = requireGlobal();
4600
4603
  const Util_1 = requireUtil();
4601
4604
  const Factory_1 = requireFactory();
@@ -4828,7 +4831,7 @@
4828
4831
  }
4829
4832
  _useBufferCanvas(forceFill) {
4830
4833
  var _a;
4831
- const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
4834
+ const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== undefined ? _a : true;
4832
4835
  if (!perfectDrawEnabled) {
4833
4836
  return false;
4834
4837
  }
@@ -5148,7 +5151,7 @@
5148
5151
  if (hasRequiredLayer) return Layer;
5149
5152
  hasRequiredLayer = 1;
5150
5153
  Object.defineProperty(Layer, "__esModule", { value: true });
5151
- Layer.Layer = void 0;
5154
+ Layer.Layer = undefined;
5152
5155
  const Util_1 = requireUtil();
5153
5156
  const Container_1 = requireContainer();
5154
5157
  const Node_1 = requireNode();
@@ -5466,7 +5469,7 @@
5466
5469
  if (hasRequiredFastLayer) return FastLayer;
5467
5470
  hasRequiredFastLayer = 1;
5468
5471
  Object.defineProperty(FastLayer, "__esModule", { value: true });
5469
- FastLayer.FastLayer = void 0;
5472
+ FastLayer.FastLayer = undefined;
5470
5473
  const Util_1 = requireUtil();
5471
5474
  const Layer_1 = requireLayer();
5472
5475
  const Global_1 = requireGlobal();
@@ -5491,7 +5494,7 @@
5491
5494
  if (hasRequiredGroup) return Group;
5492
5495
  hasRequiredGroup = 1;
5493
5496
  Object.defineProperty(Group, "__esModule", { value: true });
5494
- Group.Group = void 0;
5497
+ Group.Group = undefined;
5495
5498
  const Util_1 = requireUtil();
5496
5499
  const Container_1 = requireContainer();
5497
5500
  const Global_1 = requireGlobal();
@@ -5517,7 +5520,7 @@
5517
5520
  if (hasRequiredAnimation) return Animation;
5518
5521
  hasRequiredAnimation = 1;
5519
5522
  Object.defineProperty(Animation, "__esModule", { value: true });
5520
- Animation.Animation = void 0;
5523
+ Animation.Animation = undefined;
5521
5524
  const Global_1 = requireGlobal();
5522
5525
  const Util_1 = requireUtil();
5523
5526
  const now = (function () {
@@ -5673,7 +5676,7 @@
5673
5676
  hasRequiredTween = 1;
5674
5677
  (function (exports) {
5675
5678
  Object.defineProperty(exports, "__esModule", { value: true });
5676
- exports.Easings = exports.Tween = void 0;
5679
+ exports.Easings = exports.Tween = undefined;
5677
5680
  const Util_1 = requireUtil();
5678
5681
  const Animation_1 = requireAnimation();
5679
5682
  const Node_1 = requireNode();
@@ -6206,7 +6209,7 @@
6206
6209
  hasRequired_CoreInternals = 1;
6207
6210
  (function (exports) {
6208
6211
  Object.defineProperty(exports, "__esModule", { value: true });
6209
- exports.Konva = void 0;
6212
+ exports.Konva = undefined;
6210
6213
  const Global_1 = requireGlobal();
6211
6214
  const Util_1 = requireUtil();
6212
6215
  const Node_1 = requireNode();
@@ -6253,7 +6256,7 @@
6253
6256
  if (hasRequiredArc) return Arc;
6254
6257
  hasRequiredArc = 1;
6255
6258
  Object.defineProperty(Arc, "__esModule", { value: true });
6256
- Arc.Arc = void 0;
6259
+ Arc.Arc = undefined;
6257
6260
  const Factory_1 = requireFactory();
6258
6261
  const Shape_1 = requireShape();
6259
6262
  const Global_1 = requireGlobal();
@@ -6304,12 +6307,7 @@
6304
6307
  Arc.Arc = Arc$1;
6305
6308
  Arc$1.prototype._centroid = true;
6306
6309
  Arc$1.prototype.className = 'Arc';
6307
- Arc$1.prototype._attrsAffectingSize = [
6308
- 'innerRadius',
6309
- 'outerRadius',
6310
- 'angle',
6311
- 'clockwise',
6312
- ];
6310
+ Arc$1.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
6313
6311
  (0, Global_2._registerNode)(Arc$1);
6314
6312
  Factory_1.Factory.addGetterSetter(Arc$1, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
6315
6313
  Factory_1.Factory.addGetterSetter(Arc$1, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
@@ -6328,7 +6326,7 @@
6328
6326
  if (hasRequiredLine) return Line;
6329
6327
  hasRequiredLine = 1;
6330
6328
  Object.defineProperty(Line, "__esModule", { value: true });
6331
- Line.Line = void 0;
6329
+ Line.Line = undefined;
6332
6330
  const Factory_1 = requireFactory();
6333
6331
  const Global_1 = requireGlobal();
6334
6332
  const Shape_1 = requireShape();
@@ -6499,7 +6497,7 @@
6499
6497
  hasRequiredBezierFunctions = 1;
6500
6498
  (function (exports) {
6501
6499
  Object.defineProperty(exports, "__esModule", { value: true });
6502
- exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = void 0;
6500
+ exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = undefined;
6503
6501
  exports.tValues = [
6504
6502
  [],
6505
6503
  [],
@@ -7297,7 +7295,7 @@
7297
7295
  if (hasRequiredPath) return Path;
7298
7296
  hasRequiredPath = 1;
7299
7297
  Object.defineProperty(Path, "__esModule", { value: true });
7300
- Path.Path = void 0;
7298
+ Path.Path = undefined;
7301
7299
  const Factory_1 = requireFactory();
7302
7300
  const Shape_1 = requireShape();
7303
7301
  const Global_1 = requireGlobal();
@@ -7480,8 +7478,8 @@
7480
7478
  return null;
7481
7479
  }
7482
7480
  static getPointOnLine(dist, P1x, P1y, P2x, P2y, fromX, fromY) {
7483
- fromX = fromX !== null && fromX !== void 0 ? fromX : P1x;
7484
- fromY = fromY !== null && fromY !== void 0 ? fromY : P1y;
7481
+ fromX = fromX !== null && fromX !== undefined ? fromX : P1x;
7482
+ fromY = fromY !== null && fromY !== undefined ? fromY : P1y;
7485
7483
  const len = this.getLineLength(P1x, P1y, P2x, P2y);
7486
7484
  if (len < 1e-10) {
7487
7485
  return { x: P1x, y: P1y };
@@ -7910,7 +7908,7 @@
7910
7908
  if (hasRequiredArrow) return Arrow;
7911
7909
  hasRequiredArrow = 1;
7912
7910
  Object.defineProperty(Arrow, "__esModule", { value: true });
7913
- Arrow.Arrow = void 0;
7911
+ Arrow.Arrow = undefined;
7914
7912
  const Factory_1 = requireFactory();
7915
7913
  const Line_1 = requireLine();
7916
7914
  const Validators_1 = requireValidators();
@@ -8022,7 +8020,7 @@
8022
8020
  if (hasRequiredCircle) return Circle;
8023
8021
  hasRequiredCircle = 1;
8024
8022
  Object.defineProperty(Circle, "__esModule", { value: true });
8025
- Circle.Circle = void 0;
8023
+ Circle.Circle = undefined;
8026
8024
  const Factory_1 = requireFactory();
8027
8025
  const Shape_1 = requireShape();
8028
8026
  const Validators_1 = requireValidators();
@@ -8068,7 +8066,7 @@
8068
8066
  if (hasRequiredEllipse) return Ellipse;
8069
8067
  hasRequiredEllipse = 1;
8070
8068
  Object.defineProperty(Ellipse, "__esModule", { value: true });
8071
- Ellipse.Ellipse = void 0;
8069
+ Ellipse.Ellipse = undefined;
8072
8070
  const Factory_1 = requireFactory();
8073
8071
  const Shape_1 = requireShape();
8074
8072
  const Validators_1 = requireValidators();
@@ -8118,7 +8116,7 @@
8118
8116
  if (hasRequiredImage) return Image$1;
8119
8117
  hasRequiredImage = 1;
8120
8118
  Object.defineProperty(Image$1, "__esModule", { value: true });
8121
- Image$1.Image = void 0;
8119
+ Image$1.Image = undefined;
8122
8120
  const Util_1 = requireUtil();
8123
8121
  const Factory_1 = requireFactory();
8124
8122
  const Shape_1 = requireShape();
@@ -8127,11 +8125,7 @@
8127
8125
  class Image extends Shape_1.Shape {
8128
8126
  constructor(attrs) {
8129
8127
  super(attrs);
8130
- this._loadListener = () => {
8131
- this._requestDraw();
8132
- };
8133
- this.on('imageChange.konva', (props) => {
8134
- this._removeImageLoad(props.oldVal);
8128
+ this.on('imageChange.konva', () => {
8135
8129
  this._setImageLoad();
8136
8130
  });
8137
8131
  this._setImageLoad();
@@ -8145,19 +8139,11 @@
8145
8139
  return;
8146
8140
  }
8147
8141
  if (image && image['addEventListener']) {
8148
- image['addEventListener']('load', this._loadListener);
8149
- }
8150
- }
8151
- _removeImageLoad(image) {
8152
- if (image && image['removeEventListener']) {
8153
- image['removeEventListener']('load', this._loadListener);
8142
+ image['addEventListener']('load', () => {
8143
+ this._requestDraw();
8144
+ });
8154
8145
  }
8155
8146
  }
8156
- destroy() {
8157
- this._removeImageLoad(this.image());
8158
- super.destroy();
8159
- return this;
8160
- }
8161
8147
  _useBufferCanvas() {
8162
8148
  const hasCornerRadius = !!this.cornerRadius();
8163
8149
  const hasShadow = this.hasShadow();
@@ -8221,11 +8207,11 @@
8221
8207
  }
8222
8208
  getWidth() {
8223
8209
  var _a, _b;
8224
- return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
8210
+ return (_a = this.attrs.width) !== null && _a !== undefined ? _a : (_b = this.image()) === null || _b === undefined ? undefined : _b.width;
8225
8211
  }
8226
8212
  getHeight() {
8227
8213
  var _a, _b;
8228
- return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
8214
+ return (_a = this.attrs.height) !== null && _a !== undefined ? _a : (_b = this.image()) === null || _b === undefined ? undefined : _b.height;
8229
8215
  }
8230
8216
  static fromURL(url, callback, onError = null) {
8231
8217
  const img = Util_1.Util.createImageElement();
@@ -8261,7 +8247,7 @@
8261
8247
  if (hasRequiredLabel) return Label;
8262
8248
  hasRequiredLabel = 1;
8263
8249
  Object.defineProperty(Label, "__esModule", { value: true });
8264
- Label.Tag = Label.Label = void 0;
8250
+ Label.Tag = Label.Label = undefined;
8265
8251
  const Factory_1 = requireFactory();
8266
8252
  const Shape_1 = requireShape();
8267
8253
  const Group_1 = requireGroup();
@@ -8448,7 +8434,7 @@
8448
8434
  if (hasRequiredRect) return Rect;
8449
8435
  hasRequiredRect = 1;
8450
8436
  Object.defineProperty(Rect, "__esModule", { value: true });
8451
- Rect.Rect = void 0;
8437
+ Rect.Rect = undefined;
8452
8438
  const Factory_1 = requireFactory();
8453
8439
  const Shape_1 = requireShape();
8454
8440
  const Global_1 = requireGlobal();
@@ -8483,7 +8469,7 @@
8483
8469
  if (hasRequiredRegularPolygon) return RegularPolygon;
8484
8470
  hasRequiredRegularPolygon = 1;
8485
8471
  Object.defineProperty(RegularPolygon, "__esModule", { value: true });
8486
- RegularPolygon.RegularPolygon = void 0;
8472
+ RegularPolygon.RegularPolygon = undefined;
8487
8473
  const Factory_1 = requireFactory();
8488
8474
  const Shape_1 = requireShape();
8489
8475
  const Validators_1 = requireValidators();
@@ -8561,7 +8547,7 @@
8561
8547
  if (hasRequiredRing) return Ring;
8562
8548
  hasRequiredRing = 1;
8563
8549
  Object.defineProperty(Ring, "__esModule", { value: true });
8564
- Ring.Ring = void 0;
8550
+ Ring.Ring = undefined;
8565
8551
  const Factory_1 = requireFactory();
8566
8552
  const Shape_1 = requireShape();
8567
8553
  const Validators_1 = requireValidators();
@@ -8607,7 +8593,7 @@
8607
8593
  if (hasRequiredSprite) return Sprite;
8608
8594
  hasRequiredSprite = 1;
8609
8595
  Object.defineProperty(Sprite, "__esModule", { value: true });
8610
- Sprite.Sprite = void 0;
8596
+ Sprite.Sprite = undefined;
8611
8597
  const Factory_1 = requireFactory();
8612
8598
  const Shape_1 = requireShape();
8613
8599
  const Animation_1 = requireAnimation();
@@ -8728,7 +8714,7 @@
8728
8714
  if (hasRequiredStar) return Star;
8729
8715
  hasRequiredStar = 1;
8730
8716
  Object.defineProperty(Star, "__esModule", { value: true });
8731
- Star.Star = void 0;
8717
+ Star.Star = undefined;
8732
8718
  const Factory_1 = requireFactory();
8733
8719
  const Shape_1 = requireShape();
8734
8720
  const Validators_1 = requireValidators();
@@ -8779,7 +8765,7 @@
8779
8765
  if (hasRequiredText) return Text;
8780
8766
  hasRequiredText = 1;
8781
8767
  Object.defineProperty(Text, "__esModule", { value: true });
8782
- Text.Text = void 0;
8768
+ Text.Text = undefined;
8783
8769
  Text.stringToArray = stringToArray;
8784
8770
  const Util_1 = requireUtil();
8785
8771
  const Factory_1 = requireFactory();
@@ -9025,17 +9011,17 @@
9025
9011
  _context.restore();
9026
9012
  const scaleFactor = fontSize / 100;
9027
9013
  return {
9028
- actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== void 0 ? _a : 71.58203125 * scaleFactor,
9029
- actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== void 0 ? _b : 0,
9030
- actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== void 0 ? _c : -7.421875 * scaleFactor,
9031
- actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== void 0 ? _d : 75.732421875 * scaleFactor,
9032
- alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== void 0 ? _e : 0,
9033
- emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== void 0 ? _f : 100 * scaleFactor,
9034
- emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== void 0 ? _g : -20 * scaleFactor,
9035
- fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== void 0 ? _h : 91 * scaleFactor,
9036
- fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== void 0 ? _j : 21 * scaleFactor,
9037
- hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== void 0 ? _k : 72.80000305175781 * scaleFactor,
9038
- ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== void 0 ? _l : -21 * scaleFactor,
9014
+ actualBoundingBoxAscent: (_a = metrics.actualBoundingBoxAscent) !== null && _a !== undefined ? _a : 71.58203125 * scaleFactor,
9015
+ actualBoundingBoxDescent: (_b = metrics.actualBoundingBoxDescent) !== null && _b !== undefined ? _b : 0,
9016
+ actualBoundingBoxLeft: (_c = metrics.actualBoundingBoxLeft) !== null && _c !== undefined ? _c : -7.421875 * scaleFactor,
9017
+ actualBoundingBoxRight: (_d = metrics.actualBoundingBoxRight) !== null && _d !== undefined ? _d : 75.732421875 * scaleFactor,
9018
+ alphabeticBaseline: (_e = metrics.alphabeticBaseline) !== null && _e !== undefined ? _e : 0,
9019
+ emHeightAscent: (_f = metrics.emHeightAscent) !== null && _f !== undefined ? _f : 100 * scaleFactor,
9020
+ emHeightDescent: (_g = metrics.emHeightDescent) !== null && _g !== undefined ? _g : -20 * scaleFactor,
9021
+ fontBoundingBoxAscent: (_h = metrics.fontBoundingBoxAscent) !== null && _h !== undefined ? _h : 91 * scaleFactor,
9022
+ fontBoundingBoxDescent: (_j = metrics.fontBoundingBoxDescent) !== null && _j !== undefined ? _j : 21 * scaleFactor,
9023
+ hangingBaseline: (_k = metrics.hangingBaseline) !== null && _k !== undefined ? _k : 72.80000305175781 * scaleFactor,
9024
+ ideographicBaseline: (_l = metrics.ideographicBaseline) !== null && _l !== undefined ? _l : -21 * scaleFactor,
9039
9025
  width: metrics.width,
9040
9026
  height: fontSize,
9041
9027
  };
@@ -9079,14 +9065,8 @@
9079
9065
  while (line.length > 0) {
9080
9066
  let low = 0, high = stringToArray(line).length, match = '', matchWidth = 0;
9081
9067
  while (low < high) {
9082
- const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr);
9083
- const shouldConsiderEllipsis = shouldAddEllipsis &&
9084
- fixedHeight &&
9085
- currentHeightPx + lineHeightPx > maxHeightPx;
9086
- const effectiveWidth = shouldConsiderEllipsis
9087
- ? substrWidth + additionalWidth
9088
- : substrWidth;
9089
- if (effectiveWidth <= maxWidth) {
9068
+ const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr) + additionalWidth;
9069
+ if (substrWidth <= maxWidth) {
9090
9070
  low = mid + 1;
9091
9071
  match = substr;
9092
9072
  matchWidth = substrWidth;
@@ -9233,7 +9213,7 @@
9233
9213
  if (hasRequiredTextPath) return TextPath;
9234
9214
  hasRequiredTextPath = 1;
9235
9215
  Object.defineProperty(TextPath, "__esModule", { value: true });
9236
- TextPath.TextPath = void 0;
9216
+ TextPath.TextPath = undefined;
9237
9217
  const Util_1 = requireUtil();
9238
9218
  const Factory_1 = requireFactory();
9239
9219
  const Shape_1 = requireShape();
@@ -9483,7 +9463,7 @@
9483
9463
  if (hasRequiredTransformer) return Transformer;
9484
9464
  hasRequiredTransformer = 1;
9485
9465
  Object.defineProperty(Transformer, "__esModule", { value: true });
9486
- Transformer.Transformer = void 0;
9466
+ Transformer.Transformer = undefined;
9487
9467
  const Util_1 = requireUtil();
9488
9468
  const Factory_1 = requireFactory();
9489
9469
  const Node_1 = requireNode();
@@ -9680,12 +9660,10 @@
9680
9660
  this.update();
9681
9661
  }
9682
9662
  };
9683
- if (node._attrsAffectingSize.length) {
9684
- const additionalEvents = node._attrsAffectingSize
9685
- .map((prop) => prop + 'Change.' + this._getEventNamespace())
9686
- .join(' ');
9687
- node.on(additionalEvents, onChange);
9688
- }
9663
+ const additionalEvents = node._attrsAffectingSize
9664
+ .map((prop) => prop + 'Change.' + this._getEventNamespace())
9665
+ .join(' ');
9666
+ node.on(additionalEvents, onChange);
9689
9667
  node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
9690
9668
  node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
9691
9669
  this._proxyDrag(node);
@@ -10160,12 +10138,12 @@
10160
10138
  const node = this.getNode();
10161
10139
  activeTransformersCount--;
10162
10140
  this._fire('transformend', { evt: e, target: node });
10163
- (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10141
+ (_a = this.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10164
10142
  if (node) {
10165
10143
  this._nodes.forEach((target) => {
10166
10144
  var _a;
10167
10145
  target._fire('transformend', { evt: e, target });
10168
- (_a = target.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10146
+ (_a = target.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10169
10147
  });
10170
10148
  }
10171
10149
  this._movingAnchorName = null;
@@ -10278,7 +10256,7 @@
10278
10256
  .multiply(localTransform);
10279
10257
  const attrs = newLocalTransform.decompose();
10280
10258
  node.setAttrs(attrs);
10281
- (_a = node.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10259
+ (_a = node.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10282
10260
  });
10283
10261
  this.rotation(Util_1.Util._getRotation(newAttrs.rotation));
10284
10262
  this._nodes.forEach((node) => {
@@ -10393,7 +10371,7 @@
10393
10371
  styleFunc(node);
10394
10372
  });
10395
10373
  }
10396
- (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
10374
+ (_a = this.getLayer()) === null || _a === undefined ? undefined : _a.batchDraw();
10397
10375
  }
10398
10376
  isTransforming() {
10399
10377
  return this._transforming;
@@ -10500,7 +10478,7 @@
10500
10478
  if (hasRequiredWedge) return Wedge;
10501
10479
  hasRequiredWedge = 1;
10502
10480
  Object.defineProperty(Wedge, "__esModule", { value: true });
10503
- Wedge.Wedge = void 0;
10481
+ Wedge.Wedge = undefined;
10504
10482
  const Factory_1 = requireFactory();
10505
10483
  const Shape_1 = requireShape();
10506
10484
  const Global_1 = requireGlobal();
@@ -10551,7 +10529,7 @@
10551
10529
  if (hasRequiredBlur) return Blur;
10552
10530
  hasRequiredBlur = 1;
10553
10531
  Object.defineProperty(Blur, "__esModule", { value: true });
10554
- Blur.Blur = void 0;
10532
+ Blur.Blur = undefined;
10555
10533
  const Factory_1 = requireFactory();
10556
10534
  const Node_1 = requireNode();
10557
10535
  const Validators_1 = requireValidators();
@@ -10799,7 +10777,7 @@
10799
10777
  if (hasRequiredBrighten) return Brighten;
10800
10778
  hasRequiredBrighten = 1;
10801
10779
  Object.defineProperty(Brighten, "__esModule", { value: true });
10802
- Brighten.Brighten = void 0;
10780
+ Brighten.Brighten = undefined;
10803
10781
  const Factory_1 = requireFactory();
10804
10782
  const Node_1 = requireNode();
10805
10783
  const Validators_1 = requireValidators();
@@ -10824,7 +10802,7 @@
10824
10802
  if (hasRequiredContrast) return Contrast;
10825
10803
  hasRequiredContrast = 1;
10826
10804
  Object.defineProperty(Contrast, "__esModule", { value: true });
10827
- Contrast.Contrast = void 0;
10805
+ Contrast.Contrast = undefined;
10828
10806
  const Factory_1 = requireFactory();
10829
10807
  const Node_1 = requireNode();
10830
10808
  const Validators_1 = requireValidators();
@@ -10872,7 +10850,7 @@
10872
10850
  if (hasRequiredEmboss) return Emboss;
10873
10851
  hasRequiredEmboss = 1;
10874
10852
  Object.defineProperty(Emboss, "__esModule", { value: true });
10875
- Emboss.Emboss = void 0;
10853
+ Emboss.Emboss = undefined;
10876
10854
  const Factory_1 = requireFactory();
10877
10855
  const Node_1 = requireNode();
10878
10856
  const Util_1 = requireUtil();
@@ -10988,7 +10966,7 @@
10988
10966
  if (hasRequiredEnhance) return Enhance;
10989
10967
  hasRequiredEnhance = 1;
10990
10968
  Object.defineProperty(Enhance, "__esModule", { value: true });
10991
- Enhance.Enhance = void 0;
10969
+ Enhance.Enhance = undefined;
10992
10970
  const Factory_1 = requireFactory();
10993
10971
  const Node_1 = requireNode();
10994
10972
  const Validators_1 = requireValidators();
@@ -11085,7 +11063,7 @@
11085
11063
  if (hasRequiredGrayscale) return Grayscale;
11086
11064
  hasRequiredGrayscale = 1;
11087
11065
  Object.defineProperty(Grayscale, "__esModule", { value: true });
11088
- Grayscale.Grayscale = void 0;
11066
+ Grayscale.Grayscale = undefined;
11089
11067
  const Grayscale$1 = function (imageData) {
11090
11068
  const data = imageData.data, len = data.length;
11091
11069
  for (let i = 0; i < len; i += 4) {
@@ -11107,7 +11085,7 @@
11107
11085
  if (hasRequiredHSL) return HSL;
11108
11086
  hasRequiredHSL = 1;
11109
11087
  Object.defineProperty(HSL, "__esModule", { value: true });
11110
- HSL.HSL = void 0;
11088
+ HSL.HSL = undefined;
11111
11089
  const Factory_1 = requireFactory();
11112
11090
  const Node_1 = requireNode();
11113
11091
  const Validators_1 = requireValidators();
@@ -11144,7 +11122,7 @@
11144
11122
  if (hasRequiredHSV) return HSV;
11145
11123
  hasRequiredHSV = 1;
11146
11124
  Object.defineProperty(HSV, "__esModule", { value: true });
11147
- HSV.HSV = void 0;
11125
+ HSV.HSV = undefined;
11148
11126
  const Factory_1 = requireFactory();
11149
11127
  const Node_1 = requireNode();
11150
11128
  const Validators_1 = requireValidators();
@@ -11181,7 +11159,7 @@
11181
11159
  if (hasRequiredInvert) return Invert;
11182
11160
  hasRequiredInvert = 1;
11183
11161
  Object.defineProperty(Invert, "__esModule", { value: true });
11184
- Invert.Invert = void 0;
11162
+ Invert.Invert = undefined;
11185
11163
  const Invert$1 = function (imageData) {
11186
11164
  const data = imageData.data, len = data.length;
11187
11165
  for (let i = 0; i < len; i += 4) {
@@ -11202,7 +11180,7 @@
11202
11180
  if (hasRequiredKaleidoscope) return Kaleidoscope;
11203
11181
  hasRequiredKaleidoscope = 1;
11204
11182
  Object.defineProperty(Kaleidoscope, "__esModule", { value: true });
11205
- Kaleidoscope.Kaleidoscope = void 0;
11183
+ Kaleidoscope.Kaleidoscope = undefined;
11206
11184
  const Factory_1 = requireFactory();
11207
11185
  const Node_1 = requireNode();
11208
11186
  const Util_1 = requireUtil();
@@ -11348,7 +11326,7 @@
11348
11326
  if (hasRequiredMask) return Mask;
11349
11327
  hasRequiredMask = 1;
11350
11328
  Object.defineProperty(Mask, "__esModule", { value: true });
11351
- Mask.Mask = void 0;
11329
+ Mask.Mask = undefined;
11352
11330
  const Factory_1 = requireFactory();
11353
11331
  const Node_1 = requireNode();
11354
11332
  const Validators_1 = requireValidators();
@@ -11502,7 +11480,7 @@
11502
11480
  if (hasRequiredNoise) return Noise;
11503
11481
  hasRequiredNoise = 1;
11504
11482
  Object.defineProperty(Noise, "__esModule", { value: true });
11505
- Noise.Noise = void 0;
11483
+ Noise.Noise = undefined;
11506
11484
  const Factory_1 = requireFactory();
11507
11485
  const Node_1 = requireNode();
11508
11486
  const Validators_1 = requireValidators();
@@ -11527,7 +11505,7 @@
11527
11505
  if (hasRequiredPixelate) return Pixelate;
11528
11506
  hasRequiredPixelate = 1;
11529
11507
  Object.defineProperty(Pixelate, "__esModule", { value: true });
11530
- Pixelate.Pixelate = void 0;
11508
+ Pixelate.Pixelate = undefined;
11531
11509
  const Factory_1 = requireFactory();
11532
11510
  const Util_1 = requireUtil();
11533
11511
  const Node_1 = requireNode();
@@ -11600,7 +11578,7 @@
11600
11578
  if (hasRequiredPosterize) return Posterize;
11601
11579
  hasRequiredPosterize = 1;
11602
11580
  Object.defineProperty(Posterize, "__esModule", { value: true });
11603
- Posterize.Posterize = void 0;
11581
+ Posterize.Posterize = undefined;
11604
11582
  const Factory_1 = requireFactory();
11605
11583
  const Node_1 = requireNode();
11606
11584
  const Validators_1 = requireValidators();
@@ -11623,7 +11601,7 @@
11623
11601
  if (hasRequiredRGB) return RGB;
11624
11602
  hasRequiredRGB = 1;
11625
11603
  Object.defineProperty(RGB, "__esModule", { value: true });
11626
- RGB.RGB = void 0;
11604
+ RGB.RGB = undefined;
11627
11605
  const Factory_1 = requireFactory();
11628
11606
  const Node_1 = requireNode();
11629
11607
  const Validators_1 = requireValidators();
@@ -11674,7 +11652,7 @@
11674
11652
  if (hasRequiredRGBA) return RGBA;
11675
11653
  hasRequiredRGBA = 1;
11676
11654
  Object.defineProperty(RGBA, "__esModule", { value: true });
11677
- RGBA.RGBA = void 0;
11655
+ RGBA.RGBA = undefined;
11678
11656
  const Factory_1 = requireFactory();
11679
11657
  const Node_1 = requireNode();
11680
11658
  const Validators_1 = requireValidators();
@@ -11736,7 +11714,7 @@
11736
11714
  if (hasRequiredSepia) return Sepia;
11737
11715
  hasRequiredSepia = 1;
11738
11716
  Object.defineProperty(Sepia, "__esModule", { value: true });
11739
- Sepia.Sepia = void 0;
11717
+ Sepia.Sepia = undefined;
11740
11718
  const Sepia$1 = function (imageData) {
11741
11719
  const data = imageData.data, nPixels = data.length;
11742
11720
  for (let i = 0; i < nPixels; i += 4) {
@@ -11760,7 +11738,7 @@
11760
11738
  if (hasRequiredSolarize) return Solarize;
11761
11739
  hasRequiredSolarize = 1;
11762
11740
  Object.defineProperty(Solarize, "__esModule", { value: true });
11763
- Solarize.Solarize = void 0;
11741
+ Solarize.Solarize = undefined;
11764
11742
  const Solarize$1 = function (imageData) {
11765
11743
  const data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
11766
11744
  let y = h;
@@ -11799,7 +11777,7 @@
11799
11777
  if (hasRequiredThreshold) return Threshold;
11800
11778
  hasRequiredThreshold = 1;
11801
11779
  Object.defineProperty(Threshold, "__esModule", { value: true });
11802
- Threshold.Threshold = void 0;
11780
+ Threshold.Threshold = undefined;
11803
11781
  const Factory_1 = requireFactory();
11804
11782
  const Node_1 = requireNode();
11805
11783
  const Validators_1 = requireValidators();
@@ -11820,7 +11798,7 @@
11820
11798
  if (hasRequired_FullInternals) return _FullInternals;
11821
11799
  hasRequired_FullInternals = 1;
11822
11800
  Object.defineProperty(_FullInternals, "__esModule", { value: true });
11823
- _FullInternals.Konva = void 0;
11801
+ _FullInternals.Konva = undefined;
11824
11802
  const _CoreInternals_1 = require_CoreInternals();
11825
11803
  const Arc_1 = requireArc();
11826
11804
  const Arrow_1 = requireArrow();
@@ -12023,16 +12001,50 @@
12023
12001
  }
12024
12002
  }
12025
12003
 
12004
+ ///////////////////////////////////////////////////////////////////////////////
12005
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12006
+ // All rights reserved.
12007
+ //
12008
+ // This software and its documentation and related materials are owned by
12009
+ // the Alliance. The software may only be incorporated into application
12010
+ // programs owned by members of the Alliance, subject to a signed
12011
+ // Membership Agreement and Supplemental Software License Agreement with the
12012
+ // Alliance. The structure and organization of this software are the valuable
12013
+ // trade secrets of the Alliance and its suppliers. The software is also
12014
+ // protected by copyright law and international treaty provisions. Application
12015
+ // programs incorporating this software must include the following statement
12016
+ // with their copyright notices:
12017
+ //
12018
+ // This application incorporates Open Design Alliance software pursuant to a
12019
+ // license agreement with Open Design Alliance.
12020
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12021
+ // All rights reserved.
12022
+ //
12023
+ // By use of this software, its documentation or related materials, you
12024
+ // acknowledge and accept the above terms.
12025
+ ///////////////////////////////////////////////////////////////////////////////
12026
12026
  const LineTypeSpecs = new Map([
12027
12027
  ["solid", []],
12028
12028
  ["dot", [30, 30, 0.001, 30]],
12029
12029
  ["dash", [30, 30]],
12030
12030
  ]);
12031
12031
  class KonvaLine {
12032
- constructor(params, ref = null) {
12032
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12033
12033
  var _a, _b;
12034
+ this._worldTransformer = worldTransformer;
12034
12035
  if (ref) {
12035
12036
  this._ref = ref;
12037
+ let wcsPoints = this._ref.getAttr("wcsPoints");
12038
+ if (!wcsPoints) {
12039
+ wcsPoints = [];
12040
+ let points = this._ref.points();
12041
+ let wcsPoint;
12042
+ for (let i = 0; i < points.length; i += 2) {
12043
+ wcsPoint = this._worldTransformer.screenToWorld({ x: points[i], y: points[i + 1] });
12044
+ wcsPoints.push({ x: wcsPoint.x, y: wcsPoint.y, z: wcsPoint.z });
12045
+ }
12046
+ this._ref.setAttr("wcsPoints", wcsPoints);
12047
+ }
12036
12048
  return;
12037
12049
  }
12038
12050
  if (!params)
@@ -12043,10 +12055,15 @@
12043
12055
  { x: 100, y: 100 },
12044
12056
  ];
12045
12057
  const konvaPoints = [];
12046
- params.points.forEach((point) => konvaPoints.push(point.x, point.y));
12058
+ const wcsPoints = [];
12059
+ params.points.forEach((point) => {
12060
+ konvaPoints.push(point.x, point.y);
12061
+ let wcsPoint = this._worldTransformer.screenToWorld({ x: point.x, y: point.y });
12062
+ wcsPoints.push({ x: wcsPoint.x, y: wcsPoint.y, z: wcsPoint.z });
12063
+ });
12047
12064
  this._ref = new Konva.Line({
12048
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12049
- strokeWidth: (_b = params.width) !== null && _b !== void 0 ? _b : 4,
12065
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12066
+ strokeWidth: (_b = params.width) !== null && _b !== undefined ? _b : 4,
12050
12067
  globalCompositeOperation: "source-over",
12051
12068
  lineCap: "round",
12052
12069
  lineJoin: "round",
@@ -12055,11 +12072,36 @@
12055
12072
  strokeScaleEnabled: false,
12056
12073
  dash: LineTypeSpecs.get(params.type) || [],
12057
12074
  });
12075
+ this._ref.setAttr("wcsPoints", wcsPoints);
12058
12076
  this._ref.on("transform", (e) => {
12059
12077
  const attrs = e.target.attrs;
12060
12078
  if (attrs.rotation !== this._ref.rotation())
12061
12079
  this._ref.rotation(attrs.rotation);
12062
12080
  });
12081
+ this._ref.on("transformend", (e) => {
12082
+ const absoluteTransform = this._ref.getAbsoluteTransform();
12083
+ let wcsPoints = [];
12084
+ let points = this._ref.points();
12085
+ let wcsPoint;
12086
+ for (let i = 0; i < points.length; i += 2) {
12087
+ const position = absoluteTransform.point({ x: points[i], y: points[i + 1] });
12088
+ wcsPoint = this._worldTransformer.screenToWorld({ x: position.x, y: position.y });
12089
+ wcsPoints.push({ x: wcsPoint.x, y: wcsPoint.y, z: wcsPoint.z });
12090
+ }
12091
+ this._ref.setAttr("wcsPoints", wcsPoints);
12092
+ });
12093
+ this._ref.on("dragend", (e) => {
12094
+ const absoluteTransform = this._ref.getAbsoluteTransform();
12095
+ let wcsPoints = [];
12096
+ let points = this._ref.points();
12097
+ let wcsPoint;
12098
+ for (let i = 0; i < points.length; i += 2) {
12099
+ const position = absoluteTransform.point({ x: points[i], y: points[i + 1] });
12100
+ wcsPoint = this._worldTransformer.screenToWorld({ x: position.x, y: position.y });
12101
+ wcsPoints.push({ x: wcsPoint.x, y: wcsPoint.y, z: wcsPoint.z });
12102
+ }
12103
+ this._ref.setAttr("wcsPoints", wcsPoints);
12104
+ });
12063
12105
  this._ref.id(this._ref._id.toString());
12064
12106
  }
12065
12107
  ref() {
@@ -12128,19 +12170,64 @@
12128
12170
  }
12129
12171
  addPoints(points) {
12130
12172
  let newPoints = this._ref.points();
12173
+ let wcsPoints = this._ref.getAttr("wcsPoints");
12131
12174
  points.forEach((point) => {
12132
12175
  newPoints = newPoints.concat([point.x, point.y]);
12176
+ let wcsPoint = this._worldTransformer.screenToWorld(point);
12177
+ wcsPoints.push(wcsPoint);
12133
12178
  });
12134
12179
  this._ref.points(newPoints);
12135
12180
  }
12181
+ updateScreenCoordinates() {
12182
+ let wcsPoints = this._ref.getAttr("wcsPoints");
12183
+ let points = [];
12184
+ let invert = this._ref.getAbsoluteTransform().copy();
12185
+ invert = invert.invert();
12186
+ wcsPoints.forEach((point) => {
12187
+ let screenPoint = this._worldTransformer.worldToScreen(point);
12188
+ screenPoint = invert.point({ x: screenPoint.x, y: screenPoint.y });
12189
+ points.push(screenPoint.x);
12190
+ points.push(screenPoint.y);
12191
+ });
12192
+ this._ref.points([]);
12193
+ this._ref.points(points);
12194
+ this._ref.clearCache();
12195
+ }
12136
12196
  }
12137
12197
 
12198
+ ///////////////////////////////////////////////////////////////////////////////
12199
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12200
+ // All rights reserved.
12201
+ //
12202
+ // This software and its documentation and related materials are owned by
12203
+ // the Alliance. The software may only be incorporated into application
12204
+ // programs owned by members of the Alliance, subject to a signed
12205
+ // Membership Agreement and Supplemental Software License Agreement with the
12206
+ // Alliance. The structure and organization of this software are the valuable
12207
+ // trade secrets of the Alliance and its suppliers. The software is also
12208
+ // protected by copyright law and international treaty provisions. Application
12209
+ // programs incorporating this software must include the following statement
12210
+ // with their copyright notices:
12211
+ //
12212
+ // This application incorporates Open Design Alliance software pursuant to a
12213
+ // license agreement with Open Design Alliance.
12214
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12215
+ // All rights reserved.
12216
+ //
12217
+ // By use of this software, its documentation or related materials, you
12218
+ // acknowledge and accept the above terms.
12219
+ ///////////////////////////////////////////////////////////////////////////////
12138
12220
  class KonvaText {
12139
- constructor(params, ref = null) {
12221
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12140
12222
  var _a, _b, _c;
12141
12223
  this.TEXT_FONT_FAMILY = "Calibri";
12224
+ this._worldTransformer = worldTransformer;
12142
12225
  if (ref) {
12143
12226
  this._ref = ref;
12227
+ const wcsStart = this._ref.getAttr("wcsStart");
12228
+ if (!wcsStart) {
12229
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: ref.x(), y: ref.y() }));
12230
+ }
12144
12231
  return;
12145
12232
  }
12146
12233
  if (!params)
@@ -12153,14 +12240,15 @@
12153
12240
  x: params.position.x,
12154
12241
  y: params.position.y,
12155
12242
  text: params.text,
12156
- fontSize: (_a = params.fontSize) !== null && _a !== void 0 ? _a : 34,
12243
+ fontSize: (_a = params.fontSize) !== null && _a !== undefined ? _a : 34,
12157
12244
  fontFamily: this.TEXT_FONT_FAMILY,
12158
- fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
12245
+ fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
12159
12246
  align: "left",
12160
12247
  draggable: true,
12161
- rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0,
12248
+ rotation: (_c = params.rotation) !== null && _c !== undefined ? _c : 0,
12162
12249
  });
12163
12250
  this._ref.width(this._ref.getTextWidth());
12251
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
12164
12252
  this._ref.on("transform", (e) => {
12165
12253
  const attrs = e.target.attrs;
12166
12254
  if (attrs.rotation !== this._ref.rotation())
@@ -12186,6 +12274,19 @@
12186
12274
  }
12187
12275
  this._ref.scale({ x: 1, y: 1 });
12188
12276
  });
12277
+ this._ref.on("transformend", (e) => {
12278
+ const attrs = e.target.attrs;
12279
+ if (attrs.rotation !== this._ref.rotation())
12280
+ this._ref.rotation(attrs.rotation);
12281
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
12282
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
12283
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
12284
+ });
12285
+ this._ref.on("dragend", (e) => {
12286
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
12287
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
12288
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
12289
+ });
12189
12290
  this._ref.id(this._ref._id.toString());
12190
12291
  }
12191
12292
  ref() {
@@ -12233,6 +12334,7 @@
12233
12334
  }
12234
12335
  setPosition(x, y) {
12235
12336
  this._ref.setPosition({ x, y });
12337
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x, y }));
12236
12338
  }
12237
12339
  getFontSize() {
12238
12340
  return this._ref.fontSize();
@@ -12240,36 +12342,89 @@
12240
12342
  setFontSize(size) {
12241
12343
  this._ref.fontSize(size);
12242
12344
  }
12345
+ updateScreenCoordinates() {
12346
+ let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
12347
+ let invert = this._ref.getStage().getAbsoluteTransform().copy();
12348
+ invert = invert.invert();
12349
+ const positionStart = invert.point(screenPositionStart);
12350
+ this._ref.position({ x: positionStart.x, y: positionStart.y });
12351
+ }
12243
12352
  }
12244
12353
 
12354
+ ///////////////////////////////////////////////////////////////////////////////
12355
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12356
+ // All rights reserved.
12357
+ //
12358
+ // This software and its documentation and related materials are owned by
12359
+ // the Alliance. The software may only be incorporated into application
12360
+ // programs owned by members of the Alliance, subject to a signed
12361
+ // Membership Agreement and Supplemental Software License Agreement with the
12362
+ // Alliance. The structure and organization of this software are the valuable
12363
+ // trade secrets of the Alliance and its suppliers. The software is also
12364
+ // protected by copyright law and international treaty provisions. Application
12365
+ // programs incorporating this software must include the following statement
12366
+ // with their copyright notices:
12367
+ //
12368
+ // This application incorporates Open Design Alliance software pursuant to a
12369
+ // license agreement with Open Design Alliance.
12370
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12371
+ // All rights reserved.
12372
+ //
12373
+ // By use of this software, its documentation or related materials, you
12374
+ // acknowledge and accept the above terms.
12375
+ ///////////////////////////////////////////////////////////////////////////////
12245
12376
  class KonvaRectangle {
12246
- constructor(params, ref = null) {
12377
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12247
12378
  var _a, _b, _c, _d;
12379
+ this._worldTransformer = worldTransformer;
12248
12380
  if (ref) {
12249
12381
  this._ref = ref;
12382
+ const wcsStart = this._ref.getAttr("wcsStart");
12383
+ const wcsEnd = this._ref.getAttr("wcsEnd");
12384
+ if (!wcsStart) {
12385
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: ref.x(), y: ref.y() }));
12386
+ }
12387
+ if (!wcsEnd) {
12388
+ const rightBottomPoint = { x: ref.x() + ref.width(), y: ref.y() + ref.height() };
12389
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: rightBottomPoint.x, y: rightBottomPoint.y }));
12390
+ }
12250
12391
  return;
12251
12392
  }
12252
12393
  if (!params)
12253
12394
  params = {};
12254
12395
  if (!params.position)
12255
12396
  params.position = { x: 0, y: 0 };
12397
+ if (params.position2) {
12398
+ params.width = params.position.x - params.position2.x;
12399
+ params.height = params.position.y - params.position2.y;
12400
+ }
12401
+ else {
12402
+ if (!params.width || !params.height) {
12403
+ params.position2 = { x: 200, y: 200 };
12404
+ params.width = 200;
12405
+ params.height = 200;
12406
+ }
12407
+ else {
12408
+ params.position2 = { x: params.position.x + params.width, y: params.position.y + params.height };
12409
+ }
12410
+ }
12256
12411
  this._ref = new Konva.Rect({
12257
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12258
- strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
12412
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12413
+ strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
12259
12414
  globalCompositeOperation: "source-over",
12260
12415
  lineCap: "round",
12261
12416
  lineJoin: "round",
12262
12417
  x: params.position.x,
12263
12418
  y: params.position.y,
12264
- width: (_c = params.width) !== null && _c !== void 0 ? _c : 200,
12265
- height: (_d = params.height) !== null && _d !== void 0 ? _d : 200,
12419
+ width: (_c = params.width) !== null && _c !== undefined ? _c : 200,
12420
+ height: (_d = params.height) !== null && _d !== undefined ? _d : 200,
12266
12421
  draggable: true,
12267
12422
  strokeScaleEnabled: false,
12268
12423
  });
12424
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
12425
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: params.position2.x, y: params.position2.y }));
12269
12426
  this._ref.on("transform", (e) => {
12270
12427
  const attrs = e.target.attrs;
12271
- if (attrs.rotation !== this._ref.rotation())
12272
- this._ref.rotation(attrs.rotation);
12273
12428
  const scaleByX = Math.abs(attrs.scaleX - 1) > 10e-6;
12274
12429
  const scaleByY = Math.abs(attrs.scaleY - 1) > 10e-6;
12275
12430
  let newWidth = this._ref.width();
@@ -12292,6 +12447,21 @@
12292
12447
  }
12293
12448
  this._ref.scale({ x: 1, y: 1 });
12294
12449
  });
12450
+ this._ref.on("transformend", (e) => {
12451
+ const attrs = e.target.attrs;
12452
+ if (attrs.rotation !== this._ref.rotation())
12453
+ this._ref.rotation(attrs.rotation);
12454
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
12455
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
12456
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
12457
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: position.x + this._ref.width(), y: position.y + this._ref.height() }));
12458
+ });
12459
+ this._ref.on("dragend", (e) => {
12460
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
12461
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
12462
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
12463
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: position.x + this._ref.width(), y: position.y + this._ref.height() }));
12464
+ });
12295
12465
  this._ref.id(this._ref._id.toString());
12296
12466
  }
12297
12467
  getPosition() {
@@ -12305,12 +12475,19 @@
12305
12475
  }
12306
12476
  setWidth(w) {
12307
12477
  this._ref.width(w);
12478
+ const rightLowerPoint = { x: this._ref.x() + w, y: this._ref.y() + this._ref.height() };
12479
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
12480
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
12308
12481
  }
12309
12482
  setHeight(h) {
12310
12483
  this._ref.height(h);
12484
+ const rightLowerPoint = { x: this._ref.x() + this._ref.width(), y: this._ref.y() + h };
12485
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
12486
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
12311
12487
  }
12312
12488
  setPosition(x, y) {
12313
12489
  this._ref.setPosition({ x, y });
12490
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x, y }));
12314
12491
  }
12315
12492
  ref() {
12316
12493
  return this._ref;
@@ -12352,13 +12529,59 @@
12352
12529
  getLineWidth() {
12353
12530
  return this._ref.strokeWidth();
12354
12531
  }
12532
+ updateScreenCoordinates() {
12533
+ let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
12534
+ let screenPositionEnd = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
12535
+ let invert = this._ref.getStage().getAbsoluteTransform().copy();
12536
+ invert = invert.invert();
12537
+ const positionStart = invert.point(screenPositionStart);
12538
+ const positionEnd = invert.point(screenPositionEnd);
12539
+ this._ref.position({ x: positionStart.x, y: positionStart.y });
12540
+ this._ref.width(Math.abs(positionEnd.x - positionStart.x));
12541
+ this._ref.height(Math.abs(positionEnd.y - positionStart.y));
12542
+ }
12355
12543
  }
12356
12544
 
12545
+ ///////////////////////////////////////////////////////////////////////////////
12546
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12547
+ // All rights reserved.
12548
+ //
12549
+ // This software and its documentation and related materials are owned by
12550
+ // the Alliance. The software may only be incorporated into application
12551
+ // programs owned by members of the Alliance, subject to a signed
12552
+ // Membership Agreement and Supplemental Software License Agreement with the
12553
+ // Alliance. The structure and organization of this software are the valuable
12554
+ // trade secrets of the Alliance and its suppliers. The software is also
12555
+ // protected by copyright law and international treaty provisions. Application
12556
+ // programs incorporating this software must include the following statement
12557
+ // with their copyright notices:
12558
+ //
12559
+ // This application incorporates Open Design Alliance software pursuant to a
12560
+ // license agreement with Open Design Alliance.
12561
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12562
+ // All rights reserved.
12563
+ //
12564
+ // By use of this software, its documentation or related materials, you
12565
+ // acknowledge and accept the above terms.
12566
+ ///////////////////////////////////////////////////////////////////////////////
12357
12567
  class KonvaEllipse {
12358
- constructor(params, ref = null) {
12568
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12359
12569
  var _a, _b;
12570
+ this._worldTransformer = worldTransformer;
12360
12571
  if (ref) {
12361
12572
  this._ref = ref;
12573
+ const wcsPosition = this._ref.getAttr("wcsPosition");
12574
+ const radiusX = this._ref.getAttr("wcsRadiusX");
12575
+ const radiusY = this._ref.getAttr("wcsRadiusY");
12576
+ if (!wcsPosition) {
12577
+ this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld({ x: ref.x(), y: ref.y() }));
12578
+ }
12579
+ if (!radiusX) {
12580
+ this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld({ x: ref.x() + ref.radiusX(), y: ref.y() }));
12581
+ }
12582
+ if (!radiusY) {
12583
+ this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld({ x: ref.x(), y: ref.y() + ref.radiusY() }));
12584
+ }
12362
12585
  return;
12363
12586
  }
12364
12587
  if (!params)
@@ -12368,8 +12591,8 @@
12368
12591
  if (!params.radius)
12369
12592
  params.radius = { x: 25, y: 25 };
12370
12593
  this._ref = new Konva.Ellipse({
12371
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12372
- strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
12594
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12595
+ strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
12373
12596
  globalCompositeOperation: "source-over",
12374
12597
  lineCap: "round",
12375
12598
  lineJoin: "round",
@@ -12380,6 +12603,9 @@
12380
12603
  draggable: true,
12381
12604
  strokeScaleEnabled: false,
12382
12605
  });
12606
+ this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
12607
+ this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld({ x: this._ref.x() + params.radius.x, y: this._ref.y() }));
12608
+ this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld({ x: this._ref.x(), y: this._ref.y() + params.radius.y }));
12383
12609
  this._ref.on("transform", (e) => {
12384
12610
  const attrs = e.target.attrs;
12385
12611
  if (attrs.rotation !== this._ref.rotation())
@@ -12411,6 +12637,24 @@
12411
12637
  }
12412
12638
  this._ref.scale({ x: 1, y: 1 });
12413
12639
  });
12640
+ this._ref.on("transformend", (e) => {
12641
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
12642
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
12643
+ this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld(position));
12644
+ const radiusX = absoluteTransform.point({ x: this._ref.x() + this._ref.radiusX(), y: this._ref.y() });
12645
+ this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld(radiusX));
12646
+ const radiusY = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() + this._ref.radiusY() });
12647
+ this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld(radiusY));
12648
+ });
12649
+ this._ref.on("dragend", (e) => {
12650
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
12651
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
12652
+ this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld(position));
12653
+ const radiusX = absoluteTransform.point({ x: this._ref.x() + this._ref.radiusX(), y: this._ref.y() });
12654
+ this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld(radiusX));
12655
+ const radiusY = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() + this._ref.radiusY() });
12656
+ this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld(radiusY));
12657
+ });
12414
12658
  this._ref.id(this._ref._id.toString());
12415
12659
  }
12416
12660
  getPosition() {
@@ -12418,18 +12662,21 @@
12418
12662
  }
12419
12663
  setPosition(x, y) {
12420
12664
  this._ref.setPosition({ x, y });
12665
+ this._ref.setAttr("wcsPosition", this._worldTransformer.screenToWorld({ x, y }));
12421
12666
  }
12422
12667
  getRadiusX() {
12423
12668
  return this._ref.radiusX();
12424
12669
  }
12425
12670
  setRadiusX(r) {
12426
12671
  this._ref.radiusX(r);
12672
+ this._ref.setAttr("wcsRadiusX", this._worldTransformer.screenToWorld({ x: this._ref.x() + r, y: this._ref.y() }));
12427
12673
  }
12428
12674
  getRadiusY() {
12429
12675
  return this._ref.radiusY();
12430
12676
  }
12431
12677
  setRadiusY(r) {
12432
12678
  this._ref.radiusY(r);
12679
+ this._ref.setAttr("wcsRadiusY", this._worldTransformer.screenToWorld({ x: this._ref.x(), y: this._ref.y() + r }));
12433
12680
  }
12434
12681
  getLineWidth() {
12435
12682
  return this._ref.strokeWidth();
@@ -12471,6 +12718,19 @@
12471
12718
  this._ref.destroy();
12472
12719
  this._ref = null;
12473
12720
  }
12721
+ updateScreenCoordinates() {
12722
+ let screenPosition = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsPosition"));
12723
+ let radiusX = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusX"));
12724
+ let radiusY = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsRadiusY"));
12725
+ let invert = this._ref.getStage().getAbsoluteTransform().copy();
12726
+ invert = invert.invert();
12727
+ const position = invert.point({ x: screenPosition.x, y: screenPosition.y });
12728
+ this._ref.position({ x: position.x, y: position.y });
12729
+ this._ref.radius({
12730
+ x: Math.abs(invert.point(radiusX).x - position.x),
12731
+ y: Math.abs(invert.point(radiusY).y - position.y),
12732
+ });
12733
+ }
12474
12734
  }
12475
12735
 
12476
12736
  ///////////////////////////////////////////////////////////////////////////////
@@ -12496,10 +12756,17 @@
12496
12756
  // acknowledge and accept the above terms.
12497
12757
  ///////////////////////////////////////////////////////////////////////////////
12498
12758
  class KonvaArrow {
12499
- constructor(params, ref = null) {
12759
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12500
12760
  var _a, _b;
12761
+ this._worldTransformer = worldTransformer;
12501
12762
  if (ref) {
12502
12763
  this._ref = ref;
12764
+ const wcsStart = this._ref.getAttr("wcsStart");
12765
+ const wcsEnd = this._ref.getAttr("wcsEnd");
12766
+ if (!wcsStart)
12767
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: ref.points()[0], y: ref.points()[1] }));
12768
+ if (!wcsEnd)
12769
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: ref.points()[2], y: ref.points()[3] }));
12503
12770
  return;
12504
12771
  }
12505
12772
  if (!params)
@@ -12509,8 +12776,8 @@
12509
12776
  if (!params.end)
12510
12777
  params.end = { x: 100, y: 100 };
12511
12778
  this._ref = new Konva.Arrow({
12512
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12513
- fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
12779
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
12780
+ fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
12514
12781
  strokeWidth: 4,
12515
12782
  globalCompositeOperation: "source-over",
12516
12783
  lineCap: "round",
@@ -12519,10 +12786,26 @@
12519
12786
  draggable: true,
12520
12787
  strokeScaleEnabled: false,
12521
12788
  });
12522
- this._ref.on("transform", (e) => {
12789
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.start.x, y: params.start.y }));
12790
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: params.end.x, y: params.end.y }));
12791
+ this._ref.on("transformend", (e) => {
12523
12792
  const attrs = e.target.attrs;
12524
12793
  if (attrs.rotation !== this._ref.rotation())
12525
12794
  this._ref.rotation(attrs.rotation);
12795
+ const points = this._ref.points();
12796
+ const absoluteTransform = this._ref.getAbsoluteTransform();
12797
+ const transformStart = absoluteTransform.point({ x: points[0], y: points[1] });
12798
+ const transformEnd = absoluteTransform.point({ x: points[2], y: points[3] });
12799
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(transformStart));
12800
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld(transformEnd));
12801
+ });
12802
+ this._ref.on("dragend", (e) => {
12803
+ const points = this._ref.points();
12804
+ const absoluteTransform = e.target.getAbsoluteTransform();
12805
+ const transformStart = absoluteTransform.point({ x: points[0], y: points[1] });
12806
+ const transformEnd = absoluteTransform.point({ x: points[2], y: points[3] });
12807
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(transformStart));
12808
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld(transformEnd));
12526
12809
  });
12527
12810
  this._ref.id(this._ref._id.toString());
12528
12811
  }
@@ -12570,6 +12853,8 @@
12570
12853
  }
12571
12854
  setPoints(points) {
12572
12855
  if (points.length === 2) {
12856
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: points[0].x, y: points[0].y }));
12857
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: points[1].x, y: points[1].y }));
12573
12858
  this._ref.points([points[0].x, points[0].y, points[1].x, points[1].y]);
12574
12859
  }
12575
12860
  }
@@ -12580,6 +12865,7 @@
12580
12865
  setStartPoint(x, y) {
12581
12866
  const points = this._ref.points();
12582
12867
  this._ref.points([x, y, points[2], points[3]]);
12868
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x, y }));
12583
12869
  }
12584
12870
  getEndPoint() {
12585
12871
  const points = this._ref.points();
@@ -12588,16 +12874,49 @@
12588
12874
  setEndPoint(x, y) {
12589
12875
  const points = this._ref.points();
12590
12876
  this._ref.points([points[0], points[1], x, y]);
12877
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x, y }));
12878
+ }
12879
+ updateScreenCoordinates() {
12880
+ let screenStartPoint = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
12881
+ let screenEndPoint = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
12882
+ let invert = this._ref.getAbsoluteTransform().copy();
12883
+ invert = invert.invert();
12884
+ const startPoint = invert.point({ x: screenStartPoint.x, y: screenStartPoint.y });
12885
+ const endPoint = invert.point({ x: screenEndPoint.x, y: screenEndPoint.y });
12886
+ this._ref.points([startPoint.x, startPoint.y, endPoint.x, endPoint.y]);
12591
12887
  }
12592
12888
  }
12593
12889
 
12890
+ ///////////////////////////////////////////////////////////////////////////////
12891
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
12892
+ // All rights reserved.
12893
+ //
12894
+ // This software and its documentation and related materials are owned by
12895
+ // the Alliance. The software may only be incorporated into application
12896
+ // programs owned by members of the Alliance, subject to a signed
12897
+ // Membership Agreement and Supplemental Software License Agreement with the
12898
+ // Alliance. The structure and organization of this software are the valuable
12899
+ // trade secrets of the Alliance and its suppliers. The software is also
12900
+ // protected by copyright law and international treaty provisions. Application
12901
+ // programs incorporating this software must include the following statement
12902
+ // with their copyright notices:
12903
+ //
12904
+ // This application incorporates Open Design Alliance software pursuant to a
12905
+ // license agreement with Open Design Alliance.
12906
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
12907
+ // All rights reserved.
12908
+ //
12909
+ // By use of this software, its documentation or related materials, you
12910
+ // acknowledge and accept the above terms.
12911
+ ///////////////////////////////////////////////////////////////////////////////
12594
12912
  class KonvaImage {
12595
- constructor(params, ref = null) {
12913
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12596
12914
  var _a, _b;
12597
12915
  this._ratio = 1;
12598
12916
  this.EPSILON = 10e-6;
12599
12917
  this.BASE64_HEADER_START = "data:image/";
12600
12918
  this.BASE64_NOT_FOUND = "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=";
12919
+ this._worldTransformer = worldTransformer;
12601
12920
  if (ref) {
12602
12921
  if (!ref.src || !ref.src.startsWith(this.BASE64_HEADER_START))
12603
12922
  ref.src = this.BASE64_NOT_FOUND;
@@ -12611,6 +12930,10 @@
12611
12930
  this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON
12612
12931
  ? 1
12613
12932
  : this._ref.height() / this._ref.width();
12933
+ const wcsStart = this._ref.getAttr("wcsStart");
12934
+ if (!wcsStart) {
12935
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: ref.x(), y: ref.y() }));
12936
+ }
12614
12937
  return;
12615
12938
  }
12616
12939
  if (!params)
@@ -12656,10 +12979,11 @@
12656
12979
  x: params.position.x,
12657
12980
  y: params.position.y,
12658
12981
  image: this._canvasImage,
12659
- width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
12660
- height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
12982
+ width: (_a = params.width) !== null && _a !== undefined ? _a : 0,
12983
+ height: (_b = params.height) !== null && _b !== undefined ? _b : 0,
12661
12984
  draggable: true,
12662
12985
  });
12986
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
12663
12987
  this._ref.on("transform", (e) => {
12664
12988
  const attrs = e.target.attrs;
12665
12989
  if (attrs.rotation !== this._ref.rotation())
@@ -12692,6 +13016,16 @@
12692
13016
  }
12693
13017
  this._ref.scale({ x: 1, y: 1 });
12694
13018
  });
13019
+ this._ref.on("transformend", (e) => {
13020
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
13021
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
13022
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
13023
+ });
13024
+ this._ref.on("dragend", (e) => {
13025
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
13026
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
13027
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
13028
+ });
12695
13029
  this._ref.id(this._ref._id.toString());
12696
13030
  }
12697
13031
  getSrc() {
@@ -12747,28 +13081,82 @@
12747
13081
  }
12748
13082
  setPosition(x, y) {
12749
13083
  this._ref.setPosition({ x, y });
13084
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x, y }));
13085
+ }
13086
+ updateScreenCoordinates() {
13087
+ let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
13088
+ let invert = this._ref.getStage().getAbsoluteTransform().copy();
13089
+ invert = invert.invert();
13090
+ const positionStart = invert.point(screenPositionStart);
13091
+ this._ref.position({ x: positionStart.x, y: positionStart.y });
12750
13092
  }
12751
13093
  }
12752
13094
 
13095
+ ///////////////////////////////////////////////////////////////////////////////
13096
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
13097
+ // All rights reserved.
13098
+ //
13099
+ // This software and its documentation and related materials are owned by
13100
+ // the Alliance. The software may only be incorporated into application
13101
+ // programs owned by members of the Alliance, subject to a signed
13102
+ // Membership Agreement and Supplemental Software License Agreement with the
13103
+ // Alliance. The structure and organization of this software are the valuable
13104
+ // trade secrets of the Alliance and its suppliers. The software is also
13105
+ // protected by copyright law and international treaty provisions. Application
13106
+ // programs incorporating this software must include the following statement
13107
+ // with their copyright notices:
13108
+ //
13109
+ // This application incorporates Open Design Alliance software pursuant to a
13110
+ // license agreement with Open Design Alliance.
13111
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
13112
+ // All rights reserved.
13113
+ //
13114
+ // By use of this software, its documentation or related materials, you
13115
+ // acknowledge and accept the above terms.
13116
+ ///////////////////////////////////////////////////////////////////////////////
12753
13117
  class KonvaCloud {
12754
- constructor(params, ref = null) {
13118
+ constructor(params, ref = null, worldTransformer = new WorldTransform()) {
12755
13119
  var _a, _b, _c, _d;
13120
+ this._worldTransformer = worldTransformer;
12756
13121
  if (ref) {
12757
13122
  this._ref = ref;
13123
+ const wcsStart = this._ref.getAttr("wcsStart");
13124
+ const wcsEnd = this._ref.getAttr("wcsEnd");
13125
+ if (!wcsStart) {
13126
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: ref.x(), y: ref.y() }));
13127
+ }
13128
+ if (!wcsEnd) {
13129
+ const rightBottomPoint = { x: ref.x() + ref.width(), y: ref.y() + ref.height() };
13130
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: rightBottomPoint.x, y: rightBottomPoint.y }));
13131
+ }
12758
13132
  return;
12759
13133
  }
12760
13134
  if (!params)
12761
13135
  params = {};
12762
13136
  if (!params.position)
12763
13137
  params.position = { x: 0, y: 0 };
12764
- const arcRadius = 16;
13138
+ if (params.position2) {
13139
+ params.width = params.position.x - params.position2.x;
13140
+ params.height = params.position.y - params.position2.y;
13141
+ }
13142
+ else {
13143
+ if (!params.width || !params.height) {
13144
+ params.position2 = { x: 200, y: 200 };
13145
+ params.width = 200;
13146
+ params.height = 200;
13147
+ }
13148
+ else {
13149
+ params.position2 = { x: params.position.x + params.width, y: params.position.y + params.height };
13150
+ }
13151
+ }
13152
+ const ARC_RADIUS = 16;
12765
13153
  this._ref = new Konva.Shape({
12766
13154
  x: params.position.x,
12767
13155
  y: params.position.y,
12768
- width: (_a = params.width) !== null && _a !== void 0 ? _a : 200,
12769
- height: (_b = params.height) !== null && _b !== void 0 ? _b : 200,
12770
- stroke: (_c = params.color) !== null && _c !== void 0 ? _c : "#ff0000",
12771
- strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d : 4,
13156
+ width: (_a = params.width) !== null && _a !== undefined ? _a : 200,
13157
+ height: (_b = params.height) !== null && _b !== undefined ? _b : 200,
13158
+ stroke: (_c = params.color) !== null && _c !== undefined ? _c : "#ff0000",
13159
+ strokeWidth: (_d = params.lineWidth) !== null && _d !== undefined ? _d : 4,
12772
13160
  draggable: true,
12773
13161
  strokeScaleEnabled: false,
12774
13162
  globalCompositeOperation: "source-over",
@@ -12805,10 +13193,10 @@
12805
13193
  const counterClockwise = pX > midPoint.x && pY > midPoint.y;
12806
13194
  for (let iArc = 0; iArc < arcCount; iArc++) {
12807
13195
  if (counterClockwise) {
12808
- context.arc(pX, pY, arcRadius, endAngle, startAngle);
13196
+ context.arc(pX, pY, ARC_RADIUS, endAngle, startAngle);
12809
13197
  }
12810
13198
  else {
12811
- context.arc(pX, pY, arcRadius, startAngle, endAngle);
13199
+ context.arc(pX, pY, ARC_RADIUS, startAngle, endAngle);
12812
13200
  }
12813
13201
  pX += dx / arcCount;
12814
13202
  pY += dy / arcCount;
@@ -12821,10 +13209,10 @@
12821
13209
  },
12822
13210
  });
12823
13211
  this._ref.className = "Cloud";
13212
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x: params.position.x, y: params.position.y }));
13213
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: params.position2.x, y: params.position2.y }));
12824
13214
  this._ref.on("transform", (e) => {
12825
13215
  const attrs = e.target.attrs;
12826
- if (attrs.rotation !== this._ref.rotation())
12827
- this._ref.rotation(attrs.rotation);
12828
13216
  const scaleByX = Math.abs(attrs.scaleX - 1) > 10e-6;
12829
13217
  const scaleByY = Math.abs(attrs.scaleY - 1) > 10e-6;
12830
13218
  let newWidth = this._ref.width();
@@ -12847,12 +13235,27 @@
12847
13235
  }
12848
13236
  this._ref.scale({ x: 1, y: 1 });
12849
13237
  });
13238
+ this._ref.on("transformend", (e) => {
13239
+ const attrs = e.target.attrs;
13240
+ if (attrs.rotation !== this._ref.rotation())
13241
+ this._ref.rotation(attrs.rotation);
13242
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
13243
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
13244
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
13245
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: position.x + this._ref.width(), y: position.y + this._ref.height() }));
13246
+ });
13247
+ this._ref.on("dragend", (e) => {
13248
+ const absoluteTransform = this._ref.getStage().getAbsoluteTransform();
13249
+ const position = absoluteTransform.point({ x: this._ref.x(), y: this._ref.y() });
13250
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld(position));
13251
+ this._ref.setAttr("wcsEnd", this._worldTransformer.screenToWorld({ x: position.x + this._ref.width(), y: position.y + this._ref.height() }));
13252
+ });
12850
13253
  this._ref.getSelfRect = () => {
12851
13254
  return {
12852
- x: 0 - arcRadius,
12853
- y: 0 - arcRadius,
12854
- width: this._ref.width() + 2 * arcRadius,
12855
- height: this._ref.height() + 2 * arcRadius,
13255
+ x: 0 - ARC_RADIUS,
13256
+ y: 0 - ARC_RADIUS,
13257
+ width: this._ref.width() + 2 * ARC_RADIUS,
13258
+ height: this._ref.height() + 2 * ARC_RADIUS,
12856
13259
  };
12857
13260
  };
12858
13261
  this._ref.id(this._ref._id.toString());
@@ -12896,18 +13299,25 @@
12896
13299
  }
12897
13300
  setPosition(x, y) {
12898
13301
  this._ref.position({ x, y });
13302
+ this._ref.setAttr("wcsStart", this._worldTransformer.screenToWorld({ x, y }));
12899
13303
  }
12900
13304
  getWidth() {
12901
13305
  return this._ref.width();
12902
13306
  }
12903
13307
  setWidth(w) {
12904
13308
  this._ref.width(w);
13309
+ const rightLowerPoint = { x: this._ref.x() + w, y: this._ref.y() + this._ref.height() };
13310
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
13311
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
12905
13312
  }
12906
13313
  getHeigth() {
12907
13314
  return this._ref.height();
12908
13315
  }
12909
13316
  setHeight(h) {
12910
13317
  this._ref.height(h);
13318
+ const rightLowerPoint = { x: this._ref.x() + this._ref.width(), y: this._ref.y() + h };
13319
+ const wcsRightLowerPoint = this._worldTransformer.screenToWorld(rightLowerPoint);
13320
+ this._ref.setAttr("wcsEnd", wcsRightLowerPoint);
12911
13321
  }
12912
13322
  getLineWidth() {
12913
13323
  return this._ref.strokeWidth();
@@ -12915,6 +13325,17 @@
12915
13325
  setLineWidth(size) {
12916
13326
  this._ref.strokeWidth(size);
12917
13327
  }
13328
+ updateScreenCoordinates() {
13329
+ let screenPositionStart = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsStart"));
13330
+ let screenPositionEnd = this._worldTransformer.worldToScreen(this._ref.getAttr("wcsEnd"));
13331
+ let invert = this._ref.getStage().getAbsoluteTransform().copy();
13332
+ invert = invert.invert();
13333
+ const positionStart = invert.point(screenPositionStart);
13334
+ const positionEnd = invert.point(screenPositionEnd);
13335
+ this._ref.position({ x: positionStart.x, y: positionStart.y });
13336
+ this._ref.width(Math.abs(positionEnd.x - positionStart.x));
13337
+ this._ref.height(Math.abs(positionEnd.y - positionStart.y));
13338
+ }
12918
13339
  }
12919
13340
 
12920
13341
  ///////////////////////////////////////////////////////////////////////////////
@@ -12946,39 +13367,50 @@
12946
13367
  },
12947
13368
  Line: {
12948
13369
  name: "Line",
12949
- initializer: (ref, params = null) => new KonvaLine(params, ref),
13370
+ initializer: (ref, params = null, ...attr) => new KonvaLine(params, ref, ...attr),
12950
13371
  },
12951
13372
  Text: {
12952
13373
  name: "Text",
12953
- initializer: (ref, params = null) => new KonvaText(params, ref),
13374
+ initializer: (ref, params = null, ...attr) => new KonvaText(params, ref, ...attr),
12954
13375
  },
12955
13376
  Rectangle: {
12956
13377
  name: "Rect",
12957
- initializer: (ref, params = null) => new KonvaRectangle(params, ref),
13378
+ initializer: (ref, params = null, ...attr) => new KonvaRectangle(params, ref, ...attr),
12958
13379
  },
12959
13380
  Ellipse: {
12960
13381
  name: "Ellipse",
12961
- initializer: (ref, params = null) => new KonvaEllipse(params, ref),
13382
+ initializer: (ref, params = null, ...attr) => new KonvaEllipse(params, ref, ...attr),
12962
13383
  },
12963
13384
  Arrow: {
12964
13385
  name: "Arrow",
12965
- initializer: (ref, params = null) => new KonvaArrow(params, ref),
13386
+ initializer: (ref, params = null, ...attr) => new KonvaArrow(params, ref, ...attr),
12966
13387
  },
12967
13388
  Image: {
12968
13389
  name: "Image",
12969
- initializer: (ref, params = null) => new KonvaImage(params, ref),
13390
+ initializer: (ref, params = null, ...attr) => new KonvaImage(params, ref, ...attr),
12970
13391
  },
12971
13392
  Cloud: {
12972
13393
  name: "Cloud",
12973
- initializer: (ref, params = null) => new KonvaCloud(params, ref),
13394
+ initializer: (ref, params = null, ...attr) => new KonvaCloud(params, ref, ...attr),
12974
13395
  },
12975
13396
  };
13397
+ function debounce(func, wait) {
13398
+ let timeout = null;
13399
+ return (...args) => {
13400
+ if (timeout) {
13401
+ clearTimeout(timeout);
13402
+ }
13403
+ timeout = setTimeout(() => {
13404
+ timeout = null;
13405
+ func(...args);
13406
+ }, wait);
13407
+ };
13408
+ }
12976
13409
  /**
12977
13410
  * 2D markup core.
12978
13411
  */
12979
13412
  class KonvaMarkup {
12980
13413
  constructor() {
12981
- this._containerEvents = [];
12982
13414
  this._markupIsActive = false;
12983
13415
  this._markupColor = new MarkupColor(255, 0, 0);
12984
13416
  this.lineWidth = 4;
@@ -13004,22 +13436,31 @@
13004
13436
  return;
13005
13437
  this._konvaStage.width(width);
13006
13438
  this._konvaStage.height(height);
13439
+ this.getObjects().forEach((markupObject) => {
13440
+ markupObject.updateScreenCoordinates();
13441
+ });
13442
+ };
13443
+ this.resizeViewer = (event) => {
13444
+ const { width, height } = event;
13445
+ if (!width || !height)
13446
+ return; // <- invisible container, or container with parent removed
13447
+ if (!this._konvaStage)
13448
+ return;
13449
+ this._konvaStage.width(width);
13450
+ this._konvaStage.height(height);
13451
+ this.getObjects().forEach((markupObject) => {
13452
+ markupObject.updateScreenCoordinates();
13453
+ });
13007
13454
  };
13008
13455
  this.pan = (event) => {
13009
- const newPos = {
13010
- x: this._konvaStage.x() + event.dX,
13011
- y: this._konvaStage.y() + event.dY,
13012
- };
13013
- this._konvaStage.position(newPos);
13456
+ this.getObjects().forEach((markupObject) => {
13457
+ markupObject.updateScreenCoordinates();
13458
+ });
13014
13459
  };
13015
13460
  this.zoomAt = (event) => {
13016
- const newScale = this._konvaStage.scaleX() * event.data;
13017
- this._konvaStage.scale({ x: newScale, y: newScale });
13018
- const newPos = {
13019
- x: event.x - (event.x - this._konvaStage.x()) * event.data,
13020
- y: event.y - (event.y - this._konvaStage.y()) * event.data,
13021
- };
13022
- this._konvaStage.position(newPos);
13461
+ this.getObjects().forEach((markupObject) => {
13462
+ markupObject.updateScreenCoordinates();
13463
+ });
13023
13464
  };
13024
13465
  this.redirectToViewer = (event) => {
13025
13466
  if (this._viewer)
@@ -13042,9 +13483,8 @@
13042
13483
  if (!Konva)
13043
13484
  throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"></script> to your page?');
13044
13485
  this._viewer = viewer;
13045
- this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform();
13486
+ this._worldTransformer = worldTransformer !== null && worldTransformer !== undefined ? worldTransformer : new WorldTransform();
13046
13487
  this._container = container;
13047
- this._containerEvents = containerEvents !== null && containerEvents !== void 0 ? containerEvents : [];
13048
13488
  this._markupContainer = document.createElement("div");
13049
13489
  this._markupContainer.id = "markup-container";
13050
13490
  this._markupContainer.style.position = "absolute";
@@ -13054,12 +13494,13 @@
13054
13494
  this._markupContainer.style.pointerEvents = "none";
13055
13495
  const parentDiv = this._container.parentElement;
13056
13496
  parentDiv.appendChild(this._markupContainer);
13057
- this._resizeObserver = new ResizeObserver(this.resizeContainer);
13058
- this._resizeObserver.observe(parentDiv);
13497
+ if (viewer)
13498
+ this._viewer.addEventListener("resize", this.resizeViewer);
13499
+ else
13500
+ this._resizeObserver = new ResizeObserver(debounce(this.resizeContainer, 100));
13059
13501
  this._markupColor.setColor(255, 0, 0);
13060
13502
  this.initializeKonva();
13061
13503
  if (this._viewer) {
13062
- // this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
13063
13504
  this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
13064
13505
  this._viewer.addEventListener("pan", this.pan);
13065
13506
  this._viewer.addEventListener("zoomat", this.zoomAt);
@@ -13071,12 +13512,11 @@
13071
13512
  this._viewer.removeEventListener("zoomat", this.zoomAt);
13072
13513
  this._viewer.removeEventListener("pan", this.pan);
13073
13514
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
13074
- // this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
13075
13515
  }
13076
13516
  this.destroyKonva();
13077
- (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
13517
+ (_a = this._resizeObserver) === null || _a === undefined ? undefined : _a.disconnect();
13078
13518
  this._resizeObserver = undefined;
13079
- (_b = this._markupContainer) === null || _b === void 0 ? void 0 : _b.remove();
13519
+ (_b = this._markupContainer) === null || _b === undefined ? undefined : _b.remove();
13080
13520
  this._markupContainer = undefined;
13081
13521
  this._container = undefined;
13082
13522
  this._viewer = undefined;
@@ -13099,11 +13539,11 @@
13099
13539
  }
13100
13540
  colorizeAllMarkup(r, g, b) {
13101
13541
  const hexColor = new MarkupColor(r, g, b).asHex();
13102
- this.getObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
13542
+ this.getObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor); });
13103
13543
  }
13104
13544
  colorizeSelectedMarkups(r, g, b) {
13105
13545
  const hexColor = new MarkupColor(r, g, b).asHex();
13106
- this.getSelectedObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
13546
+ this.getSelectedObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor); });
13107
13547
  }
13108
13548
  setViewpoint(viewpoint) {
13109
13549
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -13112,9 +13552,9 @@
13112
13552
  this.removeImageInput();
13113
13553
  this._konvaStage.scale({ x: 1, y: 1 });
13114
13554
  this._konvaStage.position({ x: 0, y: 0 });
13115
- const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || { r: 255, g: 0, b: 0 };
13555
+ const markupColor = ((_a = viewpoint.custom_fields) === null || _a === undefined ? undefined : _a.markup_color) || { r: 255, g: 0, b: 0 };
13116
13556
  this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
13117
- (_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
13557
+ (_b = viewpoint.lines) === null || _b === undefined ? undefined : _b.forEach((line) => {
13118
13558
  const linePoints = [];
13119
13559
  line.points.forEach((point) => {
13120
13560
  const screenPoint = this._worldTransformer.worldToScreen(point);
@@ -13123,28 +13563,28 @@
13123
13563
  });
13124
13564
  this.addLine(linePoints, line.color, line.type, line.width, line.id);
13125
13565
  });
13126
- (_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text) => {
13566
+ (_c = viewpoint.texts) === null || _c === undefined ? undefined : _c.forEach((text) => {
13127
13567
  const screenPoint = this._worldTransformer.worldToScreen(text.position);
13128
13568
  this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
13129
13569
  });
13130
- (_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect) => {
13570
+ (_d = viewpoint.rectangles) === null || _d === undefined ? undefined : _d.forEach((rect) => {
13131
13571
  const screenPoint = this._worldTransformer.worldToScreen(rect.position);
13132
- this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
13572
+ this.addRectangle(screenPoint, null, rect.width, rect.height, rect.line_width, rect.color, rect.id);
13133
13573
  });
13134
- (_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse) => {
13574
+ (_e = viewpoint.ellipses) === null || _e === undefined ? undefined : _e.forEach((ellipse) => {
13135
13575
  const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
13136
13576
  this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
13137
13577
  });
13138
- (_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow) => {
13578
+ (_f = viewpoint.arrows) === null || _f === undefined ? undefined : _f.forEach((arrow) => {
13139
13579
  const startPoint = this._worldTransformer.worldToScreen(arrow.start);
13140
13580
  const endPoint = this._worldTransformer.worldToScreen(arrow.end);
13141
13581
  this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
13142
13582
  });
13143
- (_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud) => {
13583
+ (_g = viewpoint.clouds) === null || _g === undefined ? undefined : _g.forEach((cloud) => {
13144
13584
  const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
13145
- this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
13585
+ this.addCloud(screenPoint, null, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
13146
13586
  });
13147
- (_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image) => {
13587
+ (_h = viewpoint.images) === null || _h === undefined ? undefined : _h.forEach((image) => {
13148
13588
  const screenPoint = this._worldTransformer.worldToScreen(image.position);
13149
13589
  this.addImage(screenPoint, image.src, image.width, image.height, image.id);
13150
13590
  });
@@ -13182,7 +13622,7 @@
13182
13622
  const konvaShape = MarkupMode2Konva[type];
13183
13623
  if (!konvaShape || !konvaShape.initializer)
13184
13624
  throw new Error(`Markup CreateObject - unsupported markup type ${type}`);
13185
- const object = konvaShape.initializer(null, params);
13625
+ const object = konvaShape.initializer(null, params, this._worldTransformer);
13186
13626
  this.addObject(object);
13187
13627
  return object;
13188
13628
  }
@@ -13190,7 +13630,7 @@
13190
13630
  const objects = [];
13191
13631
  Object.keys(MarkupMode2Konva).forEach((type) => {
13192
13632
  const konvaShape = MarkupMode2Konva[type];
13193
- this.konvaLayerFind(type).forEach((ref) => objects.push(konvaShape.initializer(ref)));
13633
+ this.konvaLayerFind(type).forEach((ref) => objects.push(konvaShape.initializer(ref, null, this._worldTransformer)));
13194
13634
  });
13195
13635
  return objects;
13196
13636
  }
@@ -13202,7 +13642,7 @@
13202
13642
  .map((ref) => {
13203
13643
  const name = ref.className;
13204
13644
  const konvaShape = Object.values(MarkupMode2Konva).find((shape) => shape.name === name);
13205
- return konvaShape ? konvaShape.initializer(ref) : null;
13645
+ return konvaShape ? konvaShape.initializer(ref, null, this._worldTransformer) : null;
13206
13646
  })
13207
13647
  .filter((x) => x);
13208
13648
  }
@@ -13294,7 +13734,7 @@
13294
13734
  const dY = defParams ? 200 : Math.abs(mouseDownPos.y - pos.y);
13295
13735
  if (defParams) {
13296
13736
  if (this._markupMode === "Rectangle") {
13297
- this.addRectangle({ x: startX, y: startY }, dX, dY);
13737
+ this.addRectangle({ x: startX, y: startY }, null, dX, dY);
13298
13738
  }
13299
13739
  else if (this._markupMode === "Ellipse") {
13300
13740
  this.addEllipse({ x: startX, y: startY }, { x: dX / 2, y: dY / 2 });
@@ -13303,7 +13743,7 @@
13303
13743
  this.addArrow({ x: mouseDownPos.x, y: mouseDownPos.y }, { x: defParams ? mouseDownPos.x + 200 : pos.x, y: defParams ? startY : pos.y });
13304
13744
  }
13305
13745
  else if (this._markupMode === "Cloud") {
13306
- this.addCloud({ x: startX, y: startY }, Math.max(100, dX), Math.max(100, dY));
13746
+ this.addCloud({ x: startX, y: startY }, null, Math.max(100, dX), Math.max(100, dY));
13307
13747
  }
13308
13748
  }
13309
13749
  }
@@ -13340,7 +13780,7 @@
13340
13780
  lastObj.setHeight(dY);
13341
13781
  }
13342
13782
  else
13343
- lastObj = this.addRectangle({ x: startX, y: startY }, dX, dY);
13783
+ lastObj = this.addRectangle({ x: startX, y: startY }, null, dX, dY);
13344
13784
  }
13345
13785
  else if (this._markupMode === "Ellipse") {
13346
13786
  if (lastObj) {
@@ -13358,7 +13798,7 @@
13358
13798
  lastObj.setHeight(Math.max(100, dY));
13359
13799
  }
13360
13800
  else
13361
- lastObj = this.addCloud({ x: startX, y: startY }, dX, dY);
13801
+ lastObj = this.addCloud({ x: startX, y: startY }, null, dX, dY);
13362
13802
  }
13363
13803
  });
13364
13804
  // clicks should select/deselect shapes
@@ -13461,7 +13901,7 @@
13461
13901
  this.removeTextInput();
13462
13902
  this.removeImageInput();
13463
13903
  this.clearOverlay();
13464
- (_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
13904
+ (_a = this._konvaStage) === null || _a === undefined ? undefined : _a.destroy();
13465
13905
  this._groupImages = undefined;
13466
13906
  this._groupGeometry = undefined;
13467
13907
  this._groupTexts = undefined;
@@ -13472,25 +13912,13 @@
13472
13912
  getMarkupLines() {
13473
13913
  const lines = [];
13474
13914
  this.konvaLayerFind("Line").forEach((ref) => {
13475
- const linePoints = ref.points();
13476
- if (!linePoints)
13915
+ const wcsPoints = ref.getAttr("wcsPoints");
13916
+ if (!wcsPoints)
13477
13917
  return;
13478
- const worldPoints = [];
13479
- const absoluteTransform = ref.getAbsoluteTransform();
13480
- for (let i = 0; i < linePoints.length; i += 2) {
13481
- // we need getAbsoluteTransform because inside Konva position starts from {0, 0}
13482
- // https://stackoverflow.com/a/57641487 - check answer's comments
13483
- const atPoint = absoluteTransform.point({
13484
- x: linePoints[i],
13485
- y: linePoints[i + 1],
13486
- });
13487
- const worldPoint = this._worldTransformer.screenToWorld(atPoint);
13488
- worldPoints.push(worldPoint);
13489
- }
13490
- const konvaLine = new KonvaLine(null, ref);
13918
+ const konvaLine = new KonvaLine(null, ref, this._worldTransformer);
13491
13919
  const line = {
13492
13920
  id: konvaLine.id(),
13493
- points: worldPoints,
13921
+ points: wcsPoints,
13494
13922
  color: konvaLine.getColor() || "#ff0000",
13495
13923
  type: konvaLine.getLineType() || this.lineType,
13496
13924
  width: konvaLine.getLineWidth() || this.lineWidth,
@@ -13504,14 +13932,12 @@
13504
13932
  this.konvaLayerFind("Text").forEach((ref) => {
13505
13933
  const textSize = 0.02;
13506
13934
  const textScale = this._worldTransformer.getScale();
13507
- const position = ref.position();
13935
+ const wcsPosition = ref.getAttr("wcsStart");
13508
13936
  const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
13509
- const atPoint = stageAbsoluteTransform.point({ x: position.x, y: position.y });
13510
- const worldPoint = this._worldTransformer.screenToWorld(atPoint);
13511
- const shape = new KonvaText(null, ref);
13937
+ const shape = new KonvaText(null, ref, this._worldTransformer);
13512
13938
  const text = {
13513
13939
  id: shape.id(),
13514
- position: worldPoint,
13940
+ position: wcsPosition,
13515
13941
  text: shape.getText(),
13516
13942
  text_size: textSize * textScale.y,
13517
13943
  angle: shape.getRotation(),
@@ -13525,17 +13951,16 @@
13525
13951
  getMarkupRectangles() {
13526
13952
  const rectangles = [];
13527
13953
  this.konvaLayerFind("Rectangle").forEach((ref) => {
13528
- const position = ref.position();
13529
- const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
13530
- const atPoint = stageAbsoluteTransform.point({ x: position.x, y: position.y });
13531
- const worldPoint = this._worldTransformer.screenToWorld(atPoint);
13532
- const scale = stageAbsoluteTransform.getMatrix()[0];
13533
- const shape = new KonvaRectangle(null, ref);
13954
+ const wcsStart = ref.getAttr("wcsStart");
13955
+ const wcsEnd = ref.getAttr("wcsEnd");
13956
+ const screenStart = this._worldTransformer.worldToScreen(wcsStart);
13957
+ const screenEnd = this._worldTransformer.worldToScreen(wcsEnd);
13958
+ const shape = new KonvaRectangle(null, ref, this._worldTransformer);
13534
13959
  const rectangle = {
13535
13960
  id: shape.id(),
13536
- position: worldPoint,
13537
- width: shape.getWidth() * scale,
13538
- height: shape.getHeigth() * scale,
13961
+ position: wcsStart,
13962
+ width: Math.abs(screenStart.x - screenEnd.x),
13963
+ height: Math.abs(screenStart.y - screenEnd.y),
13539
13964
  line_width: shape.getLineWidth(),
13540
13965
  color: shape.getColor(),
13541
13966
  };
@@ -13546,15 +13971,13 @@
13546
13971
  getMarkupEllipses() {
13547
13972
  const ellipses = [];
13548
13973
  this.konvaLayerFind("Ellipse").forEach((ref) => {
13549
- const position = ref.position();
13974
+ const wcsPosition = ref.getAttr("wcsPosition");
13550
13975
  const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
13551
- const atPoint = stageAbsoluteTransform.point({ x: position.x, y: position.y });
13552
- const worldPoint = this._worldTransformer.screenToWorld(atPoint);
13553
13976
  const scale = stageAbsoluteTransform.getMatrix()[0];
13554
- const shape = new KonvaEllipse(null, ref);
13977
+ const shape = new KonvaEllipse(null, ref, this._worldTransformer);
13555
13978
  const ellipse = {
13556
13979
  id: shape.id(),
13557
- position: worldPoint,
13980
+ position: wcsPosition,
13558
13981
  radius: {
13559
13982
  x: ref.getRadiusX() * scale,
13560
13983
  y: ref.getRadiusY() * scale,
@@ -13570,22 +13993,13 @@
13570
13993
  const arrows = [];
13571
13994
  this.konvaLayerFind("Arrow").forEach((ref) => {
13572
13995
  // we need getAbsoluteTransform because inside Konva position starts from {0, 0}
13573
- const absoluteTransform = ref.getAbsoluteTransform();
13574
- const atStartPoint = absoluteTransform.point({
13575
- x: ref.points()[0],
13576
- y: ref.points()[1],
13577
- });
13578
- const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
13579
- const atEndPoint = absoluteTransform.point({
13580
- x: ref.points()[2],
13581
- y: ref.points()[3],
13582
- });
13583
- const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
13584
- const shape = new KonvaArrow(null, ref);
13996
+ const wcsStart = ref.getAttr("wcsStart");
13997
+ const wcsEnd = ref.getAttr("wcsEnd");
13998
+ const shape = new KonvaArrow(null, ref, this._worldTransformer);
13585
13999
  const arrow = {
13586
14000
  id: shape.id(),
13587
- start: worldStartPoint,
13588
- end: worldEndPoint,
14001
+ start: wcsStart,
14002
+ end: wcsEnd,
13589
14003
  color: shape.getColor(),
13590
14004
  };
13591
14005
  arrows.push(arrow);
@@ -13595,15 +14009,13 @@
13595
14009
  getMarkupImages() {
13596
14010
  const images = [];
13597
14011
  this.konvaLayerFind("Image").forEach((ref) => {
13598
- const position = ref.position();
14012
+ const wcsStart = ref.getAttr("wcsStart");
13599
14013
  const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
13600
- const atPoint = stageAbsoluteTransform.point({ x: position.x, y: position.y });
13601
- const worldPoint = this._worldTransformer.screenToWorld(atPoint);
13602
14014
  const scale = stageAbsoluteTransform.getMatrix()[0];
13603
- const shape = new KonvaImage(null, ref);
14015
+ const shape = new KonvaImage(null, ref, this._worldTransformer);
13604
14016
  const image = {
13605
14017
  id: shape.id(),
13606
- position: worldPoint,
14018
+ position: wcsStart,
13607
14019
  src: shape.getSrc(),
13608
14020
  width: shape.getWidth() * scale,
13609
14021
  height: shape.getHeight() * scale,
@@ -13615,17 +14027,16 @@
13615
14027
  getMarkupClouds() {
13616
14028
  const clouds = [];
13617
14029
  this.konvaLayerFind("Cloud").forEach((ref) => {
13618
- const position = ref.position();
13619
- const stageAbsoluteTransform = this._konvaStage.getAbsoluteTransform();
13620
- const atPoint = stageAbsoluteTransform.point({ x: position.x, y: position.y });
13621
- const worldPoint = this._worldTransformer.screenToWorld(atPoint);
13622
- const scale = stageAbsoluteTransform.getMatrix()[0];
13623
- const shape = new KonvaCloud(null, ref);
14030
+ const wcsStart = ref.getAttr("wcsStart");
14031
+ const wcsEnd = ref.getAttr("wcsEnd");
14032
+ const screenStart = this._worldTransformer.worldToScreen(wcsStart);
14033
+ const screenEnd = this._worldTransformer.worldToScreen(wcsEnd);
14034
+ const shape = new KonvaCloud(null, ref, this._worldTransformer);
13624
14035
  const cloud = {
13625
14036
  id: shape.id(),
13626
- position: worldPoint,
13627
- width: shape.getWidth() * scale,
13628
- height: shape.getHeigth() * scale,
14037
+ position: wcsStart,
14038
+ width: Math.abs(screenStart.x - screenEnd.x),
14039
+ height: Math.abs(screenStart.y - screenEnd.y),
13629
14040
  line_width: shape.getLineWidth(),
13630
14041
  color: shape.getColor(),
13631
14042
  };
@@ -13659,7 +14070,7 @@
13659
14070
  width: width || this.lineWidth,
13660
14071
  color: color || this._markupColor.asHex(),
13661
14072
  id,
13662
- });
14073
+ }, null, this._worldTransformer);
13663
14074
  this.addObject(konvaLine);
13664
14075
  return konvaLine;
13665
14076
  }
@@ -13699,7 +14110,7 @@
13699
14110
  }
13700
14111
  removeTextInput() {
13701
14112
  var _a;
13702
- (_a = this._textInputRef) === null || _a === void 0 ? void 0 : _a.remove();
14113
+ (_a = this._textInputRef) === null || _a === undefined ? undefined : _a.remove();
13703
14114
  this._textInputRef = null;
13704
14115
  this._textInputPos = null;
13705
14116
  this._textInputAngle = 0;
@@ -13742,7 +14153,7 @@
13742
14153
  }
13743
14154
  removeImageInput() {
13744
14155
  var _a;
13745
- (_a = this._imageInputRef) === null || _a === void 0 ? void 0 : _a.remove();
14156
+ (_a = this._imageInputRef) === null || _a === undefined ? undefined : _a.remove();
13746
14157
  this._imageInputRef = null;
13747
14158
  this._imageInputPos = null;
13748
14159
  }
@@ -13751,7 +14162,7 @@
13751
14162
  if (!text)
13752
14163
  return;
13753
14164
  // in case of edit - remove old Konva.Text object
13754
- (_a = this.getSelectedObjects().at(0)) === null || _a === void 0 ? void 0 : _a.delete();
14165
+ (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
13755
14166
  this.clearSelected();
13756
14167
  this.removeTextInput();
13757
14168
  // in case we have old viewpoint without font_size
@@ -13768,21 +14179,22 @@
13768
14179
  fontSize: fontSize || this.fontSize,
13769
14180
  color: color || this._markupColor.asHex(),
13770
14181
  id,
13771
- });
14182
+ }, null, this._worldTransformer);
13772
14183
  this.addObject(konvaText);
13773
14184
  return konvaText;
13774
14185
  }
13775
- addRectangle(position, width, height, lineWidth, color, id) {
14186
+ addRectangle(position, position2, width, height, lineWidth, color, id) {
13776
14187
  if (!position)
13777
14188
  return;
13778
14189
  const konvaRectangle = new KonvaRectangle({
13779
14190
  position,
14191
+ position2,
13780
14192
  width,
13781
14193
  height,
13782
14194
  lineWidth: lineWidth || this.lineWidth,
13783
14195
  color: color || this._markupColor.asHex(),
13784
14196
  id,
13785
- });
14197
+ }, null, this._worldTransformer);
13786
14198
  this.addObject(konvaRectangle);
13787
14199
  return konvaRectangle;
13788
14200
  }
@@ -13795,7 +14207,7 @@
13795
14207
  lineWidth,
13796
14208
  color: color || this._markupColor.asHex(),
13797
14209
  id,
13798
- });
14210
+ }, null, this._worldTransformer);
13799
14211
  this.addObject(konvaEllipse);
13800
14212
  return konvaEllipse;
13801
14213
  }
@@ -13807,21 +14219,22 @@
13807
14219
  end,
13808
14220
  color: color || this._markupColor.asHex(),
13809
14221
  id,
13810
- });
14222
+ }, null, this._worldTransformer);
13811
14223
  this.addObject(konvaArrow);
13812
14224
  return konvaArrow;
13813
14225
  }
13814
- addCloud(position, width, height, lineWidth, color, id) {
14226
+ addCloud(position, position2, width, height, lineWidth, color, id) {
13815
14227
  if (!position || !width || !height)
13816
14228
  return;
13817
14229
  const konvaCloud = new KonvaCloud({
13818
14230
  position,
14231
+ position2,
13819
14232
  width,
13820
14233
  height,
13821
14234
  color: color || this._markupColor.asHex(),
13822
14235
  lineWidth: lineWidth || this.lineWidth,
13823
14236
  id,
13824
- });
14237
+ }, null, this._worldTransformer);
13825
14238
  this.addObject(konvaCloud);
13826
14239
  return konvaCloud;
13827
14240
  }
@@ -13830,7 +14243,7 @@
13830
14243
  if (!position || !src)
13831
14244
  return;
13832
14245
  // in case of edit - remove old Image placeholder object
13833
- (_a = this.getSelectedObjects().at(0)) === null || _a === void 0 ? void 0 : _a.delete();
14246
+ (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
13834
14247
  this.clearSelected();
13835
14248
  this.removeImageInput();
13836
14249
  const konvaImage = new KonvaImage({
@@ -13841,7 +14254,7 @@
13841
14254
  maxWidth: this._konvaStage.width() - position.x,
13842
14255
  maxHeight: this._konvaStage.height() - position.y,
13843
14256
  id,
13844
- });
14257
+ }, null, this._worldTransformer);
13845
14258
  this.addObject(konvaImage);
13846
14259
  return konvaImage;
13847
14260
  }