@inweb/markup 25.7.6 → 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/markup.js +17 -19
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +16 -19
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/IMarkup.d.ts +15 -14
- package/lib/markup/Konva/KonvaMarkup.d.ts +3 -3
- package/package.json +3 -3
- package/src/markup/IMarkup.ts +14 -13
- package/src/markup/Konva/KonvaMarkup.ts +22 -23
package/lib/markup/IMarkup.d.ts
CHANGED
|
@@ -23,21 +23,22 @@ export interface IMarkup {
|
|
|
23
23
|
*/
|
|
24
24
|
fontSize: number;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Initializes the markup instance.
|
|
27
27
|
*
|
|
28
|
-
* @param canvas
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
* @param container - Container element used to operate on. This is usually a `canvas` or
|
|
29
|
+
* `div` on top of which the markup is drawn. If the `container` is an element of type
|
|
30
|
+
* {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement},
|
|
31
|
+
* its content will be combined with the markup in the viewpoint snapshot.
|
|
32
|
+
* @param pointerEvents - List of pointing device events that the markup should redirect to
|
|
33
|
+
* the `viewer`.
|
|
34
|
+
* @param viewer - `Viewer` instance that receives pointing device events.
|
|
35
|
+
* @param worldTransformer - Transformer of screen space into the `viewer` world space and
|
|
36
|
+
* vice versa. If a transformer is defined, viewpoint objects will be stored in world
|
|
37
|
+
* coordinates, otherwise in screen coordinates.
|
|
38
|
+
*/
|
|
39
|
+
initialize(container: HTMLElement, pointerEvents?: string[], viewer?: IEventEmitter, worldTransformer?: IWorldTransform): void;
|
|
40
|
+
/**
|
|
41
|
+
* Releases all resources allocated by this markup instance.
|
|
41
42
|
*/
|
|
42
43
|
dispose(): void;
|
|
43
44
|
/**
|
|
@@ -11,8 +11,8 @@ export declare class KonvaMarkup implements IMarkup {
|
|
|
11
11
|
private _isInitialized;
|
|
12
12
|
private _viewer;
|
|
13
13
|
private _worldTransformer;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
14
|
+
private _container;
|
|
15
|
+
private _pointerEvents;
|
|
16
16
|
private _markupIsActive;
|
|
17
17
|
private _markupMode;
|
|
18
18
|
private _markupColor;
|
|
@@ -30,7 +30,7 @@ export declare class KonvaMarkup implements IMarkup {
|
|
|
30
30
|
lineWidth: number;
|
|
31
31
|
lineType: MarkupLineType;
|
|
32
32
|
fontSize: number;
|
|
33
|
-
initialize(
|
|
33
|
+
initialize(container: HTMLElement, pointerEvents?: string[], viewer?: IEventEmitter, worldTransformer?: IWorldTransform): void;
|
|
34
34
|
dispose(): void;
|
|
35
35
|
changeActiveDragger: (event: ChangeActiveDraggerEvent) => void;
|
|
36
36
|
resize: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/markup",
|
|
3
|
-
"version": "25.7.
|
|
3
|
+
"version": "25.7.7",
|
|
4
4
|
"description": "JavaScript 2D markups",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"docs": "typedoc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/eventemitter2": "~25.7.
|
|
30
|
-
"@inweb/viewer-core": "~25.7.
|
|
29
|
+
"@inweb/eventemitter2": "~25.7.7",
|
|
30
|
+
"@inweb/viewer-core": "~25.7.7"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"canvas": "^2.11.2",
|
package/src/markup/IMarkup.ts
CHANGED
|
@@ -51,27 +51,28 @@ export interface IMarkup {
|
|
|
51
51
|
fontSize: number;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Initializes the markup instance.
|
|
55
55
|
*
|
|
56
|
-
* @param canvas
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @param
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
56
|
+
* @param container - Container element used to operate on. This is usually a `canvas` or
|
|
57
|
+
* `div` on top of which the markup is drawn. If the `container` is an element of type
|
|
58
|
+
* {@link https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement | HTMLCanvasElement},
|
|
59
|
+
* its content will be combined with the markup in the viewpoint snapshot.
|
|
60
|
+
* @param pointerEvents - List of pointing device events that the markup should redirect to
|
|
61
|
+
* the `viewer`.
|
|
62
|
+
* @param viewer - `Viewer` instance that receives pointing device events.
|
|
63
|
+
* @param worldTransformer - Transformer of screen space into the `viewer` world space and
|
|
64
|
+
* vice versa. If a transformer is defined, viewpoint objects will be stored in world
|
|
65
|
+
* coordinates, otherwise in screen coordinates.
|
|
64
66
|
*/
|
|
65
67
|
initialize(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
container: HTMLElement,
|
|
69
|
+
pointerEvents?: string[],
|
|
68
70
|
viewer?: IEventEmitter,
|
|
69
71
|
worldTransformer?: IWorldTransform
|
|
70
72
|
): void;
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
|
-
* Releases all resources allocated by this
|
|
74
|
-
* release the `Markup` instance.
|
|
75
|
+
* Releases all resources allocated by this markup instance.
|
|
75
76
|
*/
|
|
76
77
|
dispose(): void;
|
|
77
78
|
|
|
@@ -87,8 +87,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
87
87
|
private _isInitialized = false;
|
|
88
88
|
private _viewer: IEventEmitter;
|
|
89
89
|
private _worldTransformer: IWorldTransform;
|
|
90
|
-
private
|
|
91
|
-
private
|
|
90
|
+
private _container: HTMLElement;
|
|
91
|
+
private _pointerEvents: string[];
|
|
92
92
|
private _markupIsActive = false;
|
|
93
93
|
private _markupMode: string;
|
|
94
94
|
private _markupColor = new MarkupColor(255, 0, 0);
|
|
@@ -111,8 +111,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
111
111
|
public fontSize = 34;
|
|
112
112
|
|
|
113
113
|
initialize(
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
container: HTMLElement,
|
|
115
|
+
pointerEvents?: string[],
|
|
116
116
|
viewer?: IEventEmitter,
|
|
117
117
|
worldTransformer?: IWorldTransform
|
|
118
118
|
): void {
|
|
@@ -123,8 +123,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
123
123
|
|
|
124
124
|
this._viewer = viewer;
|
|
125
125
|
this._worldTransformer = worldTransformer;
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
126
|
+
this._container = container;
|
|
127
|
+
this._pointerEvents = pointerEvents ?? [];
|
|
128
128
|
|
|
129
129
|
this._markupContainer = document.createElement("div");
|
|
130
130
|
this._markupContainer.id = this._markupContainerName;
|
|
@@ -134,7 +134,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
134
134
|
// to eliminate grey box during delete elements
|
|
135
135
|
this._markupContainer.style.outline = "0px";
|
|
136
136
|
|
|
137
|
-
const parentDiv = this.
|
|
137
|
+
const parentDiv = this._container.parentElement;
|
|
138
138
|
parentDiv.appendChild(this._markupContainer);
|
|
139
139
|
|
|
140
140
|
this._markupColor.setColor(255, 0, 0);
|
|
@@ -142,9 +142,9 @@ export class KonvaMarkup implements IMarkup {
|
|
|
142
142
|
this.initializeKonva();
|
|
143
143
|
this.resize();
|
|
144
144
|
|
|
145
|
-
this._canvasEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
146
|
-
|
|
147
145
|
if (this._viewer) {
|
|
146
|
+
this._pointerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
147
|
+
|
|
148
148
|
this._viewer.addEventListener("resize", this.resize);
|
|
149
149
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
150
150
|
this._viewer.addEventListener("pan", this.pan);
|
|
@@ -162,14 +162,14 @@ export class KonvaMarkup implements IMarkup {
|
|
|
162
162
|
this._viewer.removeEventListener("resize", this.resize);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
this.
|
|
165
|
+
this._pointerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
|
|
166
166
|
|
|
167
167
|
this.destroyKonva();
|
|
168
168
|
|
|
169
169
|
this._markupContainer.remove();
|
|
170
170
|
this._markupContainer = undefined;
|
|
171
171
|
|
|
172
|
-
this.
|
|
172
|
+
this._container = undefined;
|
|
173
173
|
this._viewer = undefined;
|
|
174
174
|
this._worldTransformer = undefined;
|
|
175
175
|
|
|
@@ -180,7 +180,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
180
180
|
changeActiveDragger = (event: ChangeActiveDraggerEvent) => {
|
|
181
181
|
const draggerName = event.data;
|
|
182
182
|
|
|
183
|
-
this._markupContainer.className = this.
|
|
183
|
+
this._markupContainer.className = this._container.className
|
|
184
184
|
.split(" ")
|
|
185
185
|
.filter((x) => !x.startsWith("oda-cursor-"))
|
|
186
186
|
.filter((x) => x)
|
|
@@ -201,8 +201,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
resize = () => {
|
|
204
|
-
this._konvaStage?.width(this.
|
|
205
|
-
this._konvaStage?.height(this.
|
|
204
|
+
this._konvaStage?.width(this._container.clientWidth);
|
|
205
|
+
this._konvaStage?.height(this._container.clientHeight);
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
pan = (event: PanEvent) => {
|
|
@@ -482,8 +482,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
482
482
|
// first we need Konva core things: stage and layer
|
|
483
483
|
this._konvaStage = new Konva.Stage({
|
|
484
484
|
container: this._markupContainerName,
|
|
485
|
-
width: this.
|
|
486
|
-
height: this.
|
|
485
|
+
width: this._container.clientWidth,
|
|
486
|
+
height: this._container.clientHeight,
|
|
487
487
|
});
|
|
488
488
|
const stage = this._konvaStage;
|
|
489
489
|
const layer = new Konva.Layer({ pixelRation: window.devicePixelRatio });
|
|
@@ -920,17 +920,16 @@ export class KonvaMarkup implements IMarkup {
|
|
|
920
920
|
}
|
|
921
921
|
|
|
922
922
|
private combineMarkupWithDrawing() {
|
|
923
|
-
|
|
924
|
-
if (trNodes.length > 0) {
|
|
925
|
-
this._konvaTransformer.nodes([]);
|
|
926
|
-
}
|
|
923
|
+
this.clearSelected();
|
|
927
924
|
|
|
928
925
|
const tempCanvas = document.createElement("canvas");
|
|
929
|
-
tempCanvas.
|
|
930
|
-
tempCanvas.
|
|
926
|
+
tempCanvas.width = this._konvaStage.width();
|
|
927
|
+
tempCanvas.height = this._konvaStage.height();
|
|
928
|
+
|
|
931
929
|
const ctx = tempCanvas.getContext("2d");
|
|
932
|
-
ctx.drawImage(this.
|
|
930
|
+
if (this._container instanceof HTMLCanvasElement) ctx.drawImage(this._container, 0, 0);
|
|
933
931
|
ctx.drawImage(this._konvaStage.toCanvas({ pixelRatio: window.devicePixelRatio }), 0, 0);
|
|
932
|
+
|
|
934
933
|
return tempCanvas.toDataURL("image/jpeg", 0.25);
|
|
935
934
|
}
|
|
936
935
|
|