@inweb/markup 25.8.20 → 25.8.21

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 (41) hide show
  1. package/dist/markup.js +35 -34
  2. package/dist/markup.js.map +1 -1
  3. package/dist/markup.min.js +1 -1
  4. package/dist/markup.module.js +22 -22
  5. package/dist/markup.module.js.map +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/markup/IMarkup.d.ts +27 -16
  8. package/lib/markup/IMarkupArrow.d.ts +8 -16
  9. package/lib/markup/IMarkupCloud.d.ts +9 -18
  10. package/lib/markup/IMarkupColorable.d.ts +5 -4
  11. package/lib/markup/IMarkupEllipse.d.ts +9 -18
  12. package/lib/markup/IMarkupImage.d.ts +14 -17
  13. package/lib/markup/IMarkupLine.d.ts +44 -11
  14. package/lib/markup/IMarkupObject.d.ts +25 -15
  15. package/lib/markup/IMarkupRectangle.d.ts +9 -18
  16. package/lib/markup/IMarkupText.d.ts +7 -14
  17. package/lib/markup/IWorldTransform.d.ts +1 -1
  18. package/lib/markup/Konva/KonvaLine.d.ts +2 -11
  19. package/lib/markup/Konva/KonvaMarkup.d.ts +2 -2
  20. package/lib/markup/Konva/MarkupColor.d.ts +19 -18
  21. package/package.json +3 -3
  22. package/src/index.ts +1 -1
  23. package/src/markup/IMarkup.ts +28 -16
  24. package/src/markup/IMarkupArrow.ts +8 -16
  25. package/src/markup/IMarkupCloud.ts +9 -18
  26. package/src/markup/IMarkupColorable.ts +5 -4
  27. package/src/markup/IMarkupEllipse.ts +9 -18
  28. package/src/markup/IMarkupImage.ts +14 -17
  29. package/src/markup/IMarkupLine.ts +46 -11
  30. package/src/markup/IMarkupObject.ts +25 -15
  31. package/src/markup/IMarkupRectangle.ts +9 -18
  32. package/src/markup/IMarkupText.ts +7 -14
  33. package/src/markup/IWorldTransform.ts +1 -1
  34. package/src/markup/Konva/KonvaArrow.ts +1 -1
  35. package/src/markup/Konva/KonvaCloud.ts +1 -1
  36. package/src/markup/Konva/KonvaEllipse.ts +1 -1
  37. package/src/markup/Konva/KonvaImage.ts +1 -1
  38. package/src/markup/Konva/KonvaLine.ts +3 -12
  39. package/src/markup/Konva/KonvaMarkup.ts +15 -15
  40. package/src/markup/Konva/KonvaText.ts +1 -1
  41. package/src/markup/Konva/MarkupColor.ts +22 -23
package/dist/markup.js CHANGED
@@ -11478,43 +11478,44 @@
11478
11478
  // acknowledge and accept the above terms.
11479
11479
  ///////////////////////////////////////////////////////////////////////////////
11480
11480
  /**
11481
- * Markup color.
11481
+ * Defines the markup color helper object.
11482
11482
  */
11483
11483
  class MarkupColor {
11484
11484
  /**
11485
- * Color in #000000 format
11485
+ * Creates an instance of the color.
11486
+ *
11487
+ * @param r - The `red` component of the color, as a number between 0 and 255.
11488
+ * @param g - The `green` component of the color, as a number between 0 and 255.
11489
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
11486
11490
  */
11487
- get HexColor() {
11488
- return "#" + this._hex;
11491
+ constructor(r, g, b) {
11492
+ this.setColor(r, g, b);
11489
11493
  }
11490
11494
  /**
11491
- * Color as object with r,g,b properties
11495
+ * Returns the color as a string in hexadecimal color syntax `#RGB` using its primary color
11496
+ * components (red, green, blue) written as hexadecimal numbers.
11492
11497
  */
11493
- get RGB() {
11494
- return { r: this.R, g: this.G, b: this.B };
11498
+ asHex() {
11499
+ return "#" + this.HEX;
11495
11500
  }
11496
11501
  /**
11497
- * Create an instance of Color
11498
- *
11499
- * @param r - Red color in [0,255] range
11500
- * @param g - Green color in [0,255] range
11501
- * @param b - Blue color in [0,255] range
11502
+ * Returns the color as an {r, g, b} object.
11502
11503
  */
11503
- constructor(r, g, b) {
11504
- this.setColor(r, g, b);
11504
+ asRGB() {
11505
+ return { r: this.R, g: this.G, b: this.B };
11505
11506
  }
11506
11507
  /**
11507
- * Set Color for current instance
11508
+ * Sets the color.
11508
11509
  *
11509
- * @param r - Red color in [0,255] range
11510
- * @param g - Green color in [0,255] range
11511
- * @param b - Blue color in [0,255] range
11510
+ * @param r - The `red` component of the color, as a number between 0 and 255.
11511
+ * @param g - The `green` component of the color, as a number between 0 and 255.
11512
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
11512
11513
  */
11513
11514
  setColor(r, g, b) {
11514
11515
  this.R = r;
11515
11516
  this.G = g;
11516
11517
  this.B = b;
11517
- this._hex = this.rgbToHex(r, g, b);
11518
+ this.HEX = this.rgbToHex(r, g, b);
11518
11519
  }
11519
11520
  rgbToHex(r, g, b) {
11520
11521
  const valueToHex = (c) => {
@@ -12472,7 +12473,7 @@
12472
12473
  */
12473
12474
  class KonvaMarkup {
12474
12475
  constructor() {
12475
- this._pointerEvents = [];
12476
+ this._containerEvents = [];
12476
12477
  this._markupIsActive = false;
12477
12478
  this._markupColor = new MarkupColor(255, 0, 0);
12478
12479
  this.lineWidth = 4;
@@ -12509,13 +12510,13 @@
12509
12510
  this._viewer.emit(event);
12510
12511
  };
12511
12512
  }
12512
- initialize(container, pointerEvents, viewer, worldTransformer) {
12513
+ initialize(container, containerEvents, viewer, worldTransformer) {
12513
12514
  if (!Konva)
12514
12515
  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?');
12515
12516
  this._viewer = viewer;
12516
12517
  this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform();
12517
12518
  this._container = container;
12518
- this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
12519
+ this._containerEvents = containerEvents !== null && containerEvents !== void 0 ? containerEvents : [];
12519
12520
  this._markupContainer = document.createElement("div");
12520
12521
  this._markupContainer.id = "markup-container";
12521
12522
  this._markupContainer.style.position = "absolute";
@@ -12530,7 +12531,7 @@
12530
12531
  this._markupColor.setColor(255, 0, 0);
12531
12532
  this.initializeKonva();
12532
12533
  if (this._viewer) {
12533
- this._pointerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
12534
+ this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
12534
12535
  this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
12535
12536
  this._viewer.addEventListener("pan", this.pan);
12536
12537
  }
@@ -12540,7 +12541,7 @@
12540
12541
  if (this._viewer) {
12541
12542
  this._viewer.removeEventListener("pan", this.pan);
12542
12543
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
12543
- this._pointerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
12544
+ this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
12544
12545
  }
12545
12546
  this.destroyKonva();
12546
12547
  (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
@@ -12560,17 +12561,17 @@
12560
12561
  this.getObjects().forEach((obj) => obj.delete());
12561
12562
  }
12562
12563
  getMarkupColor() {
12563
- return this._markupColor.RGB;
12564
+ return this._markupColor.asRGB();
12564
12565
  }
12565
12566
  setMarkupColor(r, g, b) {
12566
12567
  this._markupColor.setColor(r, g, b);
12567
12568
  }
12568
12569
  colorizeAllMarkup(r, g, b) {
12569
- const hexColor = new MarkupColor(r, g, b).HexColor;
12570
+ const hexColor = new MarkupColor(r, g, b).asHex();
12570
12571
  this.getObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
12571
12572
  }
12572
12573
  colorizeSelectedMarkups(r, g, b) {
12573
- const hexColor = new MarkupColor(r, g, b).HexColor;
12574
+ const hexColor = new MarkupColor(r, g, b).asHex();
12574
12575
  this.getSelectedObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
12575
12576
  }
12576
12577
  setViewpoint(viewpoint) {
@@ -13107,7 +13108,7 @@
13107
13108
  points,
13108
13109
  type: type || this.lineType,
13109
13110
  width: width || this.lineWidth,
13110
- color: color || this._markupColor.HexColor,
13111
+ color: color || this._markupColor.asHex(),
13111
13112
  id,
13112
13113
  });
13113
13114
  this.addObject(konvaLine);
@@ -13124,7 +13125,7 @@
13124
13125
  this._textInputRef.style.top = inputY + "px";
13125
13126
  this._textInputRef.style.left = inputX + "px";
13126
13127
  this._textInputRef.style.fontSize = `${this.fontSize}px`;
13127
- this._textInputRef.style.color = `${this._markupColor.HexColor}`;
13128
+ this._textInputRef.style.color = `${this._markupColor.asHex()}`;
13128
13129
  this._textInputRef.style.fontFamily = "Calibri";
13129
13130
  this._textInputRef.onkeydown = (event) => {
13130
13131
  if (event.key === "Enter" && !event.shiftKey) {
@@ -13216,7 +13217,7 @@
13216
13217
  text,
13217
13218
  rotation: angle,
13218
13219
  fontSize: fontSize || this.fontSize,
13219
- color: color || this._markupColor.HexColor,
13220
+ color: color || this._markupColor.asHex(),
13220
13221
  id,
13221
13222
  });
13222
13223
  this.addObject(konvaText);
@@ -13230,7 +13231,7 @@
13230
13231
  width,
13231
13232
  height,
13232
13233
  lineWidth: lineWidth || this.lineWidth,
13233
- color: color || this._markupColor.HexColor,
13234
+ color: color || this._markupColor.asHex(),
13234
13235
  id,
13235
13236
  });
13236
13237
  this.addObject(konvaRectangle);
@@ -13243,7 +13244,7 @@
13243
13244
  position,
13244
13245
  radius,
13245
13246
  lineWidth,
13246
- color: color || this._markupColor.HexColor,
13247
+ color: color || this._markupColor.asHex(),
13247
13248
  id,
13248
13249
  });
13249
13250
  this.addObject(konvaEllipse);
@@ -13255,7 +13256,7 @@
13255
13256
  const konvaArrow = new KonvaArrow({
13256
13257
  start,
13257
13258
  end,
13258
- color: color || this._markupColor.HexColor,
13259
+ color: color || this._markupColor.asHex(),
13259
13260
  id,
13260
13261
  });
13261
13262
  this.addObject(konvaArrow);
@@ -13268,7 +13269,7 @@
13268
13269
  position,
13269
13270
  width,
13270
13271
  height,
13271
- color: color || this._markupColor.HexColor,
13272
+ color: color || this._markupColor.asHex(),
13272
13273
  lineWidth: lineWidth || this.lineWidth,
13273
13274
  id,
13274
13275
  });