@inweb/markup 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/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/IMarkupArrow.d.ts +2 -1
- package/lib/markup/IMarkupCloud.d.ts +2 -1
- package/lib/markup/IMarkupEllipse.d.ts +2 -1
- package/lib/markup/IMarkupLine.d.ts +2 -1
- package/lib/markup/IMarkupRectangle.d.ts +2 -1
- package/lib/markup/IMarkupText.d.ts +2 -1
- package/lib/markup/Konva/KonvaArrow.d.ts +1 -2
- package/lib/markup/Konva/KonvaCloud.d.ts +1 -2
- package/lib/markup/Konva/KonvaEllipse.d.ts +1 -2
- package/lib/markup/Konva/KonvaLine.d.ts +1 -2
- package/lib/markup/Konva/KonvaMarkup.d.ts +3 -3
- package/lib/markup/Konva/KonvaRectangle.d.ts +1 -2
- package/lib/markup/Konva/KonvaText.d.ts +1 -2
- package/package.json +3 -3
- package/src/markup/IMarkup.ts +14 -13
- package/src/markup/IMarkupArrow.ts +2 -1
- package/src/markup/IMarkupCloud.ts +2 -1
- package/src/markup/IMarkupEllipse.ts +2 -1
- package/src/markup/IMarkupLine.ts +2 -1
- package/src/markup/IMarkupRectangle.ts +2 -1
- package/src/markup/IMarkupText.ts +2 -1
- package/src/markup/Konva/KonvaArrow.ts +1 -2
- package/src/markup/Konva/KonvaCloud.ts +1 -2
- package/src/markup/Konva/KonvaEllipse.ts +1 -2
- package/src/markup/Konva/KonvaLine.ts +1 -2
- package/src/markup/Konva/KonvaMarkup.ts +22 -23
- package/src/markup/Konva/KonvaRectangle.ts +1 -2
- package/src/markup/Konva/KonvaText.ts +1 -2
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
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMarkupObject } from "./IMarkupObject";
|
|
2
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
2
3
|
/**
|
|
3
4
|
* Arrow Markup object
|
|
4
5
|
*/
|
|
5
|
-
export interface IMarkupArrow extends IMarkupObject {
|
|
6
|
+
export interface IMarkupArrow extends IMarkupObject, IMarkupColorable {
|
|
6
7
|
/**
|
|
7
8
|
* Get points of current Arrow
|
|
8
9
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMarkupObject } from "./IMarkupObject";
|
|
2
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
2
3
|
/**
|
|
3
4
|
* Cloud Markup object
|
|
4
5
|
*/
|
|
5
|
-
export interface IMarkupCloud extends IMarkupObject {
|
|
6
|
+
export interface IMarkupCloud extends IMarkupObject, IMarkupColorable {
|
|
6
7
|
/**
|
|
7
8
|
* Get position of the Cloud
|
|
8
9
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMarkupObject } from "./IMarkupObject";
|
|
2
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
2
3
|
/**
|
|
3
4
|
* Ellipse Markup object
|
|
4
5
|
*/
|
|
5
|
-
export interface IMarkupEllipse extends IMarkupObject {
|
|
6
|
+
export interface IMarkupEllipse extends IMarkupObject, IMarkupColorable {
|
|
6
7
|
/**
|
|
7
8
|
* Get position of the Ellipse
|
|
8
9
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IMarkupObject } from "./IMarkupObject";
|
|
2
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
2
3
|
/**
|
|
3
4
|
* Type of the markup line.
|
|
4
5
|
*/
|
|
@@ -6,7 +7,7 @@ export type MarkupLineType = "solid" | "dot" | "dash";
|
|
|
6
7
|
/**
|
|
7
8
|
* Line Markup object
|
|
8
9
|
*/
|
|
9
|
-
export interface IMarkupLine extends IMarkupObject {
|
|
10
|
+
export interface IMarkupLine extends IMarkupObject, IMarkupColorable {
|
|
10
11
|
/**
|
|
11
12
|
* Get points of the Line
|
|
12
13
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMarkupObject } from "./IMarkupObject";
|
|
2
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
2
3
|
/**
|
|
3
4
|
* Rectangle Markup object
|
|
4
5
|
*/
|
|
5
|
-
export interface IMarkupRectangle extends IMarkupObject {
|
|
6
|
+
export interface IMarkupRectangle extends IMarkupObject, IMarkupColorable {
|
|
6
7
|
/**
|
|
7
8
|
* Get position of the Rectangle
|
|
8
9
|
*/
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { IMarkupObject } from "./IMarkupObject";
|
|
2
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
2
3
|
/**
|
|
3
4
|
* Text Markup object
|
|
4
5
|
*/
|
|
5
|
-
export interface IMarkupText extends IMarkupObject {
|
|
6
|
+
export interface IMarkupText extends IMarkupObject, IMarkupColorable {
|
|
6
7
|
/**
|
|
7
8
|
* Get Text value
|
|
8
9
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMarkupArrow } from "../IMarkupArrow";
|
|
2
|
-
|
|
3
|
-
export declare class KonvaArrow implements IMarkupArrow, IMarkupColorable {
|
|
2
|
+
export declare class KonvaArrow implements IMarkupArrow {
|
|
4
3
|
private _ref;
|
|
5
4
|
constructor(params: {
|
|
6
5
|
start: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
2
1
|
import { IMarkupCloud } from "../IMarkupCloud";
|
|
3
|
-
export declare class KonvaCloud implements IMarkupCloud
|
|
2
|
+
export declare class KonvaCloud implements IMarkupCloud {
|
|
4
3
|
private _ref;
|
|
5
4
|
constructor(params: {
|
|
6
5
|
position: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMarkupEllipse } from "../IMarkupEllipse";
|
|
2
|
-
|
|
3
|
-
export declare class KonvaEllipse implements IMarkupEllipse, IMarkupColorable {
|
|
2
|
+
export declare class KonvaEllipse implements IMarkupEllipse {
|
|
4
3
|
private _ref;
|
|
5
4
|
constructor(params: {
|
|
6
5
|
position: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMarkupLine, MarkupLineType } from "../IMarkupLine";
|
|
2
|
-
|
|
3
|
-
export declare class KonvaLine implements IMarkupLine, IMarkupColorable {
|
|
2
|
+
export declare class KonvaLine implements IMarkupLine {
|
|
4
3
|
private _ref;
|
|
5
4
|
constructor(params: {
|
|
6
5
|
points: {
|
|
@@ -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;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMarkupRectangle } from "../IMarkupRectangle";
|
|
2
|
-
|
|
3
|
-
export declare class KonvaRectangle implements IMarkupRectangle, IMarkupColorable {
|
|
2
|
+
export declare class KonvaRectangle implements IMarkupRectangle {
|
|
4
3
|
private _ref;
|
|
5
4
|
constructor(params: {
|
|
6
5
|
position: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMarkupText } from "../IMarkupText";
|
|
2
|
-
|
|
3
|
-
export declare class KonvaText implements IMarkupText, IMarkupColorable {
|
|
2
|
+
export declare class KonvaText implements IMarkupText {
|
|
4
3
|
private _ref;
|
|
5
4
|
private readonly TEXT_FONT_FAMILY;
|
|
6
5
|
constructor(params: {
|
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
|
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IMarkupObject } from "./IMarkupObject";
|
|
25
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Arrow Markup object
|
|
28
29
|
*/
|
|
29
|
-
export interface IMarkupArrow extends IMarkupObject {
|
|
30
|
+
export interface IMarkupArrow extends IMarkupObject, IMarkupColorable {
|
|
30
31
|
/**
|
|
31
32
|
* Get points of current Arrow
|
|
32
33
|
*
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IMarkupObject } from "./IMarkupObject";
|
|
25
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Cloud Markup object
|
|
28
29
|
*/
|
|
29
|
-
export interface IMarkupCloud extends IMarkupObject {
|
|
30
|
+
export interface IMarkupCloud extends IMarkupObject, IMarkupColorable {
|
|
30
31
|
/**
|
|
31
32
|
* Get position of the Cloud
|
|
32
33
|
*/
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IMarkupObject } from "./IMarkupObject";
|
|
25
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Ellipse Markup object
|
|
28
29
|
*/
|
|
29
|
-
export interface IMarkupEllipse extends IMarkupObject {
|
|
30
|
+
export interface IMarkupEllipse extends IMarkupObject, IMarkupColorable {
|
|
30
31
|
/**
|
|
31
32
|
* Get position of the Ellipse
|
|
32
33
|
*/
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IMarkupObject } from "./IMarkupObject";
|
|
25
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Type of the markup line.
|
|
@@ -31,7 +32,7 @@ export type MarkupLineType = "solid" | "dot" | "dash";
|
|
|
31
32
|
/**
|
|
32
33
|
* Line Markup object
|
|
33
34
|
*/
|
|
34
|
-
export interface IMarkupLine extends IMarkupObject {
|
|
35
|
+
export interface IMarkupLine extends IMarkupObject, IMarkupColorable {
|
|
35
36
|
/**
|
|
36
37
|
* Get points of the Line
|
|
37
38
|
*/
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IMarkupObject } from "./IMarkupObject";
|
|
25
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Rectangle Markup object
|
|
28
29
|
*/
|
|
29
|
-
export interface IMarkupRectangle extends IMarkupObject {
|
|
30
|
+
export interface IMarkupRectangle extends IMarkupObject, IMarkupColorable {
|
|
30
31
|
/**
|
|
31
32
|
* Get position of the Rectangle
|
|
32
33
|
*/
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
24
|
import { IMarkupObject } from "./IMarkupObject";
|
|
25
|
+
import { IMarkupColorable } from "./IMarkupColorable";
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Text Markup object
|
|
28
29
|
*/
|
|
29
|
-
export interface IMarkupText extends IMarkupObject {
|
|
30
|
+
export interface IMarkupText extends IMarkupObject, IMarkupColorable {
|
|
30
31
|
/**
|
|
31
32
|
* Get Text value
|
|
32
33
|
*/
|
|
@@ -23,9 +23,8 @@
|
|
|
23
23
|
|
|
24
24
|
import Konva from "konva";
|
|
25
25
|
import { IMarkupArrow } from "../IMarkupArrow";
|
|
26
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
27
26
|
|
|
28
|
-
export class KonvaArrow implements IMarkupArrow
|
|
27
|
+
export class KonvaArrow implements IMarkupArrow {
|
|
29
28
|
private _ref: Konva.Arrow;
|
|
30
29
|
|
|
31
30
|
constructor(
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
3
2
|
import { IMarkupCloud } from "../IMarkupCloud";
|
|
4
3
|
|
|
5
|
-
export class KonvaCloud implements IMarkupCloud
|
|
4
|
+
export class KonvaCloud implements IMarkupCloud {
|
|
6
5
|
private _ref: Konva.Shape;
|
|
7
6
|
|
|
8
7
|
constructor(
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
import { IMarkupEllipse } from "../IMarkupEllipse";
|
|
3
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
4
3
|
|
|
5
|
-
export class KonvaEllipse implements IMarkupEllipse
|
|
4
|
+
export class KonvaEllipse implements IMarkupEllipse {
|
|
6
5
|
private _ref: Konva.Ellipse;
|
|
7
6
|
|
|
8
7
|
constructor(
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
import { IMarkupLine, MarkupLineType } from "../IMarkupLine";
|
|
3
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
4
3
|
|
|
5
4
|
const LineTypeSpecs = new Map<string, number[]>([
|
|
6
5
|
["solid", []],
|
|
@@ -8,7 +7,7 @@ const LineTypeSpecs = new Map<string, number[]>([
|
|
|
8
7
|
["dash", [30, 30]],
|
|
9
8
|
]);
|
|
10
9
|
|
|
11
|
-
export class KonvaLine implements IMarkupLine
|
|
10
|
+
export class KonvaLine implements IMarkupLine {
|
|
12
11
|
private _ref: Konva.Line;
|
|
13
12
|
|
|
14
13
|
constructor(
|
|
@@ -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
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
import { IMarkupRectangle } from "../IMarkupRectangle";
|
|
3
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
4
3
|
|
|
5
|
-
export class KonvaRectangle implements IMarkupRectangle
|
|
4
|
+
export class KonvaRectangle implements IMarkupRectangle {
|
|
6
5
|
private _ref: Konva.Rect;
|
|
7
6
|
|
|
8
7
|
constructor(
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
import { IMarkupText } from "../IMarkupText";
|
|
3
|
-
import { IMarkupColorable } from "../IMarkupColorable";
|
|
4
3
|
|
|
5
|
-
export class KonvaText implements IMarkupText
|
|
4
|
+
export class KonvaText implements IMarkupText {
|
|
6
5
|
private _ref: Konva.Text;
|
|
7
6
|
private readonly TEXT_FONT_FAMILY = "Calibri";
|
|
8
7
|
|