@progress/kendo-pdfviewer-common 0.3.0-dev.202409251459 → 0.3.0-dev.202410100645

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/es/annotations/annotation-editor-layer-builder.js +139 -0
  2. package/dist/es/annotations/annotation-editor-layer.js +780 -0
  3. package/dist/es/annotations/annotation-editor-ui-manager.js +1690 -0
  4. package/dist/es/annotations/annotation-layer-builder.js +217 -0
  5. package/dist/es/annotations/annotation-layer.js +2793 -0
  6. package/dist/es/annotations/draw-layer-builder.js +65 -0
  7. package/dist/es/annotations/draw-layer.js +220 -0
  8. package/dist/es/annotations/editors/annotation-editor.js +1519 -0
  9. package/dist/es/annotations/editors/free-text-editor.js +783 -0
  10. package/dist/es/annotations/editors/highlight-editor.js +717 -0
  11. package/dist/es/annotations/editors/outliner.js +747 -0
  12. package/dist/es/annotations/helpers/annotation-storage.js +294 -0
  13. package/dist/es/annotations/helpers/color-manager.js +72 -0
  14. package/dist/es/annotations/helpers/command-manager.js +133 -0
  15. package/dist/es/annotations/helpers/id-manager.js +34 -0
  16. package/dist/es/annotations/helpers/image-manager.js +176 -0
  17. package/dist/es/annotations/helpers/text-accessibility-manager.js +212 -0
  18. package/dist/es/annotations/helpers/tools.js +19 -0
  19. package/dist/es/annotations/shared/display_utils.js +1024 -0
  20. package/dist/es/annotations/shared/event_utils.js +213 -0
  21. package/dist/es/annotations/shared/murmurhash3.js +126 -0
  22. package/dist/es/annotations/shared/scripting_utils.js +90 -0
  23. package/dist/es/annotations/shared/ui_utils.js +823 -0
  24. package/dist/es/annotations/shared/utils.js +909 -0
  25. package/dist/es/common/component.js +33 -0
  26. package/dist/es/common/core.js +91 -0
  27. package/dist/es/common/dom.js +11 -0
  28. package/dist/es/common/main.js +4 -0
  29. package/dist/es/common/math.js +1 -0
  30. package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
  31. package/dist/es/links/link-service.js +505 -0
  32. package/dist/es/main.js +2 -0
  33. package/dist/es/scroller.js +29 -30
  34. package/dist/es/text/text-layer-builder.js +288 -0
  35. package/dist/es/utils.js +5 -5
  36. package/dist/es/widget/page.js +762 -0
  37. package/dist/es/widget/pdfviewer.js +1659 -0
  38. package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
  39. package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
  40. package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
  41. package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
  42. package/dist/es2015/annotations/annotation-layer.js +2793 -0
  43. package/dist/es2015/annotations/draw-layer-builder.js +65 -0
  44. package/dist/es2015/annotations/draw-layer.js +220 -0
  45. package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
  46. package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
  47. package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
  48. package/dist/es2015/annotations/editors/outliner.js +747 -0
  49. package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
  50. package/dist/es2015/annotations/helpers/color-manager.js +72 -0
  51. package/dist/es2015/annotations/helpers/command-manager.js +133 -0
  52. package/dist/es2015/annotations/helpers/id-manager.js +34 -0
  53. package/dist/es2015/annotations/helpers/image-manager.js +176 -0
  54. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
  55. package/dist/es2015/annotations/helpers/tools.js +19 -0
  56. package/dist/es2015/annotations/shared/display_utils.js +1024 -0
  57. package/dist/es2015/annotations/shared/event_utils.js +213 -0
  58. package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
  59. package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
  60. package/dist/es2015/annotations/shared/ui_utils.js +823 -0
  61. package/dist/es2015/annotations/shared/utils.js +909 -0
  62. package/dist/es2015/common/component.js +33 -0
  63. package/dist/es2015/common/core.js +91 -0
  64. package/dist/es2015/common/dom.js +11 -0
  65. package/dist/es2015/common/main.js +4 -0
  66. package/dist/es2015/common/math.js +1 -0
  67. package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
  68. package/dist/es2015/links/link-service.js +505 -0
  69. package/dist/es2015/main.js +2 -0
  70. package/dist/es2015/scroller.js +29 -30
  71. package/dist/es2015/text/text-layer-builder.js +288 -0
  72. package/dist/es2015/utils.js +5 -5
  73. package/dist/es2015/widget/page.js +762 -0
  74. package/dist/es2015/widget/pdfviewer.js +1659 -0
  75. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
  76. package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
  77. package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
  78. package/dist/npm/annotations/annotation-editor-layer.js +783 -0
  79. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
  80. package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
  81. package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
  82. package/dist/npm/annotations/annotation-layer-builder.js +220 -0
  83. package/dist/npm/annotations/annotation-layer.d.ts +134 -0
  84. package/dist/npm/annotations/annotation-layer.js +2794 -0
  85. package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
  86. package/dist/npm/annotations/draw-layer-builder.js +68 -0
  87. package/dist/npm/annotations/draw-layer.d.ts +33 -0
  88. package/dist/npm/annotations/draw-layer.js +223 -0
  89. package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
  90. package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
  91. package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
  92. package/dist/npm/annotations/editors/free-text-editor.js +786 -0
  93. package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
  94. package/dist/npm/annotations/editors/highlight-editor.js +717 -0
  95. package/dist/npm/annotations/editors/outliner.d.ts +51 -0
  96. package/dist/npm/annotations/editors/outliner.js +750 -0
  97. package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
  98. package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
  99. package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
  100. package/dist/npm/annotations/helpers/color-manager.js +76 -0
  101. package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
  102. package/dist/npm/annotations/helpers/command-manager.js +137 -0
  103. package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
  104. package/dist/npm/annotations/helpers/id-manager.js +38 -0
  105. package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
  106. package/dist/npm/annotations/helpers/image-manager.js +180 -0
  107. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
  108. package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
  109. package/dist/npm/annotations/helpers/tools.d.ts +1 -0
  110. package/dist/npm/annotations/helpers/tools.js +23 -0
  111. package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
  112. package/dist/npm/annotations/shared/display_utils.js +1030 -0
  113. package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
  114. package/dist/npm/annotations/shared/event_utils.js +165 -0
  115. package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
  116. package/dist/npm/annotations/shared/murmurhash3.js +129 -0
  117. package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
  118. package/dist/npm/annotations/shared/scripting_utils.js +93 -0
  119. package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
  120. package/dist/npm/annotations/shared/ui_utils.js +250 -0
  121. package/dist/npm/annotations/shared/utils.d.ts +148 -0
  122. package/dist/npm/annotations/shared/utils.js +872 -0
  123. package/dist/npm/common/component.d.ts +9 -0
  124. package/dist/npm/common/component.js +37 -0
  125. package/dist/npm/common/core.d.ts +18 -0
  126. package/dist/npm/common/core.js +112 -0
  127. package/dist/npm/common/dom.d.ts +3 -0
  128. package/dist/npm/common/dom.js +17 -0
  129. package/dist/npm/common/main.d.ts +4 -0
  130. package/dist/npm/common/main.js +7 -0
  131. package/dist/npm/common/math.d.ts +1 -0
  132. package/dist/npm/common/math.js +5 -0
  133. package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
  134. package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
  135. package/dist/npm/links/link-service.d.ts +116 -0
  136. package/dist/npm/links/link-service.js +501 -0
  137. package/dist/npm/main.d.ts +2 -0
  138. package/dist/npm/main.js +2 -0
  139. package/dist/npm/scroller.d.ts +7 -3
  140. package/dist/npm/scroller.js +32 -32
  141. package/dist/npm/text/text-layer-builder.d.ts +30 -0
  142. package/dist/npm/text/text-layer-builder.js +291 -0
  143. package/dist/npm/utils.d.ts +20 -2
  144. package/dist/npm/utils.js +11 -8
  145. package/dist/npm/widget/page.d.ts +75 -0
  146. package/dist/npm/widget/page.js +763 -0
  147. package/dist/npm/widget/pdfviewer.d.ts +222 -0
  148. package/dist/npm/widget/pdfviewer.js +1663 -0
  149. package/package.json +13 -9
@@ -1,6 +1,7 @@
1
1
  import Draggable from '@progress/kendo-draggable';
2
- import { renderPage, currentPage } from './utils';
3
- const throttle = function (func, wait, options = {}) {
2
+ import { Component } from './common/component';
3
+ import { noop } from './common/core';
4
+ export const throttle = function (func, wait, options = {}) {
4
5
  let timeout, context, args, result;
5
6
  let previous = 0;
6
7
  const later = function () {
@@ -52,15 +53,16 @@ const matchesElementSelector = (element, selector) => {
52
53
  return element.closest(selector);
53
54
  };
54
55
  const FRAMES_PER_SECOND = 1000 / 60;
55
- const SCROLL = 'scroll';
56
+ const SCROLL = "scroll";
56
57
  /**
57
58
  * @hidden
58
59
  */
59
- export class Scroller {
60
+ export class Scroller extends Component {
60
61
  constructor(element, options) {
62
+ super(element, options);
61
63
  this.options = {
62
64
  events: {
63
- [SCROLL]: () => undefined
65
+ [SCROLL]: noop,
64
66
  },
65
67
  filter: '',
66
68
  // throttle the scroll events to get a more similar experience
@@ -70,10 +72,13 @@ export class Scroller {
70
72
  // the drag directions are actually reversed, e.g.
71
73
  // dragging to the right actually moves the document to the left
72
74
  scrollDirectionModifier: -1,
73
- scrollThrottleDelay: FRAMES_PER_SECOND
75
+ scrollThrottleDelay: FRAMES_PER_SECOND,
74
76
  };
75
- this.onElementScroll = () => {
77
+ this.onElementScroll = (e) => {
76
78
  const element = this.element;
79
+ if (!this.shouldTrackScrollEvents()) {
80
+ return;
81
+ }
77
82
  if (this.state.trackNextElementScroll) {
78
83
  this.scrollTo(element.scrollLeft, element.scrollTop);
79
84
  }
@@ -81,21 +86,9 @@ export class Scroller {
81
86
  // reset the state, so that consecutive scroll events can be handled
82
87
  this.state.trackNextElementScroll = true;
83
88
  }
84
- };
85
- this.onDemandScroll = () => {
86
- const pages = this.options.pages, currentPageIndex = currentPage(this.element.parentElement), page = pages[currentPageIndex], nextPage = pages[currentPageIndex + 1], previousPage = pages[currentPageIndex - 1], pageInfo = page === null || page === void 0 ? void 0 : page._pageInfo, nextPageInfo = nextPage === null || nextPage === void 0 ? void 0 : nextPage._pageInfo, previousPageInfo = previousPage === null || previousPage === void 0 ? void 0 : previousPage._pageInfo, error = (e) => {
87
- throw new Error(e);
88
- };
89
- // Render the current and surrounding pages if they have not been rendered already.
90
- if (page && !pageInfo.rendered && !pageInfo.renderInProgress) {
91
- renderPage(page, pageInfo.emptyPage, error);
92
- }
93
- if (nextPage && !nextPageInfo.rendered && !nextPageInfo.renderInProgress) {
94
- renderPage(nextPage, nextPageInfo.emptyPage, error);
95
- }
96
- if (previousPage && !previousPageInfo.rendered && !previousPageInfo.renderInProgress) {
97
- renderPage(previousPage, previousPageInfo.emptyPage, error);
98
- }
89
+ this.trigger(SCROLL, {
90
+ originalEvent: e
91
+ });
99
92
  };
100
93
  this.onDragStart = (e) => {
101
94
  this.state.dragStarted = false;
@@ -143,8 +136,7 @@ export class Scroller {
143
136
  return;
144
137
  }
145
138
  };
146
- this.element = element;
147
- this.options = Object.assign({}, this.options, options);
139
+ this.extendOptions(options);
148
140
  this.resetState();
149
141
  this.bindEvents();
150
142
  }
@@ -191,9 +183,6 @@ export class Scroller {
191
183
  this.throttledOnElementScroll = this.onElementScroll;
192
184
  }
193
185
  this.element.addEventListener(SCROLL, this.throttledOnElementScroll);
194
- if (this.options.loadOnDemand) {
195
- this.element.addEventListener(SCROLL, this.onDemandScroll);
196
- }
197
186
  }
198
187
  unbindEvents() {
199
188
  this.unbindElementScroll();
@@ -208,9 +197,6 @@ export class Scroller {
208
197
  this.throttledOnElementScroll.cancel();
209
198
  this.throttledOnElementScroll = null;
210
199
  }
211
- if (this.options.loadOnDemand) {
212
- this.element.removeEventListener(SCROLL, this.onDemandScroll);
213
- }
214
200
  this.element.removeEventListener(SCROLL, this.throttledOnElementScroll);
215
201
  }
216
202
  setState(newState) {
@@ -219,6 +205,7 @@ export class Scroller {
219
205
  resetState() {
220
206
  this.setState({
221
207
  trackPanEvents: false,
208
+ trackScrollEvents: false,
222
209
  trackNextElementScroll: false,
223
210
  location: { pageX: 0, pageY: 0 },
224
211
  locationDelta: { x: 0, y: 0 }
@@ -235,6 +222,18 @@ export class Scroller {
235
222
  shouldTrackPanEvents() {
236
223
  return this.state.trackPanEvents;
237
224
  }
225
+ enableScrollEventsTracking() {
226
+ this.state.trackScrollEvents = true;
227
+ this.unbindElementScroll();
228
+ this.bindElementScroll();
229
+ }
230
+ disableScrollEventsTracking() {
231
+ this.unbindElementScroll();
232
+ this.state.trackScrollEvents = false;
233
+ }
234
+ shouldTrackScrollEvents() {
235
+ return this.state.trackScrollEvents;
236
+ }
238
237
  calculateEventLocationDelta(e) {
239
238
  this.state.locationDelta = {
240
239
  x: e.pageX - this.state.location.pageX,
@@ -0,0 +1,288 @@
1
+ /* Copyright 2012 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 _TextLayerBuilder_instances, _a, _TextLayerBuilder_onAppend, _TextLayerBuilder_textLayer, _TextLayerBuilder_textLayers, _TextLayerBuilder_selectionChangeAbortController, _TextLayerBuilder_bindMouse, _TextLayerBuilder_removeGlobalSelectionListener, _TextLayerBuilder_enableGlobalSelectionListener;
16
+ import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
17
+ import { TextLayer } from "pdfjs-dist/legacy/build/pdf.mjs";
18
+ import { addClass } from "../common/dom";
19
+ /**
20
+ * The text layer builder provides text selection functionality for the PDF.
21
+ * It does this by creating overlay divs over the PDF's text. These divs
22
+ * contain text that matches the PDF text they are overlaying.
23
+ */
24
+ class TextLayerBuilder {
25
+ constructor({ pdfPage,
26
+ // highlighter = null,
27
+ accessibilityManager,
28
+ // enablePermissions = false,
29
+ // todo: fix styles
30
+ styles, onAppend = null, }) {
31
+ _TextLayerBuilder_instances.add(this);
32
+ // todo: props
33
+ this.pdfPage = null;
34
+ // highlighter = null;
35
+ this.div = null;
36
+ this.accessibilityManager = null;
37
+ // todo: props
38
+ // #enablePermissions = false;
39
+ _TextLayerBuilder_onAppend.set(this, null);
40
+ // #renderingDone = false;
41
+ _TextLayerBuilder_textLayer.set(this, null);
42
+ this.pdfPage = pdfPage;
43
+ // this.highlighter = highlighter;
44
+ this.accessibilityManager = accessibilityManager;
45
+ // this.#enablePermissions = enablePermissions === true;
46
+ __classPrivateFieldSet(this, _TextLayerBuilder_onAppend, onAppend, "f");
47
+ this.div = document.createElement("div");
48
+ this.div.tabIndex = 0;
49
+ // this.div.className = "textLayer";
50
+ // todo: fix classes
51
+ this.div.classList.add("k-text-layer");
52
+ // todo: fix styles
53
+ Object.keys(styles).forEach((key) => (this.div.style[key] = styles[key]));
54
+ }
55
+ /**
56
+ * Renders the text layer.
57
+ * @param {PageViewport} viewport
58
+ * @param {Object} [textContentParams]
59
+ */
60
+ render(viewport_1) {
61
+ return __awaiter(this, arguments, void 0, function* (viewport, textContentParams = null) {
62
+ var _a, _b, _c;
63
+ // if (this.#renderingDone && this.#textLayer) {
64
+ if (__classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f")) {
65
+ __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f").update({
66
+ viewport,
67
+ onBefore: this.hide.bind(this),
68
+ });
69
+ this.show();
70
+ return;
71
+ }
72
+ this.cancel();
73
+ __classPrivateFieldSet(this, _TextLayerBuilder_textLayer, new TextLayer({
74
+ textContentSource: this.pdfPage.streamTextContent(textContentParams || {
75
+ // includeMarkedContent: true,
76
+ // setting this to false requires removing "await"
77
+ // in page.ts when calling this.#renderTextLayer()
78
+ includeMarkedContent: false,
79
+ disableNormalization: true,
80
+ }),
81
+ container: this.div,
82
+ viewport,
83
+ }), "f");
84
+ // const { textDivs, textContentItemsStr } = this.#textLayer;
85
+ const { textDivs } = __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f");
86
+ // this.highlighter?.setTextMapping(textDivs, textContentItemsStr);
87
+ (_a = this.accessibilityManager) === null || _a === void 0 ? void 0 : _a.setTextMapping(textDivs);
88
+ yield __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f").render();
89
+ // this.#renderingDone = true;
90
+ // todo: manually add "k-marked-content" class
91
+ // as pdf.js text layer cannot render it
92
+ const markedContentElements = Array.from(this.div.querySelectorAll(".markedContent") || []) || [];
93
+ markedContentElements.forEach(x => addClass("k-marked-content", x));
94
+ if (markedContentElements && markedContentElements.length > 0) {
95
+ const endOfContent = document.createElement("div");
96
+ endOfContent.className = "endOfContent";
97
+ this.div.append(endOfContent);
98
+ __classPrivateFieldGet(this, _TextLayerBuilder_instances, "m", _TextLayerBuilder_bindMouse).call(this, endOfContent);
99
+ }
100
+ // Ensure that the textLayer is appended to the DOM *before* handling
101
+ // e.g. a pending search operation.
102
+ (_b = __classPrivateFieldGet(this, _TextLayerBuilder_onAppend, "f")) === null || _b === void 0 ? void 0 : _b.call(this, this.div);
103
+ // this.highlighter?.enable();
104
+ (_c = this.accessibilityManager) === null || _c === void 0 ? void 0 : _c.enable();
105
+ });
106
+ }
107
+ hide() {
108
+ // if (!this.div.hidden && this.#renderingDone) {
109
+ if (!this.div.hidden) {
110
+ // We turn off the highlighter in order to avoid to scroll into view an
111
+ // element of the text layer which could be hidden.
112
+ // this.highlighter?.disable();
113
+ this.div.hidden = true;
114
+ }
115
+ }
116
+ show() {
117
+ // if (this.div.hidden && this.#renderingDone) {
118
+ if (this.div.hidden) {
119
+ this.div.hidden = false;
120
+ // this.highlighter?.enable();
121
+ }
122
+ }
123
+ /**
124
+ * Cancel rendering of the text layer.
125
+ */
126
+ cancel() {
127
+ var _b, _c;
128
+ (_b = __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f")) === null || _b === void 0 ? void 0 : _b.cancel();
129
+ __classPrivateFieldSet(this, _TextLayerBuilder_textLayer, null, "f");
130
+ // this.highlighter?.disable();
131
+ (_c = this.accessibilityManager) === null || _c === void 0 ? void 0 : _c.disable();
132
+ __classPrivateFieldGet(_a, _a, "m", _TextLayerBuilder_removeGlobalSelectionListener).call(_a, this.div);
133
+ }
134
+ }
135
+ _a = TextLayerBuilder, _TextLayerBuilder_onAppend = new WeakMap(), _TextLayerBuilder_textLayer = new WeakMap(), _TextLayerBuilder_instances = new WeakSet(), _TextLayerBuilder_bindMouse = function _TextLayerBuilder_bindMouse(end) {
136
+ const { div } = this;
137
+ // div.addEventListener("mousedown", () => {
138
+ // div.classList.add("selecting");
139
+ // });
140
+ // div.addEventListener("copy", event => {
141
+ // if (!this.#enablePermissions) {
142
+ // const selection = document.getSelection();
143
+ // event.clipboardData.setData(
144
+ // "text/plain",
145
+ // removeNullCharacters(normalizeUnicode(selection.toString()))
146
+ // );
147
+ // }
148
+ // event.preventDefault();
149
+ // event.stopPropagation();
150
+ // });
151
+ __classPrivateFieldGet(_a, _a, "f", _TextLayerBuilder_textLayers).set(div, end);
152
+ __classPrivateFieldGet(_a, _a, "m", _TextLayerBuilder_enableGlobalSelectionListener).call(_a);
153
+ }, _TextLayerBuilder_removeGlobalSelectionListener = function _TextLayerBuilder_removeGlobalSelectionListener(textLayerDiv) {
154
+ var _b;
155
+ __classPrivateFieldGet(this, _a, "f", _TextLayerBuilder_textLayers).delete(textLayerDiv);
156
+ if (__classPrivateFieldGet(this, _a, "f", _TextLayerBuilder_textLayers).size === 0) {
157
+ (_b = __classPrivateFieldGet(this, _a, "f", _TextLayerBuilder_selectionChangeAbortController)) === null || _b === void 0 ? void 0 : _b.abort();
158
+ __classPrivateFieldSet(this, _a, null, "f", _TextLayerBuilder_selectionChangeAbortController);
159
+ }
160
+ }, _TextLayerBuilder_enableGlobalSelectionListener = function _TextLayerBuilder_enableGlobalSelectionListener() {
161
+ // if (this.#selectionChangeAbortController) {
162
+ // // document-level event listeners already installed
163
+ // return;
164
+ // }
165
+ // this.#selectionChangeAbortController = new AbortController();
166
+ // const { signal } = this.#selectionChangeAbortController;
167
+ // const reset = (end, textLayer) => {
168
+ // if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
169
+ // textLayer.append(end);
170
+ // end.style.width = "";
171
+ // end.style.height = "";
172
+ // }
173
+ // textLayer.classList.remove("selecting");
174
+ // };
175
+ // let isPointerDown = false;
176
+ // document.addEventListener(
177
+ // "pointerdown",
178
+ // () => {
179
+ // isPointerDown = true;
180
+ // },
181
+ // { signal }
182
+ // );
183
+ // document.addEventListener(
184
+ // "pointerup",
185
+ // () => {
186
+ // isPointerDown = false;
187
+ // this.#textLayers.forEach(reset);
188
+ // },
189
+ // { signal }
190
+ // );
191
+ // window.addEventListener(
192
+ // "blur",
193
+ // () => {
194
+ // isPointerDown = false;
195
+ // this.#textLayers.forEach(reset);
196
+ // },
197
+ // { signal }
198
+ // );
199
+ // document.addEventListener(
200
+ // "keyup",
201
+ // () => {
202
+ // if (!isPointerDown) {
203
+ // this.#textLayers.forEach(reset);
204
+ // }
205
+ // },
206
+ // { signal }
207
+ // );
208
+ // if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
209
+ // // eslint-disable-next-line no-var
210
+ // var isFirefox, prevRange;
211
+ // }
212
+ // document.addEventListener(
213
+ // "selectionchange",
214
+ // () => {
215
+ // const selection = document.getSelection();
216
+ // if (selection.rangeCount === 0) {
217
+ // this.#textLayers.forEach(reset);
218
+ // return;
219
+ // }
220
+ // // Even though the spec says that .rangeCount should be 0 or 1, Firefox
221
+ // // creates multiple ranges when selecting across multiple pages.
222
+ // // Make sure to collect all the .textLayer elements where the selection
223
+ // // is happening.
224
+ // const activeTextLayers = new Set();
225
+ // for (let i = 0; i < selection.rangeCount; i++) {
226
+ // const range = selection.getRangeAt(i);
227
+ // for (const textLayerDiv of this.#textLayers.keys()) {
228
+ // if (
229
+ // !activeTextLayers.has(textLayerDiv) &&
230
+ // range.intersectsNode(textLayerDiv)
231
+ // ) {
232
+ // activeTextLayers.add(textLayerDiv);
233
+ // }
234
+ // }
235
+ // }
236
+ // for (const [textLayerDiv, endDiv] of this.#textLayers) {
237
+ // if (activeTextLayers.has(textLayerDiv)) {
238
+ // textLayerDiv.classList.add("selecting");
239
+ // } else {
240
+ // reset(endDiv, textLayerDiv);
241
+ // }
242
+ // }
243
+ // if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
244
+ // return;
245
+ // }
246
+ // if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
247
+ // isFirefox ??=
248
+ // getComputedStyle(
249
+ // this.#textLayers.values().next().value
250
+ // ).getPropertyValue("-moz-user-select") === "none";
251
+ // if (isFirefox) {
252
+ // return;
253
+ // }
254
+ // }
255
+ // // In non-Firefox browsers, when hovering over an empty space (thus,
256
+ // // on .endOfContent), the selection will expand to cover all the
257
+ // // text between the current selection and .endOfContent. By moving
258
+ // // .endOfContent to right after (or before, depending on which side
259
+ // // of the selection the user is moving), we limit the selection jump
260
+ // // to at most cover the enteirety of the <span> where the selection
261
+ // // is being modified.
262
+ // const range = selection.getRangeAt(0);
263
+ // const modifyStart =
264
+ // prevRange &&
265
+ // (range.compareBoundaryPoints(Range.END_TO_END, prevRange) === 0 ||
266
+ // range.compareBoundaryPoints(Range.START_TO_END, prevRange) === 0);
267
+ // let anchor = modifyStart ? range.startContainer : range.endContainer;
268
+ // if (anchor.nodeType === Node.TEXT_NODE) {
269
+ // anchor = anchor.parentNode;
270
+ // }
271
+ // const parentTextLayer = anchor.parentElement.closest(".textLayer");
272
+ // const endDiv = this.#textLayers.get(parentTextLayer);
273
+ // if (endDiv) {
274
+ // endDiv.style.width = parentTextLayer.style.width;
275
+ // endDiv.style.height = parentTextLayer.style.height;
276
+ // anchor.parentElement.insertBefore(
277
+ // endDiv,
278
+ // modifyStart ? anchor : anchor.nextSibling
279
+ // );
280
+ // }
281
+ // prevRange = range.cloneRange();
282
+ // },
283
+ // { signal }
284
+ // );
285
+ };
286
+ _TextLayerBuilder_textLayers = { value: new Map() };
287
+ _TextLayerBuilder_selectionChangeAbortController = { value: null };
288
+ export { TextLayerBuilder };
@@ -1,6 +1,6 @@
1
1
  import { saveAs } from '@progress/kendo-file-saver';
2
2
  import { detectDesktopBrowser, detectMobileOS } from '@progress/kendo-common';
3
- import { getDocument, TextLayer } from 'pdfjs-dist/legacy/build/pdf.mjs';
3
+ import { getDocument, TextLayer } from "pdfjs-dist/legacy/build/pdf.mjs";
4
4
  import { LinkAnnotation } from './annotations';
5
5
  const MAX_CANVAS_WIDTH_HEIGHT_CHROME = 65535;
6
6
  const MAX_CANVAS_AREA_CHROME_SAFARI = 268435456;
@@ -24,8 +24,8 @@ const isFirefox = (userAgent) => {
24
24
  * @hidden
25
25
  */
26
26
  export const DEFAULT_ZOOM_LEVEL = 1.25;
27
- const scale = () => (isIOS() ? devicePixelRatio : devicePixelRatio * 3);
28
- const parsePdfFromBase64String = (base64String) => {
27
+ export const scale = () => (isIOS() ? devicePixelRatio : devicePixelRatio * 3);
28
+ export const parsePdfFromBase64String = (base64String) => {
29
29
  return atob(base64String.replace(/^(data:application\/pdf;base64,)/gi, ''));
30
30
  };
31
31
  const getDocumentParameters = (options) => {
@@ -248,7 +248,7 @@ export const createElement = function (name, className, styles) {
248
248
  Object.keys(styles).forEach((key) => (element.style[key] = styles[key]));
249
249
  return element;
250
250
  };
251
- const transforms = {
251
+ export const transforms = {
252
252
  '0': '',
253
253
  '90': 'rotate(90deg) translateY(-100%)',
254
254
  '180': 'rotate(180deg) translate(-100%, -100%)',
@@ -417,7 +417,7 @@ export const currentPage = (rootElement) => {
417
417
  * if initial size after scaling is greater than browser limits,
418
418
  * we are limiting it to the limits, then halving it for performance.
419
419
  */
420
- const adjustCanvasSize = (targetWidth, targetHeight) => {
420
+ export const adjustCanvasSize = (targetWidth, targetHeight) => {
421
421
  const { maxWidth, maxHeight, maxArea } = isFirefox(navigator.userAgent) ?
422
422
  { maxWidth: MAX_CANVAS_WIDTH_HEIGHT_FIREFOX, maxHeight: MAX_CANVAS_WIDTH_HEIGHT_FIREFOX, maxArea: MAX_CANVAS_AREA_FIREFOX } :
423
423
  isSafari(navigator.userAgent) ?