@inweb/markup 26.3.3 → 26.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,8 +72,8 @@ class KonvaLine {
72
72
  const konvaPoints = [];
73
73
  params.points.forEach((point => konvaPoints.push(point.x, point.y)));
74
74
  this._ref = new Konva.Line({
75
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
76
- strokeWidth: (_b = params.width) !== null && _b !== void 0 ? _b : 4,
75
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
76
+ strokeWidth: (_b = params.width) !== null && _b !== undefined ? _b : 4,
77
77
  globalCompositeOperation: "source-over",
78
78
  lineCap: "round",
79
79
  lineJoin: "round",
@@ -180,12 +180,12 @@ class KonvaText {
180
180
  x: params.position.x,
181
181
  y: params.position.y,
182
182
  text: params.text,
183
- fontSize: (_a = params.fontSize) !== null && _a !== void 0 ? _a : 34,
183
+ fontSize: (_a = params.fontSize) !== null && _a !== undefined ? _a : 34,
184
184
  fontFamily: this.TEXT_FONT_FAMILY,
185
- fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
185
+ fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
186
186
  align: "left",
187
187
  draggable: true,
188
- rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0
188
+ rotation: (_c = params.rotation) !== null && _c !== undefined ? _c : 0
189
189
  });
190
190
  this._ref.width(this._ref.getTextWidth());
191
191
  this._ref.on("transform", (e => {
@@ -283,15 +283,15 @@ class KonvaRectangle {
283
283
  y: 0
284
284
  };
285
285
  this._ref = new Konva.Rect({
286
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
287
- strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
286
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
287
+ strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
288
288
  globalCompositeOperation: "source-over",
289
289
  lineCap: "round",
290
290
  lineJoin: "round",
291
291
  x: params.position.x,
292
292
  y: params.position.y,
293
- width: (_c = params.width) !== null && _c !== void 0 ? _c : 200,
294
- height: (_d = params.height) !== null && _d !== void 0 ? _d : 200,
293
+ width: (_c = params.width) !== null && _c !== undefined ? _c : 200,
294
+ height: (_d = params.height) !== null && _d !== undefined ? _d : 200,
295
295
  draggable: true,
296
296
  strokeScaleEnabled: false
297
297
  });
@@ -401,8 +401,8 @@ class KonvaEllipse {
401
401
  y: 25
402
402
  };
403
403
  this._ref = new Konva.Ellipse({
404
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
405
- strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
404
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
405
+ strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _b : 4,
406
406
  globalCompositeOperation: "source-over",
407
407
  lineCap: "round",
408
408
  lineJoin: "round",
@@ -531,8 +531,8 @@ class KonvaArrow {
531
531
  y: 100
532
532
  };
533
533
  this._ref = new Konva.Arrow({
534
- stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
535
- fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
534
+ stroke: (_a = params.color) !== null && _a !== undefined ? _a : "#ff0000",
535
+ fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
536
536
  strokeWidth: 4,
537
537
  globalCompositeOperation: "source-over",
538
538
  lineCap: "round",
@@ -672,8 +672,8 @@ class KonvaImage {
672
672
  x: params.position.x,
673
673
  y: params.position.y,
674
674
  image: this._canvasImage,
675
- width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
676
- height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
675
+ width: (_a = params.width) !== null && _a !== undefined ? _a : 0,
676
+ height: (_b = params.height) !== null && _b !== undefined ? _b : 0,
677
677
  draggable: true
678
678
  });
679
679
  this._ref.on("transform", (e => {
@@ -783,10 +783,10 @@ class KonvaCloud {
783
783
  this._ref = new Konva.Shape({
784
784
  x: params.position.x,
785
785
  y: params.position.y,
786
- width: (_a = params.width) !== null && _a !== void 0 ? _a : 200,
787
- height: (_b = params.height) !== null && _b !== void 0 ? _b : 200,
788
- stroke: (_c = params.color) !== null && _c !== void 0 ? _c : "#ff0000",
789
- strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d : 4,
786
+ width: (_a = params.width) !== null && _a !== undefined ? _a : 200,
787
+ height: (_b = params.height) !== null && _b !== undefined ? _b : 200,
788
+ stroke: (_c = params.color) !== null && _c !== undefined ? _c : "#ff0000",
789
+ strokeWidth: (_d = params.lineWidth) !== null && _d !== undefined ? _d : 4,
790
790
  draggable: true,
791
791
  strokeScaleEnabled: false,
792
792
  globalCompositeOperation: "source-over",
@@ -1035,9 +1035,9 @@ class KonvaMarkup {
1035
1035
  initialize(container, containerEvents, viewer, worldTransformer) {
1036
1036
  if (!Konva) 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?');
1037
1037
  this._viewer = viewer;
1038
- this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform;
1038
+ this._worldTransformer = worldTransformer !== null && worldTransformer !== undefined ? worldTransformer : new WorldTransform;
1039
1039
  this._container = container;
1040
- this._containerEvents = containerEvents !== null && containerEvents !== void 0 ? containerEvents : [];
1040
+ this._containerEvents = containerEvents !== null && containerEvents !== undefined ? containerEvents : [];
1041
1041
  this._markupContainer = document.createElement("div");
1042
1042
  this._markupContainer.id = "markup-container";
1043
1043
  this._markupContainer.style.position = "absolute";
@@ -1065,9 +1065,9 @@ class KonvaMarkup {
1065
1065
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
1066
1066
  }
1067
1067
  this.destroyKonva();
1068
- (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1068
+ (_a = this._resizeObserver) === null || _a === undefined ? undefined : _a.disconnect();
1069
1069
  this._resizeObserver = undefined;
1070
- (_b = this._markupContainer) === null || _b === void 0 ? void 0 : _b.remove();
1070
+ (_b = this._markupContainer) === null || _b === undefined ? undefined : _b.remove();
1071
1071
  this._markupContainer = undefined;
1072
1072
  this._container = undefined;
1073
1073
  this._viewer = undefined;
@@ -1099,14 +1099,14 @@ class KonvaMarkup {
1099
1099
  const hexColor = new MarkupColor(r, g, b).asHex();
1100
1100
  this.getObjects().filter((obj => {
1101
1101
  var _a;
1102
- return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
1102
+ return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor);
1103
1103
  }));
1104
1104
  }
1105
1105
  colorizeSelectedMarkups(r, g, b) {
1106
1106
  const hexColor = new MarkupColor(r, g, b).asHex();
1107
1107
  this.getSelectedObjects().filter((obj => {
1108
1108
  var _a;
1109
- return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
1109
+ return (_a = obj.setColor) === null || _a === undefined ? undefined : _a.call(obj, hexColor);
1110
1110
  }));
1111
1111
  }
1112
1112
  setViewpoint(viewpoint) {
@@ -1122,13 +1122,13 @@ class KonvaMarkup {
1122
1122
  x: 0,
1123
1123
  y: 0
1124
1124
  });
1125
- const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
1125
+ const markupColor = ((_a = viewpoint.custom_fields) === null || _a === undefined ? undefined : _a.markup_color) || {
1126
1126
  r: 255,
1127
1127
  g: 0,
1128
1128
  b: 0
1129
1129
  };
1130
1130
  this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
1131
- (_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line => {
1131
+ (_b = viewpoint.lines) === null || _b === undefined ? undefined : _b.forEach((line => {
1132
1132
  const linePoints = [];
1133
1133
  line.points.forEach((point => {
1134
1134
  const screenPoint = this._worldTransformer.worldToScreen(point);
@@ -1137,28 +1137,28 @@ class KonvaMarkup {
1137
1137
  }));
1138
1138
  this.addLine(linePoints, line.color, line.type, line.width, line.id);
1139
1139
  }));
1140
- (_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text => {
1140
+ (_c = viewpoint.texts) === null || _c === undefined ? undefined : _c.forEach((text => {
1141
1141
  const screenPoint = this._worldTransformer.worldToScreen(text.position);
1142
1142
  this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
1143
1143
  }));
1144
- (_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect => {
1144
+ (_d = viewpoint.rectangles) === null || _d === undefined ? undefined : _d.forEach((rect => {
1145
1145
  const screenPoint = this._worldTransformer.worldToScreen(rect.position);
1146
1146
  this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
1147
1147
  }));
1148
- (_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse => {
1148
+ (_e = viewpoint.ellipses) === null || _e === undefined ? undefined : _e.forEach((ellipse => {
1149
1149
  const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
1150
1150
  this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
1151
1151
  }));
1152
- (_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow => {
1152
+ (_f = viewpoint.arrows) === null || _f === undefined ? undefined : _f.forEach((arrow => {
1153
1153
  const startPoint = this._worldTransformer.worldToScreen(arrow.start);
1154
1154
  const endPoint = this._worldTransformer.worldToScreen(arrow.end);
1155
1155
  this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
1156
1156
  }));
1157
- (_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud => {
1157
+ (_g = viewpoint.clouds) === null || _g === undefined ? undefined : _g.forEach((cloud => {
1158
1158
  const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
1159
1159
  this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
1160
1160
  }));
1161
- (_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image => {
1161
+ (_h = viewpoint.images) === null || _h === undefined ? undefined : _h.forEach((image => {
1162
1162
  const screenPoint = this._worldTransformer.worldToScreen(image.position);
1163
1163
  this.addImage(screenPoint, image.src, image.width, image.height, image.id);
1164
1164
  }));
@@ -1452,7 +1452,7 @@ class KonvaMarkup {
1452
1452
  this.removeTextInput();
1453
1453
  this.removeImageInput();
1454
1454
  this.clearOverlay();
1455
- (_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
1455
+ (_a = this._konvaStage) === null || _a === undefined ? undefined : _a.destroy();
1456
1456
  this._groupImages = undefined;
1457
1457
  this._groupGeometry = undefined;
1458
1458
  this._groupTexts = undefined;
@@ -1702,7 +1702,7 @@ class KonvaMarkup {
1702
1702
  }
1703
1703
  removeTextInput() {
1704
1704
  var _a;
1705
- (_a = this._textInputRef) === null || _a === void 0 ? void 0 : _a.remove();
1705
+ (_a = this._textInputRef) === null || _a === undefined ? undefined : _a.remove();
1706
1706
  this._textInputRef = null;
1707
1707
  this._textInputPos = null;
1708
1708
  this._textInputAngle = 0;
@@ -1745,14 +1745,14 @@ class KonvaMarkup {
1745
1745
  }
1746
1746
  removeImageInput() {
1747
1747
  var _a;
1748
- (_a = this._imageInputRef) === null || _a === void 0 ? void 0 : _a.remove();
1748
+ (_a = this._imageInputRef) === null || _a === undefined ? undefined : _a.remove();
1749
1749
  this._imageInputRef = null;
1750
1750
  this._imageInputPos = null;
1751
1751
  }
1752
1752
  addText(text, position, angle, color, textSize, fontSize, id) {
1753
1753
  var _a;
1754
1754
  if (!text) return;
1755
- (_a = this.getSelectedObjects().at(0)) === null || _a === void 0 ? void 0 : _a.delete();
1755
+ (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
1756
1756
  this.clearSelected();
1757
1757
  this.removeTextInput();
1758
1758
  const tolerance = 1e-6;
@@ -1827,7 +1827,7 @@ class KonvaMarkup {
1827
1827
  addImage(position, src, width, height, id) {
1828
1828
  var _a;
1829
1829
  if (!position || !src) return;
1830
- (_a = this.getSelectedObjects().at(0)) === null || _a === void 0 ? void 0 : _a.delete();
1830
+ (_a = this.getSelectedObjects().at(0)) === null || _a === undefined ? undefined : _a.delete();
1831
1831
  this.clearSelected();
1832
1832
  this.removeImageInput();
1833
1833
  const konvaImage = new KonvaImage({