@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.
Files changed (29) hide show
  1. package/dist/es/annotations/annotation-editor-ui-manager.js +25 -0
  2. package/dist/es/annotations/annotation-layer-builder.js +2 -2
  3. package/dist/es/annotations/annotation-layer.js +352 -337
  4. package/dist/es/annotations/helpers/annotation-storage.js +14 -0
  5. package/dist/es/annotations/shared/event_utils.js +6 -0
  6. package/dist/es/utils.js +2 -2
  7. package/dist/es/widget/page.js +1 -0
  8. package/dist/es/widget/pdfviewer.js +20 -6
  9. package/dist/es2015/annotations/annotation-editor-ui-manager.js +25 -0
  10. package/dist/es2015/annotations/annotation-layer-builder.js +2 -2
  11. package/dist/es2015/annotations/annotation-layer.js +352 -337
  12. package/dist/es2015/annotations/helpers/annotation-storage.js +14 -0
  13. package/dist/es2015/annotations/shared/event_utils.js +6 -0
  14. package/dist/es2015/utils.js +2 -2
  15. package/dist/es2015/widget/page.js +1 -0
  16. package/dist/es2015/widget/pdfviewer.js +20 -6
  17. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +3 -0
  18. package/dist/npm/annotations/annotation-editor-ui-manager.js +25 -0
  19. package/dist/npm/annotations/annotation-layer-builder.js +2 -2
  20. package/dist/npm/annotations/annotation-layer.js +352 -337
  21. package/dist/npm/annotations/helpers/annotation-storage.d.ts +10 -0
  22. package/dist/npm/annotations/helpers/annotation-storage.js +14 -0
  23. package/dist/npm/annotations/shared/event_utils.d.ts +4 -0
  24. package/dist/npm/annotations/shared/event_utils.js +6 -0
  25. package/dist/npm/utils.js +2 -2
  26. package/dist/npm/widget/page.js +1 -0
  27. package/dist/npm/widget/pdfviewer.d.ts +1 -0
  28. package/dist/npm/widget/pdfviewer.js +20 -6
  29. package/package.json +1 -1
@@ -12,6 +12,16 @@ declare class AnnotationStorage {
12
12
  onResetModified: any;
13
13
  onAnnotationEditor: any;
14
14
  constructor();
15
+ /**
16
+ * Get the value for the storage - used purely for debugging purposes.
17
+ * @returns {Object}
18
+ */
19
+ getStorage(): Map<any, any>;
20
+ /**
21
+ * Get the modified flag for the storage - used purely for debugging purposes.
22
+ * @returns {Object}
23
+ */
24
+ getModified(): boolean;
15
25
  /**
16
26
  * Get the value for a given key if it exists, or return the default value.
17
27
  * @param {string} key
@@ -49,6 +49,20 @@ class AnnotationStorage {
49
49
  this.onResetModified = null;
50
50
  this.onAnnotationEditor = null;
51
51
  }
52
+ /**
53
+ * Get the value for the storage - used purely for debugging purposes.
54
+ * @returns {Object}
55
+ */
56
+ getStorage() {
57
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f");
58
+ }
59
+ /**
60
+ * Get the modified flag for the storage - used purely for debugging purposes.
61
+ * @returns {Object}
62
+ */
63
+ getModified() {
64
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_modified, "f");
65
+ }
52
66
  /**
53
67
  * Get the value for a given key if it exists, or return the default value.
54
68
  * @param {string} key
@@ -4,6 +4,10 @@
4
4
  */
5
5
  declare class EventBus {
6
6
  #private;
7
+ /**
8
+ * Returs the current event listeners - used purely for debugging purposes.
9
+ */
10
+ getListeners(): any;
7
11
  /**
8
12
  * @param {string} eventName
9
13
  * @param {function} listener
@@ -67,6 +67,12 @@ class EventBus {
67
67
  constructor() {
68
68
  _EventBus_listeners.set(this, Object.create(null));
69
69
  }
70
+ /**
71
+ * Returs the current event listeners - used purely for debugging purposes.
72
+ */
73
+ getListeners() {
74
+ return tslib_1.__classPrivateFieldGet(this, _EventBus_listeners, "f");
75
+ }
70
76
  /**
71
77
  * @param {string} eventName
72
78
  * @param {function} listener
package/dist/npm/utils.js CHANGED
@@ -415,10 +415,10 @@ exports.scrollToPage = scrollToPage;
415
415
  */
416
416
  const currentPage = (rootElement) => {
417
417
  const scrollElement = rootElement.querySelector('.k-pdf-viewer-canvas');
418
- const page = rootElement.querySelector('.k-page');
418
+ const page = rootElement.querySelector('.k-page:not(.k-blank-page)');
419
419
  return scrollElement && page
420
420
  ? Math.floor(Math.round(scrollElement.scrollTop) /
421
- (page.offsetHeight + page.offsetTop) +
421
+ Math.max(1, page.offsetHeight + page.offsetTop) +
422
422
  0.01)
423
423
  : 0;
424
424
  };
@@ -92,6 +92,7 @@ class Page extends component_1.Component {
92
92
  // todo: ported from pdf.js
93
93
  this.pdfViewer = options.pdfViewer;
94
94
  this.pdfPage = options.pdfPage;
95
+ tslib_1.__classPrivateFieldSet(this, _Page_annotationMode, this.pdfViewer.getAnnotationMode(), "f");
95
96
  this.resetState();
96
97
  }
97
98
  destroy() {
@@ -39,6 +39,7 @@ export declare class PdfViewer extends Component {
39
39
  set annotationEditorParams({ type, value }: any);
40
40
  get annotationEditorMode(): any;
41
41
  set annotationEditorMode({ mode, editId, isFromKeyboard }: any);
42
+ getAnnotationMode(): number;
42
43
  getPrintUnits(): number;
43
44
  extendOptions(options: any): void;
44
45
  setOptions(options: any): void;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var _PdfViewer_instances, _PdfViewer_annotationEditorMode, _PdfViewer_switchAnnotationEditorModeTimeoutId, _PdfViewer_eventAbortController, _PdfViewer_onPageRenderedCallback, _PdfViewer_switchToEditAnnotationMode, _PdfViewer_scrollIntoView;
2
+ var _PdfViewer_instances, _PdfViewer_annotationEditorMode, _PdfViewer_switchAnnotationEditorModeTimeoutId, _PdfViewer_annotationMode, _PdfViewer_eventAbortController, _PdfViewer_onPageRenderedCallback, _PdfViewer_switchToEditAnnotationMode, _PdfViewer_scrollIntoView;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.PdfViewer = void 0;
5
5
  const tslib_1 = require("tslib");
@@ -52,6 +52,7 @@ class PdfViewer extends main_1.Component {
52
52
  zoomLevel: DEFAULT_ZOOM_LEVEL,
53
53
  zoomBeforePrint: false,
54
54
  zoomLevelForPrint: 3,
55
+ renderForms: false,
55
56
  searchMatchScrollLeftOffset: 0,
56
57
  // add some default offset, so that the found match
57
58
  // does not appear on the top edge of the page when navigated to
@@ -124,7 +125,7 @@ class PdfViewer extends main_1.Component {
124
125
  // #annotationEditorHighlightColors = null;
125
126
  // #annotationEditorMode = AnnotationEditorType.NONE;
126
127
  // #annotationEditorUIManager = null;
127
- // #annotationMode = AnnotationMode.ENABLE_FORMS;
128
+ _PdfViewer_annotationMode.set(this, utils_2.AnnotationMode.ENABLE);
128
129
  // #containerTopLeft = null;
129
130
  // #enableHWA = false;
130
131
  // #enableHighlightFloatingButton = false;
@@ -184,7 +185,7 @@ class PdfViewer extends main_1.Component {
184
185
  // as this can only be obtained by JS
185
186
  this.tryTriggerScroll = (e) => {
186
187
  let isPageChanged = false;
187
- const pageNumber = (0, utils_1.currentPage)(this.element) + 1;
188
+ const pageNumber = this.getCurrentPageIndex() + 1;
188
189
  if (pageNumber !== this.state.activePageNumber && (pageNumber >= 1 && pageNumber <= this.state.pdfDocument.numPages)) {
189
190
  isPageChanged = true;
190
191
  this.state.activePageNumber = pageNumber;
@@ -239,6 +240,8 @@ class PdfViewer extends main_1.Component {
239
240
  this.wrapper = this.element;
240
241
  this.initEventBus();
241
242
  tslib_1.__classPrivateFieldSet(this, _PdfViewer_eventAbortController, new AbortController(), "f");
243
+ if (this.options.renderForms)
244
+ tslib_1.__classPrivateFieldSet(this, _PdfViewer_annotationMode, utils_2.AnnotationMode.ENABLE_FORMS, "f");
242
245
  this.resetState();
243
246
  this.bindEvents();
244
247
  this.initLinkService();
@@ -329,6 +332,9 @@ class PdfViewer extends main_1.Component {
329
332
  }
330
333
  updater();
331
334
  }
335
+ getAnnotationMode() {
336
+ return tslib_1.__classPrivateFieldGet(this, _PdfViewer_annotationMode, "f");
337
+ }
332
338
  getPrintUnits() {
333
339
  return this.options.printResolution / pdf_mjs_1.PixelsPerInch.PDF;
334
340
  }
@@ -854,7 +860,7 @@ class PdfViewer extends main_1.Component {
854
860
  // optionalContentConfigPromise,
855
861
  // renderingQueue: this.renderingQueue,
856
862
  textLayerMode: ui_utils_1.TextLayerMode.ENABLE,
857
- annotationMode: utils_2.AnnotationMode.ENABLE,
863
+ annotationMode: this.getAnnotationMode(),
858
864
  // imageResourcesPath: this.imageResourcesPath,
859
865
  // maxCanvasPixels: this.maxCanvasPixels,
860
866
  // pageColors,
@@ -943,8 +949,16 @@ class PdfViewer extends main_1.Component {
943
949
  // and then revert
944
950
  serializedAnnotationStorage = {};
945
951
  originalAnnotationStorage = options.pdf.annotationStorage.getAll();
952
+ // With the form filling functionality enabled, values could be coming as pure JSON objects,
953
+ // thus the additional assertion.
946
954
  Object.keys(originalAnnotationStorage).forEach((key) => {
947
- serializedAnnotationStorage[key] = originalAnnotationStorage[key].toJSON();
955
+ var _a;
956
+ if (typeof ((_a = originalAnnotationStorage[key]) === null || _a === void 0 ? void 0 : _a.toJSON) === "function") {
957
+ serializedAnnotationStorage[key] = originalAnnotationStorage[key].toJSON();
958
+ }
959
+ else {
960
+ serializedAnnotationStorage[key] = originalAnnotationStorage[key];
961
+ }
948
962
  });
949
963
  Object.keys(originalAnnotationStorage).forEach((key) => {
950
964
  options.pdf.annotationStorage.remove(key);
@@ -1632,7 +1646,7 @@ class PdfViewer extends main_1.Component {
1632
1646
  }
1633
1647
  }
1634
1648
  exports.PdfViewer = PdfViewer;
1635
- _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() {
1649
+ _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() {
1636
1650
  // const visible = this._getVisiblePages();
1637
1651
  // const visible = this._getVisiblePages();
1638
1652
  const pagesToRefresh = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-pdfviewer-common",
3
3
  "description": "Kendo UI TypeScript package exporting functions for PDFViewer component",
4
- "version": "0.4.2-develop.1",
4
+ "version": "0.5.0-develop.1",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],