@inweb/markup 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/markup.js +25 -23
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +23 -23
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/IMarkup.d.ts +15 -14
- package/lib/markup/Konva/KonvaMarkup.d.ts +5 -4
- package/package.json +3 -3
- package/src/markup/IMarkup.ts +14 -13
- package/src/markup/Konva/KonvaMarkup.ts +33 -27
package/dist/markup.js
CHANGED
|
@@ -12389,7 +12389,7 @@
|
|
|
12389
12389
|
this.fontSize = 34;
|
|
12390
12390
|
this.changeActiveDragger = (event) => {
|
|
12391
12391
|
const draggerName = event.data;
|
|
12392
|
-
this._markupContainer.className = this.
|
|
12392
|
+
this._markupContainer.className = this._container.className
|
|
12393
12393
|
.split(" ")
|
|
12394
12394
|
.filter((x) => !x.startsWith("oda-cursor-"))
|
|
12395
12395
|
.filter((x) => x)
|
|
@@ -12407,10 +12407,13 @@
|
|
|
12407
12407
|
this._konvaTransformer.nodes([]);
|
|
12408
12408
|
}
|
|
12409
12409
|
};
|
|
12410
|
-
this.
|
|
12410
|
+
this.resizeContainer = (entries) => {
|
|
12411
12411
|
var _a, _b;
|
|
12412
|
-
|
|
12413
|
-
(
|
|
12412
|
+
const { width, height } = entries[0].contentRect;
|
|
12413
|
+
if (!width || !height)
|
|
12414
|
+
return; // <- invisible container, or container with parent removed
|
|
12415
|
+
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.width(width);
|
|
12416
|
+
(_b = this._konvaStage) === null || _b === void 0 ? void 0 : _b.height(height);
|
|
12414
12417
|
};
|
|
12415
12418
|
this.pan = (event) => {
|
|
12416
12419
|
const dX = event.dX / window.devicePixelRatio;
|
|
@@ -12422,13 +12425,13 @@
|
|
|
12422
12425
|
this._viewer.emit(event);
|
|
12423
12426
|
};
|
|
12424
12427
|
}
|
|
12425
|
-
initialize(
|
|
12428
|
+
initialize(container, pointerEvents, viewer, worldTransformer) {
|
|
12426
12429
|
if (!Konva)
|
|
12427
12430
|
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>');
|
|
12428
12431
|
this._viewer = viewer;
|
|
12429
12432
|
this._worldTransformer = worldTransformer;
|
|
12430
|
-
this.
|
|
12431
|
-
this.
|
|
12433
|
+
this._container = container;
|
|
12434
|
+
this._pointerEvents = pointerEvents !== null && pointerEvents !== void 0 ? pointerEvents : [];
|
|
12432
12435
|
this._markupContainer = document.createElement("div");
|
|
12433
12436
|
this._markupContainer.id = this._markupContainerName;
|
|
12434
12437
|
this._markupContainer.style.position = "absolute";
|
|
@@ -12436,14 +12439,14 @@
|
|
|
12436
12439
|
this._markupContainer.style.left = "0px";
|
|
12437
12440
|
// to eliminate grey box during delete elements
|
|
12438
12441
|
this._markupContainer.style.outline = "0px";
|
|
12439
|
-
const parentDiv = this.
|
|
12442
|
+
const parentDiv = this._container.parentElement;
|
|
12440
12443
|
parentDiv.appendChild(this._markupContainer);
|
|
12444
|
+
this._resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
12445
|
+
this._resizeObserver.observe(parentDiv);
|
|
12441
12446
|
this._markupColor.setColor(255, 0, 0);
|
|
12442
12447
|
this.initializeKonva();
|
|
12443
|
-
this.resize();
|
|
12444
|
-
this._canvasEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
12445
12448
|
if (this._viewer) {
|
|
12446
|
-
this.
|
|
12449
|
+
this._pointerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
12447
12450
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
12448
12451
|
this._viewer.addEventListener("pan", this.pan);
|
|
12449
12452
|
}
|
|
@@ -12455,13 +12458,14 @@
|
|
|
12455
12458
|
if (this._viewer) {
|
|
12456
12459
|
this._viewer.removeEventListener("pan", this.pan);
|
|
12457
12460
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
12458
|
-
this._viewer.removeEventListener("resize", this.resize);
|
|
12459
12461
|
}
|
|
12460
|
-
this.
|
|
12462
|
+
this._pointerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
|
|
12461
12463
|
this.destroyKonva();
|
|
12464
|
+
this._resizeObserver.disconnect();
|
|
12465
|
+
this._resizeObserver = undefined;
|
|
12462
12466
|
this._markupContainer.remove();
|
|
12463
12467
|
this._markupContainer = undefined;
|
|
12464
|
-
this.
|
|
12468
|
+
this._container = undefined;
|
|
12465
12469
|
this._viewer = undefined;
|
|
12466
12470
|
this._worldTransformer = undefined;
|
|
12467
12471
|
this._markupIsActive = false;
|
|
@@ -12689,8 +12693,8 @@
|
|
|
12689
12693
|
// first we need Konva core things: stage and layer
|
|
12690
12694
|
this._konvaStage = new Konva.Stage({
|
|
12691
12695
|
container: this._markupContainerName,
|
|
12692
|
-
width: this.
|
|
12693
|
-
height: this.
|
|
12696
|
+
width: this._container.clientWidth,
|
|
12697
|
+
height: this._container.clientHeight,
|
|
12694
12698
|
});
|
|
12695
12699
|
const stage = this._konvaStage;
|
|
12696
12700
|
const layer = new Konva.Layer({ pixelRation: window.devicePixelRatio });
|
|
@@ -13079,15 +13083,13 @@
|
|
|
13079
13083
|
});
|
|
13080
13084
|
}
|
|
13081
13085
|
combineMarkupWithDrawing() {
|
|
13082
|
-
|
|
13083
|
-
if (trNodes.length > 0) {
|
|
13084
|
-
this._konvaTransformer.nodes([]);
|
|
13085
|
-
}
|
|
13086
|
+
this.clearSelected();
|
|
13086
13087
|
const tempCanvas = document.createElement("canvas");
|
|
13087
|
-
tempCanvas.
|
|
13088
|
-
tempCanvas.
|
|
13088
|
+
tempCanvas.width = this._konvaStage.width();
|
|
13089
|
+
tempCanvas.height = this._konvaStage.height();
|
|
13089
13090
|
const ctx = tempCanvas.getContext("2d");
|
|
13090
|
-
|
|
13091
|
+
if (this._container instanceof HTMLCanvasElement)
|
|
13092
|
+
ctx.drawImage(this._container, 0, 0);
|
|
13091
13093
|
ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
|
|
13092
13094
|
return tempCanvas.toDataURL("image/jpeg", 0.25);
|
|
13093
13095
|
}
|