@inweb/markup 25.8.11 → 25.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/markup.js +41 -23
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +35 -26
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/Konva/KonvaMarkup.d.ts +3 -1
- package/package.json +3 -3
- package/src/markup/Konva/KonvaArrow.ts +1 -1
- package/src/markup/Konva/KonvaCloud.ts +1 -1
- package/src/markup/Konva/KonvaEllipse.ts +1 -1
- package/src/markup/Konva/KonvaImage.ts +1 -1
- package/src/markup/Konva/KonvaLine.ts +1 -1
- package/src/markup/Konva/KonvaMarkup.ts +43 -15
- package/src/markup/Konva/KonvaRectangle.ts +1 -1
- package/src/markup/Konva/KonvaText.ts +1 -1
|
@@ -58,7 +58,6 @@ const MarkupMode2Konva = {
|
|
|
58
58
|
Line: {
|
|
59
59
|
name: "Line",
|
|
60
60
|
initializer: (ref: any, params = null) => new KonvaLine(params, ref),
|
|
61
|
-
zIndex: 1,
|
|
62
61
|
},
|
|
63
62
|
Text: {
|
|
64
63
|
name: "Text",
|
|
@@ -67,27 +66,22 @@ const MarkupMode2Konva = {
|
|
|
67
66
|
Rectangle: {
|
|
68
67
|
name: "Rect",
|
|
69
68
|
initializer: (ref: any, params = null) => new KonvaRectangle(params, ref),
|
|
70
|
-
zIndex: 1,
|
|
71
69
|
},
|
|
72
70
|
Ellipse: {
|
|
73
71
|
name: "Ellipse",
|
|
74
72
|
initializer: (ref: any, params = null) => new KonvaEllipse(params, ref),
|
|
75
|
-
zIndex: 1,
|
|
76
73
|
},
|
|
77
74
|
Arrow: {
|
|
78
75
|
name: "Arrow",
|
|
79
76
|
initializer: (ref: any, params = null) => new KonvaArrow(params, ref),
|
|
80
|
-
zIndex: 1,
|
|
81
77
|
},
|
|
82
78
|
Image: {
|
|
83
79
|
name: "Image",
|
|
84
80
|
initializer: (ref: any, params = null) => new KonvaImage(params, ref),
|
|
85
|
-
zIndex: 0,
|
|
86
81
|
},
|
|
87
82
|
Cloud: {
|
|
88
83
|
name: "Cloud",
|
|
89
84
|
initializer: (ref: any, params = null) => new KonvaCloud(params, ref),
|
|
90
|
-
zIndex: 1,
|
|
91
85
|
},
|
|
92
86
|
};
|
|
93
87
|
|
|
@@ -113,7 +107,9 @@ export class KonvaMarkup implements IMarkup {
|
|
|
113
107
|
private _imageInputPos: Konva.Vector2d;
|
|
114
108
|
private _markupContainer: HTMLDivElement;
|
|
115
109
|
private _resizeObserver: ResizeObserver;
|
|
116
|
-
private
|
|
110
|
+
private _groupImages: Konva.Group;
|
|
111
|
+
private _groupGeometry: Konva.Group;
|
|
112
|
+
private _groupTexts: Konva.Group;
|
|
117
113
|
|
|
118
114
|
public lineWidth = 4;
|
|
119
115
|
public lineType: MarkupLineType = "solid";
|
|
@@ -246,6 +242,10 @@ export class KonvaMarkup implements IMarkup {
|
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
setViewpoint(viewpoint: IViewpoint): void {
|
|
245
|
+
this.clearSelected();
|
|
246
|
+
this.removeTextInput();
|
|
247
|
+
this.removeImageInput();
|
|
248
|
+
|
|
249
249
|
const markupColor = viewpoint.custom_fields?.markup_color || { r: 255, g: 0, b: 0 };
|
|
250
250
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
251
251
|
|
|
@@ -312,6 +312,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
312
312
|
enableEditMode(mode: MarkupMode | false): this {
|
|
313
313
|
if (!mode || !MarkupMode2Konva[mode]) {
|
|
314
314
|
this.clearSelected();
|
|
315
|
+
this.removeTextInput();
|
|
316
|
+
this.removeImageInput();
|
|
315
317
|
this._markupIsActive = false;
|
|
316
318
|
} else {
|
|
317
319
|
this._markupMode = mode;
|
|
@@ -328,11 +330,6 @@ export class KonvaMarkup implements IMarkup {
|
|
|
328
330
|
const object = konvaShape.initializer(null, params);
|
|
329
331
|
this.addObject(object);
|
|
330
332
|
|
|
331
|
-
// Set zIndex only when shape has been added to Layer else we will get
|
|
332
|
-
// "Konva warning: Node has no parent. zIndex parameter is ignored."
|
|
333
|
-
object.setZIndex(konvaShape.zIndex ?? this._zIndex);
|
|
334
|
-
this._zIndex++;
|
|
335
|
-
|
|
336
333
|
return object;
|
|
337
334
|
}
|
|
338
335
|
|
|
@@ -370,7 +367,9 @@ export class KonvaMarkup implements IMarkup {
|
|
|
370
367
|
}
|
|
371
368
|
|
|
372
369
|
private addObject(object: IMarkupObject): void {
|
|
373
|
-
if (
|
|
370
|
+
if (object.type() === "Image") this._groupImages.add(object.ref());
|
|
371
|
+
else if (object.type() === "Text") this._groupTexts.add(object.ref());
|
|
372
|
+
else this._groupGeometry.add(object.ref());
|
|
374
373
|
}
|
|
375
374
|
|
|
376
375
|
private konvaLayerFind(type: string): any {
|
|
@@ -380,7 +379,15 @@ export class KonvaMarkup implements IMarkup {
|
|
|
380
379
|
if (!konvaShape || !konvaShape.initializer) return [];
|
|
381
380
|
|
|
382
381
|
// for "draggable" Konva uses Rectangles in Transformer. We need only Shapes from layer.
|
|
383
|
-
return this._konvaLayer
|
|
382
|
+
return this._konvaLayer
|
|
383
|
+
.find(konvaShape.name)
|
|
384
|
+
.filter(
|
|
385
|
+
(ref) =>
|
|
386
|
+
ref.parent === this._konvaLayer ||
|
|
387
|
+
ref.parent === this._groupImages ||
|
|
388
|
+
ref.parent === this._groupGeometry ||
|
|
389
|
+
ref.parent === this._groupTexts
|
|
390
|
+
);
|
|
384
391
|
}
|
|
385
392
|
|
|
386
393
|
private initializeKonva(): any {
|
|
@@ -394,6 +401,14 @@ export class KonvaMarkup implements IMarkup {
|
|
|
394
401
|
|
|
395
402
|
const layer = new Konva.Layer({ pixelRation: window.devicePixelRatio });
|
|
396
403
|
stage.add(layer);
|
|
404
|
+
|
|
405
|
+
this._groupImages = new Konva.Group();
|
|
406
|
+
layer.add(this._groupImages);
|
|
407
|
+
this._groupGeometry = new Konva.Group();
|
|
408
|
+
layer.add(this._groupGeometry);
|
|
409
|
+
this._groupTexts = new Konva.Group();
|
|
410
|
+
layer.add(this._groupTexts);
|
|
411
|
+
|
|
397
412
|
this._konvaLayer = layer;
|
|
398
413
|
|
|
399
414
|
const transformer = new Konva.Transformer({
|
|
@@ -561,7 +576,11 @@ export class KonvaMarkup implements IMarkup {
|
|
|
561
576
|
}
|
|
562
577
|
}
|
|
563
578
|
|
|
564
|
-
if (
|
|
579
|
+
if (
|
|
580
|
+
transformer.nodes().filter((x) => x.className === "Cloud" || x.className === "Image").length > 0 ||
|
|
581
|
+
e.target.className === "Cloud" ||
|
|
582
|
+
e.target.className === "Image"
|
|
583
|
+
) {
|
|
565
584
|
transformer.rotateEnabled(false);
|
|
566
585
|
} else {
|
|
567
586
|
transformer.rotateEnabled(true);
|
|
@@ -607,10 +626,15 @@ export class KonvaMarkup implements IMarkup {
|
|
|
607
626
|
}
|
|
608
627
|
|
|
609
628
|
private destroyKonva() {
|
|
629
|
+
this.removeTextInput();
|
|
630
|
+
this.removeImageInput();
|
|
610
631
|
this.clearOverlay();
|
|
611
632
|
|
|
612
633
|
this._konvaStage?.destroy();
|
|
613
634
|
|
|
635
|
+
this._groupImages = undefined;
|
|
636
|
+
this._groupGeometry = undefined;
|
|
637
|
+
this._groupTexts = undefined;
|
|
614
638
|
this._konvaLayer = undefined;
|
|
615
639
|
this._konvaTransformer = undefined;
|
|
616
640
|
this._konvaStage = undefined;
|
|
@@ -845,6 +869,10 @@ export class KonvaMarkup implements IMarkup {
|
|
|
845
869
|
this._textInputRef.style.display = "block";
|
|
846
870
|
this._textInputRef.style.top = inputY + "px";
|
|
847
871
|
this._textInputRef.style.left = inputX + "px";
|
|
872
|
+
this._textInputRef.style.fontSize = `${this.fontSize}px`;
|
|
873
|
+
this._textInputRef.style.color = `${this._markupColor.HexColor}`;
|
|
874
|
+
this._textInputRef.style.fontFamily = "Calibri";
|
|
875
|
+
|
|
848
876
|
this._textInputRef.onkeydown = (event) => {
|
|
849
877
|
if (event.key === "Enter" && !event.shiftKey) {
|
|
850
878
|
event.preventDefault();
|