@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,717 @@
|
|
|
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 _HighlightEditor_instances, _a, _HighlightEditor_anchorNode, _HighlightEditor_anchorOffset, _HighlightEditor_boxes, _HighlightEditor_clipPathId, _HighlightEditor_focusOutlines, _HighlightEditor_focusNode, _HighlightEditor_focusOffset, _HighlightEditor_highlightDiv, _HighlightEditor_highlightOutlines, _HighlightEditor_id, _HighlightEditor_isFreeHighlight, _HighlightEditor_lastPoint, _HighlightEditor_opacity, _HighlightEditor_outlineId, _HighlightEditor_text, _HighlightEditor_thickness, _HighlightEditor_methodOfCreation, _HighlightEditor_createOutlines, _HighlightEditor_createFreeOutlines, _HighlightEditor_updateColor, _HighlightEditor_updateThickness, _HighlightEditor_cleanDrawLayer, _HighlightEditor_addToDrawLayer, _HighlightEditor_rotateBbox, _HighlightEditor_keydown, _HighlightEditor_setCaret, _HighlightEditor_getRotation, _HighlightEditor_serializeBoxes, _HighlightEditor_serializeOutlines, _HighlightEditor_highlightMove, _HighlightEditor_endHighlight;
|
|
16
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
17
|
+
import { AnnotationEditorParamsType, AnnotationEditorType,
|
|
18
|
+
// DrawLayer,
|
|
19
|
+
// shadow,
|
|
20
|
+
Util, noContextMenu } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
21
|
+
import { bindEvents } from "../helpers/tools";
|
|
22
|
+
// import { bindEvents, KeyboardManager } from "./tools.js";
|
|
23
|
+
// import { FreeOutliner, Outliner } from "./outliner.js";
|
|
24
|
+
import { AnnotationEditor } from "./annotation-editor";
|
|
25
|
+
import { FreeOutliner, Outliner } from "./outliner";
|
|
26
|
+
// import { ColorPicker } from "./color_picker.js";
|
|
27
|
+
// import { noContextMenu } from "../../shared/display_utils";
|
|
28
|
+
/**
|
|
29
|
+
* Basic draw editor in order to generate an Highlight annotation.
|
|
30
|
+
*/
|
|
31
|
+
class HighlightEditor extends AnnotationEditor {
|
|
32
|
+
// static get _keyboardManager() {
|
|
33
|
+
// const proto = HighlightEditor.prototype;
|
|
34
|
+
// return shadow(
|
|
35
|
+
// this,
|
|
36
|
+
// "_keyboardManager",
|
|
37
|
+
// new KeyboardManager([
|
|
38
|
+
// [["ArrowLeft", "mac+ArrowLeft"], proto._moveCaret, { args: [0] }],
|
|
39
|
+
// [["ArrowRight", "mac+ArrowRight"], proto._moveCaret, { args: [1] }],
|
|
40
|
+
// [["ArrowUp", "mac+ArrowUp"], proto._moveCaret, { args: [2] }],
|
|
41
|
+
// [["ArrowDown", "mac+ArrowDown"], proto._moveCaret, { args: [3] }],
|
|
42
|
+
// ])
|
|
43
|
+
// );
|
|
44
|
+
// }
|
|
45
|
+
constructor(params) {
|
|
46
|
+
super(Object.assign(Object.assign({}, params), { name: "k-highlight-editor highlightEditor" }));
|
|
47
|
+
_HighlightEditor_instances.add(this);
|
|
48
|
+
// todo: props
|
|
49
|
+
this.color = "";
|
|
50
|
+
// parent = null;
|
|
51
|
+
// width = null;
|
|
52
|
+
// height = null;
|
|
53
|
+
// x = null;
|
|
54
|
+
// y = null;
|
|
55
|
+
// todo: props
|
|
56
|
+
_HighlightEditor_anchorNode.set(this, null);
|
|
57
|
+
_HighlightEditor_anchorOffset.set(this, 0);
|
|
58
|
+
_HighlightEditor_boxes.set(this, void 0);
|
|
59
|
+
_HighlightEditor_clipPathId.set(this, null);
|
|
60
|
+
// #colorPicker = null;
|
|
61
|
+
_HighlightEditor_focusOutlines.set(this, null);
|
|
62
|
+
_HighlightEditor_focusNode.set(this, null);
|
|
63
|
+
_HighlightEditor_focusOffset.set(this, 0);
|
|
64
|
+
_HighlightEditor_highlightDiv.set(this, null);
|
|
65
|
+
_HighlightEditor_highlightOutlines.set(this, null);
|
|
66
|
+
_HighlightEditor_id.set(this, null);
|
|
67
|
+
_HighlightEditor_isFreeHighlight.set(this, false);
|
|
68
|
+
_HighlightEditor_lastPoint.set(this, null);
|
|
69
|
+
_HighlightEditor_opacity.set(this, void 0);
|
|
70
|
+
_HighlightEditor_outlineId.set(this, null);
|
|
71
|
+
_HighlightEditor_text.set(this, "");
|
|
72
|
+
_HighlightEditor_thickness.set(this, void 0);
|
|
73
|
+
_HighlightEditor_methodOfCreation.set(this, "");
|
|
74
|
+
this.color = params.color || _a._defaultColor;
|
|
75
|
+
__classPrivateFieldSet(this, _HighlightEditor_thickness, params.thickness || _a._defaultThickness, "f");
|
|
76
|
+
__classPrivateFieldSet(this, _HighlightEditor_opacity, params.opacity || _a._defaultOpacity, "f");
|
|
77
|
+
__classPrivateFieldSet(this, _HighlightEditor_boxes, params.boxes || null, "f");
|
|
78
|
+
__classPrivateFieldSet(this, _HighlightEditor_methodOfCreation, params.methodOfCreation || "", "f");
|
|
79
|
+
__classPrivateFieldSet(this, _HighlightEditor_text, params.text || "", "f");
|
|
80
|
+
this._isDraggable = false;
|
|
81
|
+
if (params.highlightId > -1) {
|
|
82
|
+
__classPrivateFieldSet(this, _HighlightEditor_isFreeHighlight, true, "f");
|
|
83
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_createFreeOutlines).call(this, params);
|
|
84
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_addToDrawLayer).call(this);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
__classPrivateFieldSet(this, _HighlightEditor_anchorNode, params.anchorNode, "f");
|
|
88
|
+
__classPrivateFieldSet(this, _HighlightEditor_anchorOffset, params.anchorOffset, "f");
|
|
89
|
+
__classPrivateFieldSet(this, _HighlightEditor_focusNode, params.focusNode, "f");
|
|
90
|
+
__classPrivateFieldSet(this, _HighlightEditor_focusOffset, params.focusOffset, "f");
|
|
91
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_createOutlines).call(this);
|
|
92
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_addToDrawLayer).call(this);
|
|
93
|
+
this.rotate(this.rotation);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** @inheritdoc */
|
|
97
|
+
get telemetryInitialData() {
|
|
98
|
+
return {
|
|
99
|
+
action: "added",
|
|
100
|
+
type: __classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f") ? "free_highlight" : "highlight",
|
|
101
|
+
color: this._uiManager.highlightColorNames.get(this.color),
|
|
102
|
+
thickness: __classPrivateFieldGet(this, _HighlightEditor_thickness, "f"),
|
|
103
|
+
methodOfCreation: __classPrivateFieldGet(this, _HighlightEditor_methodOfCreation, "f"),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** @inheritdoc */
|
|
107
|
+
get telemetryFinalData() {
|
|
108
|
+
return {
|
|
109
|
+
type: "highlight",
|
|
110
|
+
color: this._uiManager.highlightColorNames.get(this.color),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
static computeTelemetryFinalData(data) {
|
|
114
|
+
// We want to know how many colors have been used.
|
|
115
|
+
return { numberOfColors: data.get("color").size };
|
|
116
|
+
}
|
|
117
|
+
/** @inheritdoc */
|
|
118
|
+
static initialize(l10n, uiManager) {
|
|
119
|
+
var _b, _c, _d, _e;
|
|
120
|
+
AnnotationEditor.initialize(l10n, uiManager, {});
|
|
121
|
+
_a._defaultColor || (_a._defaultColor =
|
|
122
|
+
// uiManager.highlightColors?.values().next().value || "#fff066";
|
|
123
|
+
// uiManager.highlightColors?.values().next().value || "#ffff00";
|
|
124
|
+
((_e = (_d = (_c = (_b = uiManager.viewer) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.annotations) === null || _d === void 0 ? void 0 : _d.highlight) === null || _e === void 0 ? void 0 : _e.color) || "#ffff00");
|
|
125
|
+
}
|
|
126
|
+
/** @inheritdoc */
|
|
127
|
+
static updateDefaultParams(type, value) {
|
|
128
|
+
switch (type) {
|
|
129
|
+
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
|
|
130
|
+
_a._defaultColor = value;
|
|
131
|
+
break;
|
|
132
|
+
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
|
133
|
+
_a._defaultThickness = value;
|
|
134
|
+
break;
|
|
135
|
+
default: break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** @inheritdoc */
|
|
139
|
+
// translateInPage(x, y) { }
|
|
140
|
+
translateInPage() { }
|
|
141
|
+
/** @inheritdoc */
|
|
142
|
+
get toolbarPosition() {
|
|
143
|
+
return __classPrivateFieldGet(this, _HighlightEditor_lastPoint, "f");
|
|
144
|
+
}
|
|
145
|
+
/** @inheritdoc */
|
|
146
|
+
updateParams(type, value) {
|
|
147
|
+
switch (type) {
|
|
148
|
+
case AnnotationEditorParamsType.HIGHLIGHT_COLOR:
|
|
149
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_updateColor).call(this, value);
|
|
150
|
+
break;
|
|
151
|
+
case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:
|
|
152
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_updateThickness).call(this, value);
|
|
153
|
+
break;
|
|
154
|
+
default: break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
static get defaultPropertiesToUpdate() {
|
|
158
|
+
return [
|
|
159
|
+
[
|
|
160
|
+
AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR,
|
|
161
|
+
_a._defaultColor,
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,
|
|
165
|
+
_a._defaultThickness,
|
|
166
|
+
],
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
/** @inheritdoc */
|
|
170
|
+
get propertiesToUpdate() {
|
|
171
|
+
return [
|
|
172
|
+
[
|
|
173
|
+
AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
|
174
|
+
this.color || _a._defaultColor,
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,
|
|
178
|
+
__classPrivateFieldGet(this, _HighlightEditor_thickness, "f") || _a._defaultThickness,
|
|
179
|
+
],
|
|
180
|
+
[AnnotationEditorParamsType.HIGHLIGHT_FREE, __classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f")],
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
/** @inheritdoc */
|
|
184
|
+
// async addEditToolbar() {
|
|
185
|
+
// // const toolbar = await super.addEditToolbar();
|
|
186
|
+
// // if (!toolbar) {
|
|
187
|
+
// // return null;
|
|
188
|
+
// // }
|
|
189
|
+
// // if (this._uiManager.highlightColors) {
|
|
190
|
+
// // // this.#colorPicker = new ColorPicker({ editor: this });
|
|
191
|
+
// // // toolbar.addColorPicker(this.#colorPicker);
|
|
192
|
+
// // }
|
|
193
|
+
// // return toolbar;
|
|
194
|
+
// }
|
|
195
|
+
/** @inheritdoc */
|
|
196
|
+
disableEditing() {
|
|
197
|
+
super.disableEditing();
|
|
198
|
+
this.div.classList.toggle("disabled", true);
|
|
199
|
+
// this.div.classList.toggle("k-disabled", true);
|
|
200
|
+
}
|
|
201
|
+
/** @inheritdoc */
|
|
202
|
+
enableEditing() {
|
|
203
|
+
super.enableEditing();
|
|
204
|
+
this.div.classList.toggle("disabled", false);
|
|
205
|
+
// this.div.classList.toggle("k-disabled", false);
|
|
206
|
+
}
|
|
207
|
+
/** @inheritdoc */
|
|
208
|
+
fixAndSetPosition() {
|
|
209
|
+
return super.fixAndSetPosition(__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_getRotation).call(this));
|
|
210
|
+
}
|
|
211
|
+
/** @inheritdoc */
|
|
212
|
+
getBaseTranslation() {
|
|
213
|
+
// The editor itself doesn't have any CSS border (we're drawing one
|
|
214
|
+
// ourselves in using SVG).
|
|
215
|
+
return [0, 0];
|
|
216
|
+
}
|
|
217
|
+
/** @inheritdoc */
|
|
218
|
+
getRect(tx, ty) {
|
|
219
|
+
return super.getRect(tx, ty, __classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_getRotation).call(this));
|
|
220
|
+
}
|
|
221
|
+
/** @inheritdoc */
|
|
222
|
+
onceAdded() {
|
|
223
|
+
this.parent.addUndoableEditor(this);
|
|
224
|
+
this.div.focus();
|
|
225
|
+
}
|
|
226
|
+
/** @inheritdoc */
|
|
227
|
+
remove() {
|
|
228
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_cleanDrawLayer).call(this);
|
|
229
|
+
// this._reportTelemetry({
|
|
230
|
+
// action: "deleted",
|
|
231
|
+
// });
|
|
232
|
+
super.remove();
|
|
233
|
+
}
|
|
234
|
+
/** @inheritdoc */
|
|
235
|
+
rebuild() {
|
|
236
|
+
if (!this.parent) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
super.rebuild();
|
|
240
|
+
if (this.div === null) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_addToDrawLayer).call(this);
|
|
244
|
+
if (!this.isAttachedToDOM) {
|
|
245
|
+
// At some point this editor was removed and we're rebuilding it,
|
|
246
|
+
// hence we must add it to its parent.
|
|
247
|
+
this.parent.add(this);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
setParent(parent) {
|
|
251
|
+
var _b, _c;
|
|
252
|
+
let mustBeSelected = false;
|
|
253
|
+
if (this.parent && !parent) {
|
|
254
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_cleanDrawLayer).call(this);
|
|
255
|
+
}
|
|
256
|
+
else if (parent) {
|
|
257
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_addToDrawLayer).call(this, parent);
|
|
258
|
+
// If mustBeSelected is true it means that this editor was selected
|
|
259
|
+
// when its parent has been destroyed, hence we must select it again.
|
|
260
|
+
mustBeSelected =
|
|
261
|
+
!this.parent &&
|
|
262
|
+
(((_b = this.div) === null || _b === void 0 ? void 0 : _b.classList.contains("selectedEditor")) ||
|
|
263
|
+
((_c = this.div) === null || _c === void 0 ? void 0 : _c.classList.contains("k-selected")));
|
|
264
|
+
}
|
|
265
|
+
super.setParent(parent);
|
|
266
|
+
this.show(this._isVisible);
|
|
267
|
+
if (mustBeSelected) {
|
|
268
|
+
// We select it after the parent has been set.
|
|
269
|
+
this.select();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/** @inheritdoc */
|
|
273
|
+
rotate(angle) {
|
|
274
|
+
// We need to rotate the svgs because of the coordinates system.
|
|
275
|
+
const { drawLayer } = this.parent;
|
|
276
|
+
let box;
|
|
277
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f")) {
|
|
278
|
+
angle = (angle - this.rotation + 360) % 360;
|
|
279
|
+
box = __classPrivateFieldGet(_a, _a, "m", _HighlightEditor_rotateBbox).call(_a, __classPrivateFieldGet(this, _HighlightEditor_highlightOutlines, "f").box, angle);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
// An highlight annotation is always drawn horizontally.
|
|
283
|
+
box = __classPrivateFieldGet(_a, _a, "m", _HighlightEditor_rotateBbox).call(_a, this, angle);
|
|
284
|
+
}
|
|
285
|
+
drawLayer.rotate(__classPrivateFieldGet(this, _HighlightEditor_id, "f"), angle);
|
|
286
|
+
drawLayer.rotate(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), angle);
|
|
287
|
+
drawLayer.updateBox(__classPrivateFieldGet(this, _HighlightEditor_id, "f"), box);
|
|
288
|
+
drawLayer.updateBox(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), __classPrivateFieldGet(_a, _a, "m", _HighlightEditor_rotateBbox).call(_a, __classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f").box, angle));
|
|
289
|
+
}
|
|
290
|
+
/** @inheritdoc */
|
|
291
|
+
render() {
|
|
292
|
+
if (this.div) {
|
|
293
|
+
return this.div;
|
|
294
|
+
}
|
|
295
|
+
const div = super.render();
|
|
296
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_text, "f")) {
|
|
297
|
+
div.setAttribute("aria-label", __classPrivateFieldGet(this, _HighlightEditor_text, "f"));
|
|
298
|
+
div.setAttribute("role", "mark");
|
|
299
|
+
}
|
|
300
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f")) {
|
|
301
|
+
div.classList.add("free");
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
this.div.addEventListener("keydown", __classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_keydown).bind(this), {
|
|
305
|
+
signal: this._uiManager._signal,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
const highlightDiv = (__classPrivateFieldSet(this, _HighlightEditor_highlightDiv, document.createElement("div"), "f"));
|
|
309
|
+
div.append(highlightDiv);
|
|
310
|
+
highlightDiv.setAttribute("aria-hidden", "true");
|
|
311
|
+
highlightDiv.className = "k-internal internal";
|
|
312
|
+
highlightDiv.style.clipPath = __classPrivateFieldGet(this, _HighlightEditor_clipPathId, "f");
|
|
313
|
+
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
314
|
+
this.setDims(this.width * parentWidth, this.height * parentHeight);
|
|
315
|
+
bindEvents(this, __classPrivateFieldGet(this, _HighlightEditor_highlightDiv, "f"), ["pointerover", "pointerleave"]);
|
|
316
|
+
this.enableEditing();
|
|
317
|
+
return div;
|
|
318
|
+
}
|
|
319
|
+
pointerover() {
|
|
320
|
+
this.parent.drawLayer.addClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "hovered");
|
|
321
|
+
}
|
|
322
|
+
pointerleave() {
|
|
323
|
+
this.parent.drawLayer.removeClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "hovered");
|
|
324
|
+
}
|
|
325
|
+
_moveCaret(direction) {
|
|
326
|
+
this.parent.unselect(this);
|
|
327
|
+
switch (direction) {
|
|
328
|
+
case 0 /* left */:
|
|
329
|
+
case 2 /* up */:
|
|
330
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_setCaret).call(this, /* start = */ true);
|
|
331
|
+
break;
|
|
332
|
+
case 1 /* right */:
|
|
333
|
+
case 3 /* down */:
|
|
334
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_setCaret).call(this, /* start = */ false);
|
|
335
|
+
break;
|
|
336
|
+
default: break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** @inheritdoc */
|
|
340
|
+
select() {
|
|
341
|
+
var _b, _c, _d;
|
|
342
|
+
super.select();
|
|
343
|
+
if (!__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f")) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
(_b = this.parent) === null || _b === void 0 ? void 0 : _b.drawLayer.removeClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "hovered");
|
|
347
|
+
(_c = this.parent) === null || _c === void 0 ? void 0 : _c.drawLayer.addClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "selected");
|
|
348
|
+
(_d = this.parent) === null || _d === void 0 ? void 0 : _d.drawLayer.addClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "k-selected");
|
|
349
|
+
}
|
|
350
|
+
/** @inheritdoc */
|
|
351
|
+
unselect() {
|
|
352
|
+
var _b, _c;
|
|
353
|
+
super.unselect();
|
|
354
|
+
if (!__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f")) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
(_b = this.parent) === null || _b === void 0 ? void 0 : _b.drawLayer.removeClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "selected");
|
|
358
|
+
(_c = this.parent) === null || _c === void 0 ? void 0 : _c.drawLayer.removeClass(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), "k-selected");
|
|
359
|
+
if (!__classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f")) {
|
|
360
|
+
__classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_setCaret).call(this, /* start = */ false);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/** @inheritdoc */
|
|
364
|
+
get _mustFixPosition() {
|
|
365
|
+
return !__classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f");
|
|
366
|
+
}
|
|
367
|
+
/** @inheritdoc */
|
|
368
|
+
show(visible = this._isVisible) {
|
|
369
|
+
super.show(visible);
|
|
370
|
+
if (this.parent) {
|
|
371
|
+
this.parent.drawLayer.show(__classPrivateFieldGet(this, _HighlightEditor_id, "f"), visible);
|
|
372
|
+
this.parent.drawLayer.show(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), visible);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
static startHighlighting(parent, isLTR, { target: textLayer, x, y }) {
|
|
376
|
+
const { x: layerX, y: layerY, width: parentWidth, height: parentHeight, } = textLayer.getBoundingClientRect();
|
|
377
|
+
const ac = new AbortController();
|
|
378
|
+
const signal = parent.combinedSignal(ac);
|
|
379
|
+
const pointerDown = e => {
|
|
380
|
+
// Avoid to have undesired clicks during the drawing.
|
|
381
|
+
e.preventDefault();
|
|
382
|
+
e.stopPropagation();
|
|
383
|
+
};
|
|
384
|
+
const pointerUpCallback = e => {
|
|
385
|
+
ac.abort();
|
|
386
|
+
__classPrivateFieldGet(this, _a, "m", _HighlightEditor_endHighlight).call(this, parent, e);
|
|
387
|
+
};
|
|
388
|
+
window.addEventListener("blur", pointerUpCallback, { signal });
|
|
389
|
+
window.addEventListener("pointerup", pointerUpCallback, { signal });
|
|
390
|
+
window.addEventListener("pointerdown", pointerDown, {
|
|
391
|
+
capture: true,
|
|
392
|
+
passive: false,
|
|
393
|
+
signal,
|
|
394
|
+
});
|
|
395
|
+
window.addEventListener("contextmenu", noContextMenu, { signal });
|
|
396
|
+
textLayer.addEventListener("pointermove", __classPrivateFieldGet(this, _a, "m", _HighlightEditor_highlightMove).bind(this, parent), { signal });
|
|
397
|
+
this._freeHighlight = new FreeOutliner({ x, y }, [layerX, layerY, parentWidth, parentHeight], parent.scale, this._defaultThickness / 2, isLTR,
|
|
398
|
+
/* innerMargin = */ 0.001);
|
|
399
|
+
({ id: this._freeHighlightId, clipPathId: this._freeHighlightClipId } =
|
|
400
|
+
parent.drawLayer.highlight(this._freeHighlight, this._defaultColor, this._defaultOpacity,
|
|
401
|
+
/* isPathUpdatable = */ true));
|
|
402
|
+
}
|
|
403
|
+
/** @inheritdoc */
|
|
404
|
+
static deserialize(data, parent, uiManager) {
|
|
405
|
+
const editor = super.deserialize(data, parent, uiManager);
|
|
406
|
+
const { rect: [blX, blY, trX, trY], color, quadPoints, } = data;
|
|
407
|
+
// @ts-expect-error TS()
|
|
408
|
+
editor.color = Util.makeHexColor(...color);
|
|
409
|
+
__classPrivateFieldSet(editor, _HighlightEditor_opacity, data.opacity, "f");
|
|
410
|
+
const [pageWidth, pageHeight] = editor.pageDimensions;
|
|
411
|
+
editor.width = (trX - blX) / pageWidth;
|
|
412
|
+
editor.height = (trY - blY) / pageHeight;
|
|
413
|
+
const boxes = (__classPrivateFieldSet(editor, _HighlightEditor_boxes, [], "f"));
|
|
414
|
+
for (let i = 0; i < quadPoints.length; i += 8) {
|
|
415
|
+
boxes.push({
|
|
416
|
+
x: (quadPoints[4] - trX) / pageWidth,
|
|
417
|
+
y: (trY - (1 - quadPoints[i + 5])) / pageHeight,
|
|
418
|
+
width: (quadPoints[i + 2] - quadPoints[i]) / pageWidth,
|
|
419
|
+
height: (quadPoints[i + 5] - quadPoints[i + 1]) / pageHeight,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
__classPrivateFieldGet(editor, _HighlightEditor_instances, "m", _HighlightEditor_createOutlines).call(editor);
|
|
423
|
+
return editor;
|
|
424
|
+
}
|
|
425
|
+
/** @inheritdoc */
|
|
426
|
+
serialize(isForCopying = false) {
|
|
427
|
+
// It doesn't make sense to copy/paste a highlight annotation.
|
|
428
|
+
if (this.isEmpty() || isForCopying) {
|
|
429
|
+
return null;
|
|
430
|
+
}
|
|
431
|
+
const rect = this.getRect(0, 0);
|
|
432
|
+
const color = AnnotationEditor._colorManager.convert(this.color);
|
|
433
|
+
return {
|
|
434
|
+
annotationType: AnnotationEditorType.HIGHLIGHT,
|
|
435
|
+
color,
|
|
436
|
+
opacity: __classPrivateFieldGet(this, _HighlightEditor_opacity, "f"),
|
|
437
|
+
thickness: __classPrivateFieldGet(this, _HighlightEditor_thickness, "f"),
|
|
438
|
+
quadPoints: __classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_serializeBoxes).call(this),
|
|
439
|
+
outlines: __classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_serializeOutlines).call(this, rect),
|
|
440
|
+
pageIndex: this.pageIndex,
|
|
441
|
+
rect,
|
|
442
|
+
rotation: __classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_getRotation).call(this),
|
|
443
|
+
structTreeParentId: this._structTreeParentId,
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
static canCreateNewEmptyEditor() {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
// todo: this is necessary
|
|
450
|
+
// saveDocument() has checks that test "editor instanceof AnnotationEditor", but they fail
|
|
451
|
+
// because AnnotationEditor from "pdfjs-dist/legacy/build/pdf.mjs" is not exported
|
|
452
|
+
// thus replace instances of editors with their serialized version
|
|
453
|
+
toJSON() {
|
|
454
|
+
const data = this.serialize();
|
|
455
|
+
return data;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
_a = HighlightEditor, _HighlightEditor_anchorNode = new WeakMap(), _HighlightEditor_anchorOffset = new WeakMap(), _HighlightEditor_boxes = new WeakMap(), _HighlightEditor_clipPathId = new WeakMap(), _HighlightEditor_focusOutlines = new WeakMap(), _HighlightEditor_focusNode = new WeakMap(), _HighlightEditor_focusOffset = new WeakMap(), _HighlightEditor_highlightDiv = new WeakMap(), _HighlightEditor_highlightOutlines = new WeakMap(), _HighlightEditor_id = new WeakMap(), _HighlightEditor_isFreeHighlight = new WeakMap(), _HighlightEditor_lastPoint = new WeakMap(), _HighlightEditor_opacity = new WeakMap(), _HighlightEditor_outlineId = new WeakMap(), _HighlightEditor_text = new WeakMap(), _HighlightEditor_thickness = new WeakMap(), _HighlightEditor_methodOfCreation = new WeakMap(), _HighlightEditor_instances = new WeakSet(), _HighlightEditor_createOutlines = function _HighlightEditor_createOutlines() {
|
|
459
|
+
const outliner = new Outliner(__classPrivateFieldGet(this, _HighlightEditor_boxes, "f"), /* borderWidth = */ 0.001);
|
|
460
|
+
__classPrivateFieldSet(this, _HighlightEditor_highlightOutlines, outliner.getOutlines(), "f");
|
|
461
|
+
({
|
|
462
|
+
x: this.x,
|
|
463
|
+
y: this.y,
|
|
464
|
+
width: this.width,
|
|
465
|
+
height: this.height,
|
|
466
|
+
} = __classPrivateFieldGet(this, _HighlightEditor_highlightOutlines, "f").box);
|
|
467
|
+
const outlinerForOutline = new Outliner(__classPrivateFieldGet(this, _HighlightEditor_boxes, "f"),
|
|
468
|
+
/* borderWidth = */ 0.0025,
|
|
469
|
+
/* innerMargin = */ 0.001, this._uiManager.direction === "ltr");
|
|
470
|
+
__classPrivateFieldSet(this, _HighlightEditor_focusOutlines, outlinerForOutline.getOutlines(), "f");
|
|
471
|
+
// The last point is in the pages coordinate system.
|
|
472
|
+
const { lastPoint } = __classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f").box;
|
|
473
|
+
__classPrivateFieldSet(this, _HighlightEditor_lastPoint, [
|
|
474
|
+
(lastPoint[0] - this.x) / this.width,
|
|
475
|
+
(lastPoint[1] - this.y) / this.height,
|
|
476
|
+
], "f");
|
|
477
|
+
}, _HighlightEditor_createFreeOutlines = function _HighlightEditor_createFreeOutlines({ highlightOutlines, highlightId, clipPathId }) {
|
|
478
|
+
__classPrivateFieldSet(this, _HighlightEditor_highlightOutlines, highlightOutlines, "f");
|
|
479
|
+
const extraThickness = 1.5;
|
|
480
|
+
__classPrivateFieldSet(this, _HighlightEditor_focusOutlines, highlightOutlines.getNewOutline(
|
|
481
|
+
/* Slightly bigger than the highlight in order to have a little
|
|
482
|
+
space between the highlight and the outline. */
|
|
483
|
+
__classPrivateFieldGet(this, _HighlightEditor_thickness, "f") / 2 + extraThickness,
|
|
484
|
+
/* innerMargin = */ 0.0025), "f");
|
|
485
|
+
if (highlightId >= 0) {
|
|
486
|
+
__classPrivateFieldSet(this, _HighlightEditor_id, highlightId, "f");
|
|
487
|
+
__classPrivateFieldSet(this, _HighlightEditor_clipPathId, clipPathId, "f");
|
|
488
|
+
// We need to redraw the highlight because we change the coordinates to be
|
|
489
|
+
// in the box coordinate system.
|
|
490
|
+
this.parent.drawLayer.finalizeLine(highlightId, highlightOutlines);
|
|
491
|
+
__classPrivateFieldSet(this, _HighlightEditor_outlineId, this.parent.drawLayer.highlightOutline(__classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f")), "f");
|
|
492
|
+
}
|
|
493
|
+
else if (this.parent) {
|
|
494
|
+
const angle = this.parent.viewport.rotation;
|
|
495
|
+
this.parent.drawLayer.updateLine(__classPrivateFieldGet(this, _HighlightEditor_id, "f"), highlightOutlines);
|
|
496
|
+
this.parent.drawLayer.updateBox(__classPrivateFieldGet(this, _HighlightEditor_id, "f"), __classPrivateFieldGet(_a, _a, "m", _HighlightEditor_rotateBbox).call(_a, __classPrivateFieldGet(this, _HighlightEditor_highlightOutlines, "f").box, (angle - this.rotation + 360) % 360));
|
|
497
|
+
this.parent.drawLayer.updateLine(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), __classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f"));
|
|
498
|
+
this.parent.drawLayer.updateBox(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"), __classPrivateFieldGet(_a, _a, "m", _HighlightEditor_rotateBbox).call(_a, __classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f").box, angle));
|
|
499
|
+
}
|
|
500
|
+
const { x, y, width, height } = highlightOutlines.box;
|
|
501
|
+
switch (this.rotation) {
|
|
502
|
+
case 0:
|
|
503
|
+
this.x = x;
|
|
504
|
+
this.y = y;
|
|
505
|
+
this.width = width;
|
|
506
|
+
this.height = height;
|
|
507
|
+
break;
|
|
508
|
+
case 90: {
|
|
509
|
+
const [pageWidth, pageHeight] = this.parentDimensions;
|
|
510
|
+
this.x = y;
|
|
511
|
+
this.y = 1 - x;
|
|
512
|
+
this.width = (width * pageHeight) / pageWidth;
|
|
513
|
+
this.height = (height * pageWidth) / pageHeight;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
case 180:
|
|
517
|
+
this.x = 1 - x;
|
|
518
|
+
this.y = 1 - y;
|
|
519
|
+
this.width = width;
|
|
520
|
+
this.height = height;
|
|
521
|
+
break;
|
|
522
|
+
case 270: {
|
|
523
|
+
const [pageWidth, pageHeight] = this.parentDimensions;
|
|
524
|
+
this.x = 1 - y;
|
|
525
|
+
this.y = x;
|
|
526
|
+
this.width = (width * pageHeight) / pageWidth;
|
|
527
|
+
this.height = (height * pageWidth) / pageHeight;
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
default: break;
|
|
531
|
+
}
|
|
532
|
+
const { lastPoint } = __classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f").box;
|
|
533
|
+
__classPrivateFieldSet(this, _HighlightEditor_lastPoint, [(lastPoint[0] - x) / width, (lastPoint[1] - y) / height], "f");
|
|
534
|
+
}, _HighlightEditor_updateColor = function _HighlightEditor_updateColor(color) {
|
|
535
|
+
if (!color) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
const setColor = col => {
|
|
539
|
+
var _b;
|
|
540
|
+
this.color = col;
|
|
541
|
+
(_b = this.parent) === null || _b === void 0 ? void 0 : _b.drawLayer.changeColor(__classPrivateFieldGet(this, _HighlightEditor_id, "f"), col);
|
|
542
|
+
// this.#colorPicker?.updateColor(col);
|
|
543
|
+
};
|
|
544
|
+
const savedColor = this.color;
|
|
545
|
+
this.addCommands({
|
|
546
|
+
cmd: setColor.bind(this, color),
|
|
547
|
+
undo: setColor.bind(this, savedColor),
|
|
548
|
+
post: this._uiManager.updateUI.bind(this._uiManager, this),
|
|
549
|
+
mustExec: true,
|
|
550
|
+
type: AnnotationEditorParamsType.HIGHLIGHT_COLOR,
|
|
551
|
+
overwriteIfSameType: true,
|
|
552
|
+
keepUndo: true,
|
|
553
|
+
});
|
|
554
|
+
// this._reportTelemetry(
|
|
555
|
+
// {
|
|
556
|
+
// action: "color_changed",
|
|
557
|
+
// color: this._uiManager.highlightColorNames.get(color),
|
|
558
|
+
// },
|
|
559
|
+
// /* mustWait = */ true
|
|
560
|
+
// );
|
|
561
|
+
}, _HighlightEditor_updateThickness = function _HighlightEditor_updateThickness(thickness) {
|
|
562
|
+
if (!thickness) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
// const savedThickness = this.#thickness;
|
|
566
|
+
// const setThickness = th => {
|
|
567
|
+
// this.#thickness = th;
|
|
568
|
+
// this.#changeThickness(th);
|
|
569
|
+
// };
|
|
570
|
+
// this.addCommands({
|
|
571
|
+
// cmd: setThickness.bind(this, thickness),
|
|
572
|
+
// undo: setThickness.bind(this, savedThickness),
|
|
573
|
+
// post: this._uiManager.updateUI.bind(this._uiManager, this),
|
|
574
|
+
// mustExec: true,
|
|
575
|
+
// type: AnnotationEditorParamsType.INK_THICKNESS,
|
|
576
|
+
// overwriteIfSameType: true,
|
|
577
|
+
// keepUndo: true,
|
|
578
|
+
// });
|
|
579
|
+
// this._reportTelemetry(
|
|
580
|
+
// { action: "thickness_changed", thickness },
|
|
581
|
+
// /* mustWait = */ true
|
|
582
|
+
// );
|
|
583
|
+
}, _HighlightEditor_cleanDrawLayer = function _HighlightEditor_cleanDrawLayer() {
|
|
584
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_id, "f") === null || !this.parent) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
this.parent.drawLayer.remove(__classPrivateFieldGet(this, _HighlightEditor_id, "f"));
|
|
588
|
+
__classPrivateFieldSet(this, _HighlightEditor_id, null, "f");
|
|
589
|
+
this.parent.drawLayer.remove(__classPrivateFieldGet(this, _HighlightEditor_outlineId, "f"));
|
|
590
|
+
__classPrivateFieldSet(this, _HighlightEditor_outlineId, null, "f");
|
|
591
|
+
}, _HighlightEditor_addToDrawLayer = function _HighlightEditor_addToDrawLayer(parent = this.parent) {
|
|
592
|
+
var _b, _c;
|
|
593
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_id, "f") !== null) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
(_b = this, _c = this, { id: ({ set value(_a) { __classPrivateFieldSet(_b, _HighlightEditor_id, _a, "f"); } }).value, clipPathId: ({ set value(_a) { __classPrivateFieldSet(_c, _HighlightEditor_clipPathId, _a, "f"); } }).value } =
|
|
597
|
+
parent.drawLayer.highlight(__classPrivateFieldGet(this, _HighlightEditor_highlightOutlines, "f"), this.color, __classPrivateFieldGet(this, _HighlightEditor_opacity, "f")));
|
|
598
|
+
__classPrivateFieldSet(this, _HighlightEditor_outlineId, parent.drawLayer.highlightOutline(__classPrivateFieldGet(this, _HighlightEditor_focusOutlines, "f")), "f");
|
|
599
|
+
// // todo: manually set styles, so that SVG elements are properly displayed
|
|
600
|
+
// if (parent.drawLayer.parent) {
|
|
601
|
+
// Array.from(parent.drawLayer.parent.querySelectorAll(".highlight")).forEach(x => {
|
|
602
|
+
// const element = x as any;
|
|
603
|
+
// element.style["--blend-mode"] = "multiply";
|
|
604
|
+
// element.style.position = "absolute";
|
|
605
|
+
// element.style["mix-blend-mode"] = "var(--blend-mode)";
|
|
606
|
+
// element.style.transform = "none";
|
|
607
|
+
// });
|
|
608
|
+
// }
|
|
609
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_highlightDiv, "f")) {
|
|
610
|
+
__classPrivateFieldGet(this, _HighlightEditor_highlightDiv, "f").style.clipPath = __classPrivateFieldGet(this, _HighlightEditor_clipPathId, "f");
|
|
611
|
+
}
|
|
612
|
+
}, _HighlightEditor_rotateBbox = function _HighlightEditor_rotateBbox({ x, y, width, height }, angle) {
|
|
613
|
+
switch (angle) {
|
|
614
|
+
case 90:
|
|
615
|
+
return {
|
|
616
|
+
x: 1 - y - height,
|
|
617
|
+
y: x,
|
|
618
|
+
width: height,
|
|
619
|
+
height: width,
|
|
620
|
+
};
|
|
621
|
+
case 180:
|
|
622
|
+
return {
|
|
623
|
+
x: 1 - x - width,
|
|
624
|
+
y: 1 - y - height,
|
|
625
|
+
width,
|
|
626
|
+
height,
|
|
627
|
+
};
|
|
628
|
+
case 270:
|
|
629
|
+
return {
|
|
630
|
+
x: y,
|
|
631
|
+
y: 1 - x - width,
|
|
632
|
+
width: height,
|
|
633
|
+
height: width,
|
|
634
|
+
};
|
|
635
|
+
default: break;
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
x,
|
|
639
|
+
y,
|
|
640
|
+
width,
|
|
641
|
+
height,
|
|
642
|
+
};
|
|
643
|
+
}, _HighlightEditor_keydown = function _HighlightEditor_keydown(event) {
|
|
644
|
+
if (!event) {
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
// HighlightEditor._keyboardManager.exec(this, event);
|
|
648
|
+
}, _HighlightEditor_setCaret = function _HighlightEditor_setCaret(start) {
|
|
649
|
+
if (!__classPrivateFieldGet(this, _HighlightEditor_anchorNode, "f")) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const selection = window.getSelection();
|
|
653
|
+
if (start) {
|
|
654
|
+
selection.setPosition(__classPrivateFieldGet(this, _HighlightEditor_anchorNode, "f"), __classPrivateFieldGet(this, _HighlightEditor_anchorOffset, "f"));
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
selection.setPosition(__classPrivateFieldGet(this, _HighlightEditor_focusNode, "f"), __classPrivateFieldGet(this, _HighlightEditor_focusOffset, "f"));
|
|
658
|
+
}
|
|
659
|
+
}, _HighlightEditor_getRotation = function _HighlightEditor_getRotation() {
|
|
660
|
+
// Highlight annotations are always drawn horizontally but if
|
|
661
|
+
// a free highlight annotation can be rotated.
|
|
662
|
+
return __classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f") ? this.rotation : 0;
|
|
663
|
+
}, _HighlightEditor_serializeBoxes = function _HighlightEditor_serializeBoxes() {
|
|
664
|
+
if (__classPrivateFieldGet(this, _HighlightEditor_isFreeHighlight, "f")) {
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
const [pageWidth, pageHeight] = this.pageDimensions;
|
|
668
|
+
const [pageX, pageY] = this.pageTranslation;
|
|
669
|
+
const boxes = __classPrivateFieldGet(this, _HighlightEditor_boxes, "f");
|
|
670
|
+
const quadPoints = new Float32Array(boxes.length * 8);
|
|
671
|
+
let i = 0;
|
|
672
|
+
for (const { x, y, width, height } of boxes) {
|
|
673
|
+
const sx = x * pageWidth + pageX;
|
|
674
|
+
const sy = (1 - y - height) * pageHeight + pageY;
|
|
675
|
+
// The specifications say that the rectangle should start from the bottom
|
|
676
|
+
// left corner and go counter-clockwise.
|
|
677
|
+
// But when opening the file in Adobe Acrobat it appears that this isn't
|
|
678
|
+
// correct hence the 4th and 6th numbers are just swapped.
|
|
679
|
+
quadPoints[i] = quadPoints[i + 4] = sx;
|
|
680
|
+
quadPoints[i + 1] = quadPoints[i + 3] = sy;
|
|
681
|
+
quadPoints[i + 2] = quadPoints[i + 6] = sx + width * pageWidth;
|
|
682
|
+
quadPoints[i + 5] = quadPoints[i + 7] = sy + height * pageHeight;
|
|
683
|
+
i += 8;
|
|
684
|
+
}
|
|
685
|
+
return quadPoints;
|
|
686
|
+
}, _HighlightEditor_serializeOutlines = function _HighlightEditor_serializeOutlines(rect) {
|
|
687
|
+
return __classPrivateFieldGet(this, _HighlightEditor_highlightOutlines, "f").serialize(rect, __classPrivateFieldGet(this, _HighlightEditor_instances, "m", _HighlightEditor_getRotation).call(this));
|
|
688
|
+
}, _HighlightEditor_highlightMove = function _HighlightEditor_highlightMove(parent, event) {
|
|
689
|
+
if (this._freeHighlight.add(event)) {
|
|
690
|
+
// Redraw only if the point has been added.
|
|
691
|
+
parent.drawLayer.updatePath(this._freeHighlightId, this._freeHighlight);
|
|
692
|
+
}
|
|
693
|
+
}, _HighlightEditor_endHighlight = function _HighlightEditor_endHighlight(parent, event) {
|
|
694
|
+
if (!this._freeHighlight.isEmpty()) {
|
|
695
|
+
parent.createAndAddNewEditor(event, false, {
|
|
696
|
+
highlightId: this._freeHighlightId,
|
|
697
|
+
highlightOutlines: this._freeHighlight.getOutlines(),
|
|
698
|
+
clipPathId: this._freeHighlightClipId,
|
|
699
|
+
methodOfCreation: "main_toolbar",
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
parent.drawLayer.removeFreeHighlight(this._freeHighlightId);
|
|
704
|
+
}
|
|
705
|
+
this._freeHighlightId = -1;
|
|
706
|
+
this._freeHighlight = null;
|
|
707
|
+
this._freeHighlightClipId = "";
|
|
708
|
+
};
|
|
709
|
+
HighlightEditor._defaultColor = null;
|
|
710
|
+
HighlightEditor._defaultOpacity = 1;
|
|
711
|
+
HighlightEditor._defaultThickness = 12;
|
|
712
|
+
HighlightEditor._type = "highlight";
|
|
713
|
+
HighlightEditor._editorType = AnnotationEditorType.HIGHLIGHT;
|
|
714
|
+
HighlightEditor._freeHighlightId = -1;
|
|
715
|
+
HighlightEditor._freeHighlight = null;
|
|
716
|
+
HighlightEditor._freeHighlightClipId = "";
|
|
717
|
+
export { HighlightEditor };
|