@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,1690 @@
|
|
|
1
|
+
/* Copyright 2014 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 _AnnotationEditorUIManager_instances, _AnnotationEditorUIManager_abortController, _AnnotationEditorUIManager_activeEditor, _AnnotationEditorUIManager_allEditors, _AnnotationEditorUIManager_allLayers, _AnnotationEditorUIManager_annotationStorage, _AnnotationEditorUIManager_changedExistingAnnotations, _AnnotationEditorUIManager_commandManager, _AnnotationEditorUIManager_currentPageIndex, _AnnotationEditorUIManager_deletedAnnotationsElementIds, _AnnotationEditorUIManager_draggingEditors, _AnnotationEditorUIManager_editorTypes, _AnnotationEditorUIManager_editorsToRescale, _AnnotationEditorUIManager_enableHighlightFloatingButton, _AnnotationEditorUIManager_focusMainContainerTimeoutId, _AnnotationEditorUIManager_focusManagerAC, _AnnotationEditorUIManager_highlightColors, _AnnotationEditorUIManager_highlightWhenShiftUp, _AnnotationEditorUIManager_highlightToolbar, _AnnotationEditorUIManager_idManager, _AnnotationEditorUIManager_isEnabled, _AnnotationEditorUIManager_isWaiting, _AnnotationEditorUIManager_lastActiveElement, _AnnotationEditorUIManager_mode, _AnnotationEditorUIManager_selectedEditors, _AnnotationEditorUIManager_selectedTextNode, _AnnotationEditorUIManager_showAllStates, _AnnotationEditorUIManager_previousStates, _AnnotationEditorUIManager_translation, _AnnotationEditorUIManager_translationTimeoutId, _AnnotationEditorUIManager_container, _AnnotationEditorUIManager_viewer, _AnnotationEditorUIManager_getAnchorElementForSelection, _AnnotationEditorUIManager_getLayerForTextLayer, _AnnotationEditorUIManager_displayHighlightToolbar, _AnnotationEditorUIManager_selectionChange, _AnnotationEditorUIManager_onSelectEnd, _AnnotationEditorUIManager_addSelectionListener, _AnnotationEditorUIManager_addFocusManager, _AnnotationEditorUIManager_removeFocusManager, _AnnotationEditorUIManager_addKeyboardManager, _AnnotationEditorUIManager_removeKeyboardManager, _AnnotationEditorUIManager_addCopyPasteListeners, _AnnotationEditorUIManager_removeCopyPasteListeners, _AnnotationEditorUIManager_addDragAndDropListeners, _AnnotationEditorUIManager_dispatchUpdateStates, _AnnotationEditorUIManager_dispatchUpdateUI, _AnnotationEditorUIManager_enableAll, _AnnotationEditorUIManager_disableAll, _AnnotationEditorUIManager_addEditorToLayer, _AnnotationEditorUIManager_lastSelectedEditor_get, _AnnotationEditorUIManager_isEmpty, _AnnotationEditorUIManager_selectEditors;
|
|
16
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
17
|
+
// import { PixelsPerInch, shadow } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
18
|
+
import { AnnotationEditorParamsType, AnnotationEditorType, PixelsPerInch, shadow } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
19
|
+
// import { CommandManager } from "./helpers/command-manager";
|
|
20
|
+
import { IdManager } from "./helpers/id-manager";
|
|
21
|
+
// import { AnnotationEditorType } from "../shared/utils";
|
|
22
|
+
import { CommandManager } from "./helpers/command-manager";
|
|
23
|
+
// import { ImageManager } from "./helpers/image-manager";
|
|
24
|
+
export class AnnotationEditorUIManager {
|
|
25
|
+
// static get _keyboardManager() {
|
|
26
|
+
// const proto = AnnotationEditorUIManager.prototype;
|
|
27
|
+
// /**
|
|
28
|
+
// * If the focused element is an input, we don't want to handle the arrow.
|
|
29
|
+
// * For example, sliders can be controlled with the arrow keys.
|
|
30
|
+
// */
|
|
31
|
+
// const arrowChecker = self =>
|
|
32
|
+
// self.#container.contains(document.activeElement) &&
|
|
33
|
+
// document.activeElement.tagName !== "BUTTON" &&
|
|
34
|
+
// self.hasSomethingToControl();
|
|
35
|
+
// const textInputChecker = (_self, { target: el }) => {
|
|
36
|
+
// if (el instanceof HTMLInputElement) {
|
|
37
|
+
// const { type } = el;
|
|
38
|
+
// return type !== "text" && type !== "number";
|
|
39
|
+
// }
|
|
40
|
+
// return true;
|
|
41
|
+
// };
|
|
42
|
+
// const small = this.TRANSLATE_SMALL;
|
|
43
|
+
// const big = this.TRANSLATE_BIG;
|
|
44
|
+
// return shadow(
|
|
45
|
+
// this,
|
|
46
|
+
// "_keyboardManager",
|
|
47
|
+
// new KeyboardManager([
|
|
48
|
+
// [
|
|
49
|
+
// ["ctrl+a", "mac+meta+a"],
|
|
50
|
+
// proto.selectAll,
|
|
51
|
+
// { checker: textInputChecker },
|
|
52
|
+
// ],
|
|
53
|
+
// [["ctrl+z", "mac+meta+z"], proto.undo, { checker: textInputChecker }],
|
|
54
|
+
// [
|
|
55
|
+
// // On mac, depending of the OS version, the event.key is either "z" or
|
|
56
|
+
// // "Z" when the user presses "meta+shift+z".
|
|
57
|
+
// [
|
|
58
|
+
// "ctrl+y",
|
|
59
|
+
// "ctrl+shift+z",
|
|
60
|
+
// "mac+meta+shift+z",
|
|
61
|
+
// "ctrl+shift+Z",
|
|
62
|
+
// "mac+meta+shift+Z",
|
|
63
|
+
// ],
|
|
64
|
+
// proto.redo,
|
|
65
|
+
// { checker: textInputChecker },
|
|
66
|
+
// ],
|
|
67
|
+
// [
|
|
68
|
+
// [
|
|
69
|
+
// "Backspace",
|
|
70
|
+
// "alt+Backspace",
|
|
71
|
+
// "ctrl+Backspace",
|
|
72
|
+
// "shift+Backspace",
|
|
73
|
+
// "mac+Backspace",
|
|
74
|
+
// "mac+alt+Backspace",
|
|
75
|
+
// "mac+ctrl+Backspace",
|
|
76
|
+
// "Delete",
|
|
77
|
+
// "ctrl+Delete",
|
|
78
|
+
// "shift+Delete",
|
|
79
|
+
// "mac+Delete",
|
|
80
|
+
// ],
|
|
81
|
+
// proto.delete,
|
|
82
|
+
// { checker: textInputChecker },
|
|
83
|
+
// ],
|
|
84
|
+
// [
|
|
85
|
+
// ["Enter", "mac+Enter"],
|
|
86
|
+
// proto.addNewEditorFromKeyboard,
|
|
87
|
+
// {
|
|
88
|
+
// // Those shortcuts can be used in the toolbar for some other actions
|
|
89
|
+
// // like zooming, hence we need to check if the container has the
|
|
90
|
+
// // focus.
|
|
91
|
+
// checker: (self, { target: el }) =>
|
|
92
|
+
// !(el instanceof HTMLButtonElement) &&
|
|
93
|
+
// self.#container.contains(el) &&
|
|
94
|
+
// !self.isEnterHandled,
|
|
95
|
+
// },
|
|
96
|
+
// ],
|
|
97
|
+
// [
|
|
98
|
+
// [" ", "mac+ "],
|
|
99
|
+
// proto.addNewEditorFromKeyboard,
|
|
100
|
+
// {
|
|
101
|
+
// // Those shortcuts can be used in the toolbar for some other actions
|
|
102
|
+
// // like zooming, hence we need to check if the container has the
|
|
103
|
+
// // focus.
|
|
104
|
+
// checker: (self, { target: el }) =>
|
|
105
|
+
// !(el instanceof HTMLButtonElement) &&
|
|
106
|
+
// self.#container.contains(document.activeElement),
|
|
107
|
+
// },
|
|
108
|
+
// ],
|
|
109
|
+
// [["Escape", "mac+Escape"], proto.unselectAll],
|
|
110
|
+
// [
|
|
111
|
+
// ["ArrowLeft", "mac+ArrowLeft"],
|
|
112
|
+
// proto.translateSelectedEditors,
|
|
113
|
+
// { args: [-small, 0], checker: arrowChecker },
|
|
114
|
+
// ],
|
|
115
|
+
// [
|
|
116
|
+
// ["ctrl+ArrowLeft", "mac+shift+ArrowLeft"],
|
|
117
|
+
// proto.translateSelectedEditors,
|
|
118
|
+
// { args: [-big, 0], checker: arrowChecker },
|
|
119
|
+
// ],
|
|
120
|
+
// [
|
|
121
|
+
// ["ArrowRight", "mac+ArrowRight"],
|
|
122
|
+
// proto.translateSelectedEditors,
|
|
123
|
+
// { args: [small, 0], checker: arrowChecker },
|
|
124
|
+
// ],
|
|
125
|
+
// [
|
|
126
|
+
// ["ctrl+ArrowRight", "mac+shift+ArrowRight"],
|
|
127
|
+
// proto.translateSelectedEditors,
|
|
128
|
+
// { args: [big, 0], checker: arrowChecker },
|
|
129
|
+
// ],
|
|
130
|
+
// [
|
|
131
|
+
// ["ArrowUp", "mac+ArrowUp"],
|
|
132
|
+
// proto.translateSelectedEditors,
|
|
133
|
+
// { args: [0, -small], checker: arrowChecker },
|
|
134
|
+
// ],
|
|
135
|
+
// [
|
|
136
|
+
// ["ctrl+ArrowUp", "mac+shift+ArrowUp"],
|
|
137
|
+
// proto.translateSelectedEditors,
|
|
138
|
+
// { args: [0, -big], checker: arrowChecker },
|
|
139
|
+
// ],
|
|
140
|
+
// [
|
|
141
|
+
// ["ArrowDown", "mac+ArrowDown"],
|
|
142
|
+
// proto.translateSelectedEditors,
|
|
143
|
+
// { args: [0, small], checker: arrowChecker },
|
|
144
|
+
// ],
|
|
145
|
+
// [
|
|
146
|
+
// ["ctrl+ArrowDown", "mac+shift+ArrowDown"],
|
|
147
|
+
// proto.translateSelectedEditors,
|
|
148
|
+
// { args: [0, big], checker: arrowChecker },
|
|
149
|
+
// ],
|
|
150
|
+
// ])
|
|
151
|
+
// );
|
|
152
|
+
// }
|
|
153
|
+
constructor({ container = null, viewer, pdfViewer,
|
|
154
|
+
// altTextManager,
|
|
155
|
+
eventBus, pdfDocument,
|
|
156
|
+
// pageColors,
|
|
157
|
+
highlightColors = "",
|
|
158
|
+
// enableHighlightFloatingButton,
|
|
159
|
+
// enableUpdatedAddImage,
|
|
160
|
+
// enableNewAltTextWhenAddingImage,
|
|
161
|
+
// mlManager
|
|
162
|
+
}) {
|
|
163
|
+
_AnnotationEditorUIManager_instances.add(this);
|
|
164
|
+
// todo: props
|
|
165
|
+
// todo: extract to pdf viewer
|
|
166
|
+
this.pdfViewer = null;
|
|
167
|
+
this.annotationEditorMode = AnnotationEditorType.NONE;
|
|
168
|
+
this.viewParameters = {};
|
|
169
|
+
this.isShiftKeyDown = false;
|
|
170
|
+
this._eventBus = null;
|
|
171
|
+
// todo: props
|
|
172
|
+
_AnnotationEditorUIManager_abortController.set(this, new AbortController());
|
|
173
|
+
_AnnotationEditorUIManager_activeEditor.set(this, null);
|
|
174
|
+
_AnnotationEditorUIManager_allEditors.set(this, new Map());
|
|
175
|
+
_AnnotationEditorUIManager_allLayers.set(this, new Map());
|
|
176
|
+
// #altTextManager = null;
|
|
177
|
+
_AnnotationEditorUIManager_annotationStorage.set(this, null);
|
|
178
|
+
_AnnotationEditorUIManager_changedExistingAnnotations.set(this, null);
|
|
179
|
+
_AnnotationEditorUIManager_commandManager.set(this, new CommandManager());
|
|
180
|
+
// #copyPasteAC = null;
|
|
181
|
+
_AnnotationEditorUIManager_currentPageIndex.set(this, 0);
|
|
182
|
+
_AnnotationEditorUIManager_deletedAnnotationsElementIds.set(this, new Set());
|
|
183
|
+
_AnnotationEditorUIManager_draggingEditors.set(this, null);
|
|
184
|
+
_AnnotationEditorUIManager_editorTypes.set(this, null);
|
|
185
|
+
_AnnotationEditorUIManager_editorsToRescale.set(this, new Set());
|
|
186
|
+
// todo: change default value
|
|
187
|
+
// #enableHighlightFloatingButton = false;
|
|
188
|
+
_AnnotationEditorUIManager_enableHighlightFloatingButton.set(this, true);
|
|
189
|
+
// #enableUpdatedAddImage = false;
|
|
190
|
+
// #enableNewAltTextWhenAddingImage = false;
|
|
191
|
+
// #filterFactory = null;
|
|
192
|
+
_AnnotationEditorUIManager_focusMainContainerTimeoutId.set(this, null);
|
|
193
|
+
_AnnotationEditorUIManager_focusManagerAC.set(this, null);
|
|
194
|
+
// todo: this is defined in "highlightEditorColors" in pdf.js as
|
|
195
|
+
// value: "yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",
|
|
196
|
+
_AnnotationEditorUIManager_highlightColors.set(this, "");
|
|
197
|
+
_AnnotationEditorUIManager_highlightWhenShiftUp.set(this, false);
|
|
198
|
+
_AnnotationEditorUIManager_highlightToolbar.set(this, null);
|
|
199
|
+
_AnnotationEditorUIManager_idManager.set(this, new IdManager());
|
|
200
|
+
_AnnotationEditorUIManager_isEnabled.set(this, false);
|
|
201
|
+
_AnnotationEditorUIManager_isWaiting.set(this, false);
|
|
202
|
+
// #keyboardManagerAC = null;
|
|
203
|
+
_AnnotationEditorUIManager_lastActiveElement.set(this, null);
|
|
204
|
+
// #mainHighlightColorPicker = null;
|
|
205
|
+
// #mlManager = null;
|
|
206
|
+
_AnnotationEditorUIManager_mode.set(this, AnnotationEditorType.NONE);
|
|
207
|
+
_AnnotationEditorUIManager_selectedEditors.set(this, new Set());
|
|
208
|
+
_AnnotationEditorUIManager_selectedTextNode.set(this, null);
|
|
209
|
+
// #pageColors = null;
|
|
210
|
+
_AnnotationEditorUIManager_showAllStates.set(this, null);
|
|
211
|
+
_AnnotationEditorUIManager_previousStates.set(this, {
|
|
212
|
+
isEditing: false,
|
|
213
|
+
isEmpty: true,
|
|
214
|
+
hasSomethingToUndo: false,
|
|
215
|
+
hasSomethingToRedo: false,
|
|
216
|
+
hasSelectedEditor: false,
|
|
217
|
+
hasSelectedText: false,
|
|
218
|
+
});
|
|
219
|
+
_AnnotationEditorUIManager_translation.set(this, [0, 0]);
|
|
220
|
+
_AnnotationEditorUIManager_translationTimeoutId.set(this, null);
|
|
221
|
+
_AnnotationEditorUIManager_container.set(this, null);
|
|
222
|
+
_AnnotationEditorUIManager_viewer.set(this, null);
|
|
223
|
+
// // const signal = (this._signal = this.#abortController.signal);
|
|
224
|
+
const signal = this._signal = __classPrivateFieldGet(this, _AnnotationEditorUIManager_abortController, "f").signal;
|
|
225
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_container, container, "f");
|
|
226
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_viewer, viewer, "f");
|
|
227
|
+
this.pdfViewer = pdfViewer;
|
|
228
|
+
// this.#altTextManager = altTextManager;
|
|
229
|
+
this._eventBus = eventBus;
|
|
230
|
+
this._eventBus._on("editingaction", this.onEditingAction.bind(this), {
|
|
231
|
+
signal,
|
|
232
|
+
});
|
|
233
|
+
this._eventBus._on("pagechanging", this.onPageChanging.bind(this), {
|
|
234
|
+
signal,
|
|
235
|
+
});
|
|
236
|
+
this._eventBus._on("scalechanging", this.onScaleChanging.bind(this), {
|
|
237
|
+
signal,
|
|
238
|
+
});
|
|
239
|
+
this._eventBus._on("rotationchanging", this.onRotationChanging.bind(this), {
|
|
240
|
+
signal,
|
|
241
|
+
});
|
|
242
|
+
this._eventBus._on("setpreference", this.onSetPreference.bind(this), {
|
|
243
|
+
signal,
|
|
244
|
+
});
|
|
245
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addSelectionListener).call(this);
|
|
246
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addDragAndDropListeners).call(this);
|
|
247
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addKeyboardManager).call(this);
|
|
248
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_annotationStorage, pdfDocument.annotationStorage, "f");
|
|
249
|
+
// this.#filterFactory = pdfDocument.filterFactory;
|
|
250
|
+
// this.#pageColors = pageColors;
|
|
251
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_highlightColors, highlightColors || "", "f");
|
|
252
|
+
// this.#enableHighlightFloatingButton = enableHighlightFloatingButton;
|
|
253
|
+
// this.#enableUpdatedAddImage = enableUpdatedAddImage;
|
|
254
|
+
// this.#enableNewAltTextWhenAddingImage = enableNewAltTextWhenAddingImage;
|
|
255
|
+
// this.#mlManager = mlManager || null;
|
|
256
|
+
this.viewParameters = {
|
|
257
|
+
realScale: PixelsPerInch.PDF_TO_CSS_UNITS,
|
|
258
|
+
rotation: 0,
|
|
259
|
+
};
|
|
260
|
+
// this.isShiftKeyDown = false;
|
|
261
|
+
// if ( typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
|
|
262
|
+
// window.uiManager = this;
|
|
263
|
+
// Object.defineProperty(this, "reset", {
|
|
264
|
+
// value: () => {
|
|
265
|
+
// this.selectAll();
|
|
266
|
+
// this.delete();
|
|
267
|
+
// this.#idManager.reset();
|
|
268
|
+
// },
|
|
269
|
+
// });
|
|
270
|
+
// }
|
|
271
|
+
}
|
|
272
|
+
destroy() {
|
|
273
|
+
var _a;
|
|
274
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_abortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
|
275
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_abortController, null, "f");
|
|
276
|
+
this._signal = null;
|
|
277
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
278
|
+
layer.destroy();
|
|
279
|
+
}
|
|
280
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").clear();
|
|
281
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").clear();
|
|
282
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_editorsToRescale, "f").clear();
|
|
283
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_activeEditor, null, "f");
|
|
284
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").clear();
|
|
285
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").destroy();
|
|
286
|
+
// this.#altTextManager?.destroy();
|
|
287
|
+
// this.#highlightToolbar?.hide();
|
|
288
|
+
// this.#highlightToolbar = null;
|
|
289
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, "f")) {
|
|
290
|
+
clearTimeout(__classPrivateFieldGet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, "f"));
|
|
291
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, null, "f");
|
|
292
|
+
}
|
|
293
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_translationTimeoutId, "f")) {
|
|
294
|
+
clearTimeout(__classPrivateFieldGet(this, _AnnotationEditorUIManager_translationTimeoutId, "f"));
|
|
295
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_translationTimeoutId, null, "f");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// todo: new
|
|
299
|
+
getTextLayerForAnchor(anchorElement) {
|
|
300
|
+
if (!anchorElement) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
return anchorElement.closest(".textLayer") || anchorElement.closest(".k-text-layer");
|
|
304
|
+
}
|
|
305
|
+
combinedSignal(abortSignal) {
|
|
306
|
+
// eslint-disable-next-line
|
|
307
|
+
if (AbortSignal && AbortSignal["any"]) {
|
|
308
|
+
return AbortSignal.any([this._signal, abortSignal.signal]);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
// add this for the unit tests
|
|
312
|
+
// AbortSignal.any is an API since March 2024
|
|
313
|
+
// however, this API is not currently available in
|
|
314
|
+
// the node/jest-related bits version that we are using
|
|
315
|
+
return this._signal || abortSignal.signal;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// get mlManager() {
|
|
319
|
+
// return this.#mlManager;
|
|
320
|
+
// }
|
|
321
|
+
// get useNewAltTextFlow() {
|
|
322
|
+
// return this.#enableUpdatedAddImage;
|
|
323
|
+
// }
|
|
324
|
+
// get useNewAltTextWhenAddingImage() {
|
|
325
|
+
// return this.#enableNewAltTextWhenAddingImage;
|
|
326
|
+
// }
|
|
327
|
+
// get hcmFilter() {
|
|
328
|
+
// return shadow(
|
|
329
|
+
// this,
|
|
330
|
+
// "hcmFilter",
|
|
331
|
+
// this.#pageColors
|
|
332
|
+
// ? this.#filterFactory.addHCMFilter(
|
|
333
|
+
// this.#pageColors.foreground,
|
|
334
|
+
// this.#pageColors.background
|
|
335
|
+
// )
|
|
336
|
+
// : "none"
|
|
337
|
+
// );
|
|
338
|
+
// }
|
|
339
|
+
get direction() {
|
|
340
|
+
return shadow(this, "direction", getComputedStyle(__classPrivateFieldGet(this, _AnnotationEditorUIManager_container, "f")).direction);
|
|
341
|
+
}
|
|
342
|
+
get highlightColors() {
|
|
343
|
+
return shadow(this, "highlightColors", __classPrivateFieldGet(this, _AnnotationEditorUIManager_highlightColors, "f")
|
|
344
|
+
? new Map(
|
|
345
|
+
// Array.from(
|
|
346
|
+
// this.#highlightColors
|
|
347
|
+
// .split(",")
|
|
348
|
+
// .map(pair => pair.split("=").map(x => x.trim()))
|
|
349
|
+
// )
|
|
350
|
+
)
|
|
351
|
+
: null);
|
|
352
|
+
}
|
|
353
|
+
get highlightColorNames() {
|
|
354
|
+
return shadow(this, "highlightColorNames", this.highlightColors
|
|
355
|
+
? new Map(Array.from(this.highlightColors, e => e.reverse()))
|
|
356
|
+
: null);
|
|
357
|
+
}
|
|
358
|
+
// setMainHighlightColorPicker(colorPicker) {
|
|
359
|
+
// this.#mainHighlightColorPicker = colorPicker;
|
|
360
|
+
// }
|
|
361
|
+
// editAltText(editor, firstTime = false) {
|
|
362
|
+
// this.#altTextManager?.editAltText(this, editor, firstTime);
|
|
363
|
+
// }
|
|
364
|
+
switchToMode(mode, callback) {
|
|
365
|
+
// Switching to a mode can be asynchronous.
|
|
366
|
+
this._eventBus.on("annotationeditormodechanged", callback, {
|
|
367
|
+
once: true,
|
|
368
|
+
signal: this._signal,
|
|
369
|
+
mode
|
|
370
|
+
});
|
|
371
|
+
this._eventBus.dispatch("showannotationeditorui", {
|
|
372
|
+
source: this,
|
|
373
|
+
mode,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
setPreference(name, value) {
|
|
377
|
+
this._eventBus.dispatch("setpreference", {
|
|
378
|
+
source: this,
|
|
379
|
+
name,
|
|
380
|
+
value,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
// onSetPreference({ name, value }) {
|
|
384
|
+
onSetPreference({ name }) {
|
|
385
|
+
switch (name) {
|
|
386
|
+
case "enableNewAltTextWhenAddingImage":
|
|
387
|
+
// this.#enableNewAltTextWhenAddingImage = value;
|
|
388
|
+
break;
|
|
389
|
+
default: break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
onPageChanging({ pageNumber }) {
|
|
393
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_currentPageIndex, pageNumber - 1, "f");
|
|
394
|
+
}
|
|
395
|
+
focusMainContainer() {
|
|
396
|
+
var _a;
|
|
397
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_container, "f")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
398
|
+
}
|
|
399
|
+
findParent(x, y) {
|
|
400
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
401
|
+
const { x: layerX, y: layerY, width, height, } = layer.div.getBoundingClientRect();
|
|
402
|
+
if (x >= layerX &&
|
|
403
|
+
x <= layerX + width &&
|
|
404
|
+
y >= layerY &&
|
|
405
|
+
y <= layerY + height) {
|
|
406
|
+
return layer;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
disableUserSelect(value = false) {
|
|
412
|
+
var _a;
|
|
413
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_viewer, "f")) === null || _a === void 0 ? void 0 : _a.classList.toggle("noUserSelect", value);
|
|
414
|
+
}
|
|
415
|
+
addShouldRescale(editor) {
|
|
416
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_editorsToRescale, "f").add(editor);
|
|
417
|
+
}
|
|
418
|
+
removeShouldRescale(editor) {
|
|
419
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_editorsToRescale, "f").delete(editor);
|
|
420
|
+
}
|
|
421
|
+
onScaleChanging({ scale }) {
|
|
422
|
+
this.commitOrRemove();
|
|
423
|
+
this.viewParameters.realScale = scale * PixelsPerInch.PDF_TO_CSS_UNITS;
|
|
424
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_editorsToRescale, "f")) {
|
|
425
|
+
editor.onScaleChanging();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
onRotationChanging({ pagesRotation }) {
|
|
429
|
+
this.commitOrRemove();
|
|
430
|
+
this.viewParameters.rotation = pagesRotation;
|
|
431
|
+
}
|
|
432
|
+
highlightSelection(methodOfCreation = "") {
|
|
433
|
+
const selection = document.getSelection();
|
|
434
|
+
if (!selection || selection.isCollapsed) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;
|
|
438
|
+
const text = selection.toString();
|
|
439
|
+
const anchorElement = __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_getAnchorElementForSelection).call(this, selection);
|
|
440
|
+
// const textLayer = anchorElement.closest(".textLayer");
|
|
441
|
+
const textLayer = this.getTextLayerForAnchor(anchorElement);
|
|
442
|
+
const boxes = this.getSelectionBoxes(textLayer);
|
|
443
|
+
if (!boxes) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
selection.empty();
|
|
447
|
+
const layer = __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_getLayerForTextLayer).call(this, textLayer);
|
|
448
|
+
const isNoneMode = __classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === AnnotationEditorType.NONE;
|
|
449
|
+
const callback = () => {
|
|
450
|
+
layer === null || layer === void 0 ? void 0 : layer.createAndAddNewEditor({ x: 0, y: 0 }, false, {
|
|
451
|
+
methodOfCreation,
|
|
452
|
+
boxes,
|
|
453
|
+
anchorNode,
|
|
454
|
+
anchorOffset,
|
|
455
|
+
focusNode,
|
|
456
|
+
focusOffset,
|
|
457
|
+
text,
|
|
458
|
+
});
|
|
459
|
+
if (isNoneMode) {
|
|
460
|
+
// this.showAllEditors("highlight", true, /* updateButton = */ true);
|
|
461
|
+
this.showAllEditors("highlight", true);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
if (isNoneMode) {
|
|
465
|
+
this.switchToMode(AnnotationEditorType.HIGHLIGHT, callback);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
callback();
|
|
469
|
+
}
|
|
470
|
+
showEditorToolBar(anchor) {
|
|
471
|
+
if (!anchor) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
// todo: disable showing a toolbar for other annotations
|
|
475
|
+
const annotationEditorMode = this.getMode();
|
|
476
|
+
if (annotationEditorMode === AnnotationEditorType.HIGHLIGHT) {
|
|
477
|
+
const editor = anchor.closest(".highlightEditor");
|
|
478
|
+
if (!editor) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (annotationEditorMode === AnnotationEditorType.FREETEXT) {
|
|
483
|
+
const editor = anchor.closest(".freeTextEditor");
|
|
484
|
+
if (!editor) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (annotationEditorMode !== AnnotationEditorType.HIGHLIGHT &&
|
|
489
|
+
annotationEditorMode !== AnnotationEditorType.FREETEXT) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
this._eventBus.dispatch("kendoAnnotationEditorToolBarShow", {
|
|
493
|
+
source: this,
|
|
494
|
+
anchor: anchor
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
hideEditorToolBar() {
|
|
498
|
+
this._eventBus.dispatch("kendoAnnotationEditorToolBarHide", {
|
|
499
|
+
source: this,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Add an editor in the annotation storage.
|
|
504
|
+
* @param {AnnotationEditor} editor
|
|
505
|
+
*/
|
|
506
|
+
addToAnnotationStorage(editor) {
|
|
507
|
+
if (!editor.isEmpty() &&
|
|
508
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_annotationStorage, "f") &&
|
|
509
|
+
!__classPrivateFieldGet(this, _AnnotationEditorUIManager_annotationStorage, "f").has(editor.id)) {
|
|
510
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_annotationStorage, "f").setValue(editor.id, editor);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
blur() {
|
|
514
|
+
this.isShiftKeyDown = false;
|
|
515
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_highlightWhenShiftUp, "f")) {
|
|
516
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_highlightWhenShiftUp, false, "f");
|
|
517
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_onSelectEnd).call(this, "main_toolbar");
|
|
518
|
+
}
|
|
519
|
+
if (!this.hasSelection) {
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
// When several editors are selected and the window loses focus, we want to
|
|
523
|
+
// keep the last active element in order to be able to focus it again when
|
|
524
|
+
// the window gets the focus back but we don't want to trigger any focus
|
|
525
|
+
// callbacks else only one editor will be selected.
|
|
526
|
+
const { activeElement } = document;
|
|
527
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
528
|
+
if (editor.div.contains(activeElement)) {
|
|
529
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_lastActiveElement, [editor, activeElement], "f");
|
|
530
|
+
editor._focusEventsAllowed = false;
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
focus() {
|
|
536
|
+
if (!__classPrivateFieldGet(this, _AnnotationEditorUIManager_lastActiveElement, "f")) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const [lastEditor, lastActiveElement] = __classPrivateFieldGet(this, _AnnotationEditorUIManager_lastActiveElement, "f");
|
|
540
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_lastActiveElement, null, "f");
|
|
541
|
+
lastActiveElement.addEventListener("focusin", () => {
|
|
542
|
+
lastEditor._focusEventsAllowed = true;
|
|
543
|
+
}, { once: true, signal: this._signal });
|
|
544
|
+
lastActiveElement.focus();
|
|
545
|
+
}
|
|
546
|
+
addEditListeners() {
|
|
547
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addKeyboardManager).call(this);
|
|
548
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addCopyPasteListeners).call(this);
|
|
549
|
+
}
|
|
550
|
+
removeEditListeners() {
|
|
551
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_removeKeyboardManager).call(this);
|
|
552
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_removeCopyPasteListeners).call(this);
|
|
553
|
+
}
|
|
554
|
+
dragOver(event) {
|
|
555
|
+
for (const { type } of event.dataTransfer.items) {
|
|
556
|
+
for (const editorType of __classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
557
|
+
if (editorType.isHandlingMimeForPasting(type)) {
|
|
558
|
+
event.dataTransfer.dropEffect = "copy";
|
|
559
|
+
event.preventDefault();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Drop callback.
|
|
567
|
+
* @param {DragEvent} event
|
|
568
|
+
*/
|
|
569
|
+
drop(event) {
|
|
570
|
+
for (const item of event.dataTransfer.items) {
|
|
571
|
+
for (const editorType of __classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
572
|
+
if (editorType.isHandlingMimeForPasting(item.type)) {
|
|
573
|
+
editorType.paste(item, this.currentLayer);
|
|
574
|
+
event.preventDefault();
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Copy callback.
|
|
582
|
+
* @param {ClipboardEvent} event
|
|
583
|
+
*/
|
|
584
|
+
copy(event) {
|
|
585
|
+
var _a;
|
|
586
|
+
event.preventDefault();
|
|
587
|
+
// An editor is being edited so just commit it.
|
|
588
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f")) === null || _a === void 0 ? void 0 : _a.commitOrRemove();
|
|
589
|
+
if (!this.hasSelection) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const editors = [];
|
|
593
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
594
|
+
const serialized = editor.serialize(/* isForCopying = */ true);
|
|
595
|
+
if (serialized) {
|
|
596
|
+
editors.push(serialized);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (editors.length === 0) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
event.clipboardData.setData("application/pdfjs", JSON.stringify(editors));
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Cut callback.
|
|
606
|
+
* @param {ClipboardEvent} event
|
|
607
|
+
*/
|
|
608
|
+
cut(event) {
|
|
609
|
+
this.copy(event);
|
|
610
|
+
this.delete();
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Paste callback.
|
|
614
|
+
* @param {ClipboardEvent} event
|
|
615
|
+
*/
|
|
616
|
+
paste(event) {
|
|
617
|
+
event.preventDefault();
|
|
618
|
+
const { clipboardData } = event;
|
|
619
|
+
for (const item of clipboardData.items) {
|
|
620
|
+
for (const editorType of __classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
621
|
+
if (editorType.isHandlingMimeForPasting(item.type)) {
|
|
622
|
+
editorType.paste(item, this.currentLayer);
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
let data = clipboardData.getData("application/pdfjs");
|
|
628
|
+
if (!data) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
data = JSON.parse(data);
|
|
633
|
+
}
|
|
634
|
+
catch (ex) {
|
|
635
|
+
// warn(`paste: "${ex.message}".`);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
if (!Array.isArray(data)) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
this.unselectAll();
|
|
642
|
+
const layer = this.currentLayer;
|
|
643
|
+
try {
|
|
644
|
+
const newEditors = [];
|
|
645
|
+
for (const editor of data) {
|
|
646
|
+
const deserializedEditor = layer.deserialize(editor);
|
|
647
|
+
if (!deserializedEditor) {
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
newEditors.push(deserializedEditor);
|
|
651
|
+
}
|
|
652
|
+
const cmd = () => {
|
|
653
|
+
for (const editor of newEditors) {
|
|
654
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addEditorToLayer).call(this, editor);
|
|
655
|
+
}
|
|
656
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_selectEditors).call(this, newEditors);
|
|
657
|
+
};
|
|
658
|
+
const undo = () => {
|
|
659
|
+
for (const editor of newEditors) {
|
|
660
|
+
editor.remove();
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
this.addCommands({ cmd, undo, mustExec: true });
|
|
664
|
+
}
|
|
665
|
+
catch (ex) {
|
|
666
|
+
// warn(`paste: "${ex.message}".`);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
// /**
|
|
670
|
+
// * Keydown callback.
|
|
671
|
+
// * @param {KeyboardEvent} event
|
|
672
|
+
// */
|
|
673
|
+
// keydown(event) {
|
|
674
|
+
// if (!this.isShiftKeyDown && event.key === "Shift") {
|
|
675
|
+
// this.isShiftKeyDown = true;
|
|
676
|
+
// }
|
|
677
|
+
// if (
|
|
678
|
+
// this.#mode !== AnnotationEditorType.NONE &&
|
|
679
|
+
// !this.isEditorHandlingKeyboard
|
|
680
|
+
// ) {
|
|
681
|
+
// AnnotationEditorUIManager._keyboardManager.exec(this, event);
|
|
682
|
+
// }
|
|
683
|
+
// }
|
|
684
|
+
// /**
|
|
685
|
+
// * Keyup callback.
|
|
686
|
+
// * @param {KeyboardEvent} event
|
|
687
|
+
// */
|
|
688
|
+
// keyup(event) {
|
|
689
|
+
// if (this.isShiftKeyDown && event.key === "Shift") {
|
|
690
|
+
// this.isShiftKeyDown = false;
|
|
691
|
+
// if (this.#highlightWhenShiftUp) {
|
|
692
|
+
// this.#highlightWhenShiftUp = false;
|
|
693
|
+
// this.#onSelectEnd("main_toolbar");
|
|
694
|
+
// }
|
|
695
|
+
// }
|
|
696
|
+
// }
|
|
697
|
+
/**
|
|
698
|
+
* Execute an action for a given name.
|
|
699
|
+
* For example, the user can click on the "Undo" entry in the context menu
|
|
700
|
+
* and it'll trigger the undo action.
|
|
701
|
+
*/
|
|
702
|
+
onEditingAction({ name }) {
|
|
703
|
+
switch (name) {
|
|
704
|
+
case "undo":
|
|
705
|
+
case "redo":
|
|
706
|
+
case "delete":
|
|
707
|
+
case "selectAll":
|
|
708
|
+
this[name]();
|
|
709
|
+
break;
|
|
710
|
+
case "highlightSelection":
|
|
711
|
+
this.highlightSelection("context_menu");
|
|
712
|
+
break;
|
|
713
|
+
default: break;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Set the editing state.
|
|
718
|
+
* It can be useful to temporarily disable it when the user is editing a
|
|
719
|
+
* FreeText annotation.
|
|
720
|
+
* @param {boolean} isEditing
|
|
721
|
+
*/
|
|
722
|
+
setEditingState(isEditing) {
|
|
723
|
+
// setEditingState() {
|
|
724
|
+
if (isEditing) {
|
|
725
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addFocusManager).call(this);
|
|
726
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addCopyPasteListeners).call(this);
|
|
727
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
728
|
+
isEditing: __classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") !== AnnotationEditorType.NONE,
|
|
729
|
+
isEmpty: __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_isEmpty).call(this),
|
|
730
|
+
hasSomethingToUndo: __classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").hasSomethingToUndo(),
|
|
731
|
+
hasSomethingToRedo: __classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").hasSomethingToRedo(),
|
|
732
|
+
hasSelectedEditor: false,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_removeFocusManager).call(this);
|
|
737
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_removeCopyPasteListeners).call(this);
|
|
738
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
739
|
+
isEditing: false,
|
|
740
|
+
});
|
|
741
|
+
this.disableUserSelect(false);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
registerEditorTypes(types) {
|
|
745
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_editorTypes, types, "f");
|
|
749
|
+
for (const editorType of __classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
750
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, editorType.defaultPropertiesToUpdate);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Get an id.
|
|
755
|
+
* @returns {string}
|
|
756
|
+
*/
|
|
757
|
+
getId() {
|
|
758
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_idManager, "f").id;
|
|
759
|
+
}
|
|
760
|
+
get currentLayer() {
|
|
761
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").get(__classPrivateFieldGet(this, _AnnotationEditorUIManager_currentPageIndex, "f"));
|
|
762
|
+
}
|
|
763
|
+
getLayer(pageIndex) {
|
|
764
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").get(pageIndex);
|
|
765
|
+
}
|
|
766
|
+
get currentPageIndex() {
|
|
767
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_currentPageIndex, "f");
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Add a new layer for a page which will contains the editors.
|
|
771
|
+
* @param {AnnotationEditorLayer} layer
|
|
772
|
+
*/
|
|
773
|
+
addLayer(layer) {
|
|
774
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").set(layer.pageIndex, layer);
|
|
775
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_isEnabled, "f")) {
|
|
776
|
+
layer.enable();
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
layer.disable();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Remove a layer.
|
|
784
|
+
* @param {AnnotationEditorLayer} layer
|
|
785
|
+
*/
|
|
786
|
+
removeLayer(layer) {
|
|
787
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").delete(layer.pageIndex);
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Change the editor mode (None, FreeText, Ink, ...)
|
|
791
|
+
* @param {number} mode
|
|
792
|
+
* @param {string|null} editId
|
|
793
|
+
* @param {boolean} [isFromKeyboard] - true if the mode change is due to a
|
|
794
|
+
* keyboard action.
|
|
795
|
+
*/
|
|
796
|
+
updateMode(mode, editId = null, isFromKeyboard = false) {
|
|
797
|
+
// todo: set isFromKeyboard intentionally to allow editor creation
|
|
798
|
+
// updateMode(mode, editId = null, isFromKeyboard = true) {
|
|
799
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === mode) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_mode, mode, "f");
|
|
803
|
+
if (mode === AnnotationEditorType.NONE) {
|
|
804
|
+
this.setEditingState(false);
|
|
805
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_disableAll).call(this);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
this.setEditingState(true);
|
|
809
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_enableAll).call(this);
|
|
810
|
+
this.unselectAll();
|
|
811
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
812
|
+
layer.updateMode(mode);
|
|
813
|
+
}
|
|
814
|
+
if (!editId && isFromKeyboard) {
|
|
815
|
+
this.addNewEditorFromKeyboard();
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if (!editId) {
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values()) {
|
|
822
|
+
if (editor.annotationElementId === editId) {
|
|
823
|
+
this.setSelected(editor);
|
|
824
|
+
editor.enterInEditMode();
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
addNewEditorFromKeyboard() {
|
|
830
|
+
if (this.currentLayer.canCreateNewEmptyEditor()) {
|
|
831
|
+
this.currentLayer.addNewEditor();
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Update the toolbar if it's required to reflect the tool currently used.
|
|
836
|
+
* @param {number} mode
|
|
837
|
+
* @returns {undefined}
|
|
838
|
+
*/
|
|
839
|
+
updateToolbar(mode) {
|
|
840
|
+
if (mode === __classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f")) {
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
this._eventBus.dispatch("switchannotationeditormode", {
|
|
844
|
+
source: this,
|
|
845
|
+
mode,
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Update a parameter in the current editor or globally.
|
|
850
|
+
* @param {number} type
|
|
851
|
+
* @param {*} value
|
|
852
|
+
*/
|
|
853
|
+
updateParams(type, value) {
|
|
854
|
+
if (!__classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
switch (type) {
|
|
858
|
+
case AnnotationEditorParamsType.CREATE:
|
|
859
|
+
this.currentLayer.addNewEditor();
|
|
860
|
+
return;
|
|
861
|
+
case AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:
|
|
862
|
+
// this.#mainHighlightColorPicker?.updateColor(value);
|
|
863
|
+
break;
|
|
864
|
+
case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:
|
|
865
|
+
// this._eventBus.dispatch("reporttelemetry", {
|
|
866
|
+
// source: this,
|
|
867
|
+
// details: {
|
|
868
|
+
// type: "editing",
|
|
869
|
+
// data: {
|
|
870
|
+
// type: "highlight",
|
|
871
|
+
// action: "toggle_visibility",
|
|
872
|
+
// },
|
|
873
|
+
// },
|
|
874
|
+
// });
|
|
875
|
+
(__classPrivateFieldSet(this, _AnnotationEditorUIManager_showAllStates, __classPrivateFieldGet(this, _AnnotationEditorUIManager_showAllStates, "f") || new Map(), "f")).set(type, value);
|
|
876
|
+
this.showAllEditors("highlight", value);
|
|
877
|
+
break;
|
|
878
|
+
default: break;
|
|
879
|
+
}
|
|
880
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
881
|
+
editor.updateParams(type, value);
|
|
882
|
+
}
|
|
883
|
+
for (const editorType of __classPrivateFieldGet(this, _AnnotationEditorUIManager_editorTypes, "f")) {
|
|
884
|
+
editorType.updateDefaultParams(type, value);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
// showAllEditors(type, visible, updateButton = false) {
|
|
888
|
+
showAllEditors(type, visible) {
|
|
889
|
+
var _a, _b;
|
|
890
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values()) {
|
|
891
|
+
if (editor.editorType === type) {
|
|
892
|
+
editor.show(visible);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
const state = (_b = (_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_showAllStates, "f")) === null || _a === void 0 ? void 0 : _a.get(AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL)) !== null && _b !== void 0 ? _b : true;
|
|
896
|
+
if (state !== visible) {
|
|
897
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, [
|
|
898
|
+
[AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL, visible],
|
|
899
|
+
]);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
enableWaiting(mustWait = false) {
|
|
903
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_isWaiting, "f") === mustWait) {
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_isWaiting, mustWait, "f");
|
|
907
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
908
|
+
if (mustWait) {
|
|
909
|
+
layer.disableClick();
|
|
910
|
+
}
|
|
911
|
+
else {
|
|
912
|
+
layer.enableClick();
|
|
913
|
+
}
|
|
914
|
+
layer.div.classList.toggle("waiting", mustWait);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Get all the editors belonging to a given page.
|
|
919
|
+
* @param {number} pageIndex
|
|
920
|
+
* @returns {Array<AnnotationEditor>}
|
|
921
|
+
*/
|
|
922
|
+
getEditors(pageIndex) {
|
|
923
|
+
const editors = [];
|
|
924
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values()) {
|
|
925
|
+
if (editor.pageIndex === pageIndex) {
|
|
926
|
+
editors.push(editor);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return editors;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Get an editor with the given id.
|
|
933
|
+
* @param {string} id
|
|
934
|
+
* @returns {AnnotationEditor}
|
|
935
|
+
*/
|
|
936
|
+
getEditor(id) {
|
|
937
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").get(id);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Add a new editor.
|
|
941
|
+
* @param {AnnotationEditor} editor
|
|
942
|
+
*/
|
|
943
|
+
addEditor(editor) {
|
|
944
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").set(editor.id, editor);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Remove an editor.
|
|
948
|
+
* @param {AnnotationEditor} editor
|
|
949
|
+
*/
|
|
950
|
+
removeEditor(editor) {
|
|
951
|
+
var _a;
|
|
952
|
+
if (editor.div.contains(document.activeElement)) {
|
|
953
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, "f")) {
|
|
954
|
+
clearTimeout(__classPrivateFieldGet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, "f"));
|
|
955
|
+
}
|
|
956
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, setTimeout(() => {
|
|
957
|
+
// When the div is removed from DOM the focus can move on the
|
|
958
|
+
// document.body, so we need to move it back to the main container.
|
|
959
|
+
this.focusMainContainer();
|
|
960
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_focusMainContainerTimeoutId, null, "f");
|
|
961
|
+
}, 0), "f");
|
|
962
|
+
}
|
|
963
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").delete(editor.id);
|
|
964
|
+
this.unselect(editor);
|
|
965
|
+
if (!editor.annotationElementId ||
|
|
966
|
+
!__classPrivateFieldGet(this, _AnnotationEditorUIManager_deletedAnnotationsElementIds, "f").has(editor.annotationElementId)) {
|
|
967
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_annotationStorage, "f")) === null || _a === void 0 ? void 0 : _a.remove(editor.id);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* The annotation element with the given id has been deleted.
|
|
972
|
+
* @param {AnnotationEditor} editor
|
|
973
|
+
*/
|
|
974
|
+
addDeletedAnnotationElement(editor) {
|
|
975
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_deletedAnnotationsElementIds, "f").add(editor.annotationElementId);
|
|
976
|
+
this.addChangedExistingAnnotation(editor);
|
|
977
|
+
editor.deleted = true;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Check if the annotation element with the given id has been deleted.
|
|
981
|
+
* @param {string} annotationElementId
|
|
982
|
+
* @returns {boolean}
|
|
983
|
+
*/
|
|
984
|
+
isDeletedAnnotationElement(annotationElementId) {
|
|
985
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_deletedAnnotationsElementIds, "f").has(annotationElementId);
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* The annotation element with the given id have been restored.
|
|
989
|
+
* @param {AnnotationEditor} editor
|
|
990
|
+
*/
|
|
991
|
+
removeDeletedAnnotationElement(editor) {
|
|
992
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_deletedAnnotationsElementIds, "f").delete(editor.annotationElementId);
|
|
993
|
+
this.removeChangedExistingAnnotation(editor);
|
|
994
|
+
editor.deleted = false;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Set the given editor as the active one.
|
|
998
|
+
* @param {AnnotationEditor} editor
|
|
999
|
+
*/
|
|
1000
|
+
setActiveEditor(editor) {
|
|
1001
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f") === editor) {
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_activeEditor, editor, "f");
|
|
1005
|
+
if (editor) {
|
|
1006
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, editor.propertiesToUpdate);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Update the UI of the active editor.
|
|
1011
|
+
* @param {AnnotationEditor} editor
|
|
1012
|
+
*/
|
|
1013
|
+
updateUI(editor) {
|
|
1014
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "a", _AnnotationEditorUIManager_lastSelectedEditor_get) === editor) {
|
|
1015
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, editor.propertiesToUpdate);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Add or remove an editor the current selection.
|
|
1020
|
+
* @param {AnnotationEditor} editor
|
|
1021
|
+
*/
|
|
1022
|
+
toggleSelected(editor) {
|
|
1023
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").has(editor)) {
|
|
1024
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").delete(editor);
|
|
1025
|
+
editor.unselect();
|
|
1026
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1027
|
+
hasSelectedEditor: this.hasSelection,
|
|
1028
|
+
});
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").add(editor);
|
|
1032
|
+
editor.select();
|
|
1033
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, editor.propertiesToUpdate);
|
|
1034
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1035
|
+
hasSelectedEditor: true,
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Set the last selected editor.
|
|
1040
|
+
* @param {AnnotationEditor} editor
|
|
1041
|
+
*/
|
|
1042
|
+
setSelected(editor) {
|
|
1043
|
+
for (const selectedEditor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
1044
|
+
if (selectedEditor !== editor) {
|
|
1045
|
+
selectedEditor.unselect();
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").clear();
|
|
1049
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").add(editor);
|
|
1050
|
+
editor.select();
|
|
1051
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, editor.propertiesToUpdate);
|
|
1052
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1053
|
+
hasSelectedEditor: true,
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Check if the editor is selected.
|
|
1058
|
+
* @param {AnnotationEditor} editor
|
|
1059
|
+
*/
|
|
1060
|
+
isSelected(editor) {
|
|
1061
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").has(editor);
|
|
1062
|
+
}
|
|
1063
|
+
get firstSelectedEditor() {
|
|
1064
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").values().next().value;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Unselect an editor.
|
|
1068
|
+
* @param {AnnotationEditor} editor
|
|
1069
|
+
*/
|
|
1070
|
+
unselect(editor) {
|
|
1071
|
+
editor.unselect();
|
|
1072
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").delete(editor);
|
|
1073
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1074
|
+
hasSelectedEditor: this.hasSelection,
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
get hasSelection() {
|
|
1078
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").size !== 0;
|
|
1079
|
+
}
|
|
1080
|
+
get isEnterHandled() {
|
|
1081
|
+
return (__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").size === 1 &&
|
|
1082
|
+
this.firstSelectedEditor.isEnterHandled);
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Undo the last command.
|
|
1086
|
+
*/
|
|
1087
|
+
undo() {
|
|
1088
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").undo();
|
|
1089
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1090
|
+
hasSomethingToUndo: __classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").hasSomethingToUndo(),
|
|
1091
|
+
hasSomethingToRedo: true,
|
|
1092
|
+
isEmpty: __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_isEmpty).call(this),
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Redo the last undoed command.
|
|
1097
|
+
*/
|
|
1098
|
+
redo() {
|
|
1099
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").redo();
|
|
1100
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1101
|
+
hasSomethingToUndo: true,
|
|
1102
|
+
hasSomethingToRedo: __classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").hasSomethingToRedo(),
|
|
1103
|
+
isEmpty: __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_isEmpty).call(this),
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Add a command to execute (cmd) and another one to undo it.
|
|
1108
|
+
* @param {Object} params
|
|
1109
|
+
*/
|
|
1110
|
+
addCommands(params) {
|
|
1111
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_commandManager, "f").add(params);
|
|
1112
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1113
|
+
hasSomethingToUndo: true,
|
|
1114
|
+
hasSomethingToRedo: false,
|
|
1115
|
+
isEmpty: __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_isEmpty).call(this),
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Delete the current editor or all.
|
|
1120
|
+
*/
|
|
1121
|
+
delete() {
|
|
1122
|
+
this.commitOrRemove();
|
|
1123
|
+
if (!this.hasSelection) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
const editors = [...__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")];
|
|
1127
|
+
const cmd = () => {
|
|
1128
|
+
for (const editor of editors) {
|
|
1129
|
+
editor.remove();
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
const undo = () => {
|
|
1133
|
+
for (const editor of editors) {
|
|
1134
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addEditorToLayer).call(this, editor);
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
this.addCommands({ cmd, undo, mustExec: true });
|
|
1138
|
+
}
|
|
1139
|
+
commitOrRemove() {
|
|
1140
|
+
var _a;
|
|
1141
|
+
// An editor is being edited so just commit it.
|
|
1142
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f")) === null || _a === void 0 ? void 0 : _a.commitOrRemove();
|
|
1143
|
+
}
|
|
1144
|
+
hasSomethingToControl() {
|
|
1145
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f") || this.hasSelection;
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Select all the editors.
|
|
1149
|
+
*/
|
|
1150
|
+
selectAll() {
|
|
1151
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
1152
|
+
editor.commit();
|
|
1153
|
+
}
|
|
1154
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_selectEditors).call(this, __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values());
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Unselect all the selected editors.
|
|
1158
|
+
*/
|
|
1159
|
+
unselectAll() {
|
|
1160
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f")) {
|
|
1161
|
+
// An editor is being edited so just commit it.
|
|
1162
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f").commitOrRemove();
|
|
1163
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") !== AnnotationEditorType.NONE) {
|
|
1164
|
+
// If the mode is NONE, we want to really unselect the editor, hence we
|
|
1165
|
+
// mustn't return here.
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
if (!this.hasSelection) {
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
1173
|
+
editor.unselect();
|
|
1174
|
+
}
|
|
1175
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").clear();
|
|
1176
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1177
|
+
hasSelectedEditor: false,
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
translateSelectedEditors(x, y, noCommit = false) {
|
|
1181
|
+
if (!noCommit) {
|
|
1182
|
+
this.commitOrRemove();
|
|
1183
|
+
}
|
|
1184
|
+
if (!this.hasSelection) {
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_translation, "f")[0] += x;
|
|
1188
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_translation, "f")[1] += y;
|
|
1189
|
+
const [totalX, totalY] = __classPrivateFieldGet(this, _AnnotationEditorUIManager_translation, "f");
|
|
1190
|
+
const editors = [...__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")];
|
|
1191
|
+
// We don't want to have an undo/redo for each translation so we wait a bit
|
|
1192
|
+
// before adding the command to the command manager.
|
|
1193
|
+
const TIME_TO_WAIT = 1000;
|
|
1194
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_translationTimeoutId, "f")) {
|
|
1195
|
+
clearTimeout(__classPrivateFieldGet(this, _AnnotationEditorUIManager_translationTimeoutId, "f"));
|
|
1196
|
+
}
|
|
1197
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_translationTimeoutId, setTimeout(() => {
|
|
1198
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_translationTimeoutId, null, "f");
|
|
1199
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_translation, "f")[0] = __classPrivateFieldGet(this, _AnnotationEditorUIManager_translation, "f")[1] = 0;
|
|
1200
|
+
this.addCommands({
|
|
1201
|
+
cmd: () => {
|
|
1202
|
+
for (const editor of editors) {
|
|
1203
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").has(editor.id)) {
|
|
1204
|
+
editor.translateInPage(totalX, totalY);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
},
|
|
1208
|
+
undo: () => {
|
|
1209
|
+
for (const editor of editors) {
|
|
1210
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").has(editor.id)) {
|
|
1211
|
+
editor.translateInPage(-totalX, -totalY);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
},
|
|
1215
|
+
mustExec: false,
|
|
1216
|
+
});
|
|
1217
|
+
}, TIME_TO_WAIT), "f");
|
|
1218
|
+
for (const editor of editors) {
|
|
1219
|
+
editor.translateInPage(x, y);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Set up the drag session for moving the selected editors.
|
|
1224
|
+
*/
|
|
1225
|
+
setUpDragSession() {
|
|
1226
|
+
// // Note: don't use any references to the editor's parent which can be null
|
|
1227
|
+
// // if the editor belongs to a destroyed page.
|
|
1228
|
+
if (!this.hasSelection) {
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
// Avoid to have spurious text selection in the text layer when dragging.
|
|
1232
|
+
this.disableUserSelect(true);
|
|
1233
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_draggingEditors, new Map(), "f");
|
|
1234
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
1235
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_draggingEditors, "f").set(editor, {
|
|
1236
|
+
savedX: editor.x,
|
|
1237
|
+
savedY: editor.y,
|
|
1238
|
+
savedPageIndex: editor.pageIndex,
|
|
1239
|
+
newX: 0,
|
|
1240
|
+
newY: 0,
|
|
1241
|
+
newPageIndex: -1,
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Ends the drag session.
|
|
1247
|
+
* @returns {boolean} true if at least one editor has been moved.
|
|
1248
|
+
*/
|
|
1249
|
+
endDragSession() {
|
|
1250
|
+
if (!__classPrivateFieldGet(this, _AnnotationEditorUIManager_draggingEditors, "f")) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
this.disableUserSelect(false);
|
|
1254
|
+
const map = __classPrivateFieldGet(this, _AnnotationEditorUIManager_draggingEditors, "f");
|
|
1255
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_draggingEditors, null, "f");
|
|
1256
|
+
let mustBeAddedInUndoStack = false;
|
|
1257
|
+
for (const [{ x, y, pageIndex }, value] of map) {
|
|
1258
|
+
value.newX = x;
|
|
1259
|
+
value.newY = y;
|
|
1260
|
+
value.newPageIndex = pageIndex;
|
|
1261
|
+
mustBeAddedInUndoStack || (mustBeAddedInUndoStack = x !== value.savedX ||
|
|
1262
|
+
y !== value.savedY ||
|
|
1263
|
+
pageIndex !== value.savedPageIndex);
|
|
1264
|
+
}
|
|
1265
|
+
if (!mustBeAddedInUndoStack) {
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
const move = (editor, x, y, pageIndex) => {
|
|
1269
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").has(editor.id)) {
|
|
1270
|
+
// The editor can be undone/redone on a page which is not visible (and
|
|
1271
|
+
// which potentially has no annotation editor layer), hence we need to
|
|
1272
|
+
// use the pageIndex instead of the parent.
|
|
1273
|
+
const parent = __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").get(pageIndex);
|
|
1274
|
+
if (parent) {
|
|
1275
|
+
editor._setParentAndPosition(parent, x, y);
|
|
1276
|
+
}
|
|
1277
|
+
else {
|
|
1278
|
+
editor.pageIndex = pageIndex;
|
|
1279
|
+
editor.x = x;
|
|
1280
|
+
editor.y = y;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
this.addCommands({
|
|
1285
|
+
cmd: () => {
|
|
1286
|
+
for (const [editor, { newX, newY, newPageIndex }] of map) {
|
|
1287
|
+
move(editor, newX, newY, newPageIndex);
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
undo: () => {
|
|
1291
|
+
for (const [editor, { savedX, savedY, savedPageIndex }] of map) {
|
|
1292
|
+
move(editor, savedX, savedY, savedPageIndex);
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
mustExec: true,
|
|
1296
|
+
});
|
|
1297
|
+
return true;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Drag the set of selected editors.
|
|
1301
|
+
* @param {number} tx
|
|
1302
|
+
* @param {number} ty
|
|
1303
|
+
*/
|
|
1304
|
+
dragSelectedEditors(tx, ty) {
|
|
1305
|
+
if (!__classPrivateFieldGet(this, _AnnotationEditorUIManager_draggingEditors, "f")) {
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_draggingEditors, "f").keys()) {
|
|
1309
|
+
editor.drag(tx, ty);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Rebuild the editor (usually on undo/redo actions) on a potentially
|
|
1314
|
+
* non-rendered page.
|
|
1315
|
+
* @param {AnnotationEditor} editor
|
|
1316
|
+
*/
|
|
1317
|
+
rebuild(editor) {
|
|
1318
|
+
if (editor.parent === null) {
|
|
1319
|
+
const parent = this.getLayer(editor.pageIndex);
|
|
1320
|
+
if (parent) {
|
|
1321
|
+
parent.changeParent(editor);
|
|
1322
|
+
parent.addOrRebuild(editor);
|
|
1323
|
+
}
|
|
1324
|
+
else {
|
|
1325
|
+
this.addEditor(editor);
|
|
1326
|
+
this.addToAnnotationStorage(editor);
|
|
1327
|
+
editor.rebuild();
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
editor.parent.addOrRebuild(editor);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
// get isEditorHandlingKeyboard() {
|
|
1335
|
+
// return (
|
|
1336
|
+
// this.getActive()?.shouldGetKeyboardEvents() ||
|
|
1337
|
+
// (this.#selectedEditors.size === 1 &&
|
|
1338
|
+
// this.firstSelectedEditor.shouldGetKeyboardEvents())
|
|
1339
|
+
// );
|
|
1340
|
+
// }
|
|
1341
|
+
/**
|
|
1342
|
+
* Is the current editor the one passed as argument?
|
|
1343
|
+
* @param {AnnotationEditor} editor
|
|
1344
|
+
* @returns
|
|
1345
|
+
*/
|
|
1346
|
+
isActive(editor) {
|
|
1347
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f") === editor;
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Get the current active editor.
|
|
1351
|
+
* @returns {AnnotationEditor|null}
|
|
1352
|
+
*/
|
|
1353
|
+
getActive() {
|
|
1354
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f");
|
|
1355
|
+
}
|
|
1356
|
+
getActiveEditor() {
|
|
1357
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_activeEditor, "f");
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Get the current editor mode.
|
|
1361
|
+
* @returns {number}
|
|
1362
|
+
*/
|
|
1363
|
+
getMode() {
|
|
1364
|
+
return __classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f");
|
|
1365
|
+
}
|
|
1366
|
+
// get imageManager() {
|
|
1367
|
+
// return shadow(this, "imageManager", new ImageManager());
|
|
1368
|
+
// }
|
|
1369
|
+
getSelectionBoxes(textLayer) {
|
|
1370
|
+
if (!textLayer) {
|
|
1371
|
+
return null;
|
|
1372
|
+
}
|
|
1373
|
+
const selection = document.getSelection();
|
|
1374
|
+
for (let i = 0, ii = selection.rangeCount; i < ii; i++) {
|
|
1375
|
+
if (!textLayer.contains(selection.getRangeAt(i).commonAncestorContainer)) {
|
|
1376
|
+
return null;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
const { x: layerX, y: layerY, width: parentWidth, height: parentHeight, } = textLayer.getBoundingClientRect();
|
|
1380
|
+
// We must rotate the boxes because we want to have them in the non-rotated
|
|
1381
|
+
// page coordinates.
|
|
1382
|
+
let rotator;
|
|
1383
|
+
switch (textLayer.getAttribute("data-main-rotation")) {
|
|
1384
|
+
case "90":
|
|
1385
|
+
rotator = (x, y, w, h) => ({
|
|
1386
|
+
x: (y - layerY) / parentHeight,
|
|
1387
|
+
y: 1 - (x + w - layerX) / parentWidth,
|
|
1388
|
+
width: h / parentHeight,
|
|
1389
|
+
height: w / parentWidth,
|
|
1390
|
+
});
|
|
1391
|
+
break;
|
|
1392
|
+
case "180":
|
|
1393
|
+
rotator = (x, y, w, h) => ({
|
|
1394
|
+
x: 1 - (x + w - layerX) / parentWidth,
|
|
1395
|
+
y: 1 - (y + h - layerY) / parentHeight,
|
|
1396
|
+
width: w / parentWidth,
|
|
1397
|
+
height: h / parentHeight,
|
|
1398
|
+
});
|
|
1399
|
+
break;
|
|
1400
|
+
case "270":
|
|
1401
|
+
rotator = (x, y, w, h) => ({
|
|
1402
|
+
x: 1 - (y + h - layerY) / parentHeight,
|
|
1403
|
+
y: (x - layerX) / parentWidth,
|
|
1404
|
+
width: h / parentHeight,
|
|
1405
|
+
height: w / parentWidth,
|
|
1406
|
+
});
|
|
1407
|
+
break;
|
|
1408
|
+
default:
|
|
1409
|
+
rotator = (x, y, w, h) => ({
|
|
1410
|
+
x: (x - layerX) / parentWidth,
|
|
1411
|
+
y: (y - layerY) / parentHeight,
|
|
1412
|
+
width: w / parentWidth,
|
|
1413
|
+
height: h / parentHeight,
|
|
1414
|
+
});
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1417
|
+
const boxes = [];
|
|
1418
|
+
for (let i = 0, ii = selection.rangeCount; i < ii; i++) {
|
|
1419
|
+
const range = selection.getRangeAt(i);
|
|
1420
|
+
if (range.collapsed) {
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
for (const { x, y, width, height } of range.getClientRects()) {
|
|
1424
|
+
if (width === 0 || height === 0) {
|
|
1425
|
+
continue;
|
|
1426
|
+
}
|
|
1427
|
+
boxes.push(rotator(x, y, width, height));
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
return boxes.length === 0 ? null : boxes;
|
|
1431
|
+
}
|
|
1432
|
+
addChangedExistingAnnotation({ annotationElementId, id }) {
|
|
1433
|
+
(__classPrivateFieldSet(this, _AnnotationEditorUIManager_changedExistingAnnotations, __classPrivateFieldGet(this, _AnnotationEditorUIManager_changedExistingAnnotations, "f") || new Map(), "f")).set(annotationElementId, id);
|
|
1434
|
+
}
|
|
1435
|
+
removeChangedExistingAnnotation({ annotationElementId }) {
|
|
1436
|
+
var _a;
|
|
1437
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_changedExistingAnnotations, "f")) === null || _a === void 0 ? void 0 : _a.delete(annotationElementId);
|
|
1438
|
+
}
|
|
1439
|
+
renderAnnotationElement(annotation) {
|
|
1440
|
+
var _a;
|
|
1441
|
+
const editorId = (_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_changedExistingAnnotations, "f")) === null || _a === void 0 ? void 0 : _a.get(annotation.data.id);
|
|
1442
|
+
if (!editorId) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
const editor = __classPrivateFieldGet(this, _AnnotationEditorUIManager_annotationStorage, "f").getRawValue(editorId);
|
|
1446
|
+
if (!editor) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === AnnotationEditorType.NONE && !editor.hasBeenModified) {
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
editor.renderAnnotationElement(annotation);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
_AnnotationEditorUIManager_abortController = new WeakMap(), _AnnotationEditorUIManager_activeEditor = new WeakMap(), _AnnotationEditorUIManager_allEditors = new WeakMap(), _AnnotationEditorUIManager_allLayers = new WeakMap(), _AnnotationEditorUIManager_annotationStorage = new WeakMap(), _AnnotationEditorUIManager_changedExistingAnnotations = new WeakMap(), _AnnotationEditorUIManager_commandManager = new WeakMap(), _AnnotationEditorUIManager_currentPageIndex = new WeakMap(), _AnnotationEditorUIManager_deletedAnnotationsElementIds = new WeakMap(), _AnnotationEditorUIManager_draggingEditors = new WeakMap(), _AnnotationEditorUIManager_editorTypes = new WeakMap(), _AnnotationEditorUIManager_editorsToRescale = new WeakMap(), _AnnotationEditorUIManager_enableHighlightFloatingButton = new WeakMap(), _AnnotationEditorUIManager_focusMainContainerTimeoutId = new WeakMap(), _AnnotationEditorUIManager_focusManagerAC = new WeakMap(), _AnnotationEditorUIManager_highlightColors = new WeakMap(), _AnnotationEditorUIManager_highlightWhenShiftUp = new WeakMap(), _AnnotationEditorUIManager_highlightToolbar = new WeakMap(), _AnnotationEditorUIManager_idManager = new WeakMap(), _AnnotationEditorUIManager_isEnabled = new WeakMap(), _AnnotationEditorUIManager_isWaiting = new WeakMap(), _AnnotationEditorUIManager_lastActiveElement = new WeakMap(), _AnnotationEditorUIManager_mode = new WeakMap(), _AnnotationEditorUIManager_selectedEditors = new WeakMap(), _AnnotationEditorUIManager_selectedTextNode = new WeakMap(), _AnnotationEditorUIManager_showAllStates = new WeakMap(), _AnnotationEditorUIManager_previousStates = new WeakMap(), _AnnotationEditorUIManager_translation = new WeakMap(), _AnnotationEditorUIManager_translationTimeoutId = new WeakMap(), _AnnotationEditorUIManager_container = new WeakMap(), _AnnotationEditorUIManager_viewer = new WeakMap(), _AnnotationEditorUIManager_instances = new WeakSet(), _AnnotationEditorUIManager_getAnchorElementForSelection = function _AnnotationEditorUIManager_getAnchorElementForSelection({ anchorNode }) {
|
|
1456
|
+
return anchorNode.nodeType === Node.TEXT_NODE
|
|
1457
|
+
? anchorNode.parentElement
|
|
1458
|
+
: anchorNode;
|
|
1459
|
+
}, _AnnotationEditorUIManager_getLayerForTextLayer = function _AnnotationEditorUIManager_getLayerForTextLayer(textLayer) {
|
|
1460
|
+
const { currentLayer } = this;
|
|
1461
|
+
if (currentLayer.hasTextLayer(textLayer)) {
|
|
1462
|
+
return currentLayer;
|
|
1463
|
+
}
|
|
1464
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
1465
|
+
if (layer.hasTextLayer(textLayer)) {
|
|
1466
|
+
return layer;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
return null;
|
|
1470
|
+
}, _AnnotationEditorUIManager_displayHighlightToolbar = function _AnnotationEditorUIManager_displayHighlightToolbar() {
|
|
1471
|
+
const selection = document.getSelection();
|
|
1472
|
+
if (!selection || selection.isCollapsed) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
const anchorElement = __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_getAnchorElementForSelection).call(this, selection);
|
|
1476
|
+
const textLayer = this.getTextLayerForAnchor(anchorElement);
|
|
1477
|
+
const boxes = this.getSelectionBoxes(textLayer);
|
|
1478
|
+
if (!boxes) {
|
|
1479
|
+
return;
|
|
1480
|
+
}
|
|
1481
|
+
this.showEditorToolBar(anchorElement);
|
|
1482
|
+
// this._eventBus.dispatch("showannotationeditorui", {
|
|
1483
|
+
// source: this,
|
|
1484
|
+
// details: Object.assign(this.#previousStates, details),
|
|
1485
|
+
// });
|
|
1486
|
+
// this.#highlightToolbar ||= new HighlightToolbar(this);
|
|
1487
|
+
// this.#highlightToolbar.show(textLayer, boxes, this.direction === "ltr");
|
|
1488
|
+
}, _AnnotationEditorUIManager_selectionChange = function _AnnotationEditorUIManager_selectionChange() {
|
|
1489
|
+
var _a, _b;
|
|
1490
|
+
const selection = document.getSelection();
|
|
1491
|
+
if (!selection || selection.isCollapsed) {
|
|
1492
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedTextNode, "f")) {
|
|
1493
|
+
// this.#highlightToolbar?.hide();
|
|
1494
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_selectedTextNode, null, "f");
|
|
1495
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1496
|
+
hasSelectedText: false,
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
const { anchorNode } = selection;
|
|
1502
|
+
if (anchorNode === __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedTextNode, "f")) {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
const anchorElement = __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_getAnchorElementForSelection).call(this, selection);
|
|
1506
|
+
// const textLayer = anchorElement.closest(".textLayer");
|
|
1507
|
+
const textLayer = this.getTextLayerForAnchor(anchorElement);
|
|
1508
|
+
if (!textLayer) {
|
|
1509
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedTextNode, "f")) {
|
|
1510
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_highlightToolbar, "f")) === null || _a === void 0 ? void 0 : _a.hide();
|
|
1511
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_selectedTextNode, null, "f");
|
|
1512
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1513
|
+
hasSelectedText: false,
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
(_b = __classPrivateFieldGet(this, _AnnotationEditorUIManager_highlightToolbar, "f")) === null || _b === void 0 ? void 0 : _b.hide();
|
|
1519
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_selectedTextNode, anchorNode, "f");
|
|
1520
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, {
|
|
1521
|
+
hasSelectedText: true,
|
|
1522
|
+
});
|
|
1523
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") !== AnnotationEditorType.HIGHLIGHT && __classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") !== AnnotationEditorType.NONE) {
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === AnnotationEditorType.HIGHLIGHT) {
|
|
1527
|
+
// this.showAllEditors("highlight", true, /* updateButton = */ true);
|
|
1528
|
+
this.showAllEditors("highlight", true);
|
|
1529
|
+
}
|
|
1530
|
+
// this.#highlightWhenShiftUp = this.isShiftKeyDown;
|
|
1531
|
+
if (!this.isShiftKeyDown) {
|
|
1532
|
+
const activeLayer = __classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === AnnotationEditorType.HIGHLIGHT
|
|
1533
|
+
? __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_getLayerForTextLayer).call(this, textLayer)
|
|
1534
|
+
: null;
|
|
1535
|
+
activeLayer === null || activeLayer === void 0 ? void 0 : activeLayer.toggleDrawing();
|
|
1536
|
+
const abortController = new AbortController();
|
|
1537
|
+
const signal = this.combinedSignal(abortController);
|
|
1538
|
+
const pointerup = e => {
|
|
1539
|
+
if (e.type === "pointerup" && e.button !== 0) {
|
|
1540
|
+
// Do nothing on right click.
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
abortController.abort();
|
|
1544
|
+
activeLayer === null || activeLayer === void 0 ? void 0 : activeLayer.toggleDrawing(true);
|
|
1545
|
+
if (e.type === "pointerup") {
|
|
1546
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_onSelectEnd).call(this, "main_toolbar");
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
window.removeEventListener("pointerup", pointerup);
|
|
1550
|
+
window.addEventListener("pointerup", pointerup, { signal });
|
|
1551
|
+
window.removeEventListener("blur", pointerup);
|
|
1552
|
+
window.addEventListener("blur", pointerup, { signal });
|
|
1553
|
+
}
|
|
1554
|
+
}, _AnnotationEditorUIManager_onSelectEnd = function _AnnotationEditorUIManager_onSelectEnd(methodOfCreation = "") {
|
|
1555
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === AnnotationEditorType.HIGHLIGHT) {
|
|
1556
|
+
this.highlightSelection(methodOfCreation);
|
|
1557
|
+
}
|
|
1558
|
+
else if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_enableHighlightFloatingButton, "f")) {
|
|
1559
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_displayHighlightToolbar).call(this);
|
|
1560
|
+
}
|
|
1561
|
+
}, _AnnotationEditorUIManager_addSelectionListener = function _AnnotationEditorUIManager_addSelectionListener() {
|
|
1562
|
+
document.addEventListener("selectionchange", __classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_selectionChange).bind(this), { signal: this._signal });
|
|
1563
|
+
}, _AnnotationEditorUIManager_addFocusManager = function _AnnotationEditorUIManager_addFocusManager() {
|
|
1564
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_focusManagerAC, "f")) {
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_focusManagerAC, new AbortController(), "f");
|
|
1568
|
+
const signal = this.combinedSignal(__classPrivateFieldGet(this, _AnnotationEditorUIManager_focusManagerAC, "f"));
|
|
1569
|
+
window.addEventListener("focus", this.focus.bind(this), { signal });
|
|
1570
|
+
window.addEventListener("blur", this.blur.bind(this), { signal });
|
|
1571
|
+
}, _AnnotationEditorUIManager_removeFocusManager = function _AnnotationEditorUIManager_removeFocusManager() {
|
|
1572
|
+
var _a;
|
|
1573
|
+
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_focusManagerAC, "f")) === null || _a === void 0 ? void 0 : _a.abort();
|
|
1574
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_focusManagerAC, null, "f");
|
|
1575
|
+
}, _AnnotationEditorUIManager_addKeyboardManager = function _AnnotationEditorUIManager_addKeyboardManager() {
|
|
1576
|
+
// if (this.#keyboardManagerAC) {
|
|
1577
|
+
// return;
|
|
1578
|
+
// }
|
|
1579
|
+
// this.#keyboardManagerAC = new AbortController();
|
|
1580
|
+
// const signal = this.combinedSignal(this.#keyboardManagerAC);
|
|
1581
|
+
// // The keyboard events are caught at the container level in order to be able
|
|
1582
|
+
// // to execute some callbacks even if the current page doesn't have focus.
|
|
1583
|
+
// window.addEventListener("keydown", this.keydown.bind(this), { signal });
|
|
1584
|
+
// window.addEventListener("keyup", this.keyup.bind(this), { signal });
|
|
1585
|
+
}, _AnnotationEditorUIManager_removeKeyboardManager = function _AnnotationEditorUIManager_removeKeyboardManager() {
|
|
1586
|
+
// this.#keyboardManagerAC?.abort();
|
|
1587
|
+
// this.#keyboardManagerAC = null;
|
|
1588
|
+
}, _AnnotationEditorUIManager_addCopyPasteListeners = function _AnnotationEditorUIManager_addCopyPasteListeners() {
|
|
1589
|
+
// if (this.#copyPasteAC) {
|
|
1590
|
+
// return;
|
|
1591
|
+
// }
|
|
1592
|
+
// this.#copyPasteAC = new AbortController();
|
|
1593
|
+
// const signal = this.combinedSignal(this.#copyPasteAC);
|
|
1594
|
+
// document.addEventListener("copy", this.copy.bind(this), { signal });
|
|
1595
|
+
// document.addEventListener("cut", this.cut.bind(this), { signal });
|
|
1596
|
+
// document.addEventListener("paste", this.paste.bind(this), { signal });
|
|
1597
|
+
}, _AnnotationEditorUIManager_removeCopyPasteListeners = function _AnnotationEditorUIManager_removeCopyPasteListeners() {
|
|
1598
|
+
// this.#copyPasteAC?.abort();
|
|
1599
|
+
// this.#copyPasteAC = null;
|
|
1600
|
+
}, _AnnotationEditorUIManager_addDragAndDropListeners = function _AnnotationEditorUIManager_addDragAndDropListeners() {
|
|
1601
|
+
const signal = this._signal;
|
|
1602
|
+
document.addEventListener("dragover", this.dragOver.bind(this), { signal });
|
|
1603
|
+
document.addEventListener("drop", this.drop.bind(this), { signal });
|
|
1604
|
+
}, _AnnotationEditorUIManager_dispatchUpdateStates = function _AnnotationEditorUIManager_dispatchUpdateStates(details) {
|
|
1605
|
+
if (!details) {
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
const hasChanged = Object.entries(details).some(([key, value]) => __classPrivateFieldGet(this, _AnnotationEditorUIManager_previousStates, "f")[key] !== value);
|
|
1609
|
+
if (hasChanged) {
|
|
1610
|
+
this._eventBus.dispatch("annotationeditorstateschanged", {
|
|
1611
|
+
source: this,
|
|
1612
|
+
details: Object.assign(__classPrivateFieldGet(this, _AnnotationEditorUIManager_previousStates, "f"), details),
|
|
1613
|
+
});
|
|
1614
|
+
// We could listen on our own event but it sounds like a bit weird and
|
|
1615
|
+
// it's a way to simpler to handle that stuff here instead of having to
|
|
1616
|
+
// add something in every place where an editor can be unselected.
|
|
1617
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_mode, "f") === AnnotationEditorType.HIGHLIGHT &&
|
|
1618
|
+
details.hasSelectedEditor === false) {
|
|
1619
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateUI).call(this, [
|
|
1620
|
+
[AnnotationEditorParamsType.HIGHLIGHT_FREE, true],
|
|
1621
|
+
]);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}, _AnnotationEditorUIManager_dispatchUpdateUI = function _AnnotationEditorUIManager_dispatchUpdateUI(details) {
|
|
1625
|
+
this._eventBus.dispatch("annotationeditorparamschanged", {
|
|
1626
|
+
source: this,
|
|
1627
|
+
details,
|
|
1628
|
+
});
|
|
1629
|
+
}, _AnnotationEditorUIManager_enableAll = function _AnnotationEditorUIManager_enableAll() {
|
|
1630
|
+
if (!__classPrivateFieldGet(this, _AnnotationEditorUIManager_isEnabled, "f")) {
|
|
1631
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_isEnabled, true, "f");
|
|
1632
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
1633
|
+
layer.enable();
|
|
1634
|
+
}
|
|
1635
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values()) {
|
|
1636
|
+
editor.enable();
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}, _AnnotationEditorUIManager_disableAll = function _AnnotationEditorUIManager_disableAll() {
|
|
1640
|
+
this.unselectAll();
|
|
1641
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_isEnabled, "f")) {
|
|
1642
|
+
__classPrivateFieldSet(this, _AnnotationEditorUIManager_isEnabled, false, "f");
|
|
1643
|
+
for (const layer of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").values()) {
|
|
1644
|
+
layer.disable();
|
|
1645
|
+
}
|
|
1646
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values()) {
|
|
1647
|
+
editor.disable();
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
}, _AnnotationEditorUIManager_addEditorToLayer = function _AnnotationEditorUIManager_addEditorToLayer(editor) {
|
|
1651
|
+
const layer = __classPrivateFieldGet(this, _AnnotationEditorUIManager_allLayers, "f").get(editor.pageIndex);
|
|
1652
|
+
if (layer) {
|
|
1653
|
+
layer.addOrRebuild(editor);
|
|
1654
|
+
}
|
|
1655
|
+
else {
|
|
1656
|
+
this.addEditor(editor);
|
|
1657
|
+
this.addToAnnotationStorage(editor);
|
|
1658
|
+
}
|
|
1659
|
+
}, _AnnotationEditorUIManager_lastSelectedEditor_get = function _AnnotationEditorUIManager_lastSelectedEditor_get() {
|
|
1660
|
+
let ed = null;
|
|
1661
|
+
for (ed of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
1662
|
+
// Iterate to get the last element.
|
|
1663
|
+
}
|
|
1664
|
+
return ed;
|
|
1665
|
+
}, _AnnotationEditorUIManager_isEmpty = function _AnnotationEditorUIManager_isEmpty() {
|
|
1666
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").size === 0) {
|
|
1667
|
+
return true;
|
|
1668
|
+
}
|
|
1669
|
+
if (__classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").size === 1) {
|
|
1670
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_allEditors, "f").values()) {
|
|
1671
|
+
return editor.isEmpty();
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return false;
|
|
1675
|
+
}, _AnnotationEditorUIManager_selectEditors = function _AnnotationEditorUIManager_selectEditors(editors) {
|
|
1676
|
+
for (const editor of __classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f")) {
|
|
1677
|
+
editor.unselect();
|
|
1678
|
+
}
|
|
1679
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").clear();
|
|
1680
|
+
for (const editor of editors) {
|
|
1681
|
+
if (editor.isEmpty()) {
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_selectedEditors, "f").add(editor);
|
|
1685
|
+
editor.select();
|
|
1686
|
+
}
|
|
1687
|
+
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_dispatchUpdateStates).call(this, { hasSelectedEditor: this.hasSelection });
|
|
1688
|
+
};
|
|
1689
|
+
AnnotationEditorUIManager.TRANSLATE_SMALL = 1; // page units.
|
|
1690
|
+
AnnotationEditorUIManager.TRANSLATE_BIG = 10; // page units.
|