@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.
Files changed (149) hide show
  1. package/dist/es/annotations/annotation-editor-layer-builder.js +139 -0
  2. package/dist/es/annotations/annotation-editor-layer.js +780 -0
  3. package/dist/es/annotations/annotation-editor-ui-manager.js +1690 -0
  4. package/dist/es/annotations/annotation-layer-builder.js +217 -0
  5. package/dist/es/annotations/annotation-layer.js +2793 -0
  6. package/dist/es/annotations/draw-layer-builder.js +65 -0
  7. package/dist/es/annotations/draw-layer.js +220 -0
  8. package/dist/es/annotations/editors/annotation-editor.js +1519 -0
  9. package/dist/es/annotations/editors/free-text-editor.js +783 -0
  10. package/dist/es/annotations/editors/highlight-editor.js +717 -0
  11. package/dist/es/annotations/editors/outliner.js +747 -0
  12. package/dist/es/annotations/helpers/annotation-storage.js +294 -0
  13. package/dist/es/annotations/helpers/color-manager.js +72 -0
  14. package/dist/es/annotations/helpers/command-manager.js +133 -0
  15. package/dist/es/annotations/helpers/id-manager.js +34 -0
  16. package/dist/es/annotations/helpers/image-manager.js +176 -0
  17. package/dist/es/annotations/helpers/text-accessibility-manager.js +212 -0
  18. package/dist/es/annotations/helpers/tools.js +19 -0
  19. package/dist/es/annotations/shared/display_utils.js +1024 -0
  20. package/dist/es/annotations/shared/event_utils.js +213 -0
  21. package/dist/es/annotations/shared/murmurhash3.js +126 -0
  22. package/dist/es/annotations/shared/scripting_utils.js +90 -0
  23. package/dist/es/annotations/shared/ui_utils.js +823 -0
  24. package/dist/es/annotations/shared/utils.js +909 -0
  25. package/dist/es/common/component.js +33 -0
  26. package/dist/es/common/core.js +91 -0
  27. package/dist/es/common/dom.js +11 -0
  28. package/dist/es/common/main.js +4 -0
  29. package/dist/es/common/math.js +1 -0
  30. package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
  31. package/dist/es/links/link-service.js +505 -0
  32. package/dist/es/main.js +2 -0
  33. package/dist/es/scroller.js +29 -30
  34. package/dist/es/text/text-layer-builder.js +288 -0
  35. package/dist/es/utils.js +5 -5
  36. package/dist/es/widget/page.js +762 -0
  37. package/dist/es/widget/pdfviewer.js +1659 -0
  38. package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
  39. package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
  40. package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
  41. package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
  42. package/dist/es2015/annotations/annotation-layer.js +2793 -0
  43. package/dist/es2015/annotations/draw-layer-builder.js +65 -0
  44. package/dist/es2015/annotations/draw-layer.js +220 -0
  45. package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
  46. package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
  47. package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
  48. package/dist/es2015/annotations/editors/outliner.js +747 -0
  49. package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
  50. package/dist/es2015/annotations/helpers/color-manager.js +72 -0
  51. package/dist/es2015/annotations/helpers/command-manager.js +133 -0
  52. package/dist/es2015/annotations/helpers/id-manager.js +34 -0
  53. package/dist/es2015/annotations/helpers/image-manager.js +176 -0
  54. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
  55. package/dist/es2015/annotations/helpers/tools.js +19 -0
  56. package/dist/es2015/annotations/shared/display_utils.js +1024 -0
  57. package/dist/es2015/annotations/shared/event_utils.js +213 -0
  58. package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
  59. package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
  60. package/dist/es2015/annotations/shared/ui_utils.js +823 -0
  61. package/dist/es2015/annotations/shared/utils.js +909 -0
  62. package/dist/es2015/common/component.js +33 -0
  63. package/dist/es2015/common/core.js +91 -0
  64. package/dist/es2015/common/dom.js +11 -0
  65. package/dist/es2015/common/main.js +4 -0
  66. package/dist/es2015/common/math.js +1 -0
  67. package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
  68. package/dist/es2015/links/link-service.js +505 -0
  69. package/dist/es2015/main.js +2 -0
  70. package/dist/es2015/scroller.js +29 -30
  71. package/dist/es2015/text/text-layer-builder.js +288 -0
  72. package/dist/es2015/utils.js +5 -5
  73. package/dist/es2015/widget/page.js +762 -0
  74. package/dist/es2015/widget/pdfviewer.js +1659 -0
  75. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
  76. package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
  77. package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
  78. package/dist/npm/annotations/annotation-editor-layer.js +783 -0
  79. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
  80. package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
  81. package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
  82. package/dist/npm/annotations/annotation-layer-builder.js +220 -0
  83. package/dist/npm/annotations/annotation-layer.d.ts +134 -0
  84. package/dist/npm/annotations/annotation-layer.js +2794 -0
  85. package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
  86. package/dist/npm/annotations/draw-layer-builder.js +68 -0
  87. package/dist/npm/annotations/draw-layer.d.ts +33 -0
  88. package/dist/npm/annotations/draw-layer.js +223 -0
  89. package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
  90. package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
  91. package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
  92. package/dist/npm/annotations/editors/free-text-editor.js +786 -0
  93. package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
  94. package/dist/npm/annotations/editors/highlight-editor.js +717 -0
  95. package/dist/npm/annotations/editors/outliner.d.ts +51 -0
  96. package/dist/npm/annotations/editors/outliner.js +750 -0
  97. package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
  98. package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
  99. package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
  100. package/dist/npm/annotations/helpers/color-manager.js +76 -0
  101. package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
  102. package/dist/npm/annotations/helpers/command-manager.js +137 -0
  103. package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
  104. package/dist/npm/annotations/helpers/id-manager.js +38 -0
  105. package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
  106. package/dist/npm/annotations/helpers/image-manager.js +180 -0
  107. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
  108. package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
  109. package/dist/npm/annotations/helpers/tools.d.ts +1 -0
  110. package/dist/npm/annotations/helpers/tools.js +23 -0
  111. package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
  112. package/dist/npm/annotations/shared/display_utils.js +1030 -0
  113. package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
  114. package/dist/npm/annotations/shared/event_utils.js +165 -0
  115. package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
  116. package/dist/npm/annotations/shared/murmurhash3.js +129 -0
  117. package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
  118. package/dist/npm/annotations/shared/scripting_utils.js +93 -0
  119. package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
  120. package/dist/npm/annotations/shared/ui_utils.js +250 -0
  121. package/dist/npm/annotations/shared/utils.d.ts +148 -0
  122. package/dist/npm/annotations/shared/utils.js +872 -0
  123. package/dist/npm/common/component.d.ts +9 -0
  124. package/dist/npm/common/component.js +37 -0
  125. package/dist/npm/common/core.d.ts +18 -0
  126. package/dist/npm/common/core.js +112 -0
  127. package/dist/npm/common/dom.d.ts +3 -0
  128. package/dist/npm/common/dom.js +17 -0
  129. package/dist/npm/common/main.d.ts +4 -0
  130. package/dist/npm/common/main.js +7 -0
  131. package/dist/npm/common/math.d.ts +1 -0
  132. package/dist/npm/common/math.js +5 -0
  133. package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
  134. package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
  135. package/dist/npm/links/link-service.d.ts +116 -0
  136. package/dist/npm/links/link-service.js +501 -0
  137. package/dist/npm/main.d.ts +2 -0
  138. package/dist/npm/main.js +2 -0
  139. package/dist/npm/scroller.d.ts +7 -3
  140. package/dist/npm/scroller.js +32 -32
  141. package/dist/npm/text/text-layer-builder.d.ts +30 -0
  142. package/dist/npm/text/text-layer-builder.js +291 -0
  143. package/dist/npm/utils.d.ts +20 -2
  144. package/dist/npm/utils.js +11 -8
  145. package/dist/npm/widget/page.d.ts +75 -0
  146. package/dist/npm/widget/page.js +763 -0
  147. package/dist/npm/widget/pdfviewer.d.ts +222 -0
  148. package/dist/npm/widget/pdfviewer.js +1663 -0
  149. package/package.json +13 -9
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @typedef {Object} DrawLayerBuilderOptions
3
+ * @property {number} pageIndex
4
+ */
5
+ declare class DrawLayerBuilder {
6
+ #private;
7
+ pageIndex: number;
8
+ _cancelled: boolean;
9
+ /**
10
+ * @param {DrawLayerBuilderOptions} options
11
+ */
12
+ constructor(options: any);
13
+ /**
14
+ * @param {string} intent (default value is 'display')
15
+ */
16
+ render(intent?: string): Promise<void>;
17
+ cancel(): void;
18
+ setParent(parent: any): void;
19
+ getDrawLayer(): any;
20
+ }
21
+ export { DrawLayerBuilder };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /* Copyright 2022 Mozilla Foundation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var _DrawLayerBuilder_drawLayer;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DrawLayerBuilder = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const draw_layer_1 = require("./draw-layer");
21
+ /**
22
+ * @typedef {Object} DrawLayerBuilderOptions
23
+ * @property {number} pageIndex
24
+ */
25
+ class DrawLayerBuilder {
26
+ /**
27
+ * @param {DrawLayerBuilderOptions} options
28
+ */
29
+ constructor(options) {
30
+ // todo: props
31
+ this.pageIndex = null;
32
+ this._cancelled = null;
33
+ // todo: props
34
+ _DrawLayerBuilder_drawLayer.set(this, null);
35
+ this.pageIndex = options.pageIndex;
36
+ }
37
+ /**
38
+ * @param {string} intent (default value is 'display')
39
+ */
40
+ render() {
41
+ return tslib_1.__awaiter(this, arguments, void 0, function* (intent = "display") {
42
+ // if (intent !== "display" || this.#drawLayer || this._cancelled) {
43
+ if (intent !== "display" || tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
44
+ return;
45
+ }
46
+ tslib_1.__classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, new draw_layer_1.DrawLayer({
47
+ pageIndex: this.pageIndex,
48
+ }), "f");
49
+ });
50
+ }
51
+ cancel() {
52
+ // this._cancelled = true;
53
+ if (!tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
54
+ return;
55
+ }
56
+ tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f").destroy();
57
+ tslib_1.__classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, null, "f");
58
+ }
59
+ setParent(parent) {
60
+ var _a;
61
+ (_a = tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) === null || _a === void 0 ? void 0 : _a.setParent(parent);
62
+ }
63
+ getDrawLayer() {
64
+ return tslib_1.__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f");
65
+ }
66
+ }
67
+ exports.DrawLayerBuilder = DrawLayerBuilder;
68
+ _DrawLayerBuilder_drawLayer = new WeakMap();
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Manage the SVGs drawn on top of the page canvas.
3
+ * It's important to have them directly on top of the canvas because we want to
4
+ * be able to use mix-blend-mode for some of them.
5
+ */
6
+ declare class DrawLayer {
7
+ #private;
8
+ pageIndex: number;
9
+ constructor({ pageIndex }: {
10
+ pageIndex: any;
11
+ });
12
+ setParent(parent: any): void;
13
+ static get _svgFactory(): any;
14
+ highlight(outlines: any, color: any, opacity: any, isPathUpdatable?: boolean): {
15
+ id: number;
16
+ clipPathId: string;
17
+ };
18
+ highlightOutline(outlines: any): number;
19
+ finalizeLine(id: any, line: any): void;
20
+ updateLine(id: any, line: any): void;
21
+ removeFreeHighlight(id: any): void;
22
+ updatePath(id: any, line: any): void;
23
+ updateBox(id: any, box: any): void;
24
+ show(id: any, visible: any): void;
25
+ rotate(id: any, angle: any): void;
26
+ changeColor(id: any, color: any): void;
27
+ changeOpacity(id: any, opacity: any): void;
28
+ addClass(id: any, className: any): void;
29
+ removeClass(id: any, className: any): void;
30
+ remove(id: any): void;
31
+ destroy(): void;
32
+ }
33
+ export { DrawLayer };
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ /* Copyright 2023 Mozilla Foundation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var _DrawLayer_instances, _a, _DrawLayer_parent, _DrawLayer_id, _DrawLayer_mapping, _DrawLayer_toUpdate, _DrawLayer_setBox, _DrawLayer_createSVG, _DrawLayer_createClipPath;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DrawLayer = void 0;
19
+ const tslib_1 = require("tslib");
20
+ // import { DOMSVGFactory } from "./display_utils.js";
21
+ // import { shadow } from "../shared/util.js";
22
+ const pdf_mjs_1 = require("pdfjs-dist/legacy/build/pdf.mjs");
23
+ /**
24
+ * Manage the SVGs drawn on top of the page canvas.
25
+ * It's important to have them directly on top of the canvas because we want to
26
+ * be able to use mix-blend-mode for some of them.
27
+ */
28
+ class DrawLayer {
29
+ constructor({ pageIndex }) {
30
+ _DrawLayer_instances.add(this);
31
+ // todo: props
32
+ this.pageIndex = 0;
33
+ // todo: props
34
+ _DrawLayer_parent.set(this, null);
35
+ _DrawLayer_id.set(this, 0);
36
+ _DrawLayer_mapping.set(this, new Map());
37
+ _DrawLayer_toUpdate.set(this, new Map());
38
+ this.pageIndex = pageIndex;
39
+ }
40
+ setParent(parent) {
41
+ if (!tslib_1.__classPrivateFieldGet(this, _DrawLayer_parent, "f")) {
42
+ tslib_1.__classPrivateFieldSet(this, _DrawLayer_parent, parent, "f");
43
+ return;
44
+ }
45
+ if (tslib_1.__classPrivateFieldGet(this, _DrawLayer_parent, "f") !== parent) {
46
+ if (tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").size > 0) {
47
+ for (const root of tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").values()) {
48
+ root.remove();
49
+ parent.append(root);
50
+ }
51
+ }
52
+ tslib_1.__classPrivateFieldSet(this, _DrawLayer_parent, parent, "f");
53
+ }
54
+ }
55
+ static get _svgFactory() {
56
+ return (0, pdf_mjs_1.shadow)(this, "_svgFactory", new pdf_mjs_1.DOMSVGFactory());
57
+ }
58
+ highlight(outlines, color, opacity, isPathUpdatable = false) {
59
+ var _b, _c;
60
+ const id = (tslib_1.__classPrivateFieldSet(this, _DrawLayer_id, (_c = tslib_1.__classPrivateFieldGet(this, _DrawLayer_id, "f"), _b = _c++, _c), "f"), _b);
61
+ const root = tslib_1.__classPrivateFieldGet(this, _DrawLayer_instances, "m", _DrawLayer_createSVG).call(this, outlines.box);
62
+ // root.classList.add("highlight");
63
+ root.classList.add("k-highlight");
64
+ if (outlines.free) {
65
+ // root.classList.add("free");
66
+ }
67
+ const defs = _a._svgFactory.createElement("defs");
68
+ root.append(defs);
69
+ const path = _a._svgFactory.createElement("path");
70
+ defs.append(path);
71
+ const pathId = `path_p${this.pageIndex}_${id}`;
72
+ path.setAttribute("id", pathId);
73
+ path.setAttribute("d", outlines.toSVGPath());
74
+ if (isPathUpdatable) {
75
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").set(id, path);
76
+ }
77
+ // Create the clipping path for the editor div.
78
+ const clipPathId = tslib_1.__classPrivateFieldGet(this, _DrawLayer_instances, "m", _DrawLayer_createClipPath).call(this, defs, pathId);
79
+ const use = _a._svgFactory.createElement("use");
80
+ root.append(use);
81
+ root.setAttribute("fill", color);
82
+ root.setAttribute("fill-opacity", opacity);
83
+ use.setAttribute("href", `#${pathId}`);
84
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").set(id, root);
85
+ return { id, clipPathId: `url(#${clipPathId})` };
86
+ }
87
+ highlightOutline(outlines) {
88
+ var _b, _c;
89
+ // We cannot draw the outline directly in the SVG for highlights because
90
+ // it composes with its parent with mix-blend-mode: multiply.
91
+ // But the outline has a different mix-blend-mode, so we need to draw it in
92
+ // its own SVG.
93
+ const id = (tslib_1.__classPrivateFieldSet(this, _DrawLayer_id, (_c = tslib_1.__classPrivateFieldGet(this, _DrawLayer_id, "f"), _b = _c++, _c), "f"), _b);
94
+ const root = tslib_1.__classPrivateFieldGet(this, _DrawLayer_instances, "m", _DrawLayer_createSVG).call(this, outlines.box);
95
+ // root.classList.add("highlightOutline");
96
+ root.classList.add("k-highlight-outline");
97
+ const defs = _a._svgFactory.createElement("defs");
98
+ root.append(defs);
99
+ const path = _a._svgFactory.createElement("path");
100
+ defs.append(path);
101
+ const pathId = `path_p${this.pageIndex}_${id}`;
102
+ path.setAttribute("id", pathId);
103
+ path.setAttribute("d", outlines.toSVGPath());
104
+ path.setAttribute("vector-effect", "non-scaling-stroke");
105
+ let maskId;
106
+ if (outlines.free) {
107
+ // root.classList.add("free");
108
+ const mask = _a._svgFactory.createElement("mask");
109
+ defs.append(mask);
110
+ maskId = `mask_p${this.pageIndex}_${id}`;
111
+ mask.setAttribute("id", maskId);
112
+ mask.setAttribute("maskUnits", "objectBoundingBox");
113
+ const rect = _a._svgFactory.createElement("rect");
114
+ mask.append(rect);
115
+ rect.setAttribute("width", "1");
116
+ rect.setAttribute("height", "1");
117
+ rect.setAttribute("fill", "white");
118
+ const use = _a._svgFactory.createElement("use");
119
+ mask.append(use);
120
+ use.setAttribute("href", `#${pathId}`);
121
+ use.setAttribute("stroke", "none");
122
+ use.setAttribute("fill", "black");
123
+ use.setAttribute("fill-rule", "nonzero");
124
+ // use.classList.add("mask");
125
+ }
126
+ const use1 = _a._svgFactory.createElement("use");
127
+ root.append(use1);
128
+ use1.setAttribute("href", `#${pathId}`);
129
+ if (maskId) {
130
+ use1.setAttribute("mask", `url(#${maskId})`);
131
+ }
132
+ const use2 = use1.cloneNode();
133
+ root.append(use2);
134
+ // use1.classList.add("mainOutline");
135
+ // use2.classList.add("secondaryOutline");
136
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").set(id, root);
137
+ return id;
138
+ }
139
+ finalizeLine(id, line) {
140
+ const path = tslib_1.__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").get(id);
141
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").delete(id);
142
+ this.updateBox(id, line.box);
143
+ path.setAttribute("d", line.toSVGPath());
144
+ }
145
+ updateLine(id, line) {
146
+ const root = tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id);
147
+ const defs = root.firstChild;
148
+ const path = defs.firstChild;
149
+ path.setAttribute("d", line.toSVGPath());
150
+ }
151
+ removeFreeHighlight(id) {
152
+ this.remove(id);
153
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").delete(id);
154
+ }
155
+ updatePath(id, line) {
156
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_toUpdate, "f").get(id).setAttribute("d", line.toSVGPath());
157
+ }
158
+ updateBox(id, box) {
159
+ tslib_1.__classPrivateFieldGet(_a, _a, "m", _DrawLayer_setBox).call(_a, tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id), box);
160
+ }
161
+ show(id, visible) {
162
+ // this.#mapping.get(id).classList.toggle("hidden", !visible);
163
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).classList.toggle("k-hidden", !visible);
164
+ }
165
+ rotate(id, angle) {
166
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).setAttribute("data-main-rotation", angle);
167
+ }
168
+ changeColor(id, color) {
169
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).setAttribute("fill", color);
170
+ }
171
+ changeOpacity(id, opacity) {
172
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).setAttribute("fill-opacity", opacity);
173
+ }
174
+ addClass(id, className) {
175
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).classList.add(className);
176
+ }
177
+ removeClass(id, className) {
178
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).classList.remove(className);
179
+ }
180
+ remove(id) {
181
+ if (tslib_1.__classPrivateFieldGet(this, _DrawLayer_parent, "f") === null) {
182
+ return;
183
+ }
184
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").get(id).remove();
185
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").delete(id);
186
+ }
187
+ destroy() {
188
+ tslib_1.__classPrivateFieldSet(this, _DrawLayer_parent, null, "f");
189
+ for (const root of tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").values()) {
190
+ root.remove();
191
+ }
192
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_mapping, "f").clear();
193
+ }
194
+ }
195
+ exports.DrawLayer = DrawLayer;
196
+ _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 } = {}) {
197
+ const { style } = element;
198
+ style.top = `${100 * y}%`;
199
+ style.left = `${100 * x}%`;
200
+ // style.width = `${100 * width}%`;
201
+ // style.height = `${100 * height}%`;
202
+ // todo: reduce the dimensions, so that the annotation editor toolbar
203
+ // does not overlap the outline
204
+ style.width = `${100 * width - 0.2}%`;
205
+ style.height = `${100 * height - 0.2}%`;
206
+ }, _DrawLayer_createSVG = function _DrawLayer_createSVG(box) {
207
+ const svg = _a._svgFactory.create(1, 1, /* skipDimensions = */ true);
208
+ tslib_1.__classPrivateFieldGet(this, _DrawLayer_parent, "f").append(svg);
209
+ svg.setAttribute("aria-hidden", true);
210
+ tslib_1.__classPrivateFieldGet(_a, _a, "m", _DrawLayer_setBox).call(_a, svg, box);
211
+ return svg;
212
+ }, _DrawLayer_createClipPath = function _DrawLayer_createClipPath(defs, pathId) {
213
+ const clipPath = _a._svgFactory.createElement("clipPath");
214
+ defs.append(clipPath);
215
+ const clipPathId = `clip_${pathId}`;
216
+ clipPath.setAttribute("id", clipPathId);
217
+ clipPath.setAttribute("clipPathUnits", "objectBoundingBox");
218
+ const clipPathUse = _a._svgFactory.createElement("use");
219
+ clipPath.append(clipPathUse);
220
+ clipPathUse.setAttribute("href", `#${pathId}`);
221
+ // clipPathUse.classList.add("clip");
222
+ return clipPathId;
223
+ };
@@ -0,0 +1,349 @@
1
+ import { IdManager } from "../helpers/id-manager";
2
+ import { ColorManager } from "../helpers/color-manager";
3
+ import { AnnotationEditorUIManager } from "../annotation-editor-ui-manager";
4
+ export declare class AnnotationEditor {
5
+ #private;
6
+ parent: any;
7
+ id: any;
8
+ width: any;
9
+ height: any;
10
+ pageIndex: number;
11
+ name: string;
12
+ div: any;
13
+ annotationElementId: any;
14
+ _willKeepAspectRatio: boolean;
15
+ _structTreeParentId: any;
16
+ rotation: number;
17
+ pageRotation: number;
18
+ pageDimensions: any[];
19
+ pageTranslation: any[];
20
+ isAttachedToDOM: boolean;
21
+ deleted: boolean;
22
+ static idManager: IdManager;
23
+ _editToolbar: any;
24
+ _initialOptions: any;
25
+ _isVisible: boolean;
26
+ _uiManager: AnnotationEditorUIManager;
27
+ _focusEventsAllowed: boolean;
28
+ _l10nPromise: any;
29
+ static _borderLineWidth: number;
30
+ static _colorManager: ColorManager;
31
+ static _zIndex: number;
32
+ static _telemetryTimeout: number;
33
+ constructor(parameters: any);
34
+ get x(): number;
35
+ set x(value: number);
36
+ get y(): number;
37
+ set y(value: number);
38
+ get editorType(): any;
39
+ static get _defaultLineColor(): any;
40
+ static deleteAnnotationElement(editor: any): void;
41
+ static initialize(l10n: any, _uiManager: any, options: any): void;
42
+ /**
43
+ * Update the default parameters for this type of editor.
44
+ * @param {number} _type
45
+ * @param {*} _value
46
+ */
47
+ static updateDefaultParams(_type: any, _value: any): void;
48
+ /**
49
+ * Get the default properties to set in the UI for this type of editor.
50
+ * @returns {Array}
51
+ */
52
+ static get defaultPropertiesToUpdate(): any[];
53
+ /**
54
+ * Check if this kind of editor is able to handle the given mime type for
55
+ * pasting.
56
+ * @param {string} mime
57
+ * @returns {boolean}
58
+ */
59
+ static isHandlingMimeForPasting(mime: any): boolean;
60
+ /**
61
+ * Extract the data from the clipboard item and delegate the creation of the
62
+ * editor to the parent.
63
+ * @param {DataTransferItem} item
64
+ * @param {AnnotationEditorLayer} parent
65
+ */
66
+ static paste(item: any, parent: any): void;
67
+ /**
68
+ * Get the properties to update in the UI for this editor.
69
+ * @returns {Array}
70
+ */
71
+ get propertiesToUpdate(): any[];
72
+ get _isDraggable(): boolean;
73
+ set _isDraggable(value: boolean);
74
+ /**
75
+ * @returns {boolean} true if the editor handles the Enter key itself.
76
+ */
77
+ get isEnterHandled(): boolean;
78
+ center(): void;
79
+ /**
80
+ * Add some commands into the CommandManager (undo/redo stuff).
81
+ * @param {Object} params
82
+ */
83
+ addCommands(params: any): void;
84
+ get currentLayer(): any;
85
+ /**
86
+ * This editor will be behind the others.
87
+ */
88
+ setInBackground(): void;
89
+ /**
90
+ * This editor will be in the foreground.
91
+ */
92
+ setInForeground(): void;
93
+ setParent(parent: any): void;
94
+ /**
95
+ * onfocus callback.
96
+ */
97
+ focusin(event: any): void;
98
+ /**
99
+ * onblur callback.
100
+ * @param {FocusEvent} event
101
+ */
102
+ focusout(event: any): void;
103
+ commitOrRemove(): void;
104
+ /**
105
+ * Commit the data contained in this editor.
106
+ */
107
+ commit(): void;
108
+ addToAnnotationStorage(): void;
109
+ /**
110
+ * Set the editor position within its parent.
111
+ * @param {number} x
112
+ * @param {number} y
113
+ * @param {number} tx - x-translation in screen coordinates.
114
+ * @param {number} ty - y-translation in screen coordinates.
115
+ */
116
+ setAt(x: any, y: any, tx: any, ty: any): void;
117
+ /**
118
+ * Translate the editor position within its parent.
119
+ * @param {number} x - x-translation in screen coordinates.
120
+ * @param {number} y - y-translation in screen coordinates.
121
+ */
122
+ translate(x: any, y: any): void;
123
+ /**
124
+ * Translate the editor position within its page and adjust the scroll
125
+ * in order to have the editor in the view.
126
+ * @param {number} x - x-translation in page coordinates.
127
+ * @param {number} y - y-translation in page coordinates.
128
+ */
129
+ translateInPage(x: any, y: any): void;
130
+ drag(tx: any, ty: any): void;
131
+ get _hasBeenMoved(): boolean;
132
+ /**
133
+ * Get the translation to take into account the editor border.
134
+ * The CSS engine positions the element by taking the border into account so
135
+ * we must apply the opposite translation to have the editor in the right
136
+ * position.
137
+ * @returns {Array<number>}
138
+ */
139
+ getBaseTranslation(): number[];
140
+ /**
141
+ * @returns {boolean} true if position must be fixed (i.e. make the x and y
142
+ * living in the page).
143
+ */
144
+ get _mustFixPosition(): boolean;
145
+ /**
146
+ * Fix the position of the editor in order to keep it inside its parent page.
147
+ * @param {number} [rotation] - the rotation of the page.
148
+ */
149
+ fixAndSetPosition(rotation?: number): void;
150
+ /**
151
+ * Convert a screen translation into a page one.
152
+ * @param {number} x
153
+ * @param {number} y
154
+ */
155
+ screenToPageTranslation(x: any, y: any): any[];
156
+ /**
157
+ * Convert a page translation into a screen one.
158
+ * @param {number} x
159
+ * @param {number} y
160
+ */
161
+ pageTranslationToScreen(x: any, y: any): any[];
162
+ get parentScale(): any;
163
+ get parentRotation(): number;
164
+ get parentDimensions(): number[];
165
+ /**
166
+ * Set the dimensions of this editor.
167
+ * @param {number} width
168
+ * @param {number} height
169
+ */
170
+ setDims(width: any, height: any): void;
171
+ fixDims(): void;
172
+ /**
173
+ * Get the translation used to position this editor when it's created.
174
+ * @returns {Array<number>}
175
+ */
176
+ getInitialTranslation(): number[];
177
+ addEditToolbar(): void;
178
+ removeEditToolbar(): void;
179
+ getClientDimensions(): any;
180
+ /**
181
+ * Render this editor in a div.
182
+ * @returns {HTMLDivElement | null}
183
+ */
184
+ render(): any;
185
+ /**
186
+ * Onpointerdown callback.
187
+ * @param {PointerEvent} event
188
+ */
189
+ pointerdown(event: any): void;
190
+ moveInDOM(): void;
191
+ _setParentAndPosition(parent: any, x: any, y: any): void;
192
+ getRect(tx: any, ty: any, rotation?: number): any[];
193
+ getRectInCurrentCoords(rect: any, pageHeight: any): any[];
194
+ onceAdded(): void;
195
+ isEmpty(): boolean;
196
+ /**
197
+ * Enable edit mode.
198
+ */
199
+ enableEditMode(): void;
200
+ /**
201
+ * Disable edit mode.
202
+ */
203
+ disableEditMode(): void;
204
+ /**
205
+ * Check if the editor is edited.
206
+ * @returns {boolean}
207
+ */
208
+ isInEditMode(): boolean;
209
+ /**
210
+ * Check if this editor needs to be rebuilt or not.
211
+ * @returns {boolean}
212
+ */
213
+ needsToBeRebuilt(): boolean;
214
+ /**
215
+ * Rebuild the editor in case it has been removed on undo.
216
+ *
217
+ * To implement in subclasses.
218
+ */
219
+ rebuild(): void;
220
+ /**
221
+ * Rotate the editor.
222
+ * @param {number} angle
223
+ */
224
+ rotate(angle: any): void;
225
+ /**
226
+ * Serialize the editor.
227
+ * The result of the serialization will be used to construct a
228
+ * new annotation to add to the pdf document.
229
+ *
230
+ * To implement in subclasses.
231
+ * @param {boolean} [isForCopying]
232
+ * @param {Object | null} [context]
233
+ * @returns {Object | null}
234
+ */
235
+ serialize(isForCopying?: boolean, context?: any): void;
236
+ /**
237
+ * Deserialize the editor.
238
+ * The result of the deserialization is a new editor.
239
+ *
240
+ * @param {Object} data
241
+ * @param {AnnotationEditorLayer} parent
242
+ * @param {AnnotationEditorUIManager} uiManager
243
+ * @returns {AnnotationEditor | null}
244
+ */
245
+ static deserialize(data: any, parent: any, uiManager: any): any;
246
+ /**
247
+ * Check if an existing annotation associated with this editor has been
248
+ * modified.
249
+ * @returns {boolean}
250
+ */
251
+ get hasBeenModified(): boolean;
252
+ /**
253
+ * Remove this editor.
254
+ * It's used on ctrl+backspace action.
255
+ */
256
+ remove(): void;
257
+ /**
258
+ * @returns {boolean} true if this editor can be resized.
259
+ */
260
+ get isResizable(): boolean;
261
+ /**
262
+ * Add the resizers to this editor.
263
+ */
264
+ makeResizable(): void;
265
+ get toolbarPosition(): any;
266
+ _stopResizingWithKeyboard(): void;
267
+ /**
268
+ * Select this editor.
269
+ */
270
+ select(): void;
271
+ /**
272
+ * Unselect this editor.
273
+ */
274
+ unselect(): void;
275
+ /**
276
+ * Update some parameters which have been changed through the UI.
277
+ * @param {number} type
278
+ * @param {*} value
279
+ */
280
+ updateParams(type: any, value: any): void;
281
+ /**
282
+ * When the user disables the editing mode some editors can change some of
283
+ * their properties.
284
+ */
285
+ disableEditing(): void;
286
+ /**
287
+ * When the user enables the editing mode some editors can change some of
288
+ * their properties.
289
+ */
290
+ enableEditing(): void;
291
+ /**
292
+ * The editor is about to be edited.
293
+ */
294
+ enterInEditMode(): void;
295
+ /**
296
+ * @returns {HTMLElement | null} the element requiring an alt text.
297
+ */
298
+ getImageForAltText(): any;
299
+ /**
300
+ * Get the div which really contains the displayed content.
301
+ * @returns {HTMLDivElement | undefined}
302
+ */
303
+ get contentDiv(): any;
304
+ /**
305
+ * If true then the editor is currently edited.
306
+ * @type {boolean}
307
+ */
308
+ get isEditing(): boolean;
309
+ /**
310
+ * When set to true, it means that this editor is currently edited.
311
+ * @param {boolean} value
312
+ */
313
+ set isEditing(value: boolean);
314
+ /**
315
+ * Set the aspect ratio to use when resizing.
316
+ * @param {number} width
317
+ * @param {number} height
318
+ */
319
+ setAspectRatio(width: any, height: any): void;
320
+ static get MIN_SIZE(): number;
321
+ static canCreateNewEmptyEditor(): boolean;
322
+ /**
323
+ * Get the data to report to the telemetry when the editor is added.
324
+ * @returns {Object}
325
+ */
326
+ get telemetryInitialData(): {
327
+ action: string;
328
+ };
329
+ /**
330
+ * The telemetry data to use when saving/printing.
331
+ * @returns {Object|null}
332
+ */
333
+ get telemetryFinalData(): any;
334
+ _reportTelemetry(): void;
335
+ /**
336
+ * Show or hide this editor.
337
+ * @param {boolean|undefined} visible
338
+ */
339
+ show(visible?: boolean): void;
340
+ enable(): void;
341
+ disable(): void;
342
+ /**
343
+ * Render an annotation in the annotation layer.
344
+ * @param {Object} annotation
345
+ * @returns {HTMLElement}
346
+ */
347
+ renderAnnotationElement(annotation: any): any;
348
+ resetAnnotationElement(annotation: any): void;
349
+ }