@inweb/markup 25.8.19 → 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 (48) hide show
  1. package/dist/markup.js +94 -57
  2. package/dist/markup.js.map +1 -1
  3. package/dist/markup.min.js +1 -1
  4. package/dist/markup.module.js +87 -37
  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/KonvaArrow.d.ts +2 -2
  19. package/lib/markup/Konva/KonvaCloud.d.ts +1 -1
  20. package/lib/markup/Konva/KonvaEllipse.d.ts +2 -2
  21. package/lib/markup/Konva/KonvaImage.d.ts +4 -2
  22. package/lib/markup/Konva/KonvaLine.d.ts +2 -11
  23. package/lib/markup/Konva/KonvaMarkup.d.ts +2 -2
  24. package/lib/markup/Konva/KonvaRectangle.d.ts +1 -1
  25. package/lib/markup/Konva/KonvaText.d.ts +2 -2
  26. package/lib/markup/Konva/MarkupColor.d.ts +19 -18
  27. package/package.json +3 -3
  28. package/src/index.ts +1 -1
  29. package/src/markup/IMarkup.ts +28 -16
  30. package/src/markup/IMarkupArrow.ts +8 -16
  31. package/src/markup/IMarkupCloud.ts +9 -18
  32. package/src/markup/IMarkupColorable.ts +5 -4
  33. package/src/markup/IMarkupEllipse.ts +9 -18
  34. package/src/markup/IMarkupImage.ts +14 -17
  35. package/src/markup/IMarkupLine.ts +46 -11
  36. package/src/markup/IMarkupObject.ts +25 -15
  37. package/src/markup/IMarkupRectangle.ts +9 -18
  38. package/src/markup/IMarkupText.ts +7 -14
  39. package/src/markup/IWorldTransform.ts +1 -1
  40. package/src/markup/Konva/KonvaArrow.ts +6 -4
  41. package/src/markup/Konva/KonvaCloud.ts +4 -3
  42. package/src/markup/Konva/KonvaEllipse.ts +6 -4
  43. package/src/markup/Konva/KonvaImage.ts +27 -14
  44. package/src/markup/Konva/KonvaLine.ts +9 -13
  45. package/src/markup/Konva/KonvaMarkup.ts +15 -15
  46. package/src/markup/Konva/KonvaRectangle.ts +3 -2
  47. package/src/markup/Konva/KonvaText.ts +6 -4
  48. package/src/markup/Konva/MarkupColor.ts +22 -23
@@ -22,57 +22,67 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  /**
25
- * Markup object
25
+ * 2D markup object interface.
26
26
  */
27
27
  export interface IMarkupObject {
28
28
  /**
29
- * Link to Library object (Konva, VisualizeJS)
29
+ * Returns a reference to a core markup library object (Konva, VisualizeJS, etc.).
30
30
  */
31
31
  ref(): any;
32
32
 
33
33
  /**
34
- * Get an internal identificator of the object. Not unique
34
+ * Returns the internal identifier of the object. Not unique.
35
35
  */
36
36
  id(): string;
37
37
 
38
38
  /**
39
- * Set Mouse editing feature
40
- *
41
- * @param value true / false
39
+ * Enables or disables the ability to select and edit an object using the mouse.
42
40
  */
43
- enableMouseEditing(value: boolean);
41
+ enableMouseEditing(value: boolean): void;
44
42
 
45
43
  /**
46
- * Get type of the Markup object
44
+ * Returns the type of the object.
47
45
  */
48
46
  type(): string;
49
47
 
50
48
  /**
51
- * Get rotation of the Markup object
49
+ * Returns the rotation angle of the object, in degress.
52
50
  */
53
51
  getRotation(): number;
54
52
 
55
53
  /**
56
- * Set rotation of the Markup object
54
+ * Sets the rotation angle of the object.
57
55
  *
58
- * @param degrees number of degress to rotate
56
+ * @param degrees - Number of degress to rotate.
59
57
  */
60
58
  setRotation(degrees: number): void;
61
59
 
62
60
  /**
63
- * Get Z-Index of the Markup object
61
+ * Returns the Z-index of a object relative to sibling objects that are in the same group.
62
+ *
63
+ * Z-Index is not absolute (like in CSS). It is relative to parent object group only:
64
+ *
65
+ * - `images` - are olways at the bottom
66
+ * - `texts` - are olways on top
67
+ * - `others` - are always between images and texts
64
68
  */
65
69
  getZIndex(): number;
66
70
 
67
71
  /**
68
- * Set Z-Index of the Markup object
72
+ * Sets the Z-index of a object relative to sibling objects that are in the same group.
73
+ *
74
+ * Z-Index is not absolute (like in CSS). It is relative to parent object group only:
75
+ *
76
+ * - `images` - are olways at the bottom
77
+ * - `texts` - are olways on top
78
+ * - `others` - are always between images and texts
69
79
  *
70
- * @param zIndex integer value of Z-Index
80
+ * @param zIndex - An integer value of Z-Index.
71
81
  */
72
82
  setZIndex(zIndex: number): void;
73
83
 
74
84
  /**
75
- * Delete current Markup object
85
+ * Deletes the current object.
76
86
  */
77
87
  delete(): void;
78
88
  }
@@ -25,55 +25,46 @@ import { IMarkupObject } from "./IMarkupObject";
25
25
  import { IMarkupColorable } from "./IMarkupColorable";
26
26
 
27
27
  /**
28
- * Rectangle Markup object
28
+ * 2D markup Rectangle object interface.
29
29
  */
30
30
  export interface IMarkupRectangle extends IMarkupObject, IMarkupColorable {
31
31
  /**
32
- * Get position of the Rectangle
32
+ * Returns the coordinates of the top-left point (position) of the rectangle.
33
33
  */
34
34
  getPosition(): { x: number; y: number };
35
35
 
36
36
  /**
37
- * Set position of the Rectangle
38
- *
39
- * @param x - value of X coordinate
40
- * @param y - value of Y coordinate
37
+ * Sets the coordinates of the top-left point (position) of the rectangle.
41
38
  */
42
39
  setPosition(x: number, y: number);
43
40
 
44
41
  /**
45
- * Get width of the Rectangle. Default value is 200
42
+ * Returns the width of the rectangle.
46
43
  */
47
44
  getWidth(): number;
48
45
 
49
46
  /**
50
- * Set width of the Rectangle
51
- *
52
- * @param w - value of width. Default value is 200
47
+ * Sets the width of the rectangle.
53
48
  */
54
49
  setWidth(w: number);
55
50
 
56
51
  /**
57
- * Get height of the Rectangle. Default value is 200
52
+ * Returns the height of the rectangle.
58
53
  */
59
54
  getHeigth(): number;
60
55
 
61
56
  /**
62
- * Set height of the Rectangle
63
- *
64
- * @param h - value of height. Default value is 200
57
+ * Sets the height of the rectangle.
65
58
  */
66
59
  setHeight(h: number);
67
60
 
68
61
  /**
69
- * Get line width of the Rectangle. Defailt value is 4
62
+ * Returns the line width of the rectangle.
70
63
  */
71
64
  getLineWidth(): number;
72
65
 
73
66
  /**
74
- * Set line width of the Rectangle
75
- *
76
- * @param size - value of width. Defailt value is 4
67
+ * Sets the line width of the rectangle.
77
68
  */
78
69
  setLineWidth(size: number);
79
70
  }
@@ -25,43 +25,36 @@ import { IMarkupObject } from "./IMarkupObject";
25
25
  import { IMarkupColorable } from "./IMarkupColorable";
26
26
 
27
27
  /**
28
- * Text Markup object
28
+ * 2D markup Text object interface.
29
29
  */
30
30
  export interface IMarkupText extends IMarkupObject, IMarkupColorable {
31
31
  /**
32
- * Get Text value
32
+ * Returns the text string.
33
33
  */
34
34
  getText(): string;
35
35
 
36
36
  /**
37
- * Set Text value
38
- *
39
- * @param text - string value
37
+ * Sets the text string.
40
38
  */
41
39
  setText(text: string): void;
42
40
 
43
41
  /**
44
- * Get position of the Text
42
+ * Returns the coordinates of the top-left point (position) of the text.
45
43
  */
46
44
  getPosition(): { x: number; y: number };
47
45
 
48
46
  /**
49
- * Set position of the Text
50
- *
51
- * @param x - value of X coordinate
52
- * @param y - value of Y coordinate
47
+ * Sets the coordinates of the top-left point (position) of the text.
53
48
  */
54
49
  setPosition(x: number, y: number);
55
50
 
56
51
  /**
57
- * Get font size. Default value is 34
52
+ * Returns the font size of the text.
58
53
  */
59
54
  getFontSize();
60
55
 
61
56
  /**
62
- * Set font size. Default value is 34
63
- *
64
- * @param size
57
+ * Sets the font size of the text.
65
58
  */
66
59
  setFontSize(size: number);
67
60
  }
@@ -22,7 +22,7 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  /**
25
- * Viewer coordiate system transformer.
25
+ * Viewer coordiate system transformer interface.
26
26
  */
27
27
  export interface IWorldTransform {
28
28
  /**
@@ -29,8 +29,8 @@ export class KonvaArrow implements IMarkupArrow {
29
29
 
30
30
  constructor(
31
31
  params: {
32
- start: { x: number; y: number };
33
- end: { x: number; y: number };
32
+ start?: { x: number; y: number };
33
+ end?: { x: number; y: number };
34
34
  color?: string;
35
35
  id?: string;
36
36
  },
@@ -41,7 +41,9 @@ export class KonvaArrow implements IMarkupArrow {
41
41
  return;
42
42
  }
43
43
 
44
- if (!params || !params.start || !params.end) return;
44
+ if (!params) params = {};
45
+ if (!params.start) params.start = { x: 50, y: 50 };
46
+ if (!params.end) params.end = { x: 100, y: 100 };
45
47
 
46
48
  this._ref = new Konva.Arrow({
47
49
  stroke: params.color ?? "#ff0000",
@@ -72,7 +74,7 @@ export class KonvaArrow implements IMarkupArrow {
72
74
  return this._ref.id();
73
75
  }
74
76
 
75
- enableMouseEditing(value: boolean) {
77
+ enableMouseEditing(value: boolean): void {
76
78
  this._ref.draggable(value);
77
79
  }
78
80
 
@@ -6,7 +6,7 @@ export class KonvaCloud implements IMarkupCloud {
6
6
 
7
7
  constructor(
8
8
  params: {
9
- position: { x: number; y: number };
9
+ position?: { x: number; y: number };
10
10
  width?: number;
11
11
  height?: number;
12
12
  lineWidth?: number;
@@ -20,7 +20,8 @@ export class KonvaCloud implements IMarkupCloud {
20
20
  return;
21
21
  }
22
22
 
23
- if (!params || !params.position) return;
23
+ if (!params) params = {};
24
+ if (!params.position) params.position = { x: 100, y: 100 };
24
25
 
25
26
  const arcRadius = 16;
26
27
 
@@ -141,7 +142,7 @@ export class KonvaCloud implements IMarkupCloud {
141
142
  return this._ref.id();
142
143
  }
143
144
 
144
- enableMouseEditing(value: boolean) {
145
+ enableMouseEditing(value: boolean): void {
145
146
  this._ref.draggable(value);
146
147
  }
147
148
 
@@ -6,8 +6,8 @@ export class KonvaEllipse implements IMarkupEllipse {
6
6
 
7
7
  constructor(
8
8
  params: {
9
- position: { x: number; y: number };
10
- radius: { x: number; y: number };
9
+ position?: { x: number; y: number };
10
+ radius?: { x: number; y: number };
11
11
  lineWidth?: number;
12
12
  color?: string;
13
13
  id?: string;
@@ -19,7 +19,9 @@ export class KonvaEllipse implements IMarkupEllipse {
19
19
  return;
20
20
  }
21
21
 
22
- if (!params || !params.position || !params.radius) return;
22
+ if (!params) params = {};
23
+ if (!params.position) params.position = { x: 100, y: 100 };
24
+ if (!params.radius) params.radius = { x: 25, y: 25 };
23
25
 
24
26
  this._ref = new Konva.Ellipse({
25
27
  stroke: params.color ?? "#ff0000",
@@ -110,7 +112,7 @@ export class KonvaEllipse implements IMarkupEllipse {
110
112
  return this._ref.id();
111
113
  }
112
114
 
113
- enableMouseEditing(value: boolean) {
115
+ enableMouseEditing(value: boolean): void {
114
116
  this._ref.draggable(value);
115
117
  }
116
118
 
@@ -6,11 +6,14 @@ export class KonvaImage implements IMarkupImage {
6
6
  private _canvasImage: HTMLImageElement;
7
7
  private _ratio = 1;
8
8
  private readonly EPSILON = 10e-6;
9
+ private readonly BASE64_NOT_FOUND =
10
+ "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=";
11
+ private readonly BASE64_HEADER_START = "data:image/";
9
12
 
10
13
  constructor(
11
14
  params: {
12
- position: { x: number; y: number };
13
- src: string;
15
+ position?: { x: number; y: number };
16
+ src?: string;
14
17
  width?: number;
15
18
  height?: number;
16
19
  maxWidth?: number;
@@ -20,7 +23,9 @@ export class KonvaImage implements IMarkupImage {
20
23
  ref = null
21
24
  ) {
22
25
  if (ref) {
23
- // if (ref.height() === 0 || ref.width() === 0) return;
26
+ if (!ref.src || !ref.src.startsWith(this.BASE64_HEADER_START)) ref.src = this.BASE64_NOT_FOUND;
27
+ if (ref.height() <= this.EPSILON) ref.height(32);
28
+ if (ref.width() <= this.EPSILON) ref.width(32);
24
29
 
25
30
  this._ref = ref;
26
31
  this._canvasImage = ref.image();
@@ -28,22 +33,16 @@ export class KonvaImage implements IMarkupImage {
28
33
  this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON
29
34
  ? 1
30
35
  : this._ref.height() / this._ref.width();
36
+
31
37
  return;
32
38
  }
33
39
 
34
- if (!params || !params.position || !params.src) return;
40
+ if (!params) params = {};
41
+ if (!params.position) params.position = { x: 50, y: 50 };
42
+ if (!params.src || !params.src.startsWith(this.BASE64_HEADER_START)) params.src = this.BASE64_NOT_FOUND;
35
43
 
36
44
  this._canvasImage = new Image();
37
45
 
38
- this._ref = new Konva.Image({
39
- x: params.position.x,
40
- y: params.position.y,
41
- image: this._canvasImage,
42
- width: params.width ?? 0,
43
- height: params.height ?? 0,
44
- draggable: true,
45
- });
46
-
47
46
  this._canvasImage.onload = () => {
48
47
  this._ref.image(this._canvasImage);
49
48
  if (this._ref.height() <= this.EPSILON) this._ref.height(this._canvasImage.height);
@@ -74,8 +73,22 @@ export class KonvaImage implements IMarkupImage {
74
73
  }
75
74
  };
76
75
 
76
+ this._canvasImage.onerror = () => {
77
+ this._canvasImage.onerror = function () {};
78
+ this._canvasImage.src = this.BASE64_NOT_FOUND;
79
+ };
80
+
77
81
  this._canvasImage.src = params.src;
78
82
 
83
+ this._ref = new Konva.Image({
84
+ x: params.position.x,
85
+ y: params.position.y,
86
+ image: this._canvasImage,
87
+ width: params.width ?? 0,
88
+ height: params.height ?? 0,
89
+ draggable: true,
90
+ });
91
+
79
92
  this._ref.on("transform", (e) => {
80
93
  const attrs = e.target.attrs;
81
94
 
@@ -146,7 +159,7 @@ export class KonvaImage implements IMarkupImage {
146
159
  return this._ref.id();
147
160
  }
148
161
 
149
- enableMouseEditing(value: boolean) {
162
+ enableMouseEditing(value: boolean): void {
150
163
  this._ref.draggable(value);
151
164
  }
152
165
 
@@ -1,5 +1,5 @@
1
1
  import Konva from "konva";
2
- import { IMarkupLine, MarkupLineType } from "../IMarkupLine";
2
+ import { IMarkupLine, IMarkupLineParams, MarkupLineType } from "../IMarkupLine";
3
3
 
4
4
  const LineTypeSpecs = new Map<string, number[]>([
5
5
  ["solid", []],
@@ -10,22 +10,18 @@ const LineTypeSpecs = new Map<string, number[]>([
10
10
  export class KonvaLine implements IMarkupLine {
11
11
  private _ref: Konva.Line;
12
12
 
13
- constructor(
14
- params: {
15
- points: { x: number; y: number }[];
16
- type?: MarkupLineType;
17
- width?: number;
18
- color?: string;
19
- id?: string;
20
- },
21
- ref = null
22
- ) {
13
+ constructor(params: IMarkupLineParams, ref = null) {
23
14
  if (ref) {
24
15
  this._ref = ref;
25
16
  return;
26
17
  }
27
18
 
28
- if (!params || !params.points) return;
19
+ if (!params) params = {};
20
+ if (!params.points)
21
+ params.points = [
22
+ { x: 50, y: 50 },
23
+ { x: 100, y: 100 },
24
+ ];
29
25
 
30
26
  const konvaPoints = [];
31
27
  params.points.forEach((point) => konvaPoints.push(point.x, point.y));
@@ -59,7 +55,7 @@ export class KonvaLine implements IMarkupLine {
59
55
  return this._ref.id();
60
56
  }
61
57
 
62
- enableMouseEditing(value: boolean) {
58
+ enableMouseEditing(value: boolean): void {
63
59
  this._ref.draggable(value);
64
60
  }
65
61
 
@@ -92,7 +92,7 @@ export class KonvaMarkup implements IMarkup {
92
92
  private _viewer: IEventEmitter;
93
93
  private _worldTransformer: IWorldTransform;
94
94
  private _container: HTMLElement;
95
- private _pointerEvents: string[] = [];
95
+ private _containerEvents: string[] = [];
96
96
  private _markupIsActive = false;
97
97
  private _markupMode: MarkupMode;
98
98
  private _markupColor = new MarkupColor(255, 0, 0);
@@ -117,7 +117,7 @@ export class KonvaMarkup implements IMarkup {
117
117
 
118
118
  initialize(
119
119
  container: HTMLElement,
120
- pointerEvents?: string[],
120
+ containerEvents?: string[],
121
121
  viewer?: IEventEmitter,
122
122
  worldTransformer?: IWorldTransform
123
123
  ): void {
@@ -129,7 +129,7 @@ export class KonvaMarkup implements IMarkup {
129
129
  this._viewer = viewer;
130
130
  this._worldTransformer = worldTransformer ?? new WorldTransform();
131
131
  this._container = container;
132
- this._pointerEvents = pointerEvents ?? [];
132
+ this._containerEvents = containerEvents ?? [];
133
133
 
134
134
  this._markupContainer = document.createElement("div");
135
135
  this._markupContainer.id = "markup-container";
@@ -150,7 +150,7 @@ export class KonvaMarkup implements IMarkup {
150
150
  this.initializeKonva();
151
151
 
152
152
  if (this._viewer) {
153
- this._pointerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
153
+ this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
154
154
  this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
155
155
  this._viewer.addEventListener("pan", this.pan);
156
156
  }
@@ -160,7 +160,7 @@ export class KonvaMarkup implements IMarkup {
160
160
  if (this._viewer) {
161
161
  this._viewer.removeEventListener("pan", this.pan);
162
162
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
163
- this._pointerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
163
+ this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
164
164
  }
165
165
 
166
166
  this.destroyKonva();
@@ -224,7 +224,7 @@ export class KonvaMarkup implements IMarkup {
224
224
  }
225
225
 
226
226
  getMarkupColor(): { r: number; g: number; b: number } {
227
- return this._markupColor.RGB;
227
+ return this._markupColor.asRGB();
228
228
  }
229
229
 
230
230
  setMarkupColor(r: number, g: number, b: number): void {
@@ -232,12 +232,12 @@ export class KonvaMarkup implements IMarkup {
232
232
  }
233
233
 
234
234
  colorizeAllMarkup(r: number, g: number, b: number): void {
235
- const hexColor = new MarkupColor(r, g, b).HexColor;
235
+ const hexColor = new MarkupColor(r, g, b).asHex();
236
236
  this.getObjects().filter((obj: any) => obj.setColor?.(hexColor));
237
237
  }
238
238
 
239
239
  colorizeSelectedMarkups(r: number, g: number, b: number): void {
240
- const hexColor = new MarkupColor(r, g, b).HexColor;
240
+ const hexColor = new MarkupColor(r, g, b).asHex();
241
241
  this.getSelectedObjects().filter((obj: any) => obj.setColor?.(hexColor));
242
242
  }
243
243
 
@@ -863,7 +863,7 @@ export class KonvaMarkup implements IMarkup {
863
863
  points,
864
864
  type: type || this.lineType,
865
865
  width: width || this.lineWidth,
866
- color: color || this._markupColor.HexColor,
866
+ color: color || this._markupColor.asHex(),
867
867
  id,
868
868
  });
869
869
 
@@ -882,7 +882,7 @@ export class KonvaMarkup implements IMarkup {
882
882
  this._textInputRef.style.top = inputY + "px";
883
883
  this._textInputRef.style.left = inputX + "px";
884
884
  this._textInputRef.style.fontSize = `${this.fontSize}px`;
885
- this._textInputRef.style.color = `${this._markupColor.HexColor}`;
885
+ this._textInputRef.style.color = `${this._markupColor.asHex()}`;
886
886
  this._textInputRef.style.fontFamily = "Calibri";
887
887
 
888
888
  this._textInputRef.onkeydown = (event) => {
@@ -989,7 +989,7 @@ export class KonvaMarkup implements IMarkup {
989
989
  text,
990
990
  rotation: angle,
991
991
  fontSize: fontSize || this.fontSize,
992
- color: color || this._markupColor.HexColor,
992
+ color: color || this._markupColor.asHex(),
993
993
  id,
994
994
  });
995
995
 
@@ -1012,7 +1012,7 @@ export class KonvaMarkup implements IMarkup {
1012
1012
  width,
1013
1013
  height,
1014
1014
  lineWidth: lineWidth || this.lineWidth,
1015
- color: color || this._markupColor.HexColor,
1015
+ color: color || this._markupColor.asHex(),
1016
1016
  id,
1017
1017
  });
1018
1018
 
@@ -1033,7 +1033,7 @@ export class KonvaMarkup implements IMarkup {
1033
1033
  position,
1034
1034
  radius,
1035
1035
  lineWidth,
1036
- color: color || this._markupColor.HexColor,
1036
+ color: color || this._markupColor.asHex(),
1037
1037
  id,
1038
1038
  });
1039
1039
 
@@ -1052,7 +1052,7 @@ export class KonvaMarkup implements IMarkup {
1052
1052
  const konvaArrow = new KonvaArrow({
1053
1053
  start,
1054
1054
  end,
1055
- color: color || this._markupColor.HexColor,
1055
+ color: color || this._markupColor.asHex(),
1056
1056
  id,
1057
1057
  });
1058
1058
 
@@ -1074,7 +1074,7 @@ export class KonvaMarkup implements IMarkup {
1074
1074
  position,
1075
1075
  width,
1076
1076
  height,
1077
- color: color || this._markupColor.HexColor,
1077
+ color: color || this._markupColor.asHex(),
1078
1078
  lineWidth: lineWidth || this.lineWidth,
1079
1079
  id,
1080
1080
  });
@@ -6,7 +6,7 @@ export class KonvaRectangle implements IMarkupRectangle {
6
6
 
7
7
  constructor(
8
8
  params: {
9
- position: { x: number; y: number };
9
+ position?: { x: number; y: number };
10
10
  width?: number;
11
11
  height?: number;
12
12
  lineWidth?: number;
@@ -20,7 +20,8 @@ export class KonvaRectangle implements IMarkupRectangle {
20
20
  return;
21
21
  }
22
22
 
23
- if (!params || !params.position) return;
23
+ if (!params) params = {};
24
+ if (!params.position) params.position = { x: 100, y: 100 };
24
25
 
25
26
  this._ref = new Konva.Rect({
26
27
  stroke: params.color ?? "#ff0000",
@@ -7,8 +7,8 @@ export class KonvaText implements IMarkupText {
7
7
 
8
8
  constructor(
9
9
  params: {
10
- position: { x: number; y: number };
11
- text: string;
10
+ position?: { x: number; y: number };
11
+ text?: string;
12
12
  rotation?: number;
13
13
  fontSize?: number;
14
14
  color?: string;
@@ -21,7 +21,9 @@ export class KonvaText implements IMarkupText {
21
21
  return;
22
22
  }
23
23
 
24
- if (!params || !params.position || !params.text) return;
24
+ if (!params) params = {};
25
+ if (!params.position) params.position = { x: 100, y: 100 };
26
+ if (!params.text) params.text = "default";
25
27
 
26
28
  this._ref = new Konva.Text({
27
29
  x: params.position.x,
@@ -77,7 +79,7 @@ export class KonvaText implements IMarkupText {
77
79
  return this._ref.id();
78
80
  }
79
81
 
80
- enableMouseEditing(value: boolean) {
82
+ enableMouseEditing(value: boolean): void {
81
83
  this._ref.draggable(value);
82
84
  }
83
85