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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/es/annotations/annotation-editor-layer-builder.js +139 -0
  2. package/dist/es/annotations/annotation-editor-layer.js +780 -0
  3. package/dist/es/annotations/annotation-editor-ui-manager.js +1690 -0
  4. package/dist/es/annotations/annotation-layer-builder.js +217 -0
  5. package/dist/es/annotations/annotation-layer.js +2793 -0
  6. package/dist/es/annotations/draw-layer-builder.js +65 -0
  7. package/dist/es/annotations/draw-layer.js +220 -0
  8. package/dist/es/annotations/editors/annotation-editor.js +1519 -0
  9. package/dist/es/annotations/editors/free-text-editor.js +783 -0
  10. package/dist/es/annotations/editors/highlight-editor.js +717 -0
  11. package/dist/es/annotations/editors/outliner.js +747 -0
  12. package/dist/es/annotations/helpers/annotation-storage.js +294 -0
  13. package/dist/es/annotations/helpers/color-manager.js +72 -0
  14. package/dist/es/annotations/helpers/command-manager.js +133 -0
  15. package/dist/es/annotations/helpers/id-manager.js +34 -0
  16. package/dist/es/annotations/helpers/image-manager.js +176 -0
  17. package/dist/es/annotations/helpers/text-accessibility-manager.js +212 -0
  18. package/dist/es/annotations/helpers/tools.js +19 -0
  19. package/dist/es/annotations/shared/display_utils.js +1024 -0
  20. package/dist/es/annotations/shared/event_utils.js +213 -0
  21. package/dist/es/annotations/shared/murmurhash3.js +126 -0
  22. package/dist/es/annotations/shared/scripting_utils.js +90 -0
  23. package/dist/es/annotations/shared/ui_utils.js +823 -0
  24. package/dist/es/annotations/shared/utils.js +909 -0
  25. package/dist/es/common/component.js +33 -0
  26. package/dist/es/common/core.js +91 -0
  27. package/dist/es/common/dom.js +11 -0
  28. package/dist/es/common/main.js +4 -0
  29. package/dist/es/common/math.js +1 -0
  30. package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
  31. package/dist/es/links/link-service.js +505 -0
  32. package/dist/es/main.js +2 -0
  33. package/dist/es/scroller.js +29 -30
  34. package/dist/es/text/text-layer-builder.js +288 -0
  35. package/dist/es/utils.js +5 -5
  36. package/dist/es/widget/page.js +762 -0
  37. package/dist/es/widget/pdfviewer.js +1659 -0
  38. package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
  39. package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
  40. package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
  41. package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
  42. package/dist/es2015/annotations/annotation-layer.js +2793 -0
  43. package/dist/es2015/annotations/draw-layer-builder.js +65 -0
  44. package/dist/es2015/annotations/draw-layer.js +220 -0
  45. package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
  46. package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
  47. package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
  48. package/dist/es2015/annotations/editors/outliner.js +747 -0
  49. package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
  50. package/dist/es2015/annotations/helpers/color-manager.js +72 -0
  51. package/dist/es2015/annotations/helpers/command-manager.js +133 -0
  52. package/dist/es2015/annotations/helpers/id-manager.js +34 -0
  53. package/dist/es2015/annotations/helpers/image-manager.js +176 -0
  54. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
  55. package/dist/es2015/annotations/helpers/tools.js +19 -0
  56. package/dist/es2015/annotations/shared/display_utils.js +1024 -0
  57. package/dist/es2015/annotations/shared/event_utils.js +213 -0
  58. package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
  59. package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
  60. package/dist/es2015/annotations/shared/ui_utils.js +823 -0
  61. package/dist/es2015/annotations/shared/utils.js +909 -0
  62. package/dist/es2015/common/component.js +33 -0
  63. package/dist/es2015/common/core.js +91 -0
  64. package/dist/es2015/common/dom.js +11 -0
  65. package/dist/es2015/common/main.js +4 -0
  66. package/dist/es2015/common/math.js +1 -0
  67. package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
  68. package/dist/es2015/links/link-service.js +505 -0
  69. package/dist/es2015/main.js +2 -0
  70. package/dist/es2015/scroller.js +29 -30
  71. package/dist/es2015/text/text-layer-builder.js +288 -0
  72. package/dist/es2015/utils.js +5 -5
  73. package/dist/es2015/widget/page.js +762 -0
  74. package/dist/es2015/widget/pdfviewer.js +1659 -0
  75. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
  76. package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
  77. package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
  78. package/dist/npm/annotations/annotation-editor-layer.js +783 -0
  79. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
  80. package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
  81. package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
  82. package/dist/npm/annotations/annotation-layer-builder.js +220 -0
  83. package/dist/npm/annotations/annotation-layer.d.ts +134 -0
  84. package/dist/npm/annotations/annotation-layer.js +2794 -0
  85. package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
  86. package/dist/npm/annotations/draw-layer-builder.js +68 -0
  87. package/dist/npm/annotations/draw-layer.d.ts +33 -0
  88. package/dist/npm/annotations/draw-layer.js +223 -0
  89. package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
  90. package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
  91. package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
  92. package/dist/npm/annotations/editors/free-text-editor.js +786 -0
  93. package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
  94. package/dist/npm/annotations/editors/highlight-editor.js +717 -0
  95. package/dist/npm/annotations/editors/outliner.d.ts +51 -0
  96. package/dist/npm/annotations/editors/outliner.js +750 -0
  97. package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
  98. package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
  99. package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
  100. package/dist/npm/annotations/helpers/color-manager.js +76 -0
  101. package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
  102. package/dist/npm/annotations/helpers/command-manager.js +137 -0
  103. package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
  104. package/dist/npm/annotations/helpers/id-manager.js +38 -0
  105. package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
  106. package/dist/npm/annotations/helpers/image-manager.js +180 -0
  107. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
  108. package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
  109. package/dist/npm/annotations/helpers/tools.d.ts +1 -0
  110. package/dist/npm/annotations/helpers/tools.js +23 -0
  111. package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
  112. package/dist/npm/annotations/shared/display_utils.js +1030 -0
  113. package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
  114. package/dist/npm/annotations/shared/event_utils.js +165 -0
  115. package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
  116. package/dist/npm/annotations/shared/murmurhash3.js +129 -0
  117. package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
  118. package/dist/npm/annotations/shared/scripting_utils.js +93 -0
  119. package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
  120. package/dist/npm/annotations/shared/ui_utils.js +250 -0
  121. package/dist/npm/annotations/shared/utils.d.ts +148 -0
  122. package/dist/npm/annotations/shared/utils.js +872 -0
  123. package/dist/npm/common/component.d.ts +9 -0
  124. package/dist/npm/common/component.js +37 -0
  125. package/dist/npm/common/core.d.ts +18 -0
  126. package/dist/npm/common/core.js +112 -0
  127. package/dist/npm/common/dom.d.ts +3 -0
  128. package/dist/npm/common/dom.js +17 -0
  129. package/dist/npm/common/main.d.ts +4 -0
  130. package/dist/npm/common/main.js +7 -0
  131. package/dist/npm/common/math.d.ts +1 -0
  132. package/dist/npm/common/math.js +5 -0
  133. package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
  134. package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
  135. package/dist/npm/links/link-service.d.ts +116 -0
  136. package/dist/npm/links/link-service.js +501 -0
  137. package/dist/npm/main.d.ts +2 -0
  138. package/dist/npm/main.js +2 -0
  139. package/dist/npm/scroller.d.ts +7 -3
  140. package/dist/npm/scroller.js +32 -32
  141. package/dist/npm/text/text-layer-builder.d.ts +30 -0
  142. package/dist/npm/text/text-layer-builder.js +291 -0
  143. package/dist/npm/utils.d.ts +20 -2
  144. package/dist/npm/utils.js +11 -8
  145. package/dist/npm/widget/page.d.ts +75 -0
  146. package/dist/npm/widget/page.js +763 -0
  147. package/dist/npm/widget/pdfviewer.d.ts +222 -0
  148. package/dist/npm/widget/pdfviewer.js +1663 -0
  149. package/package.json +13 -9
@@ -0,0 +1,217 @@
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 _AnnotationLayerBuilder_instances, _AnnotationLayerBuilder_onAppend, _AnnotationLayerBuilder_eventAbortController, _AnnotationLayerBuilder_updatePresentationModeState;
16
+ import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
17
+ /** @typedef {import("../src/display/api").PDFPageProxy} PDFPageProxy */
18
+ // eslint-disable-next-line max-len
19
+ /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */
20
+ // eslint-disable-next-line max-len
21
+ /** @typedef {import("../src/display/annotation_storage").AnnotationStorage} AnnotationStorage */
22
+ /** @typedef {import("./interfaces").IDownloadManager} IDownloadManager */
23
+ /** @typedef {import("./interfaces").IPDFLinkService} IPDFLinkService */
24
+ // eslint-disable-next-line max-len
25
+ /** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */
26
+ // eslint-disable-next-line max-len
27
+ /** @typedef {import("../src/display/editor/tools.js").AnnotationEditorUIManager} AnnotationEditorUIManager */
28
+ import { convertToHtml } from "../common/core";
29
+ import { AnnotationLayer } from "./annotation-layer";
30
+ import { PresentationModeState } from "./shared/ui_utils";
31
+ // import { PresentationModeState } from "./shared/ui_utils";
32
+ /**
33
+ * @typedef {Object} AnnotationLayerBuilderOptions
34
+ * @property {PDFPageProxy} pdfPage
35
+ * @property {AnnotationStorage} [annotationStorage]
36
+ * @property {string} [imageResourcesPath] - Path for image resources, mainly
37
+ * for annotation icons. Include trailing slash.
38
+ * @property {boolean} renderForms
39
+ * @property {IPDFLinkService} linkService
40
+ * @property {IDownloadManager} [downloadManager]
41
+ * @property {boolean} [enableScripting]
42
+ * @property {Promise<boolean>} [hasJSActionsPromise]
43
+ * @property {Promise<Object<string, Array<Object>> | null>}
44
+ * [fieldObjectsPromise]
45
+ * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
46
+ * @property {TextAccessibilityManager} [accessibilityManager]
47
+ * @property {AnnotationEditorUIManager} [annotationEditorUIManager]
48
+ * @property {function} [onAppend]
49
+ */
50
+ class AnnotationLayerBuilder {
51
+ /**
52
+ * @param {AnnotationLayerBuilderOptions} options
53
+ */
54
+ constructor({ pdfPage, eventBus, linkService = null,
55
+ // downloadManager,
56
+ annotationStorage = null,
57
+ // imageResourcesPath = "",
58
+ // renderForms = true,
59
+ // enableScripting = false,
60
+ // hasJSActionsPromise = null,
61
+ // fieldObjectsPromise = null,
62
+ annotationCanvasMap = null, accessibilityManager = null, annotationEditorUIManager = null, onAppend = null, }) {
63
+ _AnnotationLayerBuilder_instances.add(this);
64
+ // todo: props ported from pdf.js
65
+ this.annotationLayer = null;
66
+ this.pdfPage = null;
67
+ this.linkService = null;
68
+ this.annotationStorage = null;
69
+ this._annotationCanvasMap = null;
70
+ this._annotationEditorUIManager = null;
71
+ this.div = null;
72
+ this._cancelled = null;
73
+ this._eventBus = null;
74
+ this._accessibilityManager = null;
75
+ // todo: props ported from pdf.js
76
+ _AnnotationLayerBuilder_onAppend.set(this, null);
77
+ _AnnotationLayerBuilder_eventAbortController.set(this, null);
78
+ this.pdfPage = pdfPage;
79
+ this.linkService = linkService;
80
+ // this.downloadManager = downloadManager;
81
+ // this.imageResourcesPath = imageResourcesPath;
82
+ // this.renderForms = renderForms;
83
+ this.annotationStorage = annotationStorage;
84
+ // this.enableScripting = enableScripting;
85
+ // this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
86
+ // this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
87
+ this._annotationCanvasMap = annotationCanvasMap;
88
+ this._accessibilityManager = accessibilityManager;
89
+ this._annotationEditorUIManager = annotationEditorUIManager;
90
+ __classPrivateFieldSet(this, _AnnotationLayerBuilder_onAppend, onAppend, "f");
91
+ this.annotationLayer = null;
92
+ this.div = null;
93
+ this._cancelled = false;
94
+ this._eventBus = (linkService === null || linkService === void 0 ? void 0 : linkService.eventBus) || eventBus;
95
+ }
96
+ /**
97
+ * @param {PageViewport} viewport
98
+ * @param {string} intent (default value is 'display')
99
+ * @returns {Promise<void>} A promise that is resolved when rendering of the
100
+ * annotations is complete.
101
+ */
102
+ render(viewport_1) {
103
+ return __awaiter(this, arguments, void 0, function* (viewport, intent = "display") {
104
+ var _a, _b, _c;
105
+ if (this.div) {
106
+ if (this._cancelled || !this.annotationLayer) {
107
+ return;
108
+ }
109
+ // If an annotationLayer already exists, refresh its children's
110
+ // transformation matrices.
111
+ this.annotationLayer.update({
112
+ viewport: viewport.clone({ dontFlip: true }),
113
+ });
114
+ return;
115
+ }
116
+ // const [annotations, hasJSActions, fieldObjects] = await Promise.all([
117
+ const [annotations] = yield Promise.all([
118
+ this.pdfPage.getAnnotations({ intent }),
119
+ // this._hasJSActionsPromise,
120
+ // this._fieldObjectsPromise,
121
+ ]);
122
+ if (this._cancelled) {
123
+ return;
124
+ }
125
+ // Create an annotation layer div and render the annotations
126
+ // if there is at least one annotation.
127
+ // const div = (this.div = document.createElement("div"));
128
+ // div.className = "annotationLayer";
129
+ // this.#onAppend?.(div);
130
+ if (annotations.length === 0) {
131
+ this.hide();
132
+ return;
133
+ }
134
+ const page = this.pdfPage;
135
+ const pageView = (_a = page._pageInfo) === null || _a === void 0 ? void 0 : _a.view;
136
+ const pageWidthAnnotationLayer = (pageView[2] || 0) + "px";
137
+ const pageHeightAnnotationLayer = (pageView[3] || 0) + "px";
138
+ const div = convertToHtml(`
139
+ <div class="k-annotation-layer annotationLayer" data-main-rotation="0"
140
+ style="width: round(var(--scale-factor) * ${pageWidthAnnotationLayer}, 1px);
141
+ height: round(var(--scale-factor) * ${pageHeightAnnotationLayer}, 1px);">
142
+ </div>
143
+ `);
144
+ this.div = div;
145
+ (_b = __classPrivateFieldGet(this, _AnnotationLayerBuilder_onAppend, "f")) === null || _b === void 0 ? void 0 : _b.call(this, div);
146
+ this.annotationLayer = new AnnotationLayer({
147
+ div,
148
+ // accessibilityManager: this._accessibilityManager,
149
+ accessibilityManager: null,
150
+ annotationCanvasMap: this._annotationCanvasMap,
151
+ annotationEditorUIManager: this._annotationEditorUIManager,
152
+ page: this.pdfPage,
153
+ viewport: viewport.clone({ dontFlip: true }),
154
+ });
155
+ yield this.annotationLayer.render({
156
+ annotations,
157
+ // imageResourcesPath: this.imageResourcesPath,
158
+ // renderForms: this.renderForms,
159
+ linkService: this.linkService,
160
+ // downloadManager: this.downloadManager,
161
+ // annotationStorage: this.annotationStorage,
162
+ // enableScripting: this.enableScripting,
163
+ // hasJSActions,
164
+ // fieldObjects,
165
+ });
166
+ // Ensure that interactive form elements in the annotationLayer are
167
+ // disabled while PresentationMode is active (see issue 12232).
168
+ if (this.linkService.isInPresentationMode) {
169
+ __classPrivateFieldGet(this, _AnnotationLayerBuilder_instances, "m", _AnnotationLayerBuilder_updatePresentationModeState).call(this, PresentationModeState.FULLSCREEN);
170
+ }
171
+ if (!__classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f")) {
172
+ __classPrivateFieldSet(this, _AnnotationLayerBuilder_eventAbortController, new AbortController(), "f");
173
+ (_c = this._eventBus) === null || _c === void 0 ? void 0 : _c._on("presentationmodechanged", evt => {
174
+ __classPrivateFieldGet(this, _AnnotationLayerBuilder_instances, "m", _AnnotationLayerBuilder_updatePresentationModeState).call(this, evt.state);
175
+ }, { signal: __classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f").signal });
176
+ }
177
+ });
178
+ }
179
+ cancel() {
180
+ var _a;
181
+ this._cancelled = true;
182
+ (_a = __classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f")) === null || _a === void 0 ? void 0 : _a.abort();
183
+ __classPrivateFieldSet(this, _AnnotationLayerBuilder_eventAbortController, null, "f");
184
+ }
185
+ hide() {
186
+ if (!this.div) {
187
+ return;
188
+ }
189
+ this.div.hidden = true;
190
+ }
191
+ hasEditableAnnotations() {
192
+ var _a;
193
+ return !!((_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.hasEditableAnnotations());
194
+ }
195
+ }
196
+ _AnnotationLayerBuilder_onAppend = new WeakMap(), _AnnotationLayerBuilder_eventAbortController = new WeakMap(), _AnnotationLayerBuilder_instances = new WeakSet(), _AnnotationLayerBuilder_updatePresentationModeState = function _AnnotationLayerBuilder_updatePresentationModeState(state) {
197
+ if (!this.div) {
198
+ return;
199
+ }
200
+ let disableFormElements = false;
201
+ switch (state) {
202
+ case PresentationModeState.FULLSCREEN:
203
+ disableFormElements = true;
204
+ break;
205
+ case PresentationModeState.NORMAL:
206
+ break;
207
+ default:
208
+ return;
209
+ }
210
+ for (const section of this.div.childNodes) {
211
+ if (section.hasAttribute("data-internal-link")) {
212
+ continue;
213
+ }
214
+ section.inert = disableFormElements;
215
+ }
216
+ };
217
+ export { AnnotationLayerBuilder };