@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.
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];
|
|
@@ -13063,8 +13063,8 @@
|
|
|
13063
13063
|
};
|
|
13064
13064
|
this.resize = () => {
|
|
13065
13065
|
var _a, _b;
|
|
13066
|
-
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.width(this.
|
|
13067
|
-
(_b = this._konvaStage) === null || _b === void 0 ? void 0 : _b.height(this.
|
|
13066
|
+
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.width(this._container.clientWidth);
|
|
13067
|
+
(_b = this._konvaStage) === null || _b === void 0 ? void 0 : _b.height(this._container.clientHeight);
|
|
13068
13068
|
};
|
|
13069
13069
|
this.pan = event => {
|
|
13070
13070
|
const dX = event.dX / window.devicePixelRatio;
|
|
@@ -13078,25 +13078,25 @@
|
|
|
13078
13078
|
if (this._viewer) this._viewer.emit(event);
|
|
13079
13079
|
};
|
|
13080
13080
|
}
|
|
13081
|
-
initialize(
|
|
13081
|
+
initialize(container, pointerEvents, viewer, worldTransformer) {
|
|
13082
13082
|
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
13083
|
this._viewer = viewer;
|
|
13084
13084
|
this._worldTransformer = worldTransformer;
|
|
13085
|
-
this.
|
|
13086
|
-
this.
|
|
13085
|
+
this._container = container;
|
|
13086
|
+
this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
|
|
13087
13087
|
this._markupContainer = document.createElement("div");
|
|
13088
13088
|
this._markupContainer.id = this._markupContainerName;
|
|
13089
13089
|
this._markupContainer.style.position = "absolute";
|
|
13090
13090
|
this._markupContainer.style.top = "0px";
|
|
13091
13091
|
this._markupContainer.style.left = "0px";
|
|
13092
13092
|
this._markupContainer.style.outline = "0px";
|
|
13093
|
-
const parentDiv = this.
|
|
13093
|
+
const parentDiv = this._container.parentElement;
|
|
13094
13094
|
parentDiv.appendChild(this._markupContainer);
|
|
13095
13095
|
this._markupColor.setColor(255, 0, 0);
|
|
13096
13096
|
this.initializeKonva();
|
|
13097
13097
|
this.resize();
|
|
13098
|
-
this._canvasEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
13099
13098
|
if (this._viewer) {
|
|
13099
|
+
this._pointerEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
|
|
13100
13100
|
this._viewer.addEventListener("resize", this.resize);
|
|
13101
13101
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
13102
13102
|
this._viewer.addEventListener("pan", this.pan);
|
|
@@ -13110,11 +13110,11 @@
|
|
|
13110
13110
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
13111
13111
|
this._viewer.removeEventListener("resize", this.resize);
|
|
13112
13112
|
}
|
|
13113
|
-
this.
|
|
13113
|
+
this._pointerEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
|
|
13114
13114
|
this.destroyKonva();
|
|
13115
13115
|
this._markupContainer.remove();
|
|
13116
13116
|
this._markupContainer = undefined;
|
|
13117
|
-
this.
|
|
13117
|
+
this._container = undefined;
|
|
13118
13118
|
this._viewer = undefined;
|
|
13119
13119
|
this._worldTransformer = undefined;
|
|
13120
13120
|
this._markupIsActive = false;
|
|
@@ -13358,8 +13358,8 @@
|
|
|
13358
13358
|
initializeKonva() {
|
|
13359
13359
|
this._konvaStage = new Konva.Stage({
|
|
13360
13360
|
container: this._markupContainerName,
|
|
13361
|
-
width: this.
|
|
13362
|
-
height: this.
|
|
13361
|
+
width: this._container.clientWidth,
|
|
13362
|
+
height: this._container.clientHeight
|
|
13363
13363
|
});
|
|
13364
13364
|
const stage = this._konvaStage;
|
|
13365
13365
|
const layer = new Konva.Layer({
|
|
@@ -13753,15 +13753,12 @@
|
|
|
13753
13753
|
}));
|
|
13754
13754
|
}
|
|
13755
13755
|
combineMarkupWithDrawing() {
|
|
13756
|
-
|
|
13757
|
-
if (trNodes.length > 0) {
|
|
13758
|
-
this._konvaTransformer.nodes([]);
|
|
13759
|
-
}
|
|
13756
|
+
this.clearSelected();
|
|
13760
13757
|
const tempCanvas = document.createElement("canvas");
|
|
13761
|
-
tempCanvas.
|
|
13762
|
-
tempCanvas.
|
|
13758
|
+
tempCanvas.width = this._konvaStage.width();
|
|
13759
|
+
tempCanvas.height = this._konvaStage.height();
|
|
13763
13760
|
const ctx = tempCanvas.getContext("2d");
|
|
13764
|
-
ctx.drawImage(this.
|
|
13761
|
+
if (this._container instanceof HTMLCanvasElement) ctx.drawImage(this._container, 0, 0);
|
|
13765
13762
|
ctx.drawImage(this._konvaStage.toCanvas({
|
|
13766
13763
|
pixelRatio: window.devicePixelRatio
|
|
13767
13764
|
}), 0, 0);
|