@progress/kendo-pdfviewer-common 0.3.0-dev.202409251459 → 0.3.0-dev.202410100645
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/es/annotations/annotation-editor-layer-builder.js +139 -0
- package/dist/es/annotations/annotation-editor-layer.js +780 -0
- package/dist/es/annotations/annotation-editor-ui-manager.js +1690 -0
- package/dist/es/annotations/annotation-layer-builder.js +217 -0
- package/dist/es/annotations/annotation-layer.js +2793 -0
- package/dist/es/annotations/draw-layer-builder.js +65 -0
- package/dist/es/annotations/draw-layer.js +220 -0
- package/dist/es/annotations/editors/annotation-editor.js +1519 -0
- package/dist/es/annotations/editors/free-text-editor.js +783 -0
- package/dist/es/annotations/editors/highlight-editor.js +717 -0
- package/dist/es/annotations/editors/outliner.js +747 -0
- package/dist/es/annotations/helpers/annotation-storage.js +294 -0
- package/dist/es/annotations/helpers/color-manager.js +72 -0
- package/dist/es/annotations/helpers/command-manager.js +133 -0
- package/dist/es/annotations/helpers/id-manager.js +34 -0
- package/dist/es/annotations/helpers/image-manager.js +176 -0
- package/dist/es/annotations/helpers/text-accessibility-manager.js +212 -0
- package/dist/es/annotations/helpers/tools.js +19 -0
- package/dist/es/annotations/shared/display_utils.js +1024 -0
- package/dist/es/annotations/shared/event_utils.js +213 -0
- package/dist/es/annotations/shared/murmurhash3.js +126 -0
- package/dist/es/annotations/shared/scripting_utils.js +90 -0
- package/dist/es/annotations/shared/ui_utils.js +823 -0
- package/dist/es/annotations/shared/utils.js +909 -0
- package/dist/es/common/component.js +33 -0
- package/dist/es/common/core.js +91 -0
- package/dist/es/common/dom.js +11 -0
- package/dist/es/common/main.js +4 -0
- package/dist/es/common/math.js +1 -0
- package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
- package/dist/es/links/link-service.js +505 -0
- package/dist/es/main.js +2 -0
- package/dist/es/scroller.js +29 -30
- package/dist/es/text/text-layer-builder.js +288 -0
- package/dist/es/utils.js +5 -5
- package/dist/es/widget/page.js +762 -0
- package/dist/es/widget/pdfviewer.js +1659 -0
- package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
- package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
- package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
- package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
- package/dist/es2015/annotations/annotation-layer.js +2793 -0
- package/dist/es2015/annotations/draw-layer-builder.js +65 -0
- package/dist/es2015/annotations/draw-layer.js +220 -0
- package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
- package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
- package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
- package/dist/es2015/annotations/editors/outliner.js +747 -0
- package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
- package/dist/es2015/annotations/helpers/color-manager.js +72 -0
- package/dist/es2015/annotations/helpers/command-manager.js +133 -0
- package/dist/es2015/annotations/helpers/id-manager.js +34 -0
- package/dist/es2015/annotations/helpers/image-manager.js +176 -0
- package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
- package/dist/es2015/annotations/helpers/tools.js +19 -0
- package/dist/es2015/annotations/shared/display_utils.js +1024 -0
- package/dist/es2015/annotations/shared/event_utils.js +213 -0
- package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
- package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
- package/dist/es2015/annotations/shared/ui_utils.js +823 -0
- package/dist/es2015/annotations/shared/utils.js +909 -0
- package/dist/es2015/common/component.js +33 -0
- package/dist/es2015/common/core.js +91 -0
- package/dist/es2015/common/dom.js +11 -0
- package/dist/es2015/common/main.js +4 -0
- package/dist/es2015/common/math.js +1 -0
- package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
- package/dist/es2015/links/link-service.js +505 -0
- package/dist/es2015/main.js +2 -0
- package/dist/es2015/scroller.js +29 -30
- package/dist/es2015/text/text-layer-builder.js +288 -0
- package/dist/es2015/utils.js +5 -5
- package/dist/es2015/widget/page.js +762 -0
- package/dist/es2015/widget/pdfviewer.js +1659 -0
- package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
- package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
- package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
- package/dist/npm/annotations/annotation-editor-layer.js +783 -0
- package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
- package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
- package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
- package/dist/npm/annotations/annotation-layer-builder.js +220 -0
- package/dist/npm/annotations/annotation-layer.d.ts +134 -0
- package/dist/npm/annotations/annotation-layer.js +2794 -0
- package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
- package/dist/npm/annotations/draw-layer-builder.js +68 -0
- package/dist/npm/annotations/draw-layer.d.ts +33 -0
- package/dist/npm/annotations/draw-layer.js +223 -0
- package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
- package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
- package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
- package/dist/npm/annotations/editors/free-text-editor.js +786 -0
- package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
- package/dist/npm/annotations/editors/highlight-editor.js +717 -0
- package/dist/npm/annotations/editors/outliner.d.ts +51 -0
- package/dist/npm/annotations/editors/outliner.js +750 -0
- package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
- package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
- package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
- package/dist/npm/annotations/helpers/color-manager.js +76 -0
- package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
- package/dist/npm/annotations/helpers/command-manager.js +137 -0
- package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
- package/dist/npm/annotations/helpers/id-manager.js +38 -0
- package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
- package/dist/npm/annotations/helpers/image-manager.js +180 -0
- package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
- package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
- package/dist/npm/annotations/helpers/tools.d.ts +1 -0
- package/dist/npm/annotations/helpers/tools.js +23 -0
- package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
- package/dist/npm/annotations/shared/display_utils.js +1030 -0
- package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
- package/dist/npm/annotations/shared/event_utils.js +165 -0
- package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
- package/dist/npm/annotations/shared/murmurhash3.js +129 -0
- package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
- package/dist/npm/annotations/shared/scripting_utils.js +93 -0
- package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
- package/dist/npm/annotations/shared/ui_utils.js +250 -0
- package/dist/npm/annotations/shared/utils.d.ts +148 -0
- package/dist/npm/annotations/shared/utils.js +872 -0
- package/dist/npm/common/component.d.ts +9 -0
- package/dist/npm/common/component.js +37 -0
- package/dist/npm/common/core.d.ts +18 -0
- package/dist/npm/common/core.js +112 -0
- package/dist/npm/common/dom.d.ts +3 -0
- package/dist/npm/common/dom.js +17 -0
- package/dist/npm/common/main.d.ts +4 -0
- package/dist/npm/common/main.js +7 -0
- package/dist/npm/common/math.d.ts +1 -0
- package/dist/npm/common/math.js +5 -0
- package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
- package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
- package/dist/npm/links/link-service.d.ts +116 -0
- package/dist/npm/links/link-service.js +501 -0
- package/dist/npm/main.d.ts +2 -0
- package/dist/npm/main.js +2 -0
- package/dist/npm/scroller.d.ts +7 -3
- package/dist/npm/scroller.js +32 -32
- package/dist/npm/text/text-layer-builder.d.ts +30 -0
- package/dist/npm/text/text-layer-builder.js +291 -0
- package/dist/npm/utils.d.ts +20 -2
- package/dist/npm/utils.js +11 -8
- package/dist/npm/widget/page.d.ts +75 -0
- package/dist/npm/widget/page.js +763 -0
- package/dist/npm/widget/pdfviewer.d.ts +222 -0
- package/dist/npm/widget/pdfviewer.js +1663 -0
- package/package.json +13 -9
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* Copyright 2022 Mozilla Foundation
|
|
2
|
+
*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
var _DrawLayerBuilder_drawLayer;
|
|
16
|
+
import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
17
|
+
import { DrawLayer } from "./draw-layer";
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} DrawLayerBuilderOptions
|
|
20
|
+
* @property {number} pageIndex
|
|
21
|
+
*/
|
|
22
|
+
class DrawLayerBuilder {
|
|
23
|
+
/**
|
|
24
|
+
* @param {DrawLayerBuilderOptions} options
|
|
25
|
+
*/
|
|
26
|
+
constructor(options) {
|
|
27
|
+
// todo: props
|
|
28
|
+
this.pageIndex = null;
|
|
29
|
+
this._cancelled = null;
|
|
30
|
+
// todo: props
|
|
31
|
+
_DrawLayerBuilder_drawLayer.set(this, null);
|
|
32
|
+
this.pageIndex = options.pageIndex;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} intent (default value is 'display')
|
|
36
|
+
*/
|
|
37
|
+
render() {
|
|
38
|
+
return __awaiter(this, arguments, void 0, function* (intent = "display") {
|
|
39
|
+
// if (intent !== "display" || this.#drawLayer || this._cancelled) {
|
|
40
|
+
if (intent !== "display" || __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
__classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, new DrawLayer({
|
|
44
|
+
pageIndex: this.pageIndex,
|
|
45
|
+
}), "f");
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
cancel() {
|
|
49
|
+
// this._cancelled = true;
|
|
50
|
+
if (!__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f").destroy();
|
|
54
|
+
__classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, null, "f");
|
|
55
|
+
}
|
|
56
|
+
setParent(parent) {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) === null || _a === void 0 ? void 0 : _a.setParent(parent);
|
|
59
|
+
}
|
|
60
|
+
getDrawLayer() {
|
|
61
|
+
return __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
_DrawLayerBuilder_drawLayer = new WeakMap();
|
|
65
|
+
export { DrawLayerBuilder };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/* Copyright 2023 Mozilla Foundation
|
|
2
|
+
*
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
var _DrawLayer_instances, _a, _DrawLayer_parent, _DrawLayer_id, _DrawLayer_mapping, _DrawLayer_toUpdate, _DrawLayer_setBox, _DrawLayer_createSVG, _DrawLayer_createClipPath;
|
|
16
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
17
|
+
// import { DOMSVGFactory } from "./display_utils.js";
|
|
18
|
+
// import { shadow } from "../shared/util.js";
|
|
19
|
+
import { DOMSVGFactory, shadow } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
20
|
+
/**
|
|
21
|
+
* Manage the SVGs drawn on top of the page canvas.
|
|
22
|
+
* It's important to have them directly on top of the canvas because we want to
|
|
23
|
+
* be able to use mix-blend-mode for some of them.
|
|
24
|
+
*/
|
|
25
|
+
class DrawLayer {
|
|
26
|
+
constructor({ pageIndex }) {
|
|
27
|
+
_DrawLayer_instances.add(this);
|
|
28
|
+
// todo: props
|
|
29
|
+
this.pageIndex = 0;
|
|
30
|
+
// todo: props
|
|
31
|
+
_DrawLayer_parent.set(this, null);
|
|
32
|
+
_DrawLayer_id.set(this, 0);
|
|
33
|
+
_DrawLayer_mapping.set(this, new Map());
|
|
34
|
+
_DrawLayer_toUpdate.set(this, new Map());
|
|
35
|
+
this.pageIndex = pageIndex;
|
|
36
|
+
}
|
|
37
|
+
setParent(parent) {
|
|
38
|
+
if (!__classPrivateFieldGet(this, _DrawLayer_parent, "f")) {
|
|
39
|
+
__classPrivateFieldSet(this, _DrawLayer_parent, parent, "f");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (__classPrivateFieldGet(this, _DrawLayer_parent, "f") !== parent) {
|
|
43
|
+
if (__classPrivateFieldGet(this, _DrawLayer_mapping, "f").size > 0) {
|
|
44
|
+
for (const root of __classPrivateFieldGet(this, _DrawLayer_mapping, "f").values()) {
|
|
45
|
+
root.remove();
|
|
46
|
+
parent.append(root);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
__classPrivateFieldSet(this, _DrawLayer_parent, parent, "f");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static get _svgFactory() {
|
|
53
|
+
return shadow(this, "_svgFactory", new DOMSVGFactory());
|
|
54
|
+
}
|
|
55
|
+
highlight(outlines, color, opacity, isPathUpdatable = false) {
|
|
56
|
+
var _b, _c;
|
|
57
|
+
const id = (__classPrivateFieldSet(this, _DrawLayer_id, (_c = __classPrivateFieldGet(this, _DrawLayer_id, "f"), _b = _c++, _c), "f"), _b);
|
|
58
|
+
const root = __classPrivateFieldGet(this, _DrawLayer_instances, "m", _DrawLayer_createSVG).call(this, outlines.box);
|
|
59
|
+
// root.classList.add("highlight");
|
|
60
|
+
root.classList.add("k-highlight");
|
|
61
|
+
if (outlines.free) {
|
|
62
|
+
// root.classList.add("free");
|
|
63
|
+
}
|
|
64
|
+
const defs = _a._svgFactory.createElement("defs");
|
|
65
|
+
root.append(defs);
|
|
66
|
+
const path = _a._svgFactory.createElement("path");
|
|
67
|
+
defs.append(path);
|
|
68
|
+
const pathId = `path_p${this.pageIndex}_${id}`;
|
|
69
|
+
path.setAttribute("id", pathId);
|
|
70
|
+
path.setAttribute("d", outlines.toSVGPath());
|
|
71
|
+
if (isPathUpdatable) {
|
|
72
|
+
__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").set(id, path);
|
|
73
|
+
}
|
|
74
|
+
// Create the clipping path for the editor div.
|
|
75
|
+
const clipPathId = __classPrivateFieldGet(this, _DrawLayer_instances, "m", _DrawLayer_createClipPath).call(this, defs, pathId);
|
|
76
|
+
const use = _a._svgFactory.createElement("use");
|
|
77
|
+
root.append(use);
|
|
78
|
+
root.setAttribute("fill", color);
|
|
79
|
+
root.setAttribute("fill-opacity", opacity);
|
|
80
|
+
use.setAttribute("href", `#${pathId}`);
|
|
81
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").set(id, root);
|
|
82
|
+
return { id, clipPathId: `url(#${clipPathId})` };
|
|
83
|
+
}
|
|
84
|
+
highlightOutline(outlines) {
|
|
85
|
+
var _b, _c;
|
|
86
|
+
// We cannot draw the outline directly in the SVG for highlights because
|
|
87
|
+
// it composes with its parent with mix-blend-mode: multiply.
|
|
88
|
+
// But the outline has a different mix-blend-mode, so we need to draw it in
|
|
89
|
+
// its own SVG.
|
|
90
|
+
const id = (__classPrivateFieldSet(this, _DrawLayer_id, (_c = __classPrivateFieldGet(this, _DrawLayer_id, "f"), _b = _c++, _c), "f"), _b);
|
|
91
|
+
const root = __classPrivateFieldGet(this, _DrawLayer_instances, "m", _DrawLayer_createSVG).call(this, outlines.box);
|
|
92
|
+
// root.classList.add("highlightOutline");
|
|
93
|
+
root.classList.add("k-highlight-outline");
|
|
94
|
+
const defs = _a._svgFactory.createElement("defs");
|
|
95
|
+
root.append(defs);
|
|
96
|
+
const path = _a._svgFactory.createElement("path");
|
|
97
|
+
defs.append(path);
|
|
98
|
+
const pathId = `path_p${this.pageIndex}_${id}`;
|
|
99
|
+
path.setAttribute("id", pathId);
|
|
100
|
+
path.setAttribute("d", outlines.toSVGPath());
|
|
101
|
+
path.setAttribute("vector-effect", "non-scaling-stroke");
|
|
102
|
+
let maskId;
|
|
103
|
+
if (outlines.free) {
|
|
104
|
+
// root.classList.add("free");
|
|
105
|
+
const mask = _a._svgFactory.createElement("mask");
|
|
106
|
+
defs.append(mask);
|
|
107
|
+
maskId = `mask_p${this.pageIndex}_${id}`;
|
|
108
|
+
mask.setAttribute("id", maskId);
|
|
109
|
+
mask.setAttribute("maskUnits", "objectBoundingBox");
|
|
110
|
+
const rect = _a._svgFactory.createElement("rect");
|
|
111
|
+
mask.append(rect);
|
|
112
|
+
rect.setAttribute("width", "1");
|
|
113
|
+
rect.setAttribute("height", "1");
|
|
114
|
+
rect.setAttribute("fill", "white");
|
|
115
|
+
const use = _a._svgFactory.createElement("use");
|
|
116
|
+
mask.append(use);
|
|
117
|
+
use.setAttribute("href", `#${pathId}`);
|
|
118
|
+
use.setAttribute("stroke", "none");
|
|
119
|
+
use.setAttribute("fill", "black");
|
|
120
|
+
use.setAttribute("fill-rule", "nonzero");
|
|
121
|
+
// use.classList.add("mask");
|
|
122
|
+
}
|
|
123
|
+
const use1 = _a._svgFactory.createElement("use");
|
|
124
|
+
root.append(use1);
|
|
125
|
+
use1.setAttribute("href", `#${pathId}`);
|
|
126
|
+
if (maskId) {
|
|
127
|
+
use1.setAttribute("mask", `url(#${maskId})`);
|
|
128
|
+
}
|
|
129
|
+
const use2 = use1.cloneNode();
|
|
130
|
+
root.append(use2);
|
|
131
|
+
// use1.classList.add("mainOutline");
|
|
132
|
+
// use2.classList.add("secondaryOutline");
|
|
133
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").set(id, root);
|
|
134
|
+
return id;
|
|
135
|
+
}
|
|
136
|
+
finalizeLine(id, line) {
|
|
137
|
+
const path = __classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").get(id);
|
|
138
|
+
__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").delete(id);
|
|
139
|
+
this.updateBox(id, line.box);
|
|
140
|
+
path.setAttribute("d", line.toSVGPath());
|
|
141
|
+
}
|
|
142
|
+
updateLine(id, line) {
|
|
143
|
+
const root = __classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id);
|
|
144
|
+
const defs = root.firstChild;
|
|
145
|
+
const path = defs.firstChild;
|
|
146
|
+
path.setAttribute("d", line.toSVGPath());
|
|
147
|
+
}
|
|
148
|
+
removeFreeHighlight(id) {
|
|
149
|
+
this.remove(id);
|
|
150
|
+
__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").delete(id);
|
|
151
|
+
}
|
|
152
|
+
updatePath(id, line) {
|
|
153
|
+
__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").get(id).setAttribute("d", line.toSVGPath());
|
|
154
|
+
}
|
|
155
|
+
updateBox(id, box) {
|
|
156
|
+
__classPrivateFieldGet(_a, _a, "m", _DrawLayer_setBox).call(_a, __classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id), box);
|
|
157
|
+
}
|
|
158
|
+
show(id, visible) {
|
|
159
|
+
// this.#mapping.get(id).classList.toggle("hidden", !visible);
|
|
160
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).classList.toggle("k-hidden", !visible);
|
|
161
|
+
}
|
|
162
|
+
rotate(id, angle) {
|
|
163
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).setAttribute("data-main-rotation", angle);
|
|
164
|
+
}
|
|
165
|
+
changeColor(id, color) {
|
|
166
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).setAttribute("fill", color);
|
|
167
|
+
}
|
|
168
|
+
changeOpacity(id, opacity) {
|
|
169
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).setAttribute("fill-opacity", opacity);
|
|
170
|
+
}
|
|
171
|
+
addClass(id, className) {
|
|
172
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).classList.add(className);
|
|
173
|
+
}
|
|
174
|
+
removeClass(id, className) {
|
|
175
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).classList.remove(className);
|
|
176
|
+
}
|
|
177
|
+
remove(id) {
|
|
178
|
+
if (__classPrivateFieldGet(this, _DrawLayer_parent, "f") === null) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).remove();
|
|
182
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").delete(id);
|
|
183
|
+
}
|
|
184
|
+
destroy() {
|
|
185
|
+
__classPrivateFieldSet(this, _DrawLayer_parent, null, "f");
|
|
186
|
+
for (const root of __classPrivateFieldGet(this, _DrawLayer_mapping, "f").values()) {
|
|
187
|
+
root.remove();
|
|
188
|
+
}
|
|
189
|
+
__classPrivateFieldGet(this, _DrawLayer_mapping, "f").clear();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
_a = DrawLayer, _DrawLayer_parent = new WeakMap(), _DrawLayer_id = new WeakMap(), _DrawLayer_mapping = new WeakMap(), _DrawLayer_toUpdate = new WeakMap(), _DrawLayer_instances = new WeakSet(), _DrawLayer_setBox = function _DrawLayer_setBox(element, { x = 0, y = 0, width = 1, height = 1 } = {}) {
|
|
193
|
+
const { style } = element;
|
|
194
|
+
style.top = `${100 * y}%`;
|
|
195
|
+
style.left = `${100 * x}%`;
|
|
196
|
+
// style.width = `${100 * width}%`;
|
|
197
|
+
// style.height = `${100 * height}%`;
|
|
198
|
+
// todo: reduce the dimensions, so that the annotation editor toolbar
|
|
199
|
+
// does not overlap the outline
|
|
200
|
+
style.width = `${100 * width - 0.2}%`;
|
|
201
|
+
style.height = `${100 * height - 0.2}%`;
|
|
202
|
+
}, _DrawLayer_createSVG = function _DrawLayer_createSVG(box) {
|
|
203
|
+
const svg = _a._svgFactory.create(1, 1, /* skipDimensions = */ true);
|
|
204
|
+
__classPrivateFieldGet(this, _DrawLayer_parent, "f").append(svg);
|
|
205
|
+
svg.setAttribute("aria-hidden", true);
|
|
206
|
+
__classPrivateFieldGet(_a, _a, "m", _DrawLayer_setBox).call(_a, svg, box);
|
|
207
|
+
return svg;
|
|
208
|
+
}, _DrawLayer_createClipPath = function _DrawLayer_createClipPath(defs, pathId) {
|
|
209
|
+
const clipPath = _a._svgFactory.createElement("clipPath");
|
|
210
|
+
defs.append(clipPath);
|
|
211
|
+
const clipPathId = `clip_${pathId}`;
|
|
212
|
+
clipPath.setAttribute("id", clipPathId);
|
|
213
|
+
clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
|
|
214
|
+
const clipPathUse = _a._svgFactory.createElement("use");
|
|
215
|
+
clipPath.append(clipPathUse);
|
|
216
|
+
clipPathUse.setAttribute("href", `#${pathId}`);
|
|
217
|
+
// clipPathUse.classList.add("clip");
|
|
218
|
+
return clipPathId;
|
|
219
|
+
};
|
|
220
|
+
export { DrawLayer };
|