@inweb/viewer-visualize 25.7.6 → 25.7.8
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
|
@@ -13049,7 +13049,7 @@
|
|
|
13049
13049
|
this.fontSize = 34;
|
|
13050
13050
|
this.changeActiveDragger = event => {
|
|
13051
13051
|
const draggerName = event.data;
|
|
13052
|
-
this._markupContainer.className = this.
|
|
13052
|
+
this._markupContainer.className = this._container.className.split(" ").filter((x => !x.startsWith("oda-cursor-"))).filter((x => x)).concat(`oda-cursor-${draggerName.toLowerCase()}`).join(" ");
|
|
13053
13053
|
this.removeTextInput();
|
|
13054
13054
|
this.removeImageInput();
|
|
13055
13055
|
const konvaShape = MarkupMode2Konva[draggerName];
|
|
@@ -13061,10 +13061,12 @@
|
|
|
13061
13061
|
this._konvaTransformer.nodes([]);
|
|
13062
13062
|
}
|
|
13063
13063
|
};
|
|
13064
|
-
this.
|
|
13064
|
+
this.resizeContainer = entries => {
|
|
13065
13065
|
var _a, _b;
|
|
13066
|
-
|
|
13067
|
-
(
|
|
13066
|
+
const {width: width, height: height} = entries[0].contentRect;
|
|
13067
|
+
if (!width || !height) return;
|
|
13068
|
+
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.width(width);
|
|
13069
|
+
(_b = this._konvaStage) === null || _b === void 0 ? void 0 : _b.height(height);
|
|
13068
13070
|
};
|
|
13069
13071
|
this.pan = event => {
|
|
13070
13072
|
const dX = event.dX / window.devicePixelRatio;
|
|
@@ -13078,26 +13080,26 @@
|
|
|
13078
13080
|
if (this._viewer) this._viewer.emit(event);
|
|
13079
13081
|
};
|
|
13080
13082
|
}
|
|
13081
|
-
initialize(
|
|
13083
|
+
initialize(container, pointerEvents, viewer, worldTransformer) {
|
|
13082
13084
|
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>');
|
|
13083
13085
|
this._viewer = viewer;
|
|
13084
13086
|
this._worldTransformer = worldTransformer;
|
|
13085
|
-
this.
|
|
13086
|
-
this.
|
|
13087
|
+
this._container = container;
|
|
13088
|
+
this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
|
|
13087
13089
|
this._markupContainer = document.createElement("div");
|
|
13088
13090
|
this._markupContainer.id = this._markupContainerName;
|
|
13089
13091
|
this._markupContainer.style.position = "absolute";
|
|
13090
13092
|
this._markupContainer.style.top = "0px";
|
|
13091
13093
|
this._markupContainer.style.left = "0px";
|
|
13092
13094
|
this._markupContainer.style.outline = "0px";
|
|
13093
|
-
const parentDiv = this.
|
|
13095
|
+
const parentDiv = this._container.parentElement;
|
|
13094
13096
|
parentDiv.appendChild(this._markupContainer);
|
|
13097
|
+
this._resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
13098
|
+
this._resizeObserver.observe(parentDiv);
|
|
13095
13099
|
this._markupColor.setColor(255, 0, 0);
|
|
13096
13100
|
this.initializeKonva();
|
|
13097
|
-
this.resize();
|
|
13098
|
-
this._canvasEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
13099
13101
|
if (this._viewer) {
|
|
13100
|
-
this.
|
|
13102
|
+
this._pointerEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
13101
13103
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
13102
13104
|
this._viewer.addEventListener("pan", this.pan);
|
|
13103
13105
|
}
|
|
@@ -13108,13 +13110,14 @@
|
|
|
13108
13110
|
if (this._viewer) {
|
|
13109
13111
|
this._viewer.removeEventListener("pan", this.pan);
|
|
13110
13112
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
13111
|
-
this._viewer.removeEventListener("resize", this.resize);
|
|
13112
13113
|
}
|
|
13113
|
-
this.
|
|
13114
|
+
this._pointerEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
|
|
13114
13115
|
this.destroyKonva();
|
|
13116
|
+
this._resizeObserver.disconnect();
|
|
13117
|
+
this._resizeObserver = undefined;
|
|
13115
13118
|
this._markupContainer.remove();
|
|
13116
13119
|
this._markupContainer = undefined;
|
|
13117
|
-
this.
|
|
13120
|
+
this._container = undefined;
|
|
13118
13121
|
this._viewer = undefined;
|
|
13119
13122
|
this._worldTransformer = undefined;
|
|
13120
13123
|
this._markupIsActive = false;
|
|
@@ -13358,8 +13361,8 @@
|
|
|
13358
13361
|
initializeKonva() {
|
|
13359
13362
|
this._konvaStage = new Konva.Stage({
|
|
13360
13363
|
container: this._markupContainerName,
|
|
13361
|
-
width: this.
|
|
13362
|
-
height: this.
|
|
13364
|
+
width: this._container.clientWidth,
|
|
13365
|
+
height: this._container.clientHeight
|
|
13363
13366
|
});
|
|
13364
13367
|
const stage = this._konvaStage;
|
|
13365
13368
|
const layer = new Konva.Layer({
|
|
@@ -13753,15 +13756,12 @@
|
|
|
13753
13756
|
}));
|
|
13754
13757
|
}
|
|
13755
13758
|
combineMarkupWithDrawing() {
|
|
13756
|
-
|
|
13757
|
-
if (trNodes.length > 0) {
|
|
13758
|
-
this._konvaTransformer.nodes([]);
|
|
13759
|
-
}
|
|
13759
|
+
this.clearSelected();
|
|
13760
13760
|
const tempCanvas = document.createElement("canvas");
|
|
13761
|
-
tempCanvas.
|
|
13762
|
-
tempCanvas.
|
|
13761
|
+
tempCanvas.width = this._konvaStage.width();
|
|
13762
|
+
tempCanvas.height = this._konvaStage.height();
|
|
13763
13763
|
const ctx = tempCanvas.getContext("2d");
|
|
13764
|
-
ctx.drawImage(this.
|
|
13764
|
+
if (this._container instanceof HTMLCanvasElement) ctx.drawImage(this._container, 0, 0);
|
|
13765
13765
|
ctx.drawImage(this._konvaStage.toCanvas({
|
|
13766
13766
|
pixelRatio: window.devicePixelRatio
|
|
13767
13767
|
}), 0, 0);
|