@inweb/markup 26.10.4 → 26.10.5
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 +13437 -14061
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +10 -43
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/Konva/KonvaMarkup.d.ts +2 -3
- package/package.json +5 -5
- package/src/markup/Konva/KonvaMarkup.ts +12 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IEventEmitter } from "@inweb/eventemitter2";
|
|
2
|
-
import { ChangeActiveDraggerEvent, IViewpoint
|
|
2
|
+
import { ChangeActiveDraggerEvent, IViewpoint } from "@inweb/viewer-core";
|
|
3
3
|
import { IMarkup, MarkupMode } from "../IMarkup";
|
|
4
4
|
import { IWorldTransform } from "../IWorldTransform";
|
|
5
5
|
import { IMarkupObject } from "../IMarkupObject";
|
|
@@ -33,8 +33,7 @@ export declare class KonvaMarkup implements IMarkup {
|
|
|
33
33
|
initialize(container: HTMLElement, containerEvents?: string[], viewer?: IEventEmitter, worldTransformer?: IWorldTransform): void;
|
|
34
34
|
dispose(): void;
|
|
35
35
|
changeActiveDragger: (event: ChangeActiveDraggerEvent) => void;
|
|
36
|
-
resizeContainer: (
|
|
37
|
-
resizeViewer: (event: ResizeEvent) => void;
|
|
36
|
+
resizeContainer: () => void;
|
|
38
37
|
pan: () => void;
|
|
39
38
|
zoomAt: () => void;
|
|
40
39
|
redirectToViewer: (event: any) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/markup",
|
|
3
|
-
"version": "26.10.
|
|
3
|
+
"version": "26.10.5",
|
|
4
4
|
"description": "JavaScript 2D markups",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"docs": "typedoc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/eventemitter2": "~26.10.
|
|
30
|
-
"@inweb/viewer-core": "~26.10.
|
|
29
|
+
"@inweb/eventemitter2": "~26.10.5",
|
|
30
|
+
"@inweb/viewer-core": "~26.10.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"konva": "^
|
|
33
|
+
"konva": "^10.0.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"konva": "^
|
|
36
|
+
"konva": "^10.0.2"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
IRectangle,
|
|
34
34
|
IText,
|
|
35
35
|
IViewpoint,
|
|
36
|
-
ResizeEvent,
|
|
37
36
|
} from "@inweb/viewer-core";
|
|
38
37
|
|
|
39
38
|
import { IMarkup, MarkupMode } from "../IMarkup";
|
|
@@ -85,19 +84,6 @@ const MarkupMode2Konva = {
|
|
|
85
84
|
},
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
function debounce(func, wait: number) {
|
|
89
|
-
let timeout = null;
|
|
90
|
-
return (...args) => {
|
|
91
|
-
if (timeout) {
|
|
92
|
-
clearTimeout(timeout);
|
|
93
|
-
}
|
|
94
|
-
timeout = setTimeout(() => {
|
|
95
|
-
timeout = null;
|
|
96
|
-
func(...args);
|
|
97
|
-
}, wait);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
87
|
/**
|
|
102
88
|
* 2D markup core.
|
|
103
89
|
*/
|
|
@@ -133,11 +119,6 @@ export class KonvaMarkup implements IMarkup {
|
|
|
133
119
|
viewer?: IEventEmitter,
|
|
134
120
|
worldTransformer?: IWorldTransform
|
|
135
121
|
): void {
|
|
136
|
-
if (!Konva)
|
|
137
|
-
throw new Error(
|
|
138
|
-
'Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"></script> to your page?'
|
|
139
|
-
);
|
|
140
|
-
|
|
141
122
|
this._viewer = viewer;
|
|
142
123
|
this._worldTransformer = worldTransformer ?? new WorldTransform();
|
|
143
124
|
this._container = container;
|
|
@@ -151,17 +132,13 @@ export class KonvaMarkup implements IMarkup {
|
|
|
151
132
|
const parentDiv = this._container.parentElement;
|
|
152
133
|
parentDiv.appendChild(this._markupContainer);
|
|
153
134
|
|
|
154
|
-
if (viewer) {
|
|
155
|
-
this._viewer.addEventListener("resize", this.resizeViewer);
|
|
156
|
-
} else {
|
|
157
|
-
this._resizeObserver = new ResizeObserver(debounce(this.resizeContainer, 100));
|
|
158
|
-
this._resizeObserver.observe(parentDiv);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
135
|
this._markupColor.setColor(255, 0, 0);
|
|
162
136
|
|
|
163
137
|
this.initializeKonva();
|
|
164
138
|
|
|
139
|
+
this._resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
140
|
+
this._resizeObserver.observe(container);
|
|
141
|
+
|
|
165
142
|
if (this._viewer) {
|
|
166
143
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
167
144
|
this._viewer.addEventListener("pan", this.pan);
|
|
@@ -176,11 +153,11 @@ export class KonvaMarkup implements IMarkup {
|
|
|
176
153
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
177
154
|
}
|
|
178
155
|
|
|
179
|
-
this.destroyKonva();
|
|
180
|
-
|
|
181
156
|
this._resizeObserver?.disconnect();
|
|
182
157
|
this._resizeObserver = undefined;
|
|
183
158
|
|
|
159
|
+
this.destroyKonva();
|
|
160
|
+
|
|
184
161
|
this._markupContainer?.remove();
|
|
185
162
|
this._markupContainer = undefined;
|
|
186
163
|
|
|
@@ -207,29 +184,16 @@ export class KonvaMarkup implements IMarkup {
|
|
|
207
184
|
this.enableEditMode(draggerName as MarkupMode);
|
|
208
185
|
};
|
|
209
186
|
|
|
210
|
-
resizeContainer = (
|
|
211
|
-
|
|
212
|
-
const { width, height } = entries[0].contentRect;
|
|
213
|
-
|
|
214
|
-
if (!width || !height) return; // <- invisible container, or container with parent removed
|
|
215
|
-
if (!this._konvaStage) return;
|
|
216
|
-
|
|
217
|
-
this._konvaStage.width(width);
|
|
218
|
-
this._konvaStage.height(height);
|
|
219
|
-
|
|
220
|
-
this.getObjects().forEach((markupObject) => {
|
|
221
|
-
markupObject.updateScreenCoordinates();
|
|
222
|
-
});
|
|
223
|
-
};
|
|
187
|
+
resizeContainer = () => {
|
|
188
|
+
const { offsetLeft, offsetTop, offsetWidth, offsetHeight } = this._container;
|
|
224
189
|
|
|
225
|
-
|
|
226
|
-
const { width, height } = event;
|
|
190
|
+
if (!offsetWidth || !offsetHeight) return; // <- invisible container, or container with parent removed
|
|
227
191
|
|
|
228
|
-
|
|
229
|
-
|
|
192
|
+
this._markupContainer.style.left = `${offsetLeft}px`;
|
|
193
|
+
this._markupContainer.style.top = `${offsetTop}px`;
|
|
230
194
|
|
|
231
|
-
this._konvaStage.width(
|
|
232
|
-
this._konvaStage.height(
|
|
195
|
+
this._konvaStage.width(offsetWidth);
|
|
196
|
+
this._konvaStage.height(offsetHeight);
|
|
233
197
|
|
|
234
198
|
this.getObjects().forEach((markupObject) => {
|
|
235
199
|
markupObject.updateScreenCoordinates();
|