@progress/kendo-pdfviewer-common 0.4.2-develop.1 → 0.5.0-develop.2
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 +6 -1
- package/dist/es/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/es/annotations/annotation-layer-builder.js +14 -4
- package/dist/es/annotations/annotation-layer.js +358 -337
- package/dist/es/annotations/draw-layer-builder.js +5 -1
- package/dist/es/annotations/helpers/annotation-storage.js +14 -0
- package/dist/es/annotations/helpers/text-accessibility-manager.js +5 -0
- package/dist/es/annotations/shared/event_utils.js +6 -0
- package/dist/es/text/text-layer-builder.js +13 -1
- package/dist/es/utils.js +3 -2
- package/dist/es/widget/page.js +22 -0
- package/dist/es/widget/pdfviewer.js +24 -13
- package/dist/es2015/annotations/annotation-editor-layer-builder.js +6 -1
- package/dist/es2015/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/es2015/annotations/annotation-layer-builder.js +14 -4
- package/dist/es2015/annotations/annotation-layer.js +358 -337
- package/dist/es2015/annotations/draw-layer-builder.js +5 -1
- package/dist/es2015/annotations/helpers/annotation-storage.js +14 -0
- package/dist/es2015/annotations/helpers/text-accessibility-manager.js +5 -0
- package/dist/es2015/annotations/shared/event_utils.js +6 -0
- package/dist/es2015/text/text-layer-builder.js +13 -1
- package/dist/es2015/utils.js +3 -2
- package/dist/es2015/widget/page.js +22 -0
- package/dist/es2015/widget/pdfviewer.js +24 -13
- package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +3 -1
- package/dist/npm/annotations/annotation-editor-layer-builder.js +6 -1
- package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +3 -0
- package/dist/npm/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/npm/annotations/annotation-layer-builder.d.ts +3 -1
- package/dist/npm/annotations/annotation-layer-builder.js +14 -4
- package/dist/npm/annotations/annotation-layer.d.ts +3 -1
- package/dist/npm/annotations/annotation-layer.js +358 -337
- package/dist/npm/annotations/draw-layer-builder.d.ts +3 -1
- package/dist/npm/annotations/draw-layer-builder.js +5 -1
- package/dist/npm/annotations/helpers/annotation-storage.d.ts +10 -0
- package/dist/npm/annotations/helpers/annotation-storage.js +14 -0
- package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +1 -0
- package/dist/npm/annotations/helpers/text-accessibility-manager.js +5 -0
- package/dist/npm/annotations/shared/event_utils.d.ts +4 -0
- package/dist/npm/annotations/shared/event_utils.js +6 -0
- package/dist/npm/text/text-layer-builder.d.ts +3 -1
- package/dist/npm/text/text-layer-builder.js +13 -1
- package/dist/npm/utils.d.ts +1 -0
- package/dist/npm/utils.js +5 -3
- package/dist/npm/widget/page.js +22 -0
- package/dist/npm/widget/pdfviewer.d.ts +1 -0
- package/dist/npm/widget/pdfviewer.js +23 -12
- package/package.json +1 -1
|
@@ -47,10 +47,11 @@ class DrawLayerBuilder {
|
|
|
47
47
|
}
|
|
48
48
|
cancel() {
|
|
49
49
|
// this._cancelled = true;
|
|
50
|
+
var _a;
|
|
50
51
|
if (!__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) {
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
|
-
__classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f").destroy();
|
|
54
|
+
(_a = __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f")) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
54
55
|
__classPrivateFieldSet(this, _DrawLayerBuilder_drawLayer, null, "f");
|
|
55
56
|
}
|
|
56
57
|
setParent(parent) {
|
|
@@ -60,6 +61,9 @@ class DrawLayerBuilder {
|
|
|
60
61
|
getDrawLayer() {
|
|
61
62
|
return __classPrivateFieldGet(this, _DrawLayerBuilder_drawLayer, "f");
|
|
62
63
|
}
|
|
64
|
+
destroy() {
|
|
65
|
+
this.cancel();
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
68
|
_DrawLayerBuilder_drawLayer = new WeakMap();
|
|
65
69
|
export { DrawLayerBuilder };
|
|
@@ -45,6 +45,20 @@ class AnnotationStorage {
|
|
|
45
45
|
this.onResetModified = null;
|
|
46
46
|
this.onAnnotationEditor = null;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the value for the storage - used purely for debugging purposes.
|
|
50
|
+
* @returns {Object}
|
|
51
|
+
*/
|
|
52
|
+
getStorage() {
|
|
53
|
+
return __classPrivateFieldGet(this, _AnnotationStorage_storage, "f");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the modified flag for the storage - used purely for debugging purposes.
|
|
57
|
+
* @returns {Object}
|
|
58
|
+
*/
|
|
59
|
+
getModified() {
|
|
60
|
+
return __classPrivateFieldGet(this, _AnnotationStorage_modified, "f");
|
|
61
|
+
}
|
|
48
62
|
/**
|
|
49
63
|
* Get the value for a given key if it exists, or return the default value.
|
|
50
64
|
* @param {string} key
|
|
@@ -178,6 +178,11 @@ class TextAccessibilityManager {
|
|
|
178
178
|
}
|
|
179
179
|
return id;
|
|
180
180
|
}
|
|
181
|
+
destroy() {
|
|
182
|
+
__classPrivateFieldSet(this, _TextAccessibilityManager_textNodes, new Map(), "f");
|
|
183
|
+
__classPrivateFieldSet(this, _TextAccessibilityManager_waitingElements, new Map(), "f");
|
|
184
|
+
__classPrivateFieldSet(this, _TextAccessibilityManager_textChildren, null, "f");
|
|
185
|
+
}
|
|
181
186
|
}
|
|
182
187
|
_a = TextAccessibilityManager, _TextAccessibilityManager_enabled = new WeakMap(), _TextAccessibilityManager_textChildren = new WeakMap(), _TextAccessibilityManager_textNodes = new WeakMap(), _TextAccessibilityManager_waitingElements = new WeakMap(), _TextAccessibilityManager_instances = new WeakSet(), _TextAccessibilityManager_compareElementPositions = function _TextAccessibilityManager_compareElementPositions(e1, e2) {
|
|
183
188
|
const rect1 = e1.getBoundingClientRect();
|
|
@@ -64,6 +64,12 @@ class EventBus {
|
|
|
64
64
|
constructor() {
|
|
65
65
|
_EventBus_listeners.set(this, Object.create(null));
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Returs the current event listeners - used purely for debugging purposes.
|
|
69
|
+
*/
|
|
70
|
+
getListeners() {
|
|
71
|
+
return __classPrivateFieldGet(this, _EventBus_listeners, "f");
|
|
72
|
+
}
|
|
67
73
|
/**
|
|
68
74
|
* @param {string} eventName
|
|
69
75
|
* @param {function} listener
|
|
@@ -124,13 +124,25 @@ class TextLayerBuilder {
|
|
|
124
124
|
* Cancel rendering of the text layer.
|
|
125
125
|
*/
|
|
126
126
|
cancel() {
|
|
127
|
-
var _b, _c;
|
|
127
|
+
var _b, _c, _d;
|
|
128
128
|
(_b = __classPrivateFieldGet(this, _TextLayerBuilder_textLayer, "f")) === null || _b === void 0 ? void 0 : _b.cancel();
|
|
129
129
|
__classPrivateFieldSet(this, _TextLayerBuilder_textLayer, null, "f");
|
|
130
130
|
// this.highlighter?.disable();
|
|
131
131
|
(_c = this.accessibilityManager) === null || _c === void 0 ? void 0 : _c.disable();
|
|
132
|
+
(_d = this.accessibilityManager) === null || _d === void 0 ? void 0 : _d.destroy();
|
|
132
133
|
__classPrivateFieldGet(_a, _a, "m", _TextLayerBuilder_removeGlobalSelectionListener).call(_a, this.div);
|
|
133
134
|
}
|
|
135
|
+
destroy() {
|
|
136
|
+
var _b, _c;
|
|
137
|
+
TextLayer.cleanup();
|
|
138
|
+
this.cancel();
|
|
139
|
+
this.pdfPage = null;
|
|
140
|
+
// this.highlighter = null;
|
|
141
|
+
(_b = this.accessibilityManager) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
142
|
+
this.accessibilityManager = null;
|
|
143
|
+
(_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
|
|
144
|
+
this.div = null;
|
|
145
|
+
}
|
|
134
146
|
}
|
|
135
147
|
_a = TextLayerBuilder, _TextLayerBuilder_onAppend = new WeakMap(), _TextLayerBuilder_textLayer = new WeakMap(), _TextLayerBuilder_instances = new WeakSet(), _TextLayerBuilder_bindMouse = function _TextLayerBuilder_bindMouse(end) {
|
|
136
148
|
const { div } = this;
|
package/dist/es2015/utils.js
CHANGED
|
@@ -399,10 +399,10 @@ export const scrollToPage = (rootElement, pageNumber) => {
|
|
|
399
399
|
*/
|
|
400
400
|
export const currentPage = (rootElement) => {
|
|
401
401
|
const scrollElement = rootElement.querySelector('.k-pdf-viewer-canvas');
|
|
402
|
-
const page = rootElement.querySelector('.k-page');
|
|
402
|
+
const page = rootElement.querySelector('.k-page:not(.k-blank-page)');
|
|
403
403
|
return scrollElement && page
|
|
404
404
|
? Math.floor(Math.round(scrollElement.scrollTop) /
|
|
405
|
-
(page.offsetHeight + page.offsetTop) +
|
|
405
|
+
Math.max(1, page.offsetHeight + page.offsetTop) +
|
|
406
406
|
0.01)
|
|
407
407
|
: 0;
|
|
408
408
|
};
|
|
@@ -482,3 +482,4 @@ const createCanvas = (page, zoom = 1, cssClass = '') => {
|
|
|
482
482
|
styles
|
|
483
483
|
};
|
|
484
484
|
};
|
|
485
|
+
export const getDevicePixelRatio = () => (window === null || window === void 0 ? void 0 : window.devicePixelRatio) || 1;
|
|
@@ -92,12 +92,31 @@ export class Page extends Component {
|
|
|
92
92
|
// todo: ported from pdf.js
|
|
93
93
|
this.pdfViewer = options.pdfViewer;
|
|
94
94
|
this.pdfPage = options.pdfPage;
|
|
95
|
+
__classPrivateFieldSet(this, _Page_annotationMode, this.pdfViewer.getAnnotationMode(), "f");
|
|
95
96
|
this.resetState();
|
|
96
97
|
}
|
|
97
98
|
destroy() {
|
|
99
|
+
var _a, _b, _c, _d, _e;
|
|
98
100
|
this.destroyTextLayer();
|
|
101
|
+
if (this.canvas) {
|
|
102
|
+
this.canvas.width = 0;
|
|
103
|
+
this.canvas.height = 0;
|
|
104
|
+
this.canvas.remove();
|
|
105
|
+
this.canvas = null;
|
|
106
|
+
}
|
|
107
|
+
if (this.canvasForPrint) {
|
|
108
|
+
this.canvasForPrint.width = 0;
|
|
109
|
+
this.canvasForPrint.height = 0;
|
|
110
|
+
this.canvasForPrint.remove();
|
|
111
|
+
this.canvasForPrint = null;
|
|
112
|
+
}
|
|
113
|
+
(_a = this.drawLayer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
114
|
+
(_b = this.annotationLayer) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
115
|
+
(_c = this.annotationEditorLayer) === null || _c === void 0 ? void 0 : _c.destroy();
|
|
116
|
+
(_d = this.div) === null || _d === void 0 ? void 0 : _d.remove();
|
|
99
117
|
this.div = null;
|
|
100
118
|
this.pdfViewer = null;
|
|
119
|
+
(_e = this.pdfPage) === null || _e === void 0 ? void 0 : _e.cleanup();
|
|
101
120
|
this.pdfPage = null;
|
|
102
121
|
}
|
|
103
122
|
get isEditing() {
|
|
@@ -128,6 +147,9 @@ export class Page extends Component {
|
|
|
128
147
|
return viewport;
|
|
129
148
|
}
|
|
130
149
|
destroyTextLayer() {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
(_a = this.textLayer) === null || _a === void 0 ? void 0 : _a.cancel();
|
|
152
|
+
(_b = this.textLayer) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
131
153
|
this.removeTextLayer();
|
|
132
154
|
this.textLayer = null;
|
|
133
155
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var _PdfViewer_instances, _PdfViewer_annotationEditorMode, _PdfViewer_switchAnnotationEditorModeTimeoutId, _PdfViewer_eventAbortController, _PdfViewer_onPageRenderedCallback, _PdfViewer_switchToEditAnnotationMode, _PdfViewer_scrollIntoView;
|
|
1
|
+
var _PdfViewer_instances, _PdfViewer_annotationEditorMode, _PdfViewer_switchAnnotationEditorModeTimeoutId, _PdfViewer_annotationMode, _PdfViewer_eventAbortController, _PdfViewer_onPageRenderedCallback, _PdfViewer_switchToEditAnnotationMode, _PdfViewer_scrollIntoView;
|
|
2
2
|
import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { deepExtend, Component, isString, toArray, noop, hasValue, toClassSelector, addClass, removeClass, mousewheelDelta, convertToHtml, clamp, createPromise } from "../common/main";
|
|
4
|
-
import { currentPage, parsePdfFromBase64String,
|
|
4
|
+
import { currentPage, parsePdfFromBase64String, adjustCanvasSize, createElement, getDevicePixelRatio } from "../utils";
|
|
5
5
|
import { SearchService } from "../search";
|
|
6
6
|
import { Scroller, throttle } from "../scroller";
|
|
7
7
|
import { saveAs } from "@progress/kendo-file-saver";
|
|
@@ -49,6 +49,7 @@ export class PdfViewer extends Component {
|
|
|
49
49
|
zoomLevel: DEFAULT_ZOOM_LEVEL,
|
|
50
50
|
zoomBeforePrint: false,
|
|
51
51
|
zoomLevelForPrint: 3,
|
|
52
|
+
renderForms: false,
|
|
52
53
|
searchMatchScrollLeftOffset: 0,
|
|
53
54
|
// add some default offset, so that the found match
|
|
54
55
|
// does not appear on the top edge of the page when navigated to
|
|
@@ -60,6 +61,7 @@ export class PdfViewer extends Component {
|
|
|
60
61
|
pageWheelThrottleDelay: 200,
|
|
61
62
|
// ported from pdf.js
|
|
62
63
|
printResolution: 100,
|
|
64
|
+
renderScale: 1.4,
|
|
63
65
|
loadOnDemand: false,
|
|
64
66
|
loadOnDemandPageSize: 2,
|
|
65
67
|
messages: {
|
|
@@ -121,7 +123,7 @@ export class PdfViewer extends Component {
|
|
|
121
123
|
// #annotationEditorHighlightColors = null;
|
|
122
124
|
// #annotationEditorMode = AnnotationEditorType.NONE;
|
|
123
125
|
// #annotationEditorUIManager = null;
|
|
124
|
-
|
|
126
|
+
_PdfViewer_annotationMode.set(this, AnnotationMode.ENABLE);
|
|
125
127
|
// #containerTopLeft = null;
|
|
126
128
|
// #enableHWA = false;
|
|
127
129
|
// #enableHighlightFloatingButton = false;
|
|
@@ -181,7 +183,7 @@ export class PdfViewer extends Component {
|
|
|
181
183
|
// as this can only be obtained by JS
|
|
182
184
|
this.tryTriggerScroll = (e) => {
|
|
183
185
|
let isPageChanged = false;
|
|
184
|
-
const pageNumber =
|
|
186
|
+
const pageNumber = this.getCurrentPageIndex() + 1;
|
|
185
187
|
if (pageNumber !== this.state.activePageNumber && (pageNumber >= 1 && pageNumber <= this.state.pdfDocument.numPages)) {
|
|
186
188
|
isPageChanged = true;
|
|
187
189
|
this.state.activePageNumber = pageNumber;
|
|
@@ -218,6 +220,7 @@ export class PdfViewer extends Component {
|
|
|
218
220
|
return;
|
|
219
221
|
}
|
|
220
222
|
e.preventDefault();
|
|
223
|
+
e.stopPropagation();
|
|
221
224
|
const wheelDelta = mousewheelDelta(e);
|
|
222
225
|
const zoomModifier = wheelDelta < 0 ? 1 : -1;
|
|
223
226
|
const zoomLevel = this.state.zoomLevel + (zoomModifier * this.options.zoomRate);
|
|
@@ -236,6 +239,8 @@ export class PdfViewer extends Component {
|
|
|
236
239
|
this.wrapper = this.element;
|
|
237
240
|
this.initEventBus();
|
|
238
241
|
__classPrivateFieldSet(this, _PdfViewer_eventAbortController, new AbortController(), "f");
|
|
242
|
+
if (this.options.renderForms)
|
|
243
|
+
__classPrivateFieldSet(this, _PdfViewer_annotationMode, AnnotationMode.ENABLE_FORMS, "f");
|
|
239
244
|
this.resetState();
|
|
240
245
|
this.bindEvents();
|
|
241
246
|
this.initLinkService();
|
|
@@ -326,6 +331,9 @@ export class PdfViewer extends Component {
|
|
|
326
331
|
}
|
|
327
332
|
updater();
|
|
328
333
|
}
|
|
334
|
+
getAnnotationMode() {
|
|
335
|
+
return __classPrivateFieldGet(this, _PdfViewer_annotationMode, "f");
|
|
336
|
+
}
|
|
329
337
|
getPrintUnits() {
|
|
330
338
|
return this.options.printResolution / PixelsPerInch.PDF;
|
|
331
339
|
}
|
|
@@ -740,20 +748,15 @@ export class PdfViewer extends Component {
|
|
|
740
748
|
if (zoom <= 0) {
|
|
741
749
|
return;
|
|
742
750
|
}
|
|
743
|
-
const renderScale =
|
|
751
|
+
const renderScale = this.options.renderScale * getDevicePixelRatio();
|
|
744
752
|
let scaleNum = zoom * renderScale;
|
|
745
753
|
if (printUnits) {
|
|
746
754
|
scaleNum = zoom || renderScale;
|
|
747
755
|
}
|
|
748
|
-
// const scaleNum = zoom * renderScale;
|
|
749
756
|
// changing the viewport dimensions here requires changes in
|
|
750
757
|
// page.getPrintContentAsync for the printing dimensions
|
|
751
758
|
const viewport = pdfPage === null || pdfPage === void 0 ? void 0 : pdfPage.getViewport({ scale: scaleNum });
|
|
752
759
|
const { adjustedWidth, adjustedHeight, adjustRatio } = adjustCanvasSize(viewport.width, viewport.height);
|
|
753
|
-
// const styles = {
|
|
754
|
-
// width: Math.floor(viewport.width / scaleNum) * zoom + 'pt',
|
|
755
|
-
// height: Math.floor(viewport.height / scaleNum) * zoom + 'pt'
|
|
756
|
-
// };
|
|
757
760
|
// use PageView.setLayerDimensions
|
|
758
761
|
const { pageWidth, pageHeight } = viewport.rawDims;
|
|
759
762
|
const styles = {
|
|
@@ -851,7 +854,7 @@ export class PdfViewer extends Component {
|
|
|
851
854
|
// optionalContentConfigPromise,
|
|
852
855
|
// renderingQueue: this.renderingQueue,
|
|
853
856
|
textLayerMode: TextLayerMode.ENABLE,
|
|
854
|
-
annotationMode:
|
|
857
|
+
annotationMode: this.getAnnotationMode(),
|
|
855
858
|
// imageResourcesPath: this.imageResourcesPath,
|
|
856
859
|
// maxCanvasPixels: this.maxCanvasPixels,
|
|
857
860
|
// pageColors,
|
|
@@ -940,8 +943,16 @@ export class PdfViewer extends Component {
|
|
|
940
943
|
// and then revert
|
|
941
944
|
serializedAnnotationStorage = {};
|
|
942
945
|
originalAnnotationStorage = options.pdf.annotationStorage.getAll();
|
|
946
|
+
// With the form filling functionality enabled, values could be coming as pure JSON objects,
|
|
947
|
+
// thus the additional assertion.
|
|
943
948
|
Object.keys(originalAnnotationStorage).forEach((key) => {
|
|
944
|
-
|
|
949
|
+
var _a;
|
|
950
|
+
if (typeof ((_a = originalAnnotationStorage[key]) === null || _a === void 0 ? void 0 : _a.toJSON) === "function") {
|
|
951
|
+
serializedAnnotationStorage[key] = originalAnnotationStorage[key].toJSON();
|
|
952
|
+
}
|
|
953
|
+
else {
|
|
954
|
+
serializedAnnotationStorage[key] = originalAnnotationStorage[key];
|
|
955
|
+
}
|
|
945
956
|
});
|
|
946
957
|
Object.keys(originalAnnotationStorage).forEach((key) => {
|
|
947
958
|
options.pdf.annotationStorage.remove(key);
|
|
@@ -1628,7 +1639,7 @@ export class PdfViewer extends Component {
|
|
|
1628
1639
|
return true;
|
|
1629
1640
|
}
|
|
1630
1641
|
}
|
|
1631
|
-
_PdfViewer_annotationEditorMode = new WeakMap(), _PdfViewer_switchAnnotationEditorModeTimeoutId = new WeakMap(), _PdfViewer_eventAbortController = new WeakMap(), _PdfViewer_onPageRenderedCallback = new WeakMap(), _PdfViewer_instances = new WeakSet(), _PdfViewer_switchToEditAnnotationMode = function _PdfViewer_switchToEditAnnotationMode() {
|
|
1642
|
+
_PdfViewer_annotationEditorMode = new WeakMap(), _PdfViewer_switchAnnotationEditorModeTimeoutId = new WeakMap(), _PdfViewer_annotationMode = new WeakMap(), _PdfViewer_eventAbortController = new WeakMap(), _PdfViewer_onPageRenderedCallback = new WeakMap(), _PdfViewer_instances = new WeakSet(), _PdfViewer_switchToEditAnnotationMode = function _PdfViewer_switchToEditAnnotationMode() {
|
|
1632
1643
|
// const visible = this._getVisiblePages();
|
|
1633
1644
|
// const visible = this._getVisiblePages();
|
|
1634
1645
|
const pagesToRefresh = [];
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @typedef {import("./interfaces").IL10n} IL10n */
|
|
6
6
|
/** @typedef {import("../src/display/annotation_layer.js").AnnotationLayer} AnnotationLayer */
|
|
7
7
|
import { AnnotationEditorLayer } from "./annotation-editor-layer";
|
|
8
|
+
import { TextAccessibilityManager } from "./helpers/text-accessibility-manager";
|
|
8
9
|
/**
|
|
9
10
|
* @typedef {Object} AnnotationEditorLayerBuilderOptions
|
|
10
11
|
* @property {AnnotationEditorUIManager} [uiManager]
|
|
@@ -22,7 +23,7 @@ declare class AnnotationEditorLayerBuilder {
|
|
|
22
23
|
annotationEditorLayer: AnnotationEditorLayer;
|
|
23
24
|
_cancelled: any;
|
|
24
25
|
div: any;
|
|
25
|
-
accessibilityManager:
|
|
26
|
+
accessibilityManager: TextAccessibilityManager;
|
|
26
27
|
/**
|
|
27
28
|
* @param {AnnotationEditorLayerBuilderOptions} options
|
|
28
29
|
*/
|
|
@@ -35,5 +36,6 @@ declare class AnnotationEditorLayerBuilder {
|
|
|
35
36
|
cancel(): void;
|
|
36
37
|
hide(): void;
|
|
37
38
|
show(): void;
|
|
39
|
+
destroy(): void;
|
|
38
40
|
}
|
|
39
41
|
export { AnnotationEditorLayerBuilder };
|
|
@@ -115,11 +115,12 @@ class AnnotationEditorLayerBuilder {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
cancel() {
|
|
118
|
+
var _a;
|
|
118
119
|
this._cancelled = true;
|
|
119
120
|
if (!this.div) {
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
|
-
this.annotationEditorLayer.destroy();
|
|
123
|
+
(_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
123
124
|
}
|
|
124
125
|
hide() {
|
|
125
126
|
if (!this.div) {
|
|
@@ -133,6 +134,10 @@ class AnnotationEditorLayerBuilder {
|
|
|
133
134
|
}
|
|
134
135
|
this.div.hidden = false;
|
|
135
136
|
}
|
|
137
|
+
destroy() {
|
|
138
|
+
var _a;
|
|
139
|
+
(_a = this.annotationEditorLayer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
140
|
+
}
|
|
136
141
|
}
|
|
137
142
|
exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
|
|
138
143
|
_AnnotationEditorLayerBuilder_annotationLayer = new WeakMap(), _AnnotationEditorLayerBuilder_drawLayer = new WeakMap(), _AnnotationEditorLayerBuilder_onAppend = new WeakMap(), _AnnotationEditorLayerBuilder_textLayer = new WeakMap(), _AnnotationEditorLayerBuilder_uiManager = new WeakMap();
|
|
@@ -28,11 +28,14 @@ export declare class AnnotationEditorUIManager {
|
|
|
28
28
|
onSetPreference({ name }: {
|
|
29
29
|
name: any;
|
|
30
30
|
}): void;
|
|
31
|
+
onNamedAction(event: any): void;
|
|
31
32
|
onPageChanging({ pageNumber }: {
|
|
32
33
|
pageNumber: any;
|
|
33
34
|
}): void;
|
|
34
35
|
focusMainContainer(): void;
|
|
35
36
|
findParent(x: any, y: any): any;
|
|
37
|
+
triggerPrinting(): void;
|
|
38
|
+
downloadOrSave(): void;
|
|
36
39
|
disableUserSelect(value?: boolean): void;
|
|
37
40
|
addShouldRescale(editor: any): void;
|
|
38
41
|
removeShouldRescale(editor: any): void;
|
|
@@ -245,6 +245,9 @@ class AnnotationEditorUIManager {
|
|
|
245
245
|
this._eventBus._on("setpreference", this.onSetPreference.bind(this), {
|
|
246
246
|
signal
|
|
247
247
|
});
|
|
248
|
+
this._eventBus._on("namedaction", this.onNamedAction.bind(this), {
|
|
249
|
+
signal
|
|
250
|
+
});
|
|
248
251
|
tslib_1.__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addSelectionListener).call(this);
|
|
249
252
|
tslib_1.__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addDragAndDropListeners).call(this);
|
|
250
253
|
tslib_1.__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addKeyboardManager).call(this);
|
|
@@ -391,6 +394,18 @@ class AnnotationEditorUIManager {
|
|
|
391
394
|
default: break;
|
|
392
395
|
}
|
|
393
396
|
}
|
|
397
|
+
onNamedAction(event) {
|
|
398
|
+
// Processing a couple of named actions that might be useful, see also
|
|
399
|
+
// `PDFLinkService.executeNamedAction`.
|
|
400
|
+
switch (event.action) {
|
|
401
|
+
case "Print":
|
|
402
|
+
this.triggerPrinting();
|
|
403
|
+
break;
|
|
404
|
+
case "SaveAs":
|
|
405
|
+
this.downloadOrSave();
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
394
409
|
onPageChanging({ pageNumber }) {
|
|
395
410
|
tslib_1.__classPrivateFieldSet(this, _AnnotationEditorUIManager_currentPageIndex, pageNumber - 1, "f");
|
|
396
411
|
}
|
|
@@ -410,6 +425,16 @@ class AnnotationEditorUIManager {
|
|
|
410
425
|
}
|
|
411
426
|
return null;
|
|
412
427
|
}
|
|
428
|
+
triggerPrinting() {
|
|
429
|
+
var _a;
|
|
430
|
+
(_a = this.pdfViewer) === null || _a === void 0 ? void 0 : _a.printFile();
|
|
431
|
+
}
|
|
432
|
+
downloadOrSave() {
|
|
433
|
+
var _a, _b;
|
|
434
|
+
(_a = this.pdfViewer) === null || _a === void 0 ? void 0 : _a.downloadFile({
|
|
435
|
+
fileName: (_b = this.pdfViewer) === null || _b === void 0 ? void 0 : _b.options.downloadFileName
|
|
436
|
+
});
|
|
437
|
+
}
|
|
413
438
|
disableUserSelect(value = false) {
|
|
414
439
|
var _a;
|
|
415
440
|
(_a = tslib_1.__classPrivateFieldGet(this, _AnnotationEditorUIManager_viewer, "f")) === null || _a === void 0 ? void 0 : _a.classList.toggle("noUserSelect", value);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PDFLinkService } from "../links/link-service";
|
|
2
2
|
import { AnnotationLayer } from "./annotation-layer";
|
|
3
|
+
import { TextAccessibilityManager } from "./helpers/text-accessibility-manager";
|
|
3
4
|
import { EventBus } from "./shared/event_utils";
|
|
4
5
|
/**
|
|
5
6
|
* @typedef {Object} AnnotationLayerBuilderOptions
|
|
@@ -30,7 +31,7 @@ declare class AnnotationLayerBuilder {
|
|
|
30
31
|
div: any;
|
|
31
32
|
_cancelled: any;
|
|
32
33
|
_eventBus: EventBus;
|
|
33
|
-
_accessibilityManager:
|
|
34
|
+
_accessibilityManager: TextAccessibilityManager;
|
|
34
35
|
renderForms: any;
|
|
35
36
|
/**
|
|
36
37
|
* @param {AnnotationLayerBuilderOptions} options
|
|
@@ -56,5 +57,6 @@ declare class AnnotationLayerBuilder {
|
|
|
56
57
|
cancel(): void;
|
|
57
58
|
hide(): void;
|
|
58
59
|
hasEditableAnnotations(): boolean;
|
|
60
|
+
destroy(): void;
|
|
59
61
|
}
|
|
60
62
|
export { AnnotationLayerBuilder };
|
|
@@ -146,8 +146,8 @@ class AnnotationLayerBuilder {
|
|
|
146
146
|
(_b = tslib_1.__classPrivateFieldGet(this, _AnnotationLayerBuilder_onAppend, "f")) === null || _b === void 0 ? void 0 : _b.call(this, div);
|
|
147
147
|
this.annotationLayer = new annotation_layer_1.AnnotationLayer({
|
|
148
148
|
div,
|
|
149
|
-
|
|
150
|
-
accessibilityManager: null,
|
|
149
|
+
accessibilityManager: this._accessibilityManager,
|
|
150
|
+
// accessibilityManager: null,
|
|
151
151
|
annotationCanvasMap: this._annotationCanvasMap,
|
|
152
152
|
annotationEditorUIManager: this._annotationEditorUIManager,
|
|
153
153
|
page: this.pdfPage,
|
|
@@ -157,9 +157,9 @@ class AnnotationLayerBuilder {
|
|
|
157
157
|
annotations,
|
|
158
158
|
// imageResourcesPath: this.imageResourcesPath,
|
|
159
159
|
renderForms: this.renderForms,
|
|
160
|
-
linkService: this.linkService
|
|
160
|
+
linkService: this.linkService,
|
|
161
161
|
// downloadManager: this.downloadManager,
|
|
162
|
-
|
|
162
|
+
annotationStorage: this.annotationStorage
|
|
163
163
|
// enableScripting: this.enableScripting,
|
|
164
164
|
// hasJSActions,
|
|
165
165
|
// fieldObjects,
|
|
@@ -193,6 +193,16 @@ class AnnotationLayerBuilder {
|
|
|
193
193
|
var _a;
|
|
194
194
|
return !!((_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.hasEditableAnnotations());
|
|
195
195
|
}
|
|
196
|
+
destroy() {
|
|
197
|
+
var _a, _b, _c;
|
|
198
|
+
this.cancel();
|
|
199
|
+
(_a = this.annotationLayer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
200
|
+
this.annotationLayer = null;
|
|
201
|
+
(_b = tslib_1.__classPrivateFieldGet(this, _AnnotationLayerBuilder_eventAbortController, "f")) === null || _b === void 0 ? void 0 : _b.abort();
|
|
202
|
+
tslib_1.__classPrivateFieldSet(this, _AnnotationLayerBuilder_eventAbortController, null, "f");
|
|
203
|
+
(_c = this.div) === null || _c === void 0 ? void 0 : _c.remove();
|
|
204
|
+
this.div = null;
|
|
205
|
+
}
|
|
196
206
|
}
|
|
197
207
|
exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
|
|
198
208
|
_AnnotationLayerBuilder_onAppend = new WeakMap(), _AnnotationLayerBuilder_eventAbortController = new WeakMap(), _AnnotationLayerBuilder_instances = new WeakSet(), _AnnotationLayerBuilder_updatePresentationModeState = function _AnnotationLayerBuilder_updatePresentationModeState(state) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AnnotationEditorUIManager } from "./annotation-editor-ui-manager";
|
|
1
2
|
declare class AnnotationElement {
|
|
2
3
|
#private;
|
|
3
4
|
isRenderable: any;
|
|
@@ -101,7 +102,7 @@ declare class AnnotationLayer {
|
|
|
101
102
|
page: any;
|
|
102
103
|
viewport: any;
|
|
103
104
|
zIndex: any;
|
|
104
|
-
_annotationEditorUIManager:
|
|
105
|
+
_annotationEditorUIManager: AnnotationEditorUIManager;
|
|
105
106
|
constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, viewport }: {
|
|
106
107
|
div: any;
|
|
107
108
|
accessibilityManager: any;
|
|
@@ -130,5 +131,6 @@ declare class AnnotationLayer {
|
|
|
130
131
|
}): void;
|
|
131
132
|
getEditableAnnotations(): any[];
|
|
132
133
|
getEditableAnnotation(id: any): any;
|
|
134
|
+
destroy(): void;
|
|
133
135
|
}
|
|
134
136
|
export { AnnotationLayer, FreeTextAnnotationElement };
|