@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,1523 @@
|
|
|
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 _AnnotationEditor_instances, _a, _AnnotationEditor_x, _AnnotationEditor_y, _AnnotationEditor_disabled, _AnnotationEditor_keepAspectRatio, _AnnotationEditor_focusAC, _AnnotationEditor_hasBeenClicked, _AnnotationEditor_initialPosition, _AnnotationEditor_isEditing, _AnnotationEditor_isInEditMode, _AnnotationEditor_moveInDOMTimeout, _AnnotationEditor_prevDragX, _AnnotationEditor_prevDragY, _AnnotationEditor_isDraggable, _AnnotationEditor_zIndex, _AnnotationEditor_translate, _AnnotationEditor_rotatePoint, _AnnotationEditor_selectOnPointerEvent, _AnnotationEditor_setUpDragSession, _AnnotationEditor_addFocusListeners, _AnnotationEditor_stopResizing;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AnnotationEditor = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
// import { AnnotationEditorType, shadow } from "../../shared/utils";
|
|
21
|
+
// import { AnnotationEditorType } from "../../shared/utils";
|
|
22
|
+
// import { FeatureTest } from "../../shared/utils";
|
|
23
|
+
const id_manager_1 = require("../helpers/id-manager");
|
|
24
|
+
const color_manager_1 = require("../helpers/color-manager");
|
|
25
|
+
const tools_1 = require("../helpers/tools");
|
|
26
|
+
const pdf_mjs_1 = require("pdfjs-dist/legacy/build/pdf.mjs");
|
|
27
|
+
const utils_1 = require("../shared/utils");
|
|
28
|
+
class AnnotationEditor {
|
|
29
|
+
constructor(parameters) {
|
|
30
|
+
// if (this.constructor === AnnotationEditor) {
|
|
31
|
+
// unreachable("Cannot initialize AnnotationEditor.");
|
|
32
|
+
// }
|
|
33
|
+
_AnnotationEditor_instances.add(this);
|
|
34
|
+
// todo: properties
|
|
35
|
+
this.parent = null;
|
|
36
|
+
this.id = null;
|
|
37
|
+
this.width = null;
|
|
38
|
+
this.height = null;
|
|
39
|
+
this.pageIndex = 0;
|
|
40
|
+
this.name = "";
|
|
41
|
+
this.div = null;
|
|
42
|
+
this.annotationElementId = null;
|
|
43
|
+
this._willKeepAspectRatio = false;
|
|
44
|
+
// _initialOptions = {};
|
|
45
|
+
this._structTreeParentId = null;
|
|
46
|
+
this.rotation = 0;
|
|
47
|
+
this.pageRotation = 0;
|
|
48
|
+
this.pageDimensions = [];
|
|
49
|
+
this.pageTranslation = [];
|
|
50
|
+
// x = 0;
|
|
51
|
+
// y = 0;
|
|
52
|
+
_AnnotationEditor_x.set(this, 0);
|
|
53
|
+
_AnnotationEditor_y.set(this, 0);
|
|
54
|
+
this.isAttachedToDOM = false;
|
|
55
|
+
this.deleted = false;
|
|
56
|
+
// todo: end
|
|
57
|
+
// #accessibilityData = null;
|
|
58
|
+
// #allResizerDivs = null;
|
|
59
|
+
// #altText = null;
|
|
60
|
+
_AnnotationEditor_disabled.set(this, false);
|
|
61
|
+
_AnnotationEditor_keepAspectRatio.set(this, false);
|
|
62
|
+
// #resizersDiv = null;
|
|
63
|
+
// #savedDimensions = null;
|
|
64
|
+
_AnnotationEditor_focusAC.set(this, null);
|
|
65
|
+
// #focusedResizerName = "";
|
|
66
|
+
_AnnotationEditor_hasBeenClicked.set(this, false);
|
|
67
|
+
_AnnotationEditor_initialPosition.set(this, null);
|
|
68
|
+
_AnnotationEditor_isEditing.set(this, false);
|
|
69
|
+
_AnnotationEditor_isInEditMode.set(this, false);
|
|
70
|
+
// #isResizerEnabledForKeyboard = false;
|
|
71
|
+
_AnnotationEditor_moveInDOMTimeout.set(this, null);
|
|
72
|
+
_AnnotationEditor_prevDragX.set(this, 0);
|
|
73
|
+
_AnnotationEditor_prevDragY.set(this, 0);
|
|
74
|
+
// #telemetryTimeouts = null;
|
|
75
|
+
this._editToolbar = null;
|
|
76
|
+
this._initialOptions = Object.create(null);
|
|
77
|
+
this._isVisible = true;
|
|
78
|
+
this._uiManager = null;
|
|
79
|
+
this._focusEventsAllowed = true;
|
|
80
|
+
this._l10nPromise = null;
|
|
81
|
+
_AnnotationEditor_isDraggable.set(this, false);
|
|
82
|
+
_AnnotationEditor_zIndex.set(this, _a._zIndex++);
|
|
83
|
+
this.parent = parameters.parent;
|
|
84
|
+
this.id = parameters.id || _a.idManager.id;
|
|
85
|
+
this.width = this.height = null;
|
|
86
|
+
this.pageIndex = parameters.parent.pageIndex;
|
|
87
|
+
this.name = parameters.name;
|
|
88
|
+
this.div = null;
|
|
89
|
+
this._uiManager = parameters.uiManager;
|
|
90
|
+
this.annotationElementId = null;
|
|
91
|
+
this._willKeepAspectRatio = false;
|
|
92
|
+
this._initialOptions.isCentered = parameters.isCentered;
|
|
93
|
+
this._structTreeParentId = null;
|
|
94
|
+
const { rotation, rawDims: { pageWidth, pageHeight, pageX, pageY } } = this.parent.viewport;
|
|
95
|
+
this.rotation = rotation;
|
|
96
|
+
this.pageRotation =
|
|
97
|
+
(360 + rotation - this._uiManager.viewParameters.rotation) % 360;
|
|
98
|
+
this.pageDimensions = [pageWidth, pageHeight];
|
|
99
|
+
this.pageTranslation = [pageX, pageY];
|
|
100
|
+
const [width, height] = this.parentDimensions;
|
|
101
|
+
this.x = parameters.x / width;
|
|
102
|
+
this.y = parameters.y / height;
|
|
103
|
+
this.isAttachedToDOM = false;
|
|
104
|
+
this.deleted = false;
|
|
105
|
+
}
|
|
106
|
+
get x() {
|
|
107
|
+
return tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_x, "f");
|
|
108
|
+
}
|
|
109
|
+
set x(value) {
|
|
110
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_x, value, "f");
|
|
111
|
+
}
|
|
112
|
+
get y() {
|
|
113
|
+
return tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_y, "f");
|
|
114
|
+
}
|
|
115
|
+
set y(value) {
|
|
116
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_y, value, "f");
|
|
117
|
+
}
|
|
118
|
+
get editorType() {
|
|
119
|
+
return Object.getPrototypeOf(this).constructor._type;
|
|
120
|
+
}
|
|
121
|
+
static get _defaultLineColor() {
|
|
122
|
+
return (0, pdf_mjs_1.shadow)(this, "_defaultLineColor", this._colorManager.getHexCode("CanvasText"));
|
|
123
|
+
}
|
|
124
|
+
static deleteAnnotationElement(editor) {
|
|
125
|
+
const fakeEditor = new FakeEditor({
|
|
126
|
+
id: editor.parent.getNextId(),
|
|
127
|
+
parent: editor.parent,
|
|
128
|
+
uiManager: editor._uiManager,
|
|
129
|
+
});
|
|
130
|
+
fakeEditor.annotationElementId = editor.annotationElementId;
|
|
131
|
+
fakeEditor.deleted = true;
|
|
132
|
+
fakeEditor._uiManager.addToAnnotationStorage(fakeEditor);
|
|
133
|
+
}
|
|
134
|
+
static initialize(l10n, _uiManager, options) {
|
|
135
|
+
if (!l10n || !_uiManager || !options) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// static initialize() {
|
|
139
|
+
// AnnotationEditor._l10nPromise ||= new Map(
|
|
140
|
+
// [
|
|
141
|
+
// "pdfjs-editor-alt-text-button-label",
|
|
142
|
+
// "pdfjs-editor-alt-text-edit-button-label",
|
|
143
|
+
// "pdfjs-editor-alt-text-decorative-tooltip",
|
|
144
|
+
// "pdfjs-editor-new-alt-text-added-button-label",
|
|
145
|
+
// "pdfjs-editor-new-alt-text-missing-button-label",
|
|
146
|
+
// "pdfjs-editor-new-alt-text-to-review-button-label",
|
|
147
|
+
// "pdfjs-editor-resizer-label-topLeft",
|
|
148
|
+
// "pdfjs-editor-resizer-label-topMiddle",
|
|
149
|
+
// "pdfjs-editor-resizer-label-topRight",
|
|
150
|
+
// "pdfjs-editor-resizer-label-middleRight",
|
|
151
|
+
// "pdfjs-editor-resizer-label-bottomRight",
|
|
152
|
+
// "pdfjs-editor-resizer-label-bottomMiddle",
|
|
153
|
+
// "pdfjs-editor-resizer-label-bottomLeft",
|
|
154
|
+
// "pdfjs-editor-resizer-label-middleLeft",
|
|
155
|
+
// ].map(str => [
|
|
156
|
+
// str,
|
|
157
|
+
// l10n.get(str.replaceAll(/([A-Z])/g, c => `-${c.toLowerCase()}`)),
|
|
158
|
+
// ])
|
|
159
|
+
// );
|
|
160
|
+
// // The string isn't in the above list because the string has a parameter
|
|
161
|
+
// // (i.e. the guessed text) and we must pass it to the l10n function to get
|
|
162
|
+
// // the correct translation.
|
|
163
|
+
// AnnotationEditor._l10nPromise.set(
|
|
164
|
+
// "pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",
|
|
165
|
+
// l10n.get.bind(
|
|
166
|
+
// l10n,
|
|
167
|
+
// "pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer"
|
|
168
|
+
// )
|
|
169
|
+
// );
|
|
170
|
+
// if (options?.strings) {
|
|
171
|
+
// for (const str of options.strings) {
|
|
172
|
+
// AnnotationEditor._l10nPromise.set(str, l10n.get(str));
|
|
173
|
+
// }
|
|
174
|
+
// }
|
|
175
|
+
// if (AnnotationEditor._borderLineWidth !== -1) {
|
|
176
|
+
// return;
|
|
177
|
+
// }
|
|
178
|
+
// const style = getComputedStyle(document.documentElement);
|
|
179
|
+
// AnnotationEditor._borderLineWidth =
|
|
180
|
+
// parseFloat(style.getPropertyValue("--outline-width")) || 0;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Update the default parameters for this type of editor.
|
|
184
|
+
* @param {number} _type
|
|
185
|
+
* @param {*} _value
|
|
186
|
+
*/
|
|
187
|
+
static updateDefaultParams(_type, _value) {
|
|
188
|
+
if (!_type || !_value) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get the default properties to set in the UI for this type of editor.
|
|
194
|
+
* @returns {Array}
|
|
195
|
+
*/
|
|
196
|
+
static get defaultPropertiesToUpdate() {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if this kind of editor is able to handle the given mime type for
|
|
201
|
+
* pasting.
|
|
202
|
+
* @param {string} mime
|
|
203
|
+
* @returns {boolean}
|
|
204
|
+
*/
|
|
205
|
+
static isHandlingMimeForPasting(mime) {
|
|
206
|
+
if (!mime) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Extract the data from the clipboard item and delegate the creation of the
|
|
213
|
+
* editor to the parent.
|
|
214
|
+
* @param {DataTransferItem} item
|
|
215
|
+
* @param {AnnotationEditorLayer} parent
|
|
216
|
+
*/
|
|
217
|
+
static paste(item, parent) {
|
|
218
|
+
if (!item || !parent) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
// unreachable("Not implemented");
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get the properties to update in the UI for this editor.
|
|
225
|
+
* @returns {Array}
|
|
226
|
+
*/
|
|
227
|
+
get propertiesToUpdate() {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
get _isDraggable() {
|
|
231
|
+
return tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_isDraggable, "f");
|
|
232
|
+
}
|
|
233
|
+
set _isDraggable(value) {
|
|
234
|
+
var _b;
|
|
235
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_isDraggable, value, "f");
|
|
236
|
+
// this.div?.classList.toggle("draggable", value);
|
|
237
|
+
(_b = this.div) === null || _b === void 0 ? void 0 : _b.classList.toggle("k-draggable", value);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @returns {boolean} true if the editor handles the Enter key itself.
|
|
241
|
+
*/
|
|
242
|
+
get isEnterHandled() {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
center() {
|
|
246
|
+
const [pageWidth, pageHeight] = this.pageDimensions;
|
|
247
|
+
switch (this.parentRotation) {
|
|
248
|
+
case 90:
|
|
249
|
+
this.x -= (this.height * pageHeight) / (pageWidth * 2);
|
|
250
|
+
this.y += (this.width * pageWidth) / (pageHeight * 2);
|
|
251
|
+
break;
|
|
252
|
+
case 180:
|
|
253
|
+
this.x += this.width / 2;
|
|
254
|
+
this.y += this.height / 2;
|
|
255
|
+
break;
|
|
256
|
+
case 270:
|
|
257
|
+
this.x += (this.height * pageHeight) / (pageWidth * 2);
|
|
258
|
+
this.y -= (this.width * pageWidth) / (pageHeight * 2);
|
|
259
|
+
break;
|
|
260
|
+
default:
|
|
261
|
+
this.x -= this.width / 2;
|
|
262
|
+
this.y -= this.height / 2;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
this.fixAndSetPosition();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Add some commands into the CommandManager (undo/redo stuff).
|
|
269
|
+
* @param {Object} params
|
|
270
|
+
*/
|
|
271
|
+
addCommands(params) {
|
|
272
|
+
this._uiManager.addCommands(params);
|
|
273
|
+
}
|
|
274
|
+
get currentLayer() {
|
|
275
|
+
return this._uiManager.currentLayer;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* This editor will be behind the others.
|
|
279
|
+
*/
|
|
280
|
+
setInBackground() {
|
|
281
|
+
this.div.style.zIndex = 0;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* This editor will be in the foreground.
|
|
285
|
+
*/
|
|
286
|
+
setInForeground() {
|
|
287
|
+
this.div.style.zIndex = tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_zIndex, "f");
|
|
288
|
+
}
|
|
289
|
+
setParent(parent) {
|
|
290
|
+
if (parent !== null) {
|
|
291
|
+
this.pageIndex = parent.pageIndex;
|
|
292
|
+
this.pageDimensions = parent.pageDimensions;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
// The editor is being removed from the DOM, so we need to stop resizing.
|
|
296
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_stopResizing).call(this);
|
|
297
|
+
}
|
|
298
|
+
this.parent = parent;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* onfocus callback.
|
|
302
|
+
*/
|
|
303
|
+
focusin(event) {
|
|
304
|
+
if (!event) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (!this._focusEventsAllowed) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (!tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_hasBeenClicked, "f")) {
|
|
311
|
+
this.parent.setSelected(this);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_hasBeenClicked, false, "f");
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* onblur callback.
|
|
319
|
+
* @param {FocusEvent} event
|
|
320
|
+
*/
|
|
321
|
+
focusout(event) {
|
|
322
|
+
var _b;
|
|
323
|
+
if (!this._focusEventsAllowed) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (!this.isAttachedToDOM) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
// In case of focusout, the relatedTarget is the element which
|
|
330
|
+
// is grabbing the focus.
|
|
331
|
+
// So if the related target is an element under the div for this
|
|
332
|
+
// editor, then the editor isn't unactive.
|
|
333
|
+
const target = event.relatedTarget;
|
|
334
|
+
if (target === null || target === void 0 ? void 0 : target.closest(`#${this.id}`)) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
event.preventDefault();
|
|
338
|
+
if (!((_b = this.parent) === null || _b === void 0 ? void 0 : _b.isMultipleSelection)) {
|
|
339
|
+
this.commitOrRemove();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
commitOrRemove() {
|
|
343
|
+
if (this.isEmpty()) {
|
|
344
|
+
this.remove();
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
this.commit();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Commit the data contained in this editor.
|
|
352
|
+
*/
|
|
353
|
+
commit() {
|
|
354
|
+
this.addToAnnotationStorage();
|
|
355
|
+
}
|
|
356
|
+
addToAnnotationStorage() {
|
|
357
|
+
this._uiManager.addToAnnotationStorage(this);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Set the editor position within its parent.
|
|
361
|
+
* @param {number} x
|
|
362
|
+
* @param {number} y
|
|
363
|
+
* @param {number} tx - x-translation in screen coordinates.
|
|
364
|
+
* @param {number} ty - y-translation in screen coordinates.
|
|
365
|
+
*/
|
|
366
|
+
setAt(x, y, tx, ty) {
|
|
367
|
+
const [width, height] = this.parentDimensions;
|
|
368
|
+
[tx, ty] = this.screenToPageTranslation(tx, ty);
|
|
369
|
+
this.x = (x + tx) / width;
|
|
370
|
+
this.y = (y + ty) / height;
|
|
371
|
+
this.fixAndSetPosition();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Translate the editor position within its parent.
|
|
375
|
+
* @param {number} x - x-translation in screen coordinates.
|
|
376
|
+
* @param {number} y - y-translation in screen coordinates.
|
|
377
|
+
*/
|
|
378
|
+
translate(x, y) {
|
|
379
|
+
// We don't change the initial position because the move here hasn't been
|
|
380
|
+
// done by the user.
|
|
381
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_translate).call(this, this.parentDimensions, x, y);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Translate the editor position within its page and adjust the scroll
|
|
385
|
+
* in order to have the editor in the view.
|
|
386
|
+
* @param {number} x - x-translation in page coordinates.
|
|
387
|
+
* @param {number} y - y-translation in page coordinates.
|
|
388
|
+
*/
|
|
389
|
+
translateInPage(x, y) {
|
|
390
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_initialPosition, tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_initialPosition, "f") || [this.x, this.y], "f");
|
|
391
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_translate).call(this, this.pageDimensions, x, y);
|
|
392
|
+
this.div.scrollIntoView({ block: "nearest" });
|
|
393
|
+
}
|
|
394
|
+
drag(tx, ty) {
|
|
395
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_initialPosition, tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_initialPosition, "f") || [this.x, this.y], "f");
|
|
396
|
+
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
397
|
+
this.x += tx / parentWidth;
|
|
398
|
+
this.y += ty / parentHeight;
|
|
399
|
+
if (this.parent && (this.x < 0 || this.x > 1 || this.y < 0 || this.y > 1)) {
|
|
400
|
+
// It's possible to not have a parent: for example, when the user is
|
|
401
|
+
// dragging all the selected editors but this one on a page which has been
|
|
402
|
+
// destroyed.
|
|
403
|
+
// It's why we need to check for it. In such a situation, it isn't really
|
|
404
|
+
// a problem to not find a new parent: it's something which is related to
|
|
405
|
+
// what the user is seeing, hence it depends on how pages are layed out.
|
|
406
|
+
// The element will be outside of its parent so change the parent.
|
|
407
|
+
const { x: xValue, y: yValue } = this.div.getBoundingClientRect();
|
|
408
|
+
if (this.parent.findNewParent(this, xValue, yValue)) {
|
|
409
|
+
this.x -= Math.floor(this.x);
|
|
410
|
+
this.y -= Math.floor(this.y);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// The editor can be moved wherever the user wants, so we don't need to fix
|
|
414
|
+
// the position: it'll be done when the user will release the mouse button.
|
|
415
|
+
let { x, y } = this;
|
|
416
|
+
const [bx, by] = this.getBaseTranslation();
|
|
417
|
+
x += bx;
|
|
418
|
+
y += by;
|
|
419
|
+
this.div.style.left = `${(100 * x).toFixed(2)}%`;
|
|
420
|
+
this.div.style.top = `${(100 * y).toFixed(2)}%`;
|
|
421
|
+
this.div.scrollIntoView({ block: "nearest" });
|
|
422
|
+
}
|
|
423
|
+
get _hasBeenMoved() {
|
|
424
|
+
return (!!tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_initialPosition, "f") &&
|
|
425
|
+
(tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_initialPosition, "f")[0] !== this.x ||
|
|
426
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_initialPosition, "f")[1] !== this.y));
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Get the translation to take into account the editor border.
|
|
430
|
+
* The CSS engine positions the element by taking the border into account so
|
|
431
|
+
* we must apply the opposite translation to have the editor in the right
|
|
432
|
+
* position.
|
|
433
|
+
* @returns {Array<number>}
|
|
434
|
+
*/
|
|
435
|
+
getBaseTranslation() {
|
|
436
|
+
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
437
|
+
const { _borderLineWidth } = _a;
|
|
438
|
+
const x = _borderLineWidth / parentWidth;
|
|
439
|
+
const y = _borderLineWidth / parentHeight;
|
|
440
|
+
switch (this.rotation) {
|
|
441
|
+
case 90:
|
|
442
|
+
return [-x, y];
|
|
443
|
+
case 180:
|
|
444
|
+
return [x, y];
|
|
445
|
+
case 270:
|
|
446
|
+
return [x, -y];
|
|
447
|
+
default:
|
|
448
|
+
return [-x, -y];
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* @returns {boolean} true if position must be fixed (i.e. make the x and y
|
|
453
|
+
* living in the page).
|
|
454
|
+
*/
|
|
455
|
+
get _mustFixPosition() {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Fix the position of the editor in order to keep it inside its parent page.
|
|
460
|
+
* @param {number} [rotation] - the rotation of the page.
|
|
461
|
+
*/
|
|
462
|
+
fixAndSetPosition(rotation = this.rotation) {
|
|
463
|
+
if (rotation === undefined) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const [pageWidth, pageHeight] = this.pageDimensions;
|
|
467
|
+
let { x, y, width, height } = this;
|
|
468
|
+
width *= pageWidth;
|
|
469
|
+
height *= pageHeight;
|
|
470
|
+
x *= pageWidth;
|
|
471
|
+
y *= pageHeight;
|
|
472
|
+
if (this._mustFixPosition) {
|
|
473
|
+
switch (rotation) {
|
|
474
|
+
case 0:
|
|
475
|
+
x = Math.max(0, Math.min(pageWidth - width, x));
|
|
476
|
+
y = Math.max(0, Math.min(pageHeight - height, y));
|
|
477
|
+
break;
|
|
478
|
+
case 90:
|
|
479
|
+
x = Math.max(0, Math.min(pageWidth - height, x));
|
|
480
|
+
y = Math.min(pageHeight, Math.max(width, y));
|
|
481
|
+
break;
|
|
482
|
+
case 180:
|
|
483
|
+
x = Math.min(pageWidth, Math.max(width, x));
|
|
484
|
+
y = Math.min(pageHeight, Math.max(height, y));
|
|
485
|
+
break;
|
|
486
|
+
case 270:
|
|
487
|
+
x = Math.min(pageWidth, Math.max(height, x));
|
|
488
|
+
y = Math.max(0, Math.min(pageHeight - width, y));
|
|
489
|
+
break;
|
|
490
|
+
default: break;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
this.x = x /= pageWidth;
|
|
494
|
+
this.y = y /= pageHeight;
|
|
495
|
+
const [bx, by] = this.getBaseTranslation();
|
|
496
|
+
x += bx;
|
|
497
|
+
y += by;
|
|
498
|
+
const { style } = this.div;
|
|
499
|
+
style.left = `${(100 * x).toFixed(2)}%`;
|
|
500
|
+
style.top = `${(100 * y).toFixed(2)}%`;
|
|
501
|
+
this.moveInDOM();
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Convert a screen translation into a page one.
|
|
505
|
+
* @param {number} x
|
|
506
|
+
* @param {number} y
|
|
507
|
+
*/
|
|
508
|
+
screenToPageTranslation(x, y) {
|
|
509
|
+
return tslib_1.__classPrivateFieldGet(_a, _a, "m", _AnnotationEditor_rotatePoint).call(_a, x, y, this.parentRotation);
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Convert a page translation into a screen one.
|
|
513
|
+
* @param {number} x
|
|
514
|
+
* @param {number} y
|
|
515
|
+
*/
|
|
516
|
+
pageTranslationToScreen(x, y) {
|
|
517
|
+
return tslib_1.__classPrivateFieldGet(_a, _a, "m", _AnnotationEditor_rotatePoint).call(_a, x, y, 360 - this.parentRotation);
|
|
518
|
+
}
|
|
519
|
+
// #getRotationMatrix(rotation) {
|
|
520
|
+
// switch (rotation) {
|
|
521
|
+
// case 90: {
|
|
522
|
+
// const [pageWidth, pageHeight] = this.pageDimensions;
|
|
523
|
+
// return [0, -pageWidth / pageHeight, pageHeight / pageWidth, 0];
|
|
524
|
+
// }
|
|
525
|
+
// case 180:
|
|
526
|
+
// return [-1, 0, 0, -1];
|
|
527
|
+
// case 270: {
|
|
528
|
+
// const [pageWidth, pageHeight] = this.pageDimensions;
|
|
529
|
+
// return [0, pageWidth / pageHeight, -pageHeight / pageWidth, 0];
|
|
530
|
+
// }
|
|
531
|
+
// default:
|
|
532
|
+
// return [1, 0, 0, 1];
|
|
533
|
+
// }
|
|
534
|
+
// }
|
|
535
|
+
get parentScale() {
|
|
536
|
+
return this._uiManager.viewParameters.realScale;
|
|
537
|
+
}
|
|
538
|
+
get parentRotation() {
|
|
539
|
+
return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;
|
|
540
|
+
}
|
|
541
|
+
get parentDimensions() {
|
|
542
|
+
const { parentScale, pageDimensions: [pageWidth, pageHeight] } = this;
|
|
543
|
+
const scaledWidth = pageWidth * parentScale;
|
|
544
|
+
const scaledHeight = pageHeight * parentScale;
|
|
545
|
+
return pdf_mjs_1.FeatureTest.isCSSRoundSupported
|
|
546
|
+
? [Math.round(scaledWidth), Math.round(scaledHeight)]
|
|
547
|
+
: [scaledWidth, scaledHeight];
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Set the dimensions of this editor.
|
|
551
|
+
* @param {number} width
|
|
552
|
+
* @param {number} height
|
|
553
|
+
*/
|
|
554
|
+
setDims(width, height) {
|
|
555
|
+
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
556
|
+
this.div.style.width = `${((100 * width) / parentWidth).toFixed(2)}%`;
|
|
557
|
+
if (!tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_keepAspectRatio, "f")) {
|
|
558
|
+
this.div.style.height = `${((100 * height) / parentHeight).toFixed(2)}%`;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
fixDims() {
|
|
562
|
+
// const { style } = this.div;
|
|
563
|
+
// const { height, width } = style;
|
|
564
|
+
// const widthPercent = width.endsWith("%");
|
|
565
|
+
// const heightPercent = !this.#keepAspectRatio && height.endsWith("%");
|
|
566
|
+
// if (widthPercent && heightPercent) {
|
|
567
|
+
// return;
|
|
568
|
+
// }
|
|
569
|
+
// const [parentWidth, parentHeight] = this.parentDimensions;
|
|
570
|
+
// if (!widthPercent) {
|
|
571
|
+
// style.width = `${((100 * parseFloat(width)) / parentWidth).toFixed(2)}%`;
|
|
572
|
+
// }
|
|
573
|
+
// if (!this.#keepAspectRatio && !heightPercent) {
|
|
574
|
+
// style.height = `${((100 * parseFloat(height)) / parentHeight).toFixed(
|
|
575
|
+
// 2
|
|
576
|
+
// )}%`;
|
|
577
|
+
// }
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Get the translation used to position this editor when it's created.
|
|
581
|
+
* @returns {Array<number>}
|
|
582
|
+
*/
|
|
583
|
+
getInitialTranslation() {
|
|
584
|
+
return [0, 0];
|
|
585
|
+
}
|
|
586
|
+
// #createResizers() {
|
|
587
|
+
// if (this.#resizersDiv) {
|
|
588
|
+
// return;
|
|
589
|
+
// }
|
|
590
|
+
// this.#resizersDiv = document.createElement("div");
|
|
591
|
+
// this.#resizersDiv.classList.add("resizers");
|
|
592
|
+
// // When the resizers are used with the keyboard, they're focusable, hence
|
|
593
|
+
// // we want to have them in this order (top left, top middle, top right, ...)
|
|
594
|
+
// // in the DOM to have the focus order correct.
|
|
595
|
+
// const classes = this._willKeepAspectRatio
|
|
596
|
+
// ? ["topLeft", "topRight", "bottomRight", "bottomLeft"]
|
|
597
|
+
// : [
|
|
598
|
+
// "topLeft",
|
|
599
|
+
// "topMiddle",
|
|
600
|
+
// "topRight",
|
|
601
|
+
// "middleRight",
|
|
602
|
+
// "bottomRight",
|
|
603
|
+
// "bottomMiddle",
|
|
604
|
+
// "bottomLeft",
|
|
605
|
+
// "middleLeft",
|
|
606
|
+
// ];
|
|
607
|
+
// const signal = this._uiManager._signal;
|
|
608
|
+
// for (const name of classes) {
|
|
609
|
+
// const div = document.createElement("div");
|
|
610
|
+
// this.#resizersDiv.append(div);
|
|
611
|
+
// div.classList.add("resizer", name);
|
|
612
|
+
// div.setAttribute("data-resizer-name", name);
|
|
613
|
+
// div.addEventListener(
|
|
614
|
+
// "pointerdown",
|
|
615
|
+
// this.#resizerPointerdown.bind(this, name),
|
|
616
|
+
// { signal }
|
|
617
|
+
// );
|
|
618
|
+
// div.addEventListener("contextmenu", noContextMenu, { signal });
|
|
619
|
+
// div.tabIndex = -1;
|
|
620
|
+
// }
|
|
621
|
+
// this.div.prepend(this.#resizersDiv);
|
|
622
|
+
// }
|
|
623
|
+
// #resizerPointerdown(name, event) {
|
|
624
|
+
// event.preventDefault();
|
|
625
|
+
// const { isMac } = FeatureTest.platform;
|
|
626
|
+
// if (event.button !== 0 || (event.ctrlKey && isMac)) {
|
|
627
|
+
// return;
|
|
628
|
+
// }
|
|
629
|
+
// this.#altText?.toggle(false);
|
|
630
|
+
// const savedDraggable = this._isDraggable;
|
|
631
|
+
// this._isDraggable = false;
|
|
632
|
+
// const ac = new AbortController();
|
|
633
|
+
// const signal = this._uiManager.combinedSignal(ac);
|
|
634
|
+
// this.parent.togglePointerEvents(false);
|
|
635
|
+
// window.addEventListener(
|
|
636
|
+
// "pointermove",
|
|
637
|
+
// this.#resizerPointermove.bind(this, name),
|
|
638
|
+
// { passive: true, capture: true, signal }
|
|
639
|
+
// );
|
|
640
|
+
// window.addEventListener("contextmenu", noContextMenu, { signal });
|
|
641
|
+
// const savedX = this.x;
|
|
642
|
+
// const savedY = this.y;
|
|
643
|
+
// const savedWidth = this.width;
|
|
644
|
+
// const savedHeight = this.height;
|
|
645
|
+
// const savedParentCursor = this.parent.div.style.cursor;
|
|
646
|
+
// const savedCursor = this.div.style.cursor;
|
|
647
|
+
// this.div.style.cursor = this.parent.div.style.cursor =
|
|
648
|
+
// window.getComputedStyle(event.target).cursor;
|
|
649
|
+
// const pointerUpCallback = () => {
|
|
650
|
+
// ac.abort();
|
|
651
|
+
// this.parent.togglePointerEvents(true);
|
|
652
|
+
// this.#altText?.toggle(true);
|
|
653
|
+
// this._isDraggable = savedDraggable;
|
|
654
|
+
// this.parent.div.style.cursor = savedParentCursor;
|
|
655
|
+
// this.div.style.cursor = savedCursor;
|
|
656
|
+
// this.#addResizeToUndoStack(savedX, savedY, savedWidth, savedHeight);
|
|
657
|
+
// };
|
|
658
|
+
// window.addEventListener("pointerup", pointerUpCallback, { signal });
|
|
659
|
+
// // If the user switches to another window (with alt+tab), then we end the
|
|
660
|
+
// // resize session.
|
|
661
|
+
// window.addEventListener("blur", pointerUpCallback, { signal });
|
|
662
|
+
// }
|
|
663
|
+
// #addResizeToUndoStack(savedX, savedY, savedWidth, savedHeight) {
|
|
664
|
+
// const newX = this.x;
|
|
665
|
+
// const newY = this.y;
|
|
666
|
+
// const newWidth = this.width;
|
|
667
|
+
// const newHeight = this.height;
|
|
668
|
+
// if (
|
|
669
|
+
// newX === savedX &&
|
|
670
|
+
// newY === savedY &&
|
|
671
|
+
// newWidth === savedWidth &&
|
|
672
|
+
// newHeight === savedHeight
|
|
673
|
+
// ) {
|
|
674
|
+
// return;
|
|
675
|
+
// }
|
|
676
|
+
// this.addCommands({
|
|
677
|
+
// cmd: () => {
|
|
678
|
+
// this.width = newWidth;
|
|
679
|
+
// this.height = newHeight;
|
|
680
|
+
// this.x = newX;
|
|
681
|
+
// this.y = newY;
|
|
682
|
+
// const [parentWidth, parentHeight] = this.parentDimensions;
|
|
683
|
+
// this.setDims(parentWidth * newWidth, parentHeight * newHeight);
|
|
684
|
+
// this.fixAndSetPosition();
|
|
685
|
+
// },
|
|
686
|
+
// undo: () => {
|
|
687
|
+
// this.width = savedWidth;
|
|
688
|
+
// this.height = savedHeight;
|
|
689
|
+
// this.x = savedX;
|
|
690
|
+
// this.y = savedY;
|
|
691
|
+
// const [parentWidth, parentHeight] = this.parentDimensions;
|
|
692
|
+
// this.setDims(parentWidth * savedWidth, parentHeight * savedHeight);
|
|
693
|
+
// this.fixAndSetPosition();
|
|
694
|
+
// },
|
|
695
|
+
// mustExec: true,
|
|
696
|
+
// });
|
|
697
|
+
// }
|
|
698
|
+
// #resizerPointermove(name, event) {
|
|
699
|
+
// const [parentWidth, parentHeight] = this.parentDimensions;
|
|
700
|
+
// const savedX = this.x;
|
|
701
|
+
// const savedY = this.y;
|
|
702
|
+
// const savedWidth = this.width;
|
|
703
|
+
// const savedHeight = this.height;
|
|
704
|
+
// const minWidth = AnnotationEditor.MIN_SIZE / parentWidth;
|
|
705
|
+
// const minHeight = AnnotationEditor.MIN_SIZE / parentHeight;
|
|
706
|
+
// // 10000 because we multiply by 100 and use toFixed(2) in fixAndSetPosition.
|
|
707
|
+
// // Without rounding, the positions of the corners other than the top left
|
|
708
|
+
// // one can be slightly wrong.
|
|
709
|
+
// const round = x => Math.round(x * 10000) / 10000;
|
|
710
|
+
// const rotationMatrix = this.#getRotationMatrix(this.rotation);
|
|
711
|
+
// const transf = (x, y) => [
|
|
712
|
+
// rotationMatrix[0] * x + rotationMatrix[2] * y,
|
|
713
|
+
// rotationMatrix[1] * x + rotationMatrix[3] * y,
|
|
714
|
+
// ];
|
|
715
|
+
// const invRotationMatrix = this.#getRotationMatrix(360 - this.rotation);
|
|
716
|
+
// const invTransf = (x, y) => [
|
|
717
|
+
// invRotationMatrix[0] * x + invRotationMatrix[2] * y,
|
|
718
|
+
// invRotationMatrix[1] * x + invRotationMatrix[3] * y,
|
|
719
|
+
// ];
|
|
720
|
+
// let getPoint;
|
|
721
|
+
// let getOpposite;
|
|
722
|
+
// let isDiagonal = false;
|
|
723
|
+
// let isHorizontal = false;
|
|
724
|
+
// switch (name) {
|
|
725
|
+
// case "topLeft":
|
|
726
|
+
// isDiagonal = true;
|
|
727
|
+
// getPoint = (w, h) => [0, 0];
|
|
728
|
+
// getOpposite = (w, h) => [w, h];
|
|
729
|
+
// break;
|
|
730
|
+
// case "topMiddle":
|
|
731
|
+
// getPoint = (w, h) => [w / 2, 0];
|
|
732
|
+
// getOpposite = (w, h) => [w / 2, h];
|
|
733
|
+
// break;
|
|
734
|
+
// case "topRight":
|
|
735
|
+
// isDiagonal = true;
|
|
736
|
+
// getPoint = (w, h) => [w, 0];
|
|
737
|
+
// getOpposite = (w, h) => [0, h];
|
|
738
|
+
// break;
|
|
739
|
+
// case "middleRight":
|
|
740
|
+
// isHorizontal = true;
|
|
741
|
+
// getPoint = (w, h) => [w, h / 2];
|
|
742
|
+
// getOpposite = (w, h) => [0, h / 2];
|
|
743
|
+
// break;
|
|
744
|
+
// case "bottomRight":
|
|
745
|
+
// isDiagonal = true;
|
|
746
|
+
// getPoint = (w, h) => [w, h];
|
|
747
|
+
// getOpposite = (w, h) => [0, 0];
|
|
748
|
+
// break;
|
|
749
|
+
// case "bottomMiddle":
|
|
750
|
+
// getPoint = (w, h) => [w / 2, h];
|
|
751
|
+
// getOpposite = (w, h) => [w / 2, 0];
|
|
752
|
+
// break;
|
|
753
|
+
// case "bottomLeft":
|
|
754
|
+
// isDiagonal = true;
|
|
755
|
+
// getPoint = (w, h) => [0, h];
|
|
756
|
+
// getOpposite = (w, h) => [w, 0];
|
|
757
|
+
// break;
|
|
758
|
+
// case "middleLeft":
|
|
759
|
+
// isHorizontal = true;
|
|
760
|
+
// getPoint = (w, h) => [0, h / 2];
|
|
761
|
+
// getOpposite = (w, h) => [w, h / 2];
|
|
762
|
+
// break;
|
|
763
|
+
// }
|
|
764
|
+
// const point = getPoint(savedWidth, savedHeight);
|
|
765
|
+
// const oppositePoint = getOpposite(savedWidth, savedHeight);
|
|
766
|
+
// let transfOppositePoint = transf(...oppositePoint);
|
|
767
|
+
// const oppositeX = round(savedX + transfOppositePoint[0]);
|
|
768
|
+
// const oppositeY = round(savedY + transfOppositePoint[1]);
|
|
769
|
+
// let ratioX = 1;
|
|
770
|
+
// let ratioY = 1;
|
|
771
|
+
// let [deltaX, deltaY] = this.screenToPageTranslation(
|
|
772
|
+
// event.movementX,
|
|
773
|
+
// event.movementY
|
|
774
|
+
// );
|
|
775
|
+
// [deltaX, deltaY] = invTransf(deltaX / parentWidth, deltaY / parentHeight);
|
|
776
|
+
// if (isDiagonal) {
|
|
777
|
+
// const oldDiag = Math.hypot(savedWidth, savedHeight);
|
|
778
|
+
// ratioX = ratioY = Math.max(
|
|
779
|
+
// Math.min(
|
|
780
|
+
// Math.hypot(
|
|
781
|
+
// oppositePoint[0] - point[0] - deltaX,
|
|
782
|
+
// oppositePoint[1] - point[1] - deltaY
|
|
783
|
+
// ) / oldDiag,
|
|
784
|
+
// // Avoid the editor to be larger than the page.
|
|
785
|
+
// 1 / savedWidth,
|
|
786
|
+
// 1 / savedHeight
|
|
787
|
+
// ),
|
|
788
|
+
// // Avoid the editor to be smaller than the minimum size.
|
|
789
|
+
// minWidth / savedWidth,
|
|
790
|
+
// minHeight / savedHeight
|
|
791
|
+
// );
|
|
792
|
+
// } else if (isHorizontal) {
|
|
793
|
+
// ratioX =
|
|
794
|
+
// Math.max(
|
|
795
|
+
// minWidth,
|
|
796
|
+
// Math.min(1, Math.abs(oppositePoint[0] - point[0] - deltaX))
|
|
797
|
+
// ) / savedWidth;
|
|
798
|
+
// } else {
|
|
799
|
+
// ratioY =
|
|
800
|
+
// Math.max(
|
|
801
|
+
// minHeight,
|
|
802
|
+
// Math.min(1, Math.abs(oppositePoint[1] - point[1] - deltaY))
|
|
803
|
+
// ) / savedHeight;
|
|
804
|
+
// }
|
|
805
|
+
// const newWidth = round(savedWidth * ratioX);
|
|
806
|
+
// const newHeight = round(savedHeight * ratioY);
|
|
807
|
+
// transfOppositePoint = transf(...getOpposite(newWidth, newHeight));
|
|
808
|
+
// const newX = oppositeX - transfOppositePoint[0];
|
|
809
|
+
// const newY = oppositeY - transfOppositePoint[1];
|
|
810
|
+
// this.width = newWidth;
|
|
811
|
+
// this.height = newHeight;
|
|
812
|
+
// this.x = newX;
|
|
813
|
+
// this.y = newY;
|
|
814
|
+
// this.setDims(parentWidth * newWidth, parentHeight * newHeight);
|
|
815
|
+
// this.fixAndSetPosition();
|
|
816
|
+
// }
|
|
817
|
+
// /**
|
|
818
|
+
// * Called when the alt text dialog is closed.
|
|
819
|
+
// */
|
|
820
|
+
// altTextFinish() {
|
|
821
|
+
// this.#altText?.finish();
|
|
822
|
+
// }
|
|
823
|
+
// /**
|
|
824
|
+
// * Add a toolbar for this editor.
|
|
825
|
+
// * @returns {Promise<EditorToolbar|null>}
|
|
826
|
+
// */
|
|
827
|
+
// async addEditToolbar() {
|
|
828
|
+
addEditToolbar() {
|
|
829
|
+
var _b;
|
|
830
|
+
(_b = this._uiManager) === null || _b === void 0 ? void 0 : _b.showEditorToolBar(this.div);
|
|
831
|
+
// if (this._editToolbar || this.#isInEditMode) {
|
|
832
|
+
// return this._editToolbar;
|
|
833
|
+
// }
|
|
834
|
+
// this._editToolbar = new EditorToolbar(this);
|
|
835
|
+
// this.div.append(this._editToolbar.render());
|
|
836
|
+
// if (this.#altText) {
|
|
837
|
+
// this._editToolbar.addAltTextButton(await this.#altText.render());
|
|
838
|
+
// }
|
|
839
|
+
// return this._editToolbar;
|
|
840
|
+
}
|
|
841
|
+
removeEditToolbar() {
|
|
842
|
+
this._uiManager.hideEditorToolBar();
|
|
843
|
+
// if (!this._editToolbar) {
|
|
844
|
+
// return;
|
|
845
|
+
// }
|
|
846
|
+
// this._editToolbar.remove();
|
|
847
|
+
// this._editToolbar = null;
|
|
848
|
+
// // We destroy the alt text but we don't null it because we want to be able
|
|
849
|
+
// // to restore it in case the user undoes the deletion.
|
|
850
|
+
// this.#altText?.destroy();
|
|
851
|
+
}
|
|
852
|
+
getClientDimensions() {
|
|
853
|
+
return this.div.getBoundingClientRect();
|
|
854
|
+
}
|
|
855
|
+
// async addAltTextButton() {
|
|
856
|
+
// if (this.#altText) {
|
|
857
|
+
// return;
|
|
858
|
+
// }
|
|
859
|
+
// AltText.initialize(AnnotationEditor._l10nPromise);
|
|
860
|
+
// this.#altText = new AltText(this);
|
|
861
|
+
// if (this.#accessibilityData) {
|
|
862
|
+
// this.#altText.data = this.#accessibilityData;
|
|
863
|
+
// this.#accessibilityData = null;
|
|
864
|
+
// }
|
|
865
|
+
// await this.addEditToolbar();
|
|
866
|
+
// }
|
|
867
|
+
// get altTextData() {
|
|
868
|
+
// return this.#altText?.data;
|
|
869
|
+
// }
|
|
870
|
+
// /**
|
|
871
|
+
// * Set the alt text data.
|
|
872
|
+
// */
|
|
873
|
+
// set altTextData(data) {
|
|
874
|
+
// if (!this.#altText) {
|
|
875
|
+
// return;
|
|
876
|
+
// }
|
|
877
|
+
// this.#altText.data = data;
|
|
878
|
+
// }
|
|
879
|
+
// get guessedAltText() {
|
|
880
|
+
// return this.#altText?.guessedText;
|
|
881
|
+
// }
|
|
882
|
+
// async setGuessedAltText(text) {
|
|
883
|
+
// await this.#altText?.setGuessedText(text);
|
|
884
|
+
// }
|
|
885
|
+
// serializeAltText(isForCopying) {
|
|
886
|
+
// return this.#altText?.serialize(isForCopying);
|
|
887
|
+
// }
|
|
888
|
+
// hasAltText() {
|
|
889
|
+
// return !!this.#altText && !this.#altText.isEmpty();
|
|
890
|
+
// }
|
|
891
|
+
// hasAltTextData() {
|
|
892
|
+
// return this.#altText?.hasData() ?? false;
|
|
893
|
+
// }
|
|
894
|
+
/**
|
|
895
|
+
* Render this editor in a div.
|
|
896
|
+
* @returns {HTMLDivElement | null}
|
|
897
|
+
*/
|
|
898
|
+
render() {
|
|
899
|
+
this.div = document.createElement("div");
|
|
900
|
+
this.div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
|
|
901
|
+
this.div.className = this.name;
|
|
902
|
+
this.div.setAttribute("id", this.id);
|
|
903
|
+
this.div.tabIndex = tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_disabled, "f") ? -1 : 0;
|
|
904
|
+
if (!this._isVisible) {
|
|
905
|
+
// this.div.classList.add("hidden");
|
|
906
|
+
this.div.classList.add("k-hidden");
|
|
907
|
+
}
|
|
908
|
+
this.setInForeground();
|
|
909
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_addFocusListeners).call(this);
|
|
910
|
+
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
911
|
+
if (this.parentRotation % 180 !== 0) {
|
|
912
|
+
this.div.style.maxWidth = `${((100 * parentHeight) / parentWidth).toFixed(2)}%`;
|
|
913
|
+
this.div.style.maxHeight = `${((100 * parentWidth) /
|
|
914
|
+
parentHeight).toFixed(2)}%`;
|
|
915
|
+
}
|
|
916
|
+
const [tx, ty] = this.getInitialTranslation();
|
|
917
|
+
this.translate(tx, ty);
|
|
918
|
+
(0, tools_1.bindEvents)(this, this.div, ["pointerdown"]);
|
|
919
|
+
return this.div;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Onpointerdown callback.
|
|
923
|
+
* @param {PointerEvent} event
|
|
924
|
+
*/
|
|
925
|
+
pointerdown(event) {
|
|
926
|
+
var _b;
|
|
927
|
+
const { isMac } = pdf_mjs_1.FeatureTest.platform;
|
|
928
|
+
if (event.button !== 0 || (event.ctrlKey && isMac)) {
|
|
929
|
+
// Avoid to focus this editor because of a non-left click.
|
|
930
|
+
event.preventDefault();
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_hasBeenClicked, true, "f");
|
|
934
|
+
if (this._isDraggable) {
|
|
935
|
+
(_b = this._uiManager) === null || _b === void 0 ? void 0 : _b.hideEditorToolBar();
|
|
936
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_setUpDragSession).call(this, event);
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_selectOnPointerEvent).call(this, event);
|
|
940
|
+
}
|
|
941
|
+
moveInDOM() {
|
|
942
|
+
// Moving the editor in the DOM can be expensive, so we wait a bit before.
|
|
943
|
+
// It's important to not block the UI (for example when changing the font
|
|
944
|
+
// size in a FreeText).
|
|
945
|
+
if (tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_moveInDOMTimeout, "f")) {
|
|
946
|
+
clearTimeout(tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_moveInDOMTimeout, "f"));
|
|
947
|
+
}
|
|
948
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_moveInDOMTimeout, setTimeout(() => {
|
|
949
|
+
var _b;
|
|
950
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_moveInDOMTimeout, null, "f");
|
|
951
|
+
(_b = this.parent) === null || _b === void 0 ? void 0 : _b.moveEditorInDOM(this);
|
|
952
|
+
}, 0), "f");
|
|
953
|
+
}
|
|
954
|
+
_setParentAndPosition(parent, x, y) {
|
|
955
|
+
parent.changeParent(this);
|
|
956
|
+
this.x = x;
|
|
957
|
+
this.y = y;
|
|
958
|
+
this.fixAndSetPosition();
|
|
959
|
+
}
|
|
960
|
+
/*
|
|
961
|
+
* Convert the current rect into a page one.
|
|
962
|
+
* @param {number} tx - x-translation in screen coordinates.
|
|
963
|
+
* @param {number} ty - y-translation in screen coordinates.
|
|
964
|
+
* @param {number} [rotation] - the rotation of the page.
|
|
965
|
+
*/
|
|
966
|
+
getRect(tx, ty, rotation = this.rotation) {
|
|
967
|
+
const scale = this.parentScale;
|
|
968
|
+
const [pageWidth, pageHeight] = this.pageDimensions;
|
|
969
|
+
const [pageX, pageY] = this.pageTranslation;
|
|
970
|
+
const shiftX = tx / scale;
|
|
971
|
+
const shiftY = ty / scale;
|
|
972
|
+
const x = this.x * pageWidth;
|
|
973
|
+
const y = this.y * pageHeight;
|
|
974
|
+
const width = this.width * pageWidth;
|
|
975
|
+
const height = this.height * pageHeight;
|
|
976
|
+
switch (rotation) {
|
|
977
|
+
case 0:
|
|
978
|
+
return [
|
|
979
|
+
x + shiftX + pageX,
|
|
980
|
+
pageHeight - y - shiftY - height + pageY,
|
|
981
|
+
x + shiftX + width + pageX,
|
|
982
|
+
pageHeight - y - shiftY + pageY
|
|
983
|
+
];
|
|
984
|
+
case 90:
|
|
985
|
+
return [
|
|
986
|
+
x + shiftY + pageX,
|
|
987
|
+
pageHeight - y + shiftX + pageY,
|
|
988
|
+
x + shiftY + height + pageX,
|
|
989
|
+
pageHeight - y + shiftX + width + pageY
|
|
990
|
+
];
|
|
991
|
+
case 180:
|
|
992
|
+
return [
|
|
993
|
+
x - shiftX - width + pageX,
|
|
994
|
+
pageHeight - y + shiftY + pageY,
|
|
995
|
+
x - shiftX + pageX,
|
|
996
|
+
pageHeight - y + shiftY + height + pageY
|
|
997
|
+
];
|
|
998
|
+
case 270:
|
|
999
|
+
return [
|
|
1000
|
+
x - shiftY - height + pageX,
|
|
1001
|
+
pageHeight - y - shiftX - width + pageY,
|
|
1002
|
+
x - shiftY + pageX,
|
|
1003
|
+
pageHeight - y - shiftX + pageY
|
|
1004
|
+
];
|
|
1005
|
+
default:
|
|
1006
|
+
throw new Error("Invalid rotation");
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
getRectInCurrentCoords(rect, pageHeight) {
|
|
1010
|
+
const [x1, y1, x2, y2] = rect;
|
|
1011
|
+
const width = x2 - x1;
|
|
1012
|
+
const height = y2 - y1;
|
|
1013
|
+
switch (this.rotation) {
|
|
1014
|
+
case 0:
|
|
1015
|
+
return [x1, pageHeight - y2, width, height];
|
|
1016
|
+
case 90:
|
|
1017
|
+
return [x1, pageHeight - y1, height, width];
|
|
1018
|
+
case 180:
|
|
1019
|
+
return [x2, pageHeight - y1, width, height];
|
|
1020
|
+
case 270:
|
|
1021
|
+
return [x2, pageHeight - y2, height, width];
|
|
1022
|
+
default:
|
|
1023
|
+
// throw new Error("Invalid rotation");
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
// /**
|
|
1028
|
+
// * Executed once this editor has been rendered.
|
|
1029
|
+
// */
|
|
1030
|
+
onceAdded() { }
|
|
1031
|
+
// /**
|
|
1032
|
+
// * Check if the editor contains something.
|
|
1033
|
+
// * @returns {boolean}
|
|
1034
|
+
// */
|
|
1035
|
+
isEmpty() {
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Enable edit mode.
|
|
1040
|
+
*/
|
|
1041
|
+
enableEditMode() {
|
|
1042
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_isInEditMode, true, "f");
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Disable edit mode.
|
|
1046
|
+
*/
|
|
1047
|
+
disableEditMode() {
|
|
1048
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_isInEditMode, false, "f");
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Check if the editor is edited.
|
|
1052
|
+
* @returns {boolean}
|
|
1053
|
+
*/
|
|
1054
|
+
isInEditMode() {
|
|
1055
|
+
return tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_isInEditMode, "f");
|
|
1056
|
+
}
|
|
1057
|
+
// /**
|
|
1058
|
+
// * If it returns true, then this editor handles the keyboard
|
|
1059
|
+
// * events itself.
|
|
1060
|
+
// * @returns {boolean}
|
|
1061
|
+
// */
|
|
1062
|
+
// shouldGetKeyboardEvents() {
|
|
1063
|
+
// return this.#isResizerEnabledForKeyboard;
|
|
1064
|
+
// }
|
|
1065
|
+
/**
|
|
1066
|
+
* Check if this editor needs to be rebuilt or not.
|
|
1067
|
+
* @returns {boolean}
|
|
1068
|
+
*/
|
|
1069
|
+
needsToBeRebuilt() {
|
|
1070
|
+
return this.div && !this.isAttachedToDOM;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Rebuild the editor in case it has been removed on undo.
|
|
1074
|
+
*
|
|
1075
|
+
* To implement in subclasses.
|
|
1076
|
+
*/
|
|
1077
|
+
rebuild() {
|
|
1078
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_addFocusListeners).call(this);
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Rotate the editor.
|
|
1082
|
+
* @param {number} angle
|
|
1083
|
+
*/
|
|
1084
|
+
rotate(angle) {
|
|
1085
|
+
if (angle === undefined || angle === null) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Serialize the editor.
|
|
1091
|
+
* The result of the serialization will be used to construct a
|
|
1092
|
+
* new annotation to add to the pdf document.
|
|
1093
|
+
*
|
|
1094
|
+
* To implement in subclasses.
|
|
1095
|
+
* @param {boolean} [isForCopying]
|
|
1096
|
+
* @param {Object | null} [context]
|
|
1097
|
+
* @returns {Object | null}
|
|
1098
|
+
*/
|
|
1099
|
+
// @ts-expect-error (TS)
|
|
1100
|
+
// eslint-disable-next-line
|
|
1101
|
+
serialize(isForCopying = false, context = null) {
|
|
1102
|
+
// serialize() {
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Deserialize the editor.
|
|
1106
|
+
* The result of the deserialization is a new editor.
|
|
1107
|
+
*
|
|
1108
|
+
* @param {Object} data
|
|
1109
|
+
* @param {AnnotationEditorLayer} parent
|
|
1110
|
+
* @param {AnnotationEditorUIManager} uiManager
|
|
1111
|
+
* @returns {AnnotationEditor | null}
|
|
1112
|
+
*/
|
|
1113
|
+
static deserialize(data, parent, uiManager) {
|
|
1114
|
+
// @ts-expect-error TS(2556):
|
|
1115
|
+
const editor = new this.prototype.constructor({
|
|
1116
|
+
parent,
|
|
1117
|
+
id: parent.getNextId(),
|
|
1118
|
+
uiManager,
|
|
1119
|
+
});
|
|
1120
|
+
editor.rotation = data.rotation;
|
|
1121
|
+
// editor.#accessibilityData = data.accessibilityData;
|
|
1122
|
+
const [pageWidth, pageHeight] = editor.pageDimensions;
|
|
1123
|
+
const [x, y, width, height] = editor.getRectInCurrentCoords(data.rect, pageHeight);
|
|
1124
|
+
editor.x = x / pageWidth;
|
|
1125
|
+
editor.y = y / pageHeight;
|
|
1126
|
+
editor.width = width / pageWidth;
|
|
1127
|
+
editor.height = height / pageHeight;
|
|
1128
|
+
return editor;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Check if an existing annotation associated with this editor has been
|
|
1132
|
+
* modified.
|
|
1133
|
+
* @returns {boolean}
|
|
1134
|
+
*/
|
|
1135
|
+
get hasBeenModified() {
|
|
1136
|
+
return (!!this.annotationElementId && (this.deleted || this.serialize() !== null));
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Remove this editor.
|
|
1140
|
+
* It's used on ctrl+backspace action.
|
|
1141
|
+
*/
|
|
1142
|
+
remove() {
|
|
1143
|
+
var _b;
|
|
1144
|
+
(_b = tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_focusAC, "f")) === null || _b === void 0 ? void 0 : _b.abort();
|
|
1145
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_focusAC, null, "f");
|
|
1146
|
+
if (!this.isEmpty()) {
|
|
1147
|
+
// The editor is removed but it can be back at some point thanks to
|
|
1148
|
+
// undo/redo so we must commit it before.
|
|
1149
|
+
this.commit();
|
|
1150
|
+
}
|
|
1151
|
+
if (this.parent) {
|
|
1152
|
+
this.parent.remove(this);
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
this._uiManager.removeEditor(this);
|
|
1156
|
+
}
|
|
1157
|
+
if (tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_moveInDOMTimeout, "f")) {
|
|
1158
|
+
clearTimeout(tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_moveInDOMTimeout, "f"));
|
|
1159
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_moveInDOMTimeout, null, "f");
|
|
1160
|
+
}
|
|
1161
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_stopResizing).call(this);
|
|
1162
|
+
this.removeEditToolbar();
|
|
1163
|
+
// if (this.#telemetryTimeouts) {
|
|
1164
|
+
// for (const timeout of this.#telemetryTimeouts.values()) {
|
|
1165
|
+
// clearTimeout(timeout);
|
|
1166
|
+
// }
|
|
1167
|
+
// this.#telemetryTimeouts = null;
|
|
1168
|
+
// }
|
|
1169
|
+
this.parent = null;
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* @returns {boolean} true if this editor can be resized.
|
|
1173
|
+
*/
|
|
1174
|
+
get isResizable() {
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Add the resizers to this editor.
|
|
1179
|
+
*/
|
|
1180
|
+
makeResizable() {
|
|
1181
|
+
// if (this.isResizable) {
|
|
1182
|
+
// this.#createResizers();
|
|
1183
|
+
// this.#resizersDiv.classList.remove("hidden");
|
|
1184
|
+
// this.#resizersDiv.classList.remove("k-hidden");
|
|
1185
|
+
// bindEvents(this, this.div, ["keydown"]);
|
|
1186
|
+
// }
|
|
1187
|
+
}
|
|
1188
|
+
get toolbarPosition() {
|
|
1189
|
+
return null;
|
|
1190
|
+
}
|
|
1191
|
+
_stopResizingWithKeyboard() {
|
|
1192
|
+
// this.#stopResizing();
|
|
1193
|
+
// this.div.focus();
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Select this editor.
|
|
1197
|
+
*/
|
|
1198
|
+
select() {
|
|
1199
|
+
var _b;
|
|
1200
|
+
// this.makeResizable();
|
|
1201
|
+
// this.div?.classList.add("selectedEditor");
|
|
1202
|
+
(_b = this.div) === null || _b === void 0 ? void 0 : _b.classList.add("k-selected");
|
|
1203
|
+
// todo: manually show annotation toolbar
|
|
1204
|
+
this.addEditToolbar();
|
|
1205
|
+
// if (!this._editToolbar) {
|
|
1206
|
+
// this.addEditToolbar().then(() => {
|
|
1207
|
+
// if (this.div?.classList.contains("k-selected selectedEditor")) {
|
|
1208
|
+
// // The editor can have been unselected while we were waiting for the
|
|
1209
|
+
// // edit toolbar to be created, hence we want to be sure that this
|
|
1210
|
+
// // editor is still selected.
|
|
1211
|
+
// this._editToolbar?.show();
|
|
1212
|
+
// }
|
|
1213
|
+
// });
|
|
1214
|
+
// return;
|
|
1215
|
+
// }
|
|
1216
|
+
// this._editToolbar?.show();
|
|
1217
|
+
// this.#altText?.toggleAltTextBadge(false);
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Unselect this editor.
|
|
1221
|
+
*/
|
|
1222
|
+
unselect() {
|
|
1223
|
+
var _b, _c;
|
|
1224
|
+
// this.#resizersDiv?.classList.add("hidden");
|
|
1225
|
+
// this.div?.classList.remove("selectedEditor");
|
|
1226
|
+
(_b = this.div) === null || _b === void 0 ? void 0 : _b.classList.remove("k-selected");
|
|
1227
|
+
if ((_c = this.div) === null || _c === void 0 ? void 0 : _c.contains(document.activeElement)) {
|
|
1228
|
+
// Don't use this.div.blur() because we don't know where the focus will
|
|
1229
|
+
// go.
|
|
1230
|
+
this._uiManager.currentLayer.div.focus({
|
|
1231
|
+
preventScroll: true,
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
// this._editToolbar?.hide();
|
|
1235
|
+
// this.#altText?.toggleAltTextBadge(true);
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Update some parameters which have been changed through the UI.
|
|
1239
|
+
* @param {number} type
|
|
1240
|
+
* @param {*} value
|
|
1241
|
+
*/
|
|
1242
|
+
updateParams(type, value) {
|
|
1243
|
+
if (type === undefined || !value) {
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* When the user disables the editing mode some editors can change some of
|
|
1249
|
+
* their properties.
|
|
1250
|
+
*/
|
|
1251
|
+
disableEditing() { }
|
|
1252
|
+
/**
|
|
1253
|
+
* When the user enables the editing mode some editors can change some of
|
|
1254
|
+
* their properties.
|
|
1255
|
+
*/
|
|
1256
|
+
enableEditing() { }
|
|
1257
|
+
/**
|
|
1258
|
+
* The editor is about to be edited.
|
|
1259
|
+
*/
|
|
1260
|
+
enterInEditMode() { }
|
|
1261
|
+
/**
|
|
1262
|
+
* @returns {HTMLElement | null} the element requiring an alt text.
|
|
1263
|
+
*/
|
|
1264
|
+
getImageForAltText() {
|
|
1265
|
+
return null;
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Get the div which really contains the displayed content.
|
|
1269
|
+
* @returns {HTMLDivElement | undefined}
|
|
1270
|
+
*/
|
|
1271
|
+
get contentDiv() {
|
|
1272
|
+
return this.div;
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* If true then the editor is currently edited.
|
|
1276
|
+
* @type {boolean}
|
|
1277
|
+
*/
|
|
1278
|
+
get isEditing() {
|
|
1279
|
+
return tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_isEditing, "f");
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* When set to true, it means that this editor is currently edited.
|
|
1283
|
+
* @param {boolean} value
|
|
1284
|
+
*/
|
|
1285
|
+
set isEditing(value) {
|
|
1286
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_isEditing, value, "f");
|
|
1287
|
+
if (!this.parent) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (value) {
|
|
1291
|
+
this.parent.setSelected(this);
|
|
1292
|
+
this.parent.setActiveEditor(this);
|
|
1293
|
+
}
|
|
1294
|
+
else {
|
|
1295
|
+
this.parent.setActiveEditor(null);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Set the aspect ratio to use when resizing.
|
|
1300
|
+
* @param {number} width
|
|
1301
|
+
* @param {number} height
|
|
1302
|
+
*/
|
|
1303
|
+
setAspectRatio(width, height) {
|
|
1304
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_keepAspectRatio, true, "f");
|
|
1305
|
+
const aspectRatio = width / height;
|
|
1306
|
+
const { style } = this.div;
|
|
1307
|
+
style.aspectRatio = aspectRatio;
|
|
1308
|
+
style.height = "auto";
|
|
1309
|
+
}
|
|
1310
|
+
static get MIN_SIZE() {
|
|
1311
|
+
return 16;
|
|
1312
|
+
}
|
|
1313
|
+
static canCreateNewEmptyEditor() {
|
|
1314
|
+
return true;
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Get the data to report to the telemetry when the editor is added.
|
|
1318
|
+
* @returns {Object}
|
|
1319
|
+
*/
|
|
1320
|
+
get telemetryInitialData() {
|
|
1321
|
+
return { action: "added" };
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* The telemetry data to use when saving/printing.
|
|
1325
|
+
* @returns {Object|null}
|
|
1326
|
+
*/
|
|
1327
|
+
get telemetryFinalData() {
|
|
1328
|
+
return null;
|
|
1329
|
+
}
|
|
1330
|
+
_reportTelemetry() {
|
|
1331
|
+
}
|
|
1332
|
+
// _reportTelemetry(data, mustWait = false) {
|
|
1333
|
+
// if (mustWait) {
|
|
1334
|
+
// this.#telemetryTimeouts ||= new Map();
|
|
1335
|
+
// const { action } = data;
|
|
1336
|
+
// let timeout = this.#telemetryTimeouts.get(action);
|
|
1337
|
+
// if (timeout) {
|
|
1338
|
+
// clearTimeout(timeout);
|
|
1339
|
+
// }
|
|
1340
|
+
// timeout = setTimeout(() => {
|
|
1341
|
+
// this._reportTelemetry(data);
|
|
1342
|
+
// this.#telemetryTimeouts.delete(action);
|
|
1343
|
+
// if (this.#telemetryTimeouts.size === 0) {
|
|
1344
|
+
// this.#telemetryTimeouts = null;
|
|
1345
|
+
// }
|
|
1346
|
+
// }, AnnotationEditor._telemetryTimeout);
|
|
1347
|
+
// this.#telemetryTimeouts.set(action, timeout);
|
|
1348
|
+
// return;
|
|
1349
|
+
// }
|
|
1350
|
+
// data.type ||= this.editorType;
|
|
1351
|
+
// this._uiManager._eventBus.dispatch("reporttelemetry", {
|
|
1352
|
+
// source: this,
|
|
1353
|
+
// details: {
|
|
1354
|
+
// type: "editing",
|
|
1355
|
+
// data,
|
|
1356
|
+
// },
|
|
1357
|
+
// });
|
|
1358
|
+
// }
|
|
1359
|
+
/**
|
|
1360
|
+
* Show or hide this editor.
|
|
1361
|
+
* @param {boolean|undefined} visible
|
|
1362
|
+
*/
|
|
1363
|
+
show(visible = this._isVisible) {
|
|
1364
|
+
// this.div.classList.toggle("hidden", !visible);
|
|
1365
|
+
this.div.classList.toggle("k-hidden", !visible);
|
|
1366
|
+
this._isVisible = visible;
|
|
1367
|
+
}
|
|
1368
|
+
enable() {
|
|
1369
|
+
if (this.div) {
|
|
1370
|
+
this.div.tabIndex = 0;
|
|
1371
|
+
}
|
|
1372
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_disabled, false, "f");
|
|
1373
|
+
}
|
|
1374
|
+
disable() {
|
|
1375
|
+
if (this.div) {
|
|
1376
|
+
this.div.tabIndex = -1;
|
|
1377
|
+
}
|
|
1378
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_disabled, true, "f");
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Render an annotation in the annotation layer.
|
|
1382
|
+
* @param {Object} annotation
|
|
1383
|
+
* @returns {HTMLElement}
|
|
1384
|
+
*/
|
|
1385
|
+
renderAnnotationElement(annotation) {
|
|
1386
|
+
let content = annotation.container.querySelector(".annotationContent") ||
|
|
1387
|
+
annotation.container.querySelector(".k-annotation-content ");
|
|
1388
|
+
if (!content) {
|
|
1389
|
+
content = document.createElement("div");
|
|
1390
|
+
// content.classList.add("annotationContent", this.editorType);
|
|
1391
|
+
content.classList.add("k-annotation-content ", this.editorType);
|
|
1392
|
+
annotation.container.prepend(content);
|
|
1393
|
+
}
|
|
1394
|
+
else if (content.nodeName === "CANVAS") {
|
|
1395
|
+
const canvas = content;
|
|
1396
|
+
content = document.createElement("div");
|
|
1397
|
+
// content.classList.add("annotationContent", this.editorType);
|
|
1398
|
+
content.classList.add("k-annotation-content ", this.editorType);
|
|
1399
|
+
canvas.before(content);
|
|
1400
|
+
}
|
|
1401
|
+
return content;
|
|
1402
|
+
}
|
|
1403
|
+
resetAnnotationElement(annotation) {
|
|
1404
|
+
const { firstChild } = annotation.container;
|
|
1405
|
+
if (firstChild.nodeName === "DIV" &&
|
|
1406
|
+
(firstChild.classList.contains("annotationContent") ||
|
|
1407
|
+
firstChild.classList.contains("k-annotation-content "))) {
|
|
1408
|
+
firstChild.remove();
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
exports.AnnotationEditor = AnnotationEditor;
|
|
1413
|
+
_a = AnnotationEditor, _AnnotationEditor_x = new WeakMap(), _AnnotationEditor_y = new WeakMap(), _AnnotationEditor_disabled = new WeakMap(), _AnnotationEditor_keepAspectRatio = new WeakMap(), _AnnotationEditor_focusAC = new WeakMap(), _AnnotationEditor_hasBeenClicked = new WeakMap(), _AnnotationEditor_initialPosition = new WeakMap(), _AnnotationEditor_isEditing = new WeakMap(), _AnnotationEditor_isInEditMode = new WeakMap(), _AnnotationEditor_moveInDOMTimeout = new WeakMap(), _AnnotationEditor_prevDragX = new WeakMap(), _AnnotationEditor_prevDragY = new WeakMap(), _AnnotationEditor_isDraggable = new WeakMap(), _AnnotationEditor_zIndex = new WeakMap(), _AnnotationEditor_instances = new WeakSet(), _AnnotationEditor_translate = function _AnnotationEditor_translate([width, height], x, y) {
|
|
1414
|
+
[x, y] = this.screenToPageTranslation(x, y);
|
|
1415
|
+
this.x += x / width;
|
|
1416
|
+
this.y += y / height;
|
|
1417
|
+
this.fixAndSetPosition();
|
|
1418
|
+
}, _AnnotationEditor_rotatePoint = function _AnnotationEditor_rotatePoint(x, y, angle) {
|
|
1419
|
+
switch (angle) {
|
|
1420
|
+
case 90:
|
|
1421
|
+
return [y, -x];
|
|
1422
|
+
case 180:
|
|
1423
|
+
return [-x, -y];
|
|
1424
|
+
case 270:
|
|
1425
|
+
return [-y, x];
|
|
1426
|
+
default:
|
|
1427
|
+
return [x, y];
|
|
1428
|
+
}
|
|
1429
|
+
}, _AnnotationEditor_selectOnPointerEvent = function _AnnotationEditor_selectOnPointerEvent(event) {
|
|
1430
|
+
const { isMac } = pdf_mjs_1.FeatureTest.platform;
|
|
1431
|
+
const highlightEditor = event.target.closest(".k-highlight-editor");
|
|
1432
|
+
const freeTextEditor = event.target.closest(".k-free-text-editor");
|
|
1433
|
+
const annotationEditorMode = this._uiManager.getMode();
|
|
1434
|
+
// todo: manually prevent selecting a highlight annotation in freetext mode
|
|
1435
|
+
if ((annotationEditorMode === utils_1.AnnotationEditorType.HIGHLIGHT && !highlightEditor) ||
|
|
1436
|
+
(annotationEditorMode === utils_1.AnnotationEditorType.FREETEXT && !freeTextEditor)) {
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
if ((event.ctrlKey && !isMac) ||
|
|
1440
|
+
event.shiftKey ||
|
|
1441
|
+
(event.metaKey && isMac)) {
|
|
1442
|
+
this.parent.toggleSelected(this);
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
this.parent.setSelected(this);
|
|
1446
|
+
}
|
|
1447
|
+
}, _AnnotationEditor_setUpDragSession = function _AnnotationEditor_setUpDragSession(event) {
|
|
1448
|
+
const isSelected = this._uiManager.isSelected(this);
|
|
1449
|
+
this._uiManager.setUpDragSession();
|
|
1450
|
+
const ac = new AbortController();
|
|
1451
|
+
const signal = this._uiManager.combinedSignal(ac);
|
|
1452
|
+
if (isSelected) {
|
|
1453
|
+
// this.div.classList.add("moving");
|
|
1454
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_prevDragX, event.clientX, "f");
|
|
1455
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_prevDragY, event.clientY, "f");
|
|
1456
|
+
const pointerMoveCallback = e => {
|
|
1457
|
+
const { clientX: x, clientY: y } = e;
|
|
1458
|
+
const [tx, ty] = this.screenToPageTranslation(x - tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_prevDragX, "f"), y - tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_prevDragY, "f"));
|
|
1459
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_prevDragX, x, "f");
|
|
1460
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_prevDragY, y, "f");
|
|
1461
|
+
this._uiManager.dragSelectedEditors(tx, ty);
|
|
1462
|
+
};
|
|
1463
|
+
window.addEventListener("pointermove", pointerMoveCallback, {
|
|
1464
|
+
passive: true,
|
|
1465
|
+
capture: true,
|
|
1466
|
+
signal,
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
const pointerUpCallback = () => {
|
|
1470
|
+
ac.abort();
|
|
1471
|
+
if (isSelected) {
|
|
1472
|
+
this.div.classList.remove("moving");
|
|
1473
|
+
}
|
|
1474
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_hasBeenClicked, false, "f");
|
|
1475
|
+
if (!this._uiManager.endDragSession()) {
|
|
1476
|
+
tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_instances, "m", _AnnotationEditor_selectOnPointerEvent).call(this, event);
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
window.addEventListener("pointerup", pointerUpCallback, { signal });
|
|
1480
|
+
// If the user is using alt+tab during the dragging session, the pointerup
|
|
1481
|
+
// event could be not fired, but a blur event is fired so we can use it in
|
|
1482
|
+
// order to interrupt the dragging session.
|
|
1483
|
+
window.addEventListener("blur", pointerUpCallback, { signal });
|
|
1484
|
+
}, _AnnotationEditor_addFocusListeners = function _AnnotationEditor_addFocusListeners() {
|
|
1485
|
+
if (tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_focusAC, "f") || !this.div) {
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationEditor_focusAC, new AbortController(), "f");
|
|
1489
|
+
const signal = this._uiManager.combinedSignal(tslib_1.__classPrivateFieldGet(this, _AnnotationEditor_focusAC, "f"));
|
|
1490
|
+
this.div.addEventListener("focusin", this.focusin.bind(this), { signal });
|
|
1491
|
+
this.div.addEventListener("focusout", this.focusout.bind(this), { signal });
|
|
1492
|
+
}, _AnnotationEditor_stopResizing = function _AnnotationEditor_stopResizing() {
|
|
1493
|
+
// this.#isResizerEnabledForKeyboard = false;
|
|
1494
|
+
// this.#setResizerTabIndex(-1);
|
|
1495
|
+
// if (this.#savedDimensions) {
|
|
1496
|
+
// const { savedX, savedY, savedWidth, savedHeight } = this.#savedDimensions;
|
|
1497
|
+
// this.#addResizeToUndoStack(savedX, savedY, savedWidth, savedHeight);
|
|
1498
|
+
// this.#savedDimensions = null;
|
|
1499
|
+
// }
|
|
1500
|
+
};
|
|
1501
|
+
AnnotationEditor.idManager = new id_manager_1.IdManager("annotation_editor_id_");
|
|
1502
|
+
AnnotationEditor._borderLineWidth = -1;
|
|
1503
|
+
AnnotationEditor._colorManager = new color_manager_1.ColorManager();
|
|
1504
|
+
AnnotationEditor._zIndex = 1;
|
|
1505
|
+
// Time to wait (in ms) before sending the telemetry data.
|
|
1506
|
+
// We wait a bit to avoid sending too many requests when changing something
|
|
1507
|
+
// like the thickness of a line.
|
|
1508
|
+
AnnotationEditor._telemetryTimeout = 1000;
|
|
1509
|
+
// This class is used to fake an editor which has been deleted.
|
|
1510
|
+
class FakeEditor extends AnnotationEditor {
|
|
1511
|
+
constructor(params) {
|
|
1512
|
+
super(params);
|
|
1513
|
+
this.annotationElementId = params.annotationElementId;
|
|
1514
|
+
this.deleted = true;
|
|
1515
|
+
}
|
|
1516
|
+
serialize() {
|
|
1517
|
+
return {
|
|
1518
|
+
id: this.annotationElementId,
|
|
1519
|
+
deleted: true,
|
|
1520
|
+
pageIndex: this.pageIndex,
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
}
|