@inweb/markup 25.8.1 → 25.8.3
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 +132 -198
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +139 -193
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/Konva/KonvaMarkup.d.ts +0 -2
- package/lib/markup/WorldTransform.d.ts +2 -1
- package/package.json +3 -3
- package/src/markup/Konva/KonvaMarkup.ts +173 -227
- package/src/markup/WorldTransform.ts +3 -1
package/dist/markup.js
CHANGED
|
@@ -12518,43 +12518,62 @@
|
|
|
12518
12518
|
}
|
|
12519
12519
|
colorizeAllMarkup(r, g, b) {
|
|
12520
12520
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
12521
|
-
this.getObjects().
|
|
12522
|
-
const colorable = obj;
|
|
12523
|
-
if (colorable && colorable.setColor)
|
|
12524
|
-
colorable.setColor(hexColor);
|
|
12525
|
-
});
|
|
12526
|
-
this._konvaLayer.draw();
|
|
12521
|
+
this.getObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
|
|
12527
12522
|
}
|
|
12528
12523
|
colorizeSelectedMarkups(r, g, b) {
|
|
12529
12524
|
const hexColor = new MarkupColor(r, g, b).HexColor;
|
|
12530
|
-
this.getSelectedObjects().
|
|
12531
|
-
const colorable = obj;
|
|
12532
|
-
if (colorable && colorable.setColor)
|
|
12533
|
-
colorable.setColor(hexColor);
|
|
12534
|
-
});
|
|
12525
|
+
this.getSelectedObjects().filter((obj) => { var _a; return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor); });
|
|
12535
12526
|
}
|
|
12536
12527
|
setViewpoint(viewpoint) {
|
|
12537
|
-
|
|
12528
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12529
|
+
const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || { r: 255, g: 0, b: 0 };
|
|
12538
12530
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
12539
|
-
|
|
12531
|
+
(_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
|
|
12532
|
+
const linePoints = [];
|
|
12533
|
+
line.points.forEach((point) => {
|
|
12534
|
+
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
12535
|
+
linePoints.push(screenPoint.x);
|
|
12536
|
+
linePoints.push(screenPoint.y);
|
|
12537
|
+
});
|
|
12538
|
+
this.addLine(linePoints, line.color, line.type, line.width, line.id);
|
|
12539
|
+
});
|
|
12540
|
+
(_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text) => {
|
|
12541
|
+
const screenPoint = this._worldTransformer.worldToScreen(text.position);
|
|
12542
|
+
this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
|
|
12543
|
+
});
|
|
12544
|
+
(_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect) => {
|
|
12545
|
+
const screenPoint = this._worldTransformer.worldToScreen(rect.position);
|
|
12546
|
+
this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
12547
|
+
});
|
|
12548
|
+
(_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse) => {
|
|
12549
|
+
const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
|
|
12550
|
+
this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
|
|
12551
|
+
});
|
|
12552
|
+
(_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow) => {
|
|
12553
|
+
const startPoint = this._worldTransformer.worldToScreen(arrow.start);
|
|
12554
|
+
const endPoint = this._worldTransformer.worldToScreen(arrow.end);
|
|
12555
|
+
this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
|
|
12556
|
+
});
|
|
12557
|
+
(_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud) => {
|
|
12558
|
+
const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
|
|
12559
|
+
this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
12560
|
+
});
|
|
12561
|
+
(_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image) => {
|
|
12562
|
+
const screenPoint = this._worldTransformer.worldToScreen(image.position);
|
|
12563
|
+
this.addImage(screenPoint, image.src, image.width, image.height, image.id);
|
|
12564
|
+
});
|
|
12540
12565
|
}
|
|
12541
12566
|
getViewpoint() {
|
|
12542
|
-
const viewpoint = {
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
};
|
|
12551
|
-
viewpoint.snapshot = {
|
|
12552
|
-
data: this.combineMarkupWithDrawing(),
|
|
12553
|
-
};
|
|
12554
|
-
viewpoint.custom_fields = {
|
|
12555
|
-
markup_color: this.getMarkupColor(),
|
|
12556
|
-
};
|
|
12557
|
-
this.fillViewpointShapes(viewpoint);
|
|
12567
|
+
const viewpoint = {};
|
|
12568
|
+
viewpoint.lines = this.getMarkupLines();
|
|
12569
|
+
viewpoint.texts = this.getMarkupTexts();
|
|
12570
|
+
viewpoint.arrows = this.getMarkupArrows();
|
|
12571
|
+
viewpoint.clouds = this.getMarkupClouds();
|
|
12572
|
+
viewpoint.ellipses = this.getMarkupEllipses();
|
|
12573
|
+
viewpoint.images = this.getMarkupImages();
|
|
12574
|
+
viewpoint.rectangles = this.getMarkupRectangles();
|
|
12575
|
+
viewpoint.custom_fields = { markup_color: this.getMarkupColor() };
|
|
12576
|
+
viewpoint.snapshot = { data: this.combineMarkupWithDrawing() };
|
|
12558
12577
|
viewpoint.description = new Date().toDateString();
|
|
12559
12578
|
return viewpoint;
|
|
12560
12579
|
}
|
|
@@ -12607,50 +12626,6 @@
|
|
|
12607
12626
|
clearSelected() {
|
|
12608
12627
|
this._konvaTransformer.nodes([]);
|
|
12609
12628
|
}
|
|
12610
|
-
fillViewpointShapes(viewpoint) {
|
|
12611
|
-
const markupLines = this.getMarkupLines();
|
|
12612
|
-
if (markupLines && markupLines.length > 0) {
|
|
12613
|
-
markupLines === null || markupLines === void 0 ? void 0 : markupLines.forEach((line) => {
|
|
12614
|
-
viewpoint.lines.push(line);
|
|
12615
|
-
});
|
|
12616
|
-
}
|
|
12617
|
-
const markupTexts = this.getMarkupTexts();
|
|
12618
|
-
if (markupTexts && markupTexts.length > 0) {
|
|
12619
|
-
markupTexts === null || markupTexts === void 0 ? void 0 : markupTexts.forEach((text) => {
|
|
12620
|
-
viewpoint.texts.push(text);
|
|
12621
|
-
});
|
|
12622
|
-
}
|
|
12623
|
-
const markupRectangles = this.getMarkupRectangles();
|
|
12624
|
-
if (markupRectangles && markupRectangles.length > 0) {
|
|
12625
|
-
markupRectangles === null || markupRectangles === void 0 ? void 0 : markupRectangles.forEach((rectangle) => {
|
|
12626
|
-
viewpoint.rectangles.push(rectangle);
|
|
12627
|
-
});
|
|
12628
|
-
}
|
|
12629
|
-
const markupEllipses = this.getMarkupEllipses();
|
|
12630
|
-
if (markupEllipses && markupEllipses.length > 0) {
|
|
12631
|
-
markupEllipses === null || markupEllipses === void 0 ? void 0 : markupEllipses.forEach((ellipse) => {
|
|
12632
|
-
viewpoint.ellipses.push(ellipse);
|
|
12633
|
-
});
|
|
12634
|
-
}
|
|
12635
|
-
const markupArrows = this.getMarkupArrows();
|
|
12636
|
-
if (markupArrows && markupArrows.length > 0) {
|
|
12637
|
-
markupArrows === null || markupArrows === void 0 ? void 0 : markupArrows.forEach((arrow) => {
|
|
12638
|
-
viewpoint.arrows.push(arrow);
|
|
12639
|
-
});
|
|
12640
|
-
}
|
|
12641
|
-
const markupImages = this.getMarkupImages();
|
|
12642
|
-
if (markupImages && markupImages.length > 0) {
|
|
12643
|
-
markupImages === null || markupImages === void 0 ? void 0 : markupImages.forEach((image) => {
|
|
12644
|
-
viewpoint.images.push(image);
|
|
12645
|
-
});
|
|
12646
|
-
}
|
|
12647
|
-
const markupClouds = this.getMarkupClouds();
|
|
12648
|
-
if (markupClouds && markupClouds.length > 0) {
|
|
12649
|
-
markupClouds === null || markupClouds === void 0 ? void 0 : markupClouds.forEach((cloud) => {
|
|
12650
|
-
viewpoint.clouds.push(cloud);
|
|
12651
|
-
});
|
|
12652
|
-
}
|
|
12653
|
-
}
|
|
12654
12629
|
addObject(object) {
|
|
12655
12630
|
this._konvaLayer.add(object.ref());
|
|
12656
12631
|
}
|
|
@@ -12885,12 +12860,12 @@
|
|
|
12885
12860
|
}
|
|
12886
12861
|
getMarkupLines() {
|
|
12887
12862
|
const lines = [];
|
|
12888
|
-
this.konvaLayerFind("Line").forEach((
|
|
12889
|
-
const linePoints =
|
|
12863
|
+
this.konvaLayerFind("Line").forEach((ref) => {
|
|
12864
|
+
const linePoints = ref.points();
|
|
12890
12865
|
if (!linePoints)
|
|
12891
12866
|
return;
|
|
12892
12867
|
const worldPoints = [];
|
|
12893
|
-
const absoluteTransform =
|
|
12868
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
12894
12869
|
for (let i = 0; i < linePoints.length; i += 2) {
|
|
12895
12870
|
// we need getAbsoluteTransform because inside Konva position starts from {0, 0}
|
|
12896
12871
|
// https://stackoverflow.com/a/57641487 - check answer's comments
|
|
@@ -12898,14 +12873,15 @@
|
|
|
12898
12873
|
const worldPoint = this._worldTransformer.screenToWorld(atPoint);
|
|
12899
12874
|
worldPoints.push(worldPoint);
|
|
12900
12875
|
}
|
|
12901
|
-
const konvaLine = new KonvaLine(null,
|
|
12902
|
-
|
|
12876
|
+
const konvaLine = new KonvaLine(null, ref);
|
|
12877
|
+
const line = {
|
|
12903
12878
|
id: konvaLine.id(),
|
|
12904
12879
|
points: worldPoints,
|
|
12905
12880
|
color: konvaLine.getColor() || "#ff0000",
|
|
12906
12881
|
type: konvaLine.getLineType() || this.lineType,
|
|
12907
12882
|
width: konvaLine.getLineWidth() || this.lineWidth,
|
|
12908
|
-
}
|
|
12883
|
+
};
|
|
12884
|
+
lines.push(line);
|
|
12909
12885
|
});
|
|
12910
12886
|
return lines;
|
|
12911
12887
|
}
|
|
@@ -12913,13 +12889,11 @@
|
|
|
12913
12889
|
const texts = [];
|
|
12914
12890
|
const textSize = 0.02;
|
|
12915
12891
|
const textScale = this._worldTransformer.getScale();
|
|
12916
|
-
this.konvaLayerFind("Text").forEach((
|
|
12917
|
-
|
|
12918
|
-
return;
|
|
12919
|
-
const position = { x: text.x(), y: text.y() };
|
|
12892
|
+
this.konvaLayerFind("Text").forEach((ref) => {
|
|
12893
|
+
const position = { x: ref.x(), y: ref.y() };
|
|
12920
12894
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
12921
|
-
const shape = new KonvaText(null,
|
|
12922
|
-
|
|
12895
|
+
const shape = new KonvaText(null, ref);
|
|
12896
|
+
const text = {
|
|
12923
12897
|
id: shape.id(),
|
|
12924
12898
|
position: worldPoint,
|
|
12925
12899
|
text: shape.getText(),
|
|
@@ -12927,132 +12901,101 @@
|
|
|
12927
12901
|
angle: shape.getRotation(),
|
|
12928
12902
|
color: shape.getColor(),
|
|
12929
12903
|
font_size: shape.getFontSize(),
|
|
12930
|
-
}
|
|
12904
|
+
};
|
|
12905
|
+
texts.push(text);
|
|
12931
12906
|
});
|
|
12932
12907
|
return texts;
|
|
12933
12908
|
}
|
|
12934
12909
|
getMarkupRectangles() {
|
|
12935
12910
|
const rectangles = [];
|
|
12936
|
-
this.konvaLayerFind("Rectangle").forEach((
|
|
12937
|
-
const position =
|
|
12911
|
+
this.konvaLayerFind("Rectangle").forEach((ref) => {
|
|
12912
|
+
const position = ref.position();
|
|
12938
12913
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
12939
|
-
const shape = new KonvaRectangle(null,
|
|
12940
|
-
|
|
12914
|
+
const shape = new KonvaRectangle(null, ref);
|
|
12915
|
+
const rectangle = {
|
|
12941
12916
|
id: shape.id(),
|
|
12942
12917
|
position: worldPoint,
|
|
12943
12918
|
width: shape.getWidth(),
|
|
12944
12919
|
height: shape.getHeigth(),
|
|
12945
12920
|
line_width: shape.getLineWidth(),
|
|
12946
12921
|
color: shape.getColor(),
|
|
12947
|
-
}
|
|
12922
|
+
};
|
|
12923
|
+
rectangles.push(rectangle);
|
|
12948
12924
|
});
|
|
12949
12925
|
return rectangles;
|
|
12950
12926
|
}
|
|
12951
12927
|
getMarkupEllipses() {
|
|
12952
12928
|
const ellipses = [];
|
|
12953
|
-
this.konvaLayerFind("Ellipse").forEach((
|
|
12954
|
-
const position =
|
|
12929
|
+
this.konvaLayerFind("Ellipse").forEach((ref) => {
|
|
12930
|
+
const position = ref.position();
|
|
12955
12931
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
12956
|
-
const shape = new KonvaEllipse(null,
|
|
12957
|
-
|
|
12932
|
+
const shape = new KonvaEllipse(null, ref);
|
|
12933
|
+
const ellipse = {
|
|
12958
12934
|
id: shape.id(),
|
|
12959
12935
|
position: worldPoint,
|
|
12960
|
-
radius: { x:
|
|
12936
|
+
radius: { x: ref.getRadiusX(), y: ref.getRadiusY() },
|
|
12961
12937
|
line_width: shape.getLineWidth(),
|
|
12962
12938
|
color: shape.getColor(),
|
|
12963
|
-
}
|
|
12939
|
+
};
|
|
12940
|
+
ellipses.push(ellipse);
|
|
12964
12941
|
});
|
|
12965
12942
|
return ellipses;
|
|
12966
12943
|
}
|
|
12967
12944
|
getMarkupArrows() {
|
|
12968
12945
|
const arrows = [];
|
|
12969
|
-
this.konvaLayerFind("Arrow").forEach((
|
|
12946
|
+
this.konvaLayerFind("Arrow").forEach((ref) => {
|
|
12970
12947
|
// we need getAbsoluteTransform because inside Konva position starts from {0, 0}
|
|
12971
|
-
const absoluteTransform =
|
|
12972
|
-
const atStartPoint = absoluteTransform.point({ x:
|
|
12948
|
+
const absoluteTransform = ref.getAbsoluteTransform();
|
|
12949
|
+
const atStartPoint = absoluteTransform.point({ x: ref.points()[0], y: ref.points()[1] });
|
|
12973
12950
|
const worldStartPoint = this._worldTransformer.screenToWorld(atStartPoint);
|
|
12974
|
-
const atEndPoint = absoluteTransform.point({ x:
|
|
12951
|
+
const atEndPoint = absoluteTransform.point({ x: ref.points()[2], y: ref.points()[3] });
|
|
12975
12952
|
const worldEndPoint = this._worldTransformer.screenToWorld(atEndPoint);
|
|
12976
|
-
const shape = new KonvaArrow(null,
|
|
12977
|
-
|
|
12953
|
+
const shape = new KonvaArrow(null, ref);
|
|
12954
|
+
const arrow = {
|
|
12978
12955
|
id: shape.id(),
|
|
12979
12956
|
start: worldStartPoint,
|
|
12980
12957
|
end: worldEndPoint,
|
|
12981
12958
|
color: shape.getColor(),
|
|
12982
|
-
}
|
|
12959
|
+
};
|
|
12960
|
+
arrows.push(arrow);
|
|
12983
12961
|
});
|
|
12984
12962
|
return arrows;
|
|
12985
12963
|
}
|
|
12986
12964
|
getMarkupImages() {
|
|
12987
12965
|
const images = [];
|
|
12988
|
-
this.konvaLayerFind("Image").forEach((
|
|
12989
|
-
const position =
|
|
12966
|
+
this.konvaLayerFind("Image").forEach((ref) => {
|
|
12967
|
+
const position = ref.position();
|
|
12990
12968
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
12991
|
-
const shape = new KonvaImage(null,
|
|
12992
|
-
|
|
12969
|
+
const shape = new KonvaImage(null, ref);
|
|
12970
|
+
const image = {
|
|
12993
12971
|
id: shape.id(),
|
|
12994
12972
|
position: worldPoint,
|
|
12995
12973
|
src: shape.getSrc(),
|
|
12996
12974
|
width: shape.getWidth(),
|
|
12997
12975
|
height: shape.getHeight(),
|
|
12998
|
-
}
|
|
12976
|
+
};
|
|
12977
|
+
images.push(image);
|
|
12999
12978
|
});
|
|
13000
12979
|
return images;
|
|
13001
12980
|
}
|
|
13002
12981
|
getMarkupClouds() {
|
|
13003
12982
|
const clouds = [];
|
|
13004
|
-
this.konvaLayerFind("Cloud").forEach((
|
|
13005
|
-
const position =
|
|
12983
|
+
this.konvaLayerFind("Cloud").forEach((ref) => {
|
|
12984
|
+
const position = ref.position();
|
|
13006
12985
|
const worldPoint = this._worldTransformer.screenToWorld(position);
|
|
13007
|
-
const shape = new KonvaCloud(null,
|
|
13008
|
-
|
|
12986
|
+
const shape = new KonvaCloud(null, ref);
|
|
12987
|
+
const cloud = {
|
|
13009
12988
|
id: shape.id(),
|
|
13010
12989
|
position: worldPoint,
|
|
13011
12990
|
width: shape.getWidth(),
|
|
13012
12991
|
height: shape.getHeigth(),
|
|
13013
12992
|
line_width: shape.getLineWidth(),
|
|
13014
12993
|
color: shape.getColor(),
|
|
13015
|
-
}
|
|
12994
|
+
};
|
|
12995
|
+
clouds.push(cloud);
|
|
13016
12996
|
});
|
|
13017
12997
|
return clouds;
|
|
13018
12998
|
}
|
|
13019
|
-
loadMarkup(viewpoint) {
|
|
13020
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
13021
|
-
(_a = viewpoint.lines) === null || _a === void 0 ? void 0 : _a.forEach((vpLine) => {
|
|
13022
|
-
const linePoints = [];
|
|
13023
|
-
vpLine.points.forEach((point) => {
|
|
13024
|
-
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
13025
|
-
linePoints.push(screenPoint.x);
|
|
13026
|
-
linePoints.push(screenPoint.y);
|
|
13027
|
-
});
|
|
13028
|
-
this.addLine(linePoints, vpLine.color, vpLine.type, vpLine.width, vpLine.id);
|
|
13029
|
-
});
|
|
13030
|
-
(_b = viewpoint.texts) === null || _b === void 0 ? void 0 : _b.forEach((vpText) => {
|
|
13031
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpText.position);
|
|
13032
|
-
this.addText(vpText.text, screenPoint, vpText.angle, vpText.color, vpText.text_size, vpText.font_size, vpText.id);
|
|
13033
|
-
});
|
|
13034
|
-
(_c = viewpoint.rectangles) === null || _c === void 0 ? void 0 : _c.forEach((vpRect) => {
|
|
13035
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpRect.position);
|
|
13036
|
-
this.addRectangle(screenPoint, vpRect.width, vpRect.height, vpRect.line_width, vpRect.color, vpRect.id);
|
|
13037
|
-
});
|
|
13038
|
-
(_d = viewpoint.ellipses) === null || _d === void 0 ? void 0 : _d.forEach((vpEllipse) => {
|
|
13039
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpEllipse.position);
|
|
13040
|
-
this.addEllipse(screenPoint, vpEllipse.radius, vpEllipse.line_width, vpEllipse.color, vpEllipse.id);
|
|
13041
|
-
});
|
|
13042
|
-
(_e = viewpoint.arrows) === null || _e === void 0 ? void 0 : _e.forEach((vpArrow) => {
|
|
13043
|
-
const startPoint = this._worldTransformer.worldToScreen(vpArrow.start);
|
|
13044
|
-
const endPoint = this._worldTransformer.worldToScreen(vpArrow.end);
|
|
13045
|
-
this.addArrow(startPoint, endPoint, vpArrow.color, vpArrow.id);
|
|
13046
|
-
});
|
|
13047
|
-
(_f = viewpoint.clouds) === null || _f === void 0 ? void 0 : _f.forEach((vpCloud) => {
|
|
13048
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpCloud.position);
|
|
13049
|
-
this.addCloud(screenPoint, vpCloud.width, vpCloud.height, vpCloud.line_width, vpCloud.color, vpCloud.id);
|
|
13050
|
-
});
|
|
13051
|
-
(_g = viewpoint.images) === null || _g === void 0 ? void 0 : _g.forEach((vpImage) => {
|
|
13052
|
-
const screenPoint = this._worldTransformer.worldToScreen(vpImage.position);
|
|
13053
|
-
this.addImage(screenPoint, vpImage.src, vpImage.width, vpImage.height, vpImage.id);
|
|
13054
|
-
});
|
|
13055
|
-
}
|
|
13056
12999
|
combineMarkupWithDrawing() {
|
|
13057
13000
|
this.clearSelected();
|
|
13058
13001
|
const tempCanvas = document.createElement("canvas");
|
|
@@ -13078,8 +13021,7 @@
|
|
|
13078
13021
|
color: color || this._markupColor.HexColor,
|
|
13079
13022
|
id,
|
|
13080
13023
|
});
|
|
13081
|
-
|
|
13082
|
-
this._konvaLayer.add(obj);
|
|
13024
|
+
this._konvaLayer.add(konvaLine.ref());
|
|
13083
13025
|
return konvaLine;
|
|
13084
13026
|
}
|
|
13085
13027
|
createTextInput(pos, inputX, inputY, angle, text) {
|
|
@@ -13163,6 +13105,8 @@
|
|
|
13163
13105
|
this._imageInputPos = null;
|
|
13164
13106
|
}
|
|
13165
13107
|
addText(specifiedText, position, angle, color, textSize, fontSize, id) {
|
|
13108
|
+
if (!specifiedText)
|
|
13109
|
+
return;
|
|
13166
13110
|
const trNodes = this._konvaTransformer.nodes();
|
|
13167
13111
|
if (trNodes.length > 0) {
|
|
13168
13112
|
// in case of edit - remove old Konva.Text object
|
|
@@ -13170,25 +13114,23 @@
|
|
|
13170
13114
|
this._konvaTransformer.nodes([]);
|
|
13171
13115
|
}
|
|
13172
13116
|
this.removeTextInput();
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
return konvaText;
|
|
13191
|
-
}
|
|
13117
|
+
// in case we have old viewpoint without font_size
|
|
13118
|
+
const tolerance = 1.0e-6;
|
|
13119
|
+
if (textSize && textSize > tolerance && (!fontSize || fontSize < tolerance)) {
|
|
13120
|
+
const size = 0.02;
|
|
13121
|
+
const scale = this._worldTransformer.getScale();
|
|
13122
|
+
fontSize = textSize / (scale.y / size) / 34;
|
|
13123
|
+
}
|
|
13124
|
+
const konvaText = new KonvaText({
|
|
13125
|
+
position: { x: position.x, y: position.y },
|
|
13126
|
+
text: specifiedText,
|
|
13127
|
+
rotation: angle,
|
|
13128
|
+
fontSize: fontSize || this.fontSize,
|
|
13129
|
+
color: color || this._markupColor.HexColor,
|
|
13130
|
+
id,
|
|
13131
|
+
});
|
|
13132
|
+
this._konvaLayer.add(konvaText.ref());
|
|
13133
|
+
return konvaText;
|
|
13192
13134
|
}
|
|
13193
13135
|
addRectangle(position, width, height, lineWidth, color, id) {
|
|
13194
13136
|
if (!position)
|
|
@@ -13201,8 +13143,7 @@
|
|
|
13201
13143
|
color: color || this._markupColor.HexColor,
|
|
13202
13144
|
id,
|
|
13203
13145
|
});
|
|
13204
|
-
|
|
13205
|
-
this._konvaLayer.add(obj);
|
|
13146
|
+
this._konvaLayer.add(konvaRectangle.ref());
|
|
13206
13147
|
return konvaRectangle;
|
|
13207
13148
|
}
|
|
13208
13149
|
addEllipse(position, radius, lineWidth, color, id) {
|
|
@@ -13215,8 +13156,7 @@
|
|
|
13215
13156
|
color: color || this._markupColor.HexColor,
|
|
13216
13157
|
id,
|
|
13217
13158
|
});
|
|
13218
|
-
|
|
13219
|
-
this._konvaLayer.add(obj);
|
|
13159
|
+
this._konvaLayer.add(konvaEllipse.ref());
|
|
13220
13160
|
return konvaEllipse;
|
|
13221
13161
|
}
|
|
13222
13162
|
addArrow(start, end, color, id) {
|
|
@@ -13228,8 +13168,7 @@
|
|
|
13228
13168
|
color: color || this._markupColor.HexColor,
|
|
13229
13169
|
id,
|
|
13230
13170
|
});
|
|
13231
|
-
|
|
13232
|
-
this._konvaLayer.add(obj);
|
|
13171
|
+
this._konvaLayer.add(konvaArrow.ref());
|
|
13233
13172
|
return konvaArrow;
|
|
13234
13173
|
}
|
|
13235
13174
|
addCloud(position, width, height, lineWidth, color, id) {
|
|
@@ -13243,32 +13182,27 @@
|
|
|
13243
13182
|
lineWidth: lineWidth || this.lineWidth,
|
|
13244
13183
|
id,
|
|
13245
13184
|
});
|
|
13246
|
-
|
|
13247
|
-
this._konvaLayer.add(obj);
|
|
13185
|
+
this._konvaLayer.add(konvaCloud.ref());
|
|
13248
13186
|
return konvaCloud;
|
|
13249
13187
|
}
|
|
13250
13188
|
addImage(position, src, width, height, id) {
|
|
13251
|
-
if (!position)
|
|
13189
|
+
if (!position || !src)
|
|
13252
13190
|
return;
|
|
13253
|
-
|
|
13254
|
-
if (
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
width,
|
|
13259
|
-
height,
|
|
13260
|
-
id,
|
|
13261
|
-
});
|
|
13262
|
-
const obj = konvaImage.ref();
|
|
13263
|
-
this._konvaLayer.add(obj);
|
|
13264
|
-
const trNodes = this._konvaTransformer.nodes();
|
|
13265
|
-
if (trNodes.length > 0) {
|
|
13266
|
-
// in case of edit - remove old Image placeholder object
|
|
13267
|
-
trNodes[0].destroy();
|
|
13268
|
-
this._konvaTransformer.nodes([]);
|
|
13269
|
-
}
|
|
13191
|
+
const trNodes = this._konvaTransformer.nodes();
|
|
13192
|
+
if (trNodes.length > 0) {
|
|
13193
|
+
// in case of edit - remove old Image placeholder object
|
|
13194
|
+
trNodes[0].destroy();
|
|
13195
|
+
this._konvaTransformer.nodes([]);
|
|
13270
13196
|
}
|
|
13271
13197
|
this.removeImageInput();
|
|
13198
|
+
const konvaImage = new KonvaImage({
|
|
13199
|
+
position,
|
|
13200
|
+
src,
|
|
13201
|
+
width,
|
|
13202
|
+
height,
|
|
13203
|
+
id,
|
|
13204
|
+
});
|
|
13205
|
+
this._konvaLayer.add(konvaImage.ref());
|
|
13272
13206
|
return konvaImage;
|
|
13273
13207
|
}
|
|
13274
13208
|
}
|