@progress/kendo-pdfviewer-common 0.4.2-develop.1 → 0.5.0-develop.1
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-ui-manager.js +25 -0
- package/dist/es/annotations/annotation-layer-builder.js +2 -2
- package/dist/es/annotations/annotation-layer.js +352 -337
- package/dist/es/annotations/helpers/annotation-storage.js +14 -0
- package/dist/es/annotations/shared/event_utils.js +6 -0
- package/dist/es/utils.js +2 -2
- package/dist/es/widget/page.js +1 -0
- package/dist/es/widget/pdfviewer.js +20 -6
- package/dist/es2015/annotations/annotation-editor-ui-manager.js +25 -0
- package/dist/es2015/annotations/annotation-layer-builder.js +2 -2
- package/dist/es2015/annotations/annotation-layer.js +352 -337
- package/dist/es2015/annotations/helpers/annotation-storage.js +14 -0
- package/dist/es2015/annotations/shared/event_utils.js +6 -0
- package/dist/es2015/utils.js +2 -2
- package/dist/es2015/widget/page.js +1 -0
- package/dist/es2015/widget/pdfviewer.js +20 -6
- 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.js +2 -2
- package/dist/npm/annotations/annotation-layer.js +352 -337
- 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/shared/event_utils.d.ts +4 -0
- package/dist/npm/annotations/shared/event_utils.js +6 -0
- package/dist/npm/utils.js +2 -2
- package/dist/npm/widget/page.js +1 -0
- package/dist/npm/widget/pdfviewer.d.ts +1 -0
- package/dist/npm/widget/pdfviewer.js +20 -6
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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
|
package/dist/es/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
|
};
|
package/dist/es/widget/page.js
CHANGED
|
@@ -92,6 +92,7 @@ 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() {
|
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
import { currentPage, parsePdfFromBase64String, scale as getRenderScale, adjustCanvasSize, createElement } from "../utils";
|
|
@@ -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
|
|
@@ -121,7 +122,7 @@ export class PdfViewer extends Component {
|
|
|
121
122
|
// #annotationEditorHighlightColors = null;
|
|
122
123
|
// #annotationEditorMode = AnnotationEditorType.NONE;
|
|
123
124
|
// #annotationEditorUIManager = null;
|
|
124
|
-
|
|
125
|
+
_PdfViewer_annotationMode.set(this, AnnotationMode.ENABLE);
|
|
125
126
|
// #containerTopLeft = null;
|
|
126
127
|
// #enableHWA = false;
|
|
127
128
|
// #enableHighlightFloatingButton = false;
|
|
@@ -181,7 +182,7 @@ export class PdfViewer extends Component {
|
|
|
181
182
|
// as this can only be obtained by JS
|
|
182
183
|
this.tryTriggerScroll = (e) => {
|
|
183
184
|
let isPageChanged = false;
|
|
184
|
-
const pageNumber =
|
|
185
|
+
const pageNumber = this.getCurrentPageIndex() + 1;
|
|
185
186
|
if (pageNumber !== this.state.activePageNumber && (pageNumber >= 1 && pageNumber <= this.state.pdfDocument.numPages)) {
|
|
186
187
|
isPageChanged = true;
|
|
187
188
|
this.state.activePageNumber = pageNumber;
|
|
@@ -236,6 +237,8 @@ export class PdfViewer extends Component {
|
|
|
236
237
|
this.wrapper = this.element;
|
|
237
238
|
this.initEventBus();
|
|
238
239
|
__classPrivateFieldSet(this, _PdfViewer_eventAbortController, new AbortController(), "f");
|
|
240
|
+
if (this.options.renderForms)
|
|
241
|
+
__classPrivateFieldSet(this, _PdfViewer_annotationMode, AnnotationMode.ENABLE_FORMS, "f");
|
|
239
242
|
this.resetState();
|
|
240
243
|
this.bindEvents();
|
|
241
244
|
this.initLinkService();
|
|
@@ -326,6 +329,9 @@ export class PdfViewer extends Component {
|
|
|
326
329
|
}
|
|
327
330
|
updater();
|
|
328
331
|
}
|
|
332
|
+
getAnnotationMode() {
|
|
333
|
+
return __classPrivateFieldGet(this, _PdfViewer_annotationMode, "f");
|
|
334
|
+
}
|
|
329
335
|
getPrintUnits() {
|
|
330
336
|
return this.options.printResolution / PixelsPerInch.PDF;
|
|
331
337
|
}
|
|
@@ -851,7 +857,7 @@ export class PdfViewer extends Component {
|
|
|
851
857
|
// optionalContentConfigPromise,
|
|
852
858
|
// renderingQueue: this.renderingQueue,
|
|
853
859
|
textLayerMode: TextLayerMode.ENABLE,
|
|
854
|
-
annotationMode:
|
|
860
|
+
annotationMode: this.getAnnotationMode(),
|
|
855
861
|
// imageResourcesPath: this.imageResourcesPath,
|
|
856
862
|
// maxCanvasPixels: this.maxCanvasPixels,
|
|
857
863
|
// pageColors,
|
|
@@ -940,8 +946,16 @@ export class PdfViewer extends Component {
|
|
|
940
946
|
// and then revert
|
|
941
947
|
serializedAnnotationStorage = {};
|
|
942
948
|
originalAnnotationStorage = options.pdf.annotationStorage.getAll();
|
|
949
|
+
// With the form filling functionality enabled, values could be coming as pure JSON objects,
|
|
950
|
+
// thus the additional assertion.
|
|
943
951
|
Object.keys(originalAnnotationStorage).forEach((key) => {
|
|
944
|
-
|
|
952
|
+
var _a;
|
|
953
|
+
if (typeof ((_a = originalAnnotationStorage[key]) === null || _a === void 0 ? void 0 : _a.toJSON) === "function") {
|
|
954
|
+
serializedAnnotationStorage[key] = originalAnnotationStorage[key].toJSON();
|
|
955
|
+
}
|
|
956
|
+
else {
|
|
957
|
+
serializedAnnotationStorage[key] = originalAnnotationStorage[key];
|
|
958
|
+
}
|
|
945
959
|
});
|
|
946
960
|
Object.keys(originalAnnotationStorage).forEach((key) => {
|
|
947
961
|
options.pdf.annotationStorage.remove(key);
|
|
@@ -1628,7 +1642,7 @@ export class PdfViewer extends Component {
|
|
|
1628
1642
|
return true;
|
|
1629
1643
|
}
|
|
1630
1644
|
}
|
|
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() {
|
|
1645
|
+
_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
1646
|
// const visible = this._getVisiblePages();
|
|
1633
1647
|
// const visible = this._getVisiblePages();
|
|
1634
1648
|
const pagesToRefresh = [];
|
|
@@ -242,6 +242,9 @@ export class AnnotationEditorUIManager {
|
|
|
242
242
|
this._eventBus._on("setpreference", this.onSetPreference.bind(this), {
|
|
243
243
|
signal
|
|
244
244
|
});
|
|
245
|
+
this._eventBus._on("namedaction", this.onNamedAction.bind(this), {
|
|
246
|
+
signal
|
|
247
|
+
});
|
|
245
248
|
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addSelectionListener).call(this);
|
|
246
249
|
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addDragAndDropListeners).call(this);
|
|
247
250
|
__classPrivateFieldGet(this, _AnnotationEditorUIManager_instances, "m", _AnnotationEditorUIManager_addKeyboardManager).call(this);
|
|
@@ -388,6 +391,18 @@ export class AnnotationEditorUIManager {
|
|
|
388
391
|
default: break;
|
|
389
392
|
}
|
|
390
393
|
}
|
|
394
|
+
onNamedAction(event) {
|
|
395
|
+
// Processing a couple of named actions that might be useful, see also
|
|
396
|
+
// `PDFLinkService.executeNamedAction`.
|
|
397
|
+
switch (event.action) {
|
|
398
|
+
case "Print":
|
|
399
|
+
this.triggerPrinting();
|
|
400
|
+
break;
|
|
401
|
+
case "SaveAs":
|
|
402
|
+
this.downloadOrSave();
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
391
406
|
onPageChanging({ pageNumber }) {
|
|
392
407
|
__classPrivateFieldSet(this, _AnnotationEditorUIManager_currentPageIndex, pageNumber - 1, "f");
|
|
393
408
|
}
|
|
@@ -407,6 +422,16 @@ export class AnnotationEditorUIManager {
|
|
|
407
422
|
}
|
|
408
423
|
return null;
|
|
409
424
|
}
|
|
425
|
+
triggerPrinting() {
|
|
426
|
+
var _a;
|
|
427
|
+
(_a = this.pdfViewer) === null || _a === void 0 ? void 0 : _a.printFile();
|
|
428
|
+
}
|
|
429
|
+
downloadOrSave() {
|
|
430
|
+
var _a, _b;
|
|
431
|
+
(_a = this.pdfViewer) === null || _a === void 0 ? void 0 : _a.downloadFile({
|
|
432
|
+
fileName: (_b = this.pdfViewer) === null || _b === void 0 ? void 0 : _b.options.downloadFileName
|
|
433
|
+
});
|
|
434
|
+
}
|
|
410
435
|
disableUserSelect(value = false) {
|
|
411
436
|
var _a;
|
|
412
437
|
(_a = __classPrivateFieldGet(this, _AnnotationEditorUIManager_viewer, "f")) === null || _a === void 0 ? void 0 : _a.classList.toggle("noUserSelect", value);
|
|
@@ -154,9 +154,9 @@ class AnnotationLayerBuilder {
|
|
|
154
154
|
annotations,
|
|
155
155
|
// imageResourcesPath: this.imageResourcesPath,
|
|
156
156
|
renderForms: this.renderForms,
|
|
157
|
-
linkService: this.linkService
|
|
157
|
+
linkService: this.linkService,
|
|
158
158
|
// downloadManager: this.downloadManager,
|
|
159
|
-
|
|
159
|
+
annotationStorage: this.annotationStorage
|
|
160
160
|
// enableScripting: this.enableScripting,
|
|
161
161
|
// hasJSActions,
|
|
162
162
|
// fieldObjects,
|