@inweb/viewer-visualize 25.7.4 → 25.7.6
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/viewer-visualize.js
CHANGED
|
@@ -12143,19 +12143,6 @@
|
|
|
12143
12143
|
var libExports = lib$1.exports;
|
|
12144
12144
|
var Konva = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
12145
12145
|
|
|
12146
|
-
exports.MarkupMode = void 0;
|
|
12147
|
-
|
|
12148
|
-
(function(MarkupMode) {
|
|
12149
|
-
MarkupMode["SelectMarkup"] = "SelectMarkup";
|
|
12150
|
-
MarkupMode["Line"] = "Line";
|
|
12151
|
-
MarkupMode["Text"] = "Text";
|
|
12152
|
-
MarkupMode["Rectangle"] = "Rectangle";
|
|
12153
|
-
MarkupMode["Ellipse"] = "Ellipse";
|
|
12154
|
-
MarkupMode["Arrow"] = "Arrow";
|
|
12155
|
-
MarkupMode["Image"] = "Image";
|
|
12156
|
-
MarkupMode["Cloud"] = "Cloud";
|
|
12157
|
-
})(exports.MarkupMode || (exports.MarkupMode = {}));
|
|
12158
|
-
|
|
12159
12146
|
class MarkupColor {
|
|
12160
12147
|
get HexColor() {
|
|
12161
12148
|
return "#" + this._hex;
|
|
@@ -13015,31 +13002,40 @@
|
|
|
13015
13002
|
}
|
|
13016
13003
|
}
|
|
13017
13004
|
|
|
13018
|
-
const MarkupMode2Konva =
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13005
|
+
const MarkupMode2Konva = {
|
|
13006
|
+
SelectMarkup: {
|
|
13007
|
+
name: "SelectMarkup",
|
|
13008
|
+
initializer: null
|
|
13009
|
+
},
|
|
13010
|
+
Line: {
|
|
13011
|
+
name: "Line",
|
|
13012
|
+
initializer: ref => new KonvaLine(null, ref)
|
|
13013
|
+
},
|
|
13014
|
+
Text: {
|
|
13015
|
+
name: "Text",
|
|
13016
|
+
initializer: ref => new KonvaText(null, ref)
|
|
13017
|
+
},
|
|
13018
|
+
Rectangle: {
|
|
13019
|
+
name: "Rect",
|
|
13020
|
+
initializer: ref => new KonvaRectangle(null, ref)
|
|
13021
|
+
},
|
|
13022
|
+
Ellipse: {
|
|
13023
|
+
name: "Ellipse",
|
|
13024
|
+
initializer: ref => new KonvaEllipse(null, ref)
|
|
13025
|
+
},
|
|
13026
|
+
Arrow: {
|
|
13027
|
+
name: "Arrow",
|
|
13028
|
+
initializer: ref => new KonvaArrow(null, ref)
|
|
13029
|
+
},
|
|
13030
|
+
Image: {
|
|
13031
|
+
name: "Image",
|
|
13032
|
+
initializer: ref => new KonvaImage(null, ref)
|
|
13033
|
+
},
|
|
13034
|
+
Cloud: {
|
|
13035
|
+
name: "Cloud",
|
|
13036
|
+
initializer: ref => new KonvaCloud(null, ref)
|
|
13037
|
+
}
|
|
13038
|
+
};
|
|
13043
13039
|
|
|
13044
13040
|
class KonvaMarkup {
|
|
13045
13041
|
constructor() {
|
|
@@ -13056,10 +13052,9 @@
|
|
|
13056
13052
|
this._markupContainer.className = this._canvasOriginal.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
|
|
13057
13053
|
this.removeTextInput();
|
|
13058
13054
|
this.removeImageInput();
|
|
13059
|
-
const
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
this._markupMode = markupMode;
|
|
13055
|
+
const konvaShape = MarkupMode2Konva[draggerName];
|
|
13056
|
+
if (konvaShape) {
|
|
13057
|
+
this._markupMode = draggerName;
|
|
13063
13058
|
this._markupIsActive = true;
|
|
13064
13059
|
} else {
|
|
13065
13060
|
this._markupIsActive = false;
|
|
@@ -13074,7 +13069,7 @@
|
|
|
13074
13069
|
this.pan = event => {
|
|
13075
13070
|
const dX = event.dX / window.devicePixelRatio;
|
|
13076
13071
|
const dY = event.dY / window.devicePixelRatio;
|
|
13077
|
-
Object.
|
|
13072
|
+
Object.keys(MarkupMode2Konva).forEach((mode => this.konvaLayerFind(mode).forEach((ref => ref.move({
|
|
13078
13073
|
x: dX,
|
|
13079
13074
|
y: dY
|
|
13080
13075
|
})))));
|
|
@@ -13130,7 +13125,7 @@
|
|
|
13130
13125
|
this.removeTextInput();
|
|
13131
13126
|
this.removeImageInput();
|
|
13132
13127
|
this._konvaTransformer.nodes([]);
|
|
13133
|
-
Object.
|
|
13128
|
+
Object.keys(MarkupMode2Konva).forEach((mode => this.konvaLayerFind(mode).forEach((ref => ref.destroy()))));
|
|
13134
13129
|
}
|
|
13135
13130
|
getMarkupColor() {
|
|
13136
13131
|
return this._markupColor.RGB;
|
|
@@ -13140,11 +13135,11 @@
|
|
|
13140
13135
|
}
|
|
13141
13136
|
colorizeAllMarkup(r = 255, g = 0, b = 0) {
|
|
13142
13137
|
const hex = new MarkupColor(r, g, b).HexColor;
|
|
13143
|
-
Object.
|
|
13144
|
-
this.konvaLayerFind(mode).forEach((
|
|
13145
|
-
|
|
13146
|
-
const konvaObj =
|
|
13147
|
-
if (konvaObj
|
|
13138
|
+
Object.keys(MarkupMode2Konva).forEach((mode => {
|
|
13139
|
+
this.konvaLayerFind(mode).forEach((ref => {
|
|
13140
|
+
const konvaShape = MarkupMode2Konva[mode];
|
|
13141
|
+
const konvaObj = konvaShape.initializer(ref);
|
|
13142
|
+
if (konvaObj.setColor) konvaObj.setColor(hex);
|
|
13148
13143
|
}));
|
|
13149
13144
|
}));
|
|
13150
13145
|
this._konvaLayer.draw();
|
|
@@ -13233,25 +13228,25 @@
|
|
|
13233
13228
|
}
|
|
13234
13229
|
getObjects() {
|
|
13235
13230
|
const objects = [];
|
|
13236
|
-
this.konvaLayerFind(
|
|
13231
|
+
this.konvaLayerFind("Line").forEach((line => {
|
|
13237
13232
|
objects.push(new KonvaLine(null, line));
|
|
13238
13233
|
}));
|
|
13239
|
-
this.konvaLayerFind(
|
|
13234
|
+
this.konvaLayerFind("Text").forEach((text => {
|
|
13240
13235
|
objects.push(new KonvaText(null, text));
|
|
13241
13236
|
}));
|
|
13242
|
-
this.konvaLayerFind(
|
|
13237
|
+
this.konvaLayerFind("Rectangle").forEach((rectangle => {
|
|
13243
13238
|
objects.push(new KonvaRectangle(null, rectangle));
|
|
13244
13239
|
}));
|
|
13245
|
-
this.konvaLayerFind(
|
|
13240
|
+
this.konvaLayerFind("Ellipse").forEach((ellipse => {
|
|
13246
13241
|
objects.push(new KonvaEllipse(null, ellipse));
|
|
13247
13242
|
}));
|
|
13248
|
-
this.konvaLayerFind(
|
|
13243
|
+
this.konvaLayerFind("Arrow").forEach((arrow => {
|
|
13249
13244
|
objects.push(new KonvaArrow(null, arrow));
|
|
13250
13245
|
}));
|
|
13251
|
-
this.konvaLayerFind(
|
|
13246
|
+
this.konvaLayerFind("Image").forEach((image => {
|
|
13252
13247
|
objects.push(new KonvaImage(null, image));
|
|
13253
13248
|
}));
|
|
13254
|
-
this.konvaLayerFind(
|
|
13249
|
+
this.konvaLayerFind("Cloud").forEach((cloud => {
|
|
13255
13250
|
objects.push(new KonvaCloud(null, cloud));
|
|
13256
13251
|
}));
|
|
13257
13252
|
return objects;
|
|
@@ -13354,10 +13349,9 @@
|
|
|
13354
13349
|
this._konvaLayer.add(object.ref());
|
|
13355
13350
|
}
|
|
13356
13351
|
konvaLayerFind(markupShape) {
|
|
13357
|
-
const konvaShape = MarkupMode2Konva
|
|
13358
|
-
if (konvaShape) {
|
|
13359
|
-
|
|
13360
|
-
return konvaShapes;
|
|
13352
|
+
const konvaShape = MarkupMode2Konva[markupShape];
|
|
13353
|
+
if (konvaShape && konvaShape.initializer) {
|
|
13354
|
+
return this._konvaLayer.find(konvaShape.name).filter((ref => ref.parent === this._konvaLayer));
|
|
13361
13355
|
}
|
|
13362
13356
|
return [];
|
|
13363
13357
|
}
|
|
@@ -13385,15 +13379,15 @@
|
|
|
13385
13379
|
let mouseDownPos;
|
|
13386
13380
|
let lastObj;
|
|
13387
13381
|
stage.on("mousedown touchstart", (e => {
|
|
13388
|
-
if (!this._markupIsActive || e.target !== stage || this._markupMode ===
|
|
13382
|
+
if (!this._markupIsActive || e.target !== stage || this._markupMode === "Text" || this._markupMode === "Image") return;
|
|
13389
13383
|
if (e.target === stage && transformer.nodes().length > 0) {
|
|
13390
13384
|
transformer.nodes([]);
|
|
13391
13385
|
return;
|
|
13392
13386
|
}
|
|
13393
13387
|
const pos = stage.getPointerPosition();
|
|
13394
13388
|
mouseDownPos = pos;
|
|
13395
|
-
isPaint = [
|
|
13396
|
-
if (this._markupMode ===
|
|
13389
|
+
isPaint = [ "Arrow", "Cloud", "Ellipse", "Line", "Rectangle" ].some((m => m === this._markupMode));
|
|
13390
|
+
if (this._markupMode === "Line") {
|
|
13397
13391
|
lastLine = this.addLine([ pos.x, pos.y, pos.x, pos.y ]);
|
|
13398
13392
|
}
|
|
13399
13393
|
}));
|
|
@@ -13407,12 +13401,12 @@
|
|
|
13407
13401
|
const dX = defParams ? 200 : Math.abs(mouseDownPos.x - pos.x);
|
|
13408
13402
|
const dY = defParams ? 200 : Math.abs(mouseDownPos.y - pos.y);
|
|
13409
13403
|
if (defParams) {
|
|
13410
|
-
if (this._markupMode ===
|
|
13404
|
+
if (this._markupMode === "Rectangle") {
|
|
13411
13405
|
this.addRectangle({
|
|
13412
13406
|
x: startX,
|
|
13413
13407
|
y: startY
|
|
13414
13408
|
}, dX, dY);
|
|
13415
|
-
} else if (this._markupMode ===
|
|
13409
|
+
} else if (this._markupMode === "Ellipse") {
|
|
13416
13410
|
this.addEllipse({
|
|
13417
13411
|
x: startX,
|
|
13418
13412
|
y: startY
|
|
@@ -13420,7 +13414,7 @@
|
|
|
13420
13414
|
x: dX / 2,
|
|
13421
13415
|
y: dY / 2
|
|
13422
13416
|
});
|
|
13423
|
-
} else if (this._markupMode ===
|
|
13417
|
+
} else if (this._markupMode === "Arrow") {
|
|
13424
13418
|
this.addArrow({
|
|
13425
13419
|
x: mouseDownPos.x,
|
|
13426
13420
|
y: mouseDownPos.y
|
|
@@ -13428,7 +13422,7 @@
|
|
|
13428
13422
|
x: defParams ? mouseDownPos.x + 200 : pos.x,
|
|
13429
13423
|
y: defParams ? startY : pos.y
|
|
13430
13424
|
});
|
|
13431
|
-
} else if (this._markupMode ===
|
|
13425
|
+
} else if (this._markupMode === "Cloud") {
|
|
13432
13426
|
this.addCloud({
|
|
13433
13427
|
x: startX,
|
|
13434
13428
|
y: startY
|
|
@@ -13450,12 +13444,12 @@
|
|
|
13450
13444
|
const startY = defParams ? mouseDownPos.y : Math.min(mouseDownPos.y, pos.y);
|
|
13451
13445
|
const dX = defParams ? 200 : Math.abs(mouseDownPos.x - pos.x);
|
|
13452
13446
|
const dY = defParams ? 200 : Math.abs(mouseDownPos.y - pos.y);
|
|
13453
|
-
if (this._markupMode ===
|
|
13447
|
+
if (this._markupMode === "Line") {
|
|
13454
13448
|
lastLine.addPoints([ {
|
|
13455
13449
|
x: pos.x,
|
|
13456
13450
|
y: pos.y
|
|
13457
13451
|
} ]);
|
|
13458
|
-
} else if (this._markupMode ===
|
|
13452
|
+
} else if (this._markupMode === "Arrow") {
|
|
13459
13453
|
if (lastObj) lastObj.setEndPoint(pos.x, pos.y); else lastObj = this.addArrow({
|
|
13460
13454
|
x: mouseDownPos.x,
|
|
13461
13455
|
y: mouseDownPos.y
|
|
@@ -13463,7 +13457,7 @@
|
|
|
13463
13457
|
x: pos.x,
|
|
13464
13458
|
y: pos.y
|
|
13465
13459
|
});
|
|
13466
|
-
} else if (this._markupMode ===
|
|
13460
|
+
} else if (this._markupMode === "Rectangle") {
|
|
13467
13461
|
if (lastObj) {
|
|
13468
13462
|
lastObj.setPosition(startX, startY);
|
|
13469
13463
|
lastObj.setWidth(dX);
|
|
@@ -13472,7 +13466,7 @@
|
|
|
13472
13466
|
x: startX,
|
|
13473
13467
|
y: startY
|
|
13474
13468
|
}, dX, dY);
|
|
13475
|
-
} else if (this._markupMode ===
|
|
13469
|
+
} else if (this._markupMode === "Ellipse") {
|
|
13476
13470
|
if (lastObj) {
|
|
13477
13471
|
lastObj.setPosition(startX, startY);
|
|
13478
13472
|
lastObj.setRadiusX(dX);
|
|
@@ -13484,7 +13478,7 @@
|
|
|
13484
13478
|
x: dX,
|
|
13485
13479
|
y: dY
|
|
13486
13480
|
});
|
|
13487
|
-
} else if (this._markupMode ===
|
|
13481
|
+
} else if (this._markupMode === "Cloud") {
|
|
13488
13482
|
if (lastObj) {
|
|
13489
13483
|
lastObj.setPosition(startX, startY);
|
|
13490
13484
|
lastObj.setWidth(Math.max(100, dX));
|
|
@@ -13498,12 +13492,12 @@
|
|
|
13498
13492
|
stage.on("click tap", (e => {
|
|
13499
13493
|
if (!this._markupIsActive) return;
|
|
13500
13494
|
if (e.target === stage) {
|
|
13501
|
-
if (this._markupMode ===
|
|
13495
|
+
if (this._markupMode === "Text") {
|
|
13502
13496
|
if (this._textInputRef && this._textInputRef.value) this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle); else if (transformer.nodes().length === 0) {
|
|
13503
13497
|
const pos = stage.getPointerPosition();
|
|
13504
13498
|
this.createTextInput(pos, e.evt.pageX, e.evt.pageY, 0, null);
|
|
13505
13499
|
}
|
|
13506
|
-
} else if (this._markupMode ===
|
|
13500
|
+
} else if (this._markupMode === "Image") {
|
|
13507
13501
|
if (this._imageInputRef && this._imageInputRef.value) this.addImage({
|
|
13508
13502
|
x: this._imageInputPos.x,
|
|
13509
13503
|
y: this._imageInputPos.y
|
|
@@ -13515,7 +13509,7 @@
|
|
|
13515
13509
|
transformer.nodes([]);
|
|
13516
13510
|
return;
|
|
13517
13511
|
}
|
|
13518
|
-
if (this._markupMode ===
|
|
13512
|
+
if (this._markupMode === "Text" || this._markupMode === "SelectMarkup") {
|
|
13519
13513
|
if (e.target.className === "Text" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
13520
13514
|
if (this._textInputRef && this._textInputRef.value) this.addText(this._textInputRef.value, this._textInputPos, this._textInputAngle); else this.createTextInput({
|
|
13521
13515
|
x: e.target.attrs.x,
|
|
@@ -13526,7 +13520,7 @@
|
|
|
13526
13520
|
this.removeTextInput();
|
|
13527
13521
|
}
|
|
13528
13522
|
}
|
|
13529
|
-
if (this._markupMode ===
|
|
13523
|
+
if (this._markupMode === "Image" || this._markupMode === "SelectMarkup") {
|
|
13530
13524
|
if (e.target.className === "Image" && transformer.nodes().length === 1 && transformer.nodes()[0] === e.target) {
|
|
13531
13525
|
if (this._imageInputRef && this._imageInputRef.value) this.addImage(this._imageInputPos, this._imageInputRef.value, 0, 0); else this.createImageInput({
|
|
13532
13526
|
x: e.target.attrs.x,
|
|
@@ -13581,7 +13575,7 @@
|
|
|
13581
13575
|
}
|
|
13582
13576
|
getMarkupLines() {
|
|
13583
13577
|
const lines = [];
|
|
13584
|
-
this.konvaLayerFind(
|
|
13578
|
+
this.konvaLayerFind("Line").forEach((line => {
|
|
13585
13579
|
const linePoints = line.points();
|
|
13586
13580
|
if (!linePoints) return;
|
|
13587
13581
|
const worldPoints = [];
|
|
@@ -13609,7 +13603,7 @@
|
|
|
13609
13603
|
const texts = [];
|
|
13610
13604
|
const textSize = .02;
|
|
13611
13605
|
const textScale = this._worldTransformer.getScale();
|
|
13612
|
-
this.konvaLayerFind(
|
|
13606
|
+
this.konvaLayerFind("Text").forEach((text => {
|
|
13613
13607
|
if (!text) return;
|
|
13614
13608
|
const position = this._worldTransformer.screenToWorld({
|
|
13615
13609
|
x: text.x(),
|
|
@@ -13630,7 +13624,7 @@
|
|
|
13630
13624
|
}
|
|
13631
13625
|
getMarkupRectangles() {
|
|
13632
13626
|
const rectangles = [];
|
|
13633
|
-
this.konvaLayerFind(
|
|
13627
|
+
this.konvaLayerFind("Rectangle").forEach((rect => {
|
|
13634
13628
|
const position = rect.position();
|
|
13635
13629
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13636
13630
|
const shape = new KonvaRectangle(null, rect);
|
|
@@ -13647,7 +13641,7 @@
|
|
|
13647
13641
|
}
|
|
13648
13642
|
getMarkupEllipses() {
|
|
13649
13643
|
const ellipses = [];
|
|
13650
|
-
this.konvaLayerFind(
|
|
13644
|
+
this.konvaLayerFind("Ellipse").forEach((ellipse => {
|
|
13651
13645
|
const position = ellipse.position();
|
|
13652
13646
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13653
13647
|
const shape = new KonvaEllipse(null, ellipse);
|
|
@@ -13666,7 +13660,7 @@
|
|
|
13666
13660
|
}
|
|
13667
13661
|
getMarkupArrows() {
|
|
13668
13662
|
const arrows = [];
|
|
13669
|
-
this.konvaLayerFind(
|
|
13663
|
+
this.konvaLayerFind("Arrow").forEach((arrow => {
|
|
13670
13664
|
const absoluteTransform = arrow.getAbsoluteTransform();
|
|
13671
13665
|
const atStartPoint = absoluteTransform.point({
|
|
13672
13666
|
x: arrow.points()[0],
|
|
@@ -13690,7 +13684,7 @@
|
|
|
13690
13684
|
}
|
|
13691
13685
|
getMarkupImages() {
|
|
13692
13686
|
const images = [];
|
|
13693
|
-
this.konvaLayerFind(
|
|
13687
|
+
this.konvaLayerFind("Image").forEach((image => {
|
|
13694
13688
|
const position = image.position();
|
|
13695
13689
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13696
13690
|
const shape = new KonvaImage(null, image);
|
|
@@ -13706,7 +13700,7 @@
|
|
|
13706
13700
|
}
|
|
13707
13701
|
getMarkupClouds() {
|
|
13708
13702
|
const clouds = [];
|
|
13709
|
-
this.konvaLayerFind(
|
|
13703
|
+
this.konvaLayerFind("Cloud").forEach((cloud => {
|
|
13710
13704
|
const position = cloud.position();
|
|
13711
13705
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13712
13706
|
const shape = new KonvaCloud(null, cloud);
|