@inweb/viewer-visualize 25.7.5 → 25.7.7
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.
|
@@ -1611,7 +1611,7 @@ class KonvaMarkup {
|
|
|
1611
1611
|
this.fontSize = 34;
|
|
1612
1612
|
this.changeActiveDragger = event => {
|
|
1613
1613
|
const draggerName = event.data;
|
|
1614
|
-
this._markupContainer.className = this.
|
|
1614
|
+
this._markupContainer.className = this._container.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
|
|
1615
1615
|
this.removeTextInput();
|
|
1616
1616
|
this.removeImageInput();
|
|
1617
1617
|
const konvaShape = MarkupMode2Konva[draggerName];
|
|
@@ -1625,8 +1625,8 @@ class KonvaMarkup {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
this.resize = () => {
|
|
1627
1627
|
var _a, _b;
|
|
1628
|
-
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.width(this.
|
|
1629
|
-
(_b = this._konvaStage) === null || _b === void 0 ? void 0 : _b.height(this.
|
|
1628
|
+
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.width(this._container.clientWidth);
|
|
1629
|
+
(_b = this._konvaStage) === null || _b === void 0 ? void 0 : _b.height(this._container.clientHeight);
|
|
1630
1630
|
};
|
|
1631
1631
|
this.pan = event => {
|
|
1632
1632
|
const dX = event.dX / window.devicePixelRatio;
|
|
@@ -1640,25 +1640,25 @@ class KonvaMarkup {
|
|
|
1640
1640
|
if (this._viewer) this._viewer.emit(event);
|
|
1641
1641
|
};
|
|
1642
1642
|
}
|
|
1643
|
-
initialize(
|
|
1643
|
+
initialize(container, pointerEvents, viewer, worldTransformer) {
|
|
1644
1644
|
if (!Konva) throw new Error('Markup: Error during initialization. Konva is not initialized. Update node_modules or add to your page <script src="https://unpkg.com/konva@9/konva.min.js"><\/script>');
|
|
1645
1645
|
this._viewer = viewer;
|
|
1646
1646
|
this._worldTransformer = worldTransformer;
|
|
1647
|
-
this.
|
|
1648
|
-
this.
|
|
1647
|
+
this._container = container;
|
|
1648
|
+
this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
|
|
1649
1649
|
this._markupContainer = document.createElement("div");
|
|
1650
1650
|
this._markupContainer.id = this._markupContainerName;
|
|
1651
1651
|
this._markupContainer.style.position = "absolute";
|
|
1652
1652
|
this._markupContainer.style.top = "0px";
|
|
1653
1653
|
this._markupContainer.style.left = "0px";
|
|
1654
1654
|
this._markupContainer.style.outline = "0px";
|
|
1655
|
-
const parentDiv = this.
|
|
1655
|
+
const parentDiv = this._container.parentElement;
|
|
1656
1656
|
parentDiv.appendChild(this._markupContainer);
|
|
1657
1657
|
this._markupColor.setColor(255, 0, 0);
|
|
1658
1658
|
this.initializeKonva();
|
|
1659
1659
|
this.resize();
|
|
1660
|
-
this._canvasEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
1661
1660
|
if (this._viewer) {
|
|
1661
|
+
this._pointerEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
1662
1662
|
this._viewer.addEventListener("resize", this.resize);
|
|
1663
1663
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
1664
1664
|
this._viewer.addEventListener("pan", this.pan);
|
|
@@ -1672,11 +1672,11 @@ class KonvaMarkup {
|
|
|
1672
1672
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
1673
1673
|
this._viewer.removeEventListener("resize", this.resize);
|
|
1674
1674
|
}
|
|
1675
|
-
this.
|
|
1675
|
+
this._pointerEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
|
|
1676
1676
|
this.destroyKonva();
|
|
1677
1677
|
this._markupContainer.remove();
|
|
1678
1678
|
this._markupContainer = undefined;
|
|
1679
|
-
this.
|
|
1679
|
+
this._container = undefined;
|
|
1680
1680
|
this._viewer = undefined;
|
|
1681
1681
|
this._worldTransformer = undefined;
|
|
1682
1682
|
this._markupIsActive = false;
|
|
@@ -1920,8 +1920,8 @@ class KonvaMarkup {
|
|
|
1920
1920
|
initializeKonva() {
|
|
1921
1921
|
this._konvaStage = new Konva.Stage({
|
|
1922
1922
|
container: this._markupContainerName,
|
|
1923
|
-
width: this.
|
|
1924
|
-
height: this.
|
|
1923
|
+
width: this._container.clientWidth,
|
|
1924
|
+
height: this._container.clientHeight
|
|
1925
1925
|
});
|
|
1926
1926
|
const stage = this._konvaStage;
|
|
1927
1927
|
const layer = new Konva.Layer({
|
|
@@ -2315,15 +2315,12 @@ class KonvaMarkup {
|
|
|
2315
2315
|
}));
|
|
2316
2316
|
}
|
|
2317
2317
|
combineMarkupWithDrawing() {
|
|
2318
|
-
|
|
2319
|
-
if (trNodes.length > 0) {
|
|
2320
|
-
this._konvaTransformer.nodes([]);
|
|
2321
|
-
}
|
|
2318
|
+
this.clearSelected();
|
|
2322
2319
|
const tempCanvas = document.createElement("canvas");
|
|
2323
|
-
tempCanvas.
|
|
2324
|
-
tempCanvas.
|
|
2320
|
+
tempCanvas.width = this._konvaStage.width();
|
|
2321
|
+
tempCanvas.height = this._konvaStage.height();
|
|
2325
2322
|
const ctx = tempCanvas.getContext("2d");
|
|
2326
|
-
ctx.drawImage(this.
|
|
2323
|
+
if (this._container instanceof HTMLCanvasElement) ctx.drawImage(this._container, 0, 0);
|
|
2327
2324
|
ctx.drawImage(this._konvaStage.toCanvas({
|
|
2328
2325
|
pixelRatio: window.devicePixelRatio
|
|
2329
2326
|
}), 0, 0);
|