@progress/kendo-pdfviewer-common 0.3.0-dev.202409251137 → 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 (153) 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/annotations.js +68 -0
  26. package/dist/es/common/component.js +33 -0
  27. package/dist/es/common/core.js +91 -0
  28. package/dist/es/common/dom.js +11 -0
  29. package/dist/es/common/main.js +4 -0
  30. package/dist/es/common/math.js +1 -0
  31. package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
  32. package/dist/es/links/link-service.js +505 -0
  33. package/dist/es/main.js +2 -0
  34. package/dist/es/scroller.js +29 -30
  35. package/dist/es/text/text-layer-builder.js +288 -0
  36. package/dist/es/utils.js +42 -14
  37. package/dist/es/widget/page.js +762 -0
  38. package/dist/es/widget/pdfviewer.js +1659 -0
  39. package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
  40. package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
  41. package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
  42. package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
  43. package/dist/es2015/annotations/annotation-layer.js +2793 -0
  44. package/dist/es2015/annotations/draw-layer-builder.js +65 -0
  45. package/dist/es2015/annotations/draw-layer.js +220 -0
  46. package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
  47. package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
  48. package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
  49. package/dist/es2015/annotations/editors/outliner.js +747 -0
  50. package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
  51. package/dist/es2015/annotations/helpers/color-manager.js +72 -0
  52. package/dist/es2015/annotations/helpers/command-manager.js +133 -0
  53. package/dist/es2015/annotations/helpers/id-manager.js +34 -0
  54. package/dist/es2015/annotations/helpers/image-manager.js +176 -0
  55. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
  56. package/dist/es2015/annotations/helpers/tools.js +19 -0
  57. package/dist/es2015/annotations/shared/display_utils.js +1024 -0
  58. package/dist/es2015/annotations/shared/event_utils.js +213 -0
  59. package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
  60. package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
  61. package/dist/es2015/annotations/shared/ui_utils.js +823 -0
  62. package/dist/es2015/annotations/shared/utils.js +909 -0
  63. package/dist/es2015/annotations.js +68 -0
  64. package/dist/es2015/common/component.js +33 -0
  65. package/dist/es2015/common/core.js +91 -0
  66. package/dist/es2015/common/dom.js +11 -0
  67. package/dist/es2015/common/main.js +4 -0
  68. package/dist/es2015/common/math.js +1 -0
  69. package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
  70. package/dist/es2015/links/link-service.js +505 -0
  71. package/dist/es2015/main.js +2 -0
  72. package/dist/es2015/scroller.js +29 -30
  73. package/dist/es2015/text/text-layer-builder.js +288 -0
  74. package/dist/es2015/utils.js +42 -14
  75. package/dist/es2015/widget/page.js +762 -0
  76. package/dist/es2015/widget/pdfviewer.js +1659 -0
  77. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
  78. package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
  79. package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
  80. package/dist/npm/annotations/annotation-editor-layer.js +783 -0
  81. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
  82. package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
  83. package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
  84. package/dist/npm/annotations/annotation-layer-builder.js +220 -0
  85. package/dist/npm/annotations/annotation-layer.d.ts +134 -0
  86. package/dist/npm/annotations/annotation-layer.js +2794 -0
  87. package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
  88. package/dist/npm/annotations/draw-layer-builder.js +68 -0
  89. package/dist/npm/annotations/draw-layer.d.ts +33 -0
  90. package/dist/npm/annotations/draw-layer.js +223 -0
  91. package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
  92. package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
  93. package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
  94. package/dist/npm/annotations/editors/free-text-editor.js +786 -0
  95. package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
  96. package/dist/npm/annotations/editors/highlight-editor.js +717 -0
  97. package/dist/npm/annotations/editors/outliner.d.ts +51 -0
  98. package/dist/npm/annotations/editors/outliner.js +750 -0
  99. package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
  100. package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
  101. package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
  102. package/dist/npm/annotations/helpers/color-manager.js +76 -0
  103. package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
  104. package/dist/npm/annotations/helpers/command-manager.js +137 -0
  105. package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
  106. package/dist/npm/annotations/helpers/id-manager.js +38 -0
  107. package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
  108. package/dist/npm/annotations/helpers/image-manager.js +180 -0
  109. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
  110. package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
  111. package/dist/npm/annotations/helpers/tools.d.ts +1 -0
  112. package/dist/npm/annotations/helpers/tools.js +23 -0
  113. package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
  114. package/dist/npm/annotations/shared/display_utils.js +1030 -0
  115. package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
  116. package/dist/npm/annotations/shared/event_utils.js +165 -0
  117. package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
  118. package/dist/npm/annotations/shared/murmurhash3.js +129 -0
  119. package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
  120. package/dist/npm/annotations/shared/scripting_utils.js +93 -0
  121. package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
  122. package/dist/npm/annotations/shared/ui_utils.js +250 -0
  123. package/dist/npm/annotations/shared/utils.d.ts +148 -0
  124. package/dist/npm/annotations/shared/utils.js +872 -0
  125. package/dist/npm/annotations.d.ts +23 -0
  126. package/dist/npm/annotations.js +72 -0
  127. package/dist/npm/common/component.d.ts +9 -0
  128. package/dist/npm/common/component.js +37 -0
  129. package/dist/npm/common/core.d.ts +18 -0
  130. package/dist/npm/common/core.js +112 -0
  131. package/dist/npm/common/dom.d.ts +3 -0
  132. package/dist/npm/common/dom.js +17 -0
  133. package/dist/npm/common/main.d.ts +4 -0
  134. package/dist/npm/common/main.js +7 -0
  135. package/dist/npm/common/math.d.ts +1 -0
  136. package/dist/npm/common/math.js +5 -0
  137. package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
  138. package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
  139. package/dist/npm/links/link-service.d.ts +116 -0
  140. package/dist/npm/links/link-service.js +501 -0
  141. package/dist/npm/main.d.ts +2 -0
  142. package/dist/npm/main.js +2 -0
  143. package/dist/npm/scroller.d.ts +7 -3
  144. package/dist/npm/scroller.js +32 -32
  145. package/dist/npm/text/text-layer-builder.d.ts +30 -0
  146. package/dist/npm/text/text-layer-builder.js +291 -0
  147. package/dist/npm/utils.d.ts +27 -3
  148. package/dist/npm/utils.js +51 -19
  149. package/dist/npm/widget/page.d.ts +75 -0
  150. package/dist/npm/widget/page.js +763 -0
  151. package/dist/npm/widget/pdfviewer.d.ts +222 -0
  152. package/dist/npm/widget/pdfviewer.js +1663 -0
  153. package/package.json +13 -9
@@ -0,0 +1,68 @@
1
+ import { createElement, scrollToPage } from './utils';
2
+ class Annotation {
3
+ constructor(container, viewport, annotation, pdfDoc, zoom, rootElement) {
4
+ this.container = container;
5
+ this.viewport = viewport;
6
+ this.zoom = zoom;
7
+ this.annotation = annotation;
8
+ this.pdfDoc = pdfDoc;
9
+ this.rootElement = rootElement;
10
+ }
11
+ destroy() {
12
+ }
13
+ }
14
+ export class LinkAnnotation extends Annotation {
15
+ constructor(container, viewport, annotation, pdfDoc, zoom, rootElement) {
16
+ super(container, viewport, annotation, pdfDoc, zoom, rootElement);
17
+ this.onLinkClick = (e) => {
18
+ const destination = e.target.getAttribute('href');
19
+ if (destination && destination.indexOf('#') === 0) {
20
+ this.navigateToDestination(destination);
21
+ e.preventDefault();
22
+ }
23
+ };
24
+ this.linkElement = null;
25
+ this.renderAnnotation();
26
+ this.bindEvents();
27
+ }
28
+ destroy() {
29
+ this.unbindEvents();
30
+ }
31
+ bindEvents() {
32
+ this.linkElement.addEventListener('click', this.onLinkClick);
33
+ }
34
+ unbindEvents() {
35
+ this.linkElement.removeEventListener('click', this.onLinkClick);
36
+ }
37
+ navigateToDestination(destination) {
38
+ const dest = destination.split('#')[1];
39
+ this.pdfDoc.getDestination(dest).then(r => {
40
+ this.pdfDoc.getPageIndex(r[0]).then(i => this.goToPage(i));
41
+ });
42
+ }
43
+ goToPage(pageNumber) {
44
+ scrollToPage(this.rootElement, pageNumber);
45
+ }
46
+ renderAnnotation() {
47
+ const annotation = this.annotation, viewport = this.viewport, rect = annotation.rect, boundingRect = [
48
+ [rect[0], rect[1]],
49
+ [rect[2], rect[3]]
50
+ ], rawHeight = viewport.rawDims.pageHeight;
51
+ const left = Math.min(boundingRect[0][0], boundingRect[1][0]) * this.zoom, top = (rawHeight - Math.max(boundingRect[0][1], boundingRect[1][1])) * this.zoom, width = (boundingRect[1][0] - boundingRect[0][0]) * this.zoom, height = (boundingRect[1][1] - boundingRect[0][1]) * this.zoom;
52
+ const url = annotation.url || (annotation.dest && `#${encodeURI(annotation.dest)}`);
53
+ const annotationElement = createElement('span', '', {
54
+ position: 'absolute',
55
+ left: left + 'pt',
56
+ top: top + 'pt'
57
+ });
58
+ const linkElement = this.linkElement = createElement('a', '', {
59
+ width: width + 'pt',
60
+ height: height + 'pt',
61
+ display: 'inline-block',
62
+ pointerEvents: 'auto'
63
+ });
64
+ linkElement.setAttribute('href', url);
65
+ annotationElement.append(linkElement);
66
+ this.container.append(annotationElement);
67
+ }
68
+ }
@@ -0,0 +1,33 @@
1
+ import { extend, deepExtend, isFunction } from "./core";
2
+ export class Component {
3
+ constructor(element, options) {
4
+ this.options = {
5
+ events: {}
6
+ };
7
+ this.element = element;
8
+ this.options = options;
9
+ }
10
+ destroy() {
11
+ this.element = null;
12
+ }
13
+ extendOptions(options) {
14
+ this.options = deepExtend(this.options, options);
15
+ }
16
+ setOptions(options) {
17
+ this.options = options;
18
+ }
19
+ trigger(eventName, args = {}) {
20
+ const eventData = {
21
+ defaultPrevented: false,
22
+ preventDefault: () => {
23
+ eventData.defaultPrevented = true;
24
+ }
25
+ };
26
+ if (isFunction(this.options.events[eventName])) {
27
+ this.options.events[eventName](extend(eventData, args, {
28
+ sender: this
29
+ }));
30
+ }
31
+ return eventData.defaultPrevented;
32
+ }
33
+ }
@@ -0,0 +1,91 @@
1
+ import { Component } from "./component";
2
+ // @ts-expect-error TS(2556): A spread argument must either have a tuple type or... Remove this comment to see the full error message
3
+ export const extend = (...args) => Object.assign(...args);
4
+ export const isObject = (value) => value && typeof (value) === "object" && !Array.isArray(value);
5
+ export const isHtmlElement = (element) => element instanceof HTMLElement;
6
+ export const isDomElement = (element) => element instanceof Element;
7
+ /* eslint-disable no-undef */
8
+ // @ts-expect-error TS(2304): Cannot find name 'DotNet'.
9
+ export const isDotNetObject = (value) => value && window && window.DotNet && window.DotNet.DotNetObject && value instanceof DotNet.DotNetObject;
10
+ /* eslint-enable no-undef */
11
+ export const deepExtend = (target, ...sources) => {
12
+ if (!sources.length) {
13
+ return target;
14
+ }
15
+ const source = sources.shift();
16
+ if (isObject(target) && isObject(source)) {
17
+ for (const key in source) {
18
+ if (source[key] instanceof Component) {
19
+ target[key] = source[key];
20
+ }
21
+ else if (isHtmlElement(source[key])) {
22
+ target[key] = source[key];
23
+ }
24
+ else if (key === "dotNetInstance" || isDotNetObject(source[key])) {
25
+ // avoid cloning a DotNetObject as it might have circular properties
26
+ // see https://github.com/telerik/blazor/issues/7507
27
+ // the check for the name of our own option - "dotNetInstance"
28
+ // is an additional guard against the Blazor API being different in other .NET versions
29
+ target[key] = source[key];
30
+ }
31
+ else if (source[key] && source[key].buffer && source[key].buffer instanceof ArrayBuffer) {
32
+ target[key] = source[key];
33
+ }
34
+ else if (isObject(source[key]) && Object.getPrototypeOf(source[key]) !== Object.prototype) {
35
+ target[key] = source[key];
36
+ }
37
+ else if (isObject(source[key])) {
38
+ if (!target[key] || !isObject(target[key])) {
39
+ extend(target, { [key]: {} });
40
+ }
41
+ deepExtend(target[key], source[key]);
42
+ }
43
+ else {
44
+ extend(target, { [key]: source[key] });
45
+ }
46
+ }
47
+ }
48
+ return deepExtend(target, ...sources);
49
+ };
50
+ export const isFunction = fn => typeof (fn) === "function";
51
+ export const isString = value => typeof (value) === "string";
52
+ export const toArray = value => Array.from(value);
53
+ export const isDefined = value => typeof (value) !== "undefined";
54
+ export const isNotNull = value => value !== null;
55
+ export const hasValue = value => isDefined(value) && isNotNull(value);
56
+ export const noop = function () { };
57
+ export const convertToHtml = (htmlString, ownerDocument) => {
58
+ const template = (ownerDocument || document).createElement('template');
59
+ template.innerHTML = htmlString.trim();
60
+ const content = template.content;
61
+ if (content.childNodes.length > 1) {
62
+ return content.childNodes;
63
+ }
64
+ return content.firstChild;
65
+ };
66
+ export const toPixel = value => parseFloat(value) + "px";
67
+ export const toClassSelector = (className) => (className === null || className === void 0 ? void 0 : className.startsWith(".")) ? className : `.${className}`;
68
+ export const mousewheelDelta = (e) => {
69
+ let delta = 0;
70
+ if (e.wheelDelta) {
71
+ delta = -e.wheelDelta / 120;
72
+ }
73
+ else if (e.detail) {
74
+ delta = e.detail / 3;
75
+ }
76
+ delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta);
77
+ return delta;
78
+ };
79
+ export const createPromise = () => {
80
+ let resolveFn;
81
+ let rejectFn;
82
+ const promise = new Promise(function (resolve, reject) {
83
+ resolveFn = resolve;
84
+ rejectFn = reject;
85
+ });
86
+ // @ts-expect-error TS(2339): Property 'resolve' does not exist on type 'Promise... Remove this comment to see the full error message
87
+ promise.resolve = resolveFn;
88
+ // @ts-expect-error TS(2339): Property 'reject' does not exist on type 'Promise<... Remove this comment to see the full error message
89
+ promise.reject = rejectFn;
90
+ return promise;
91
+ };
@@ -0,0 +1,11 @@
1
+ export const addClass = (className, element) => {
2
+ element.classList.add(className);
3
+ };
4
+ export const removeClass = (className, element) => {
5
+ element.classList.remove(className);
6
+ };
7
+ export const hasClass = (className, element) => {
8
+ if (element instanceof HTMLElement) {
9
+ return element.classList.contains(className);
10
+ }
11
+ };
@@ -0,0 +1,4 @@
1
+ export * from './component';
2
+ export * from './core';
3
+ export * from './dom';
4
+ export * from './math';
@@ -0,0 +1 @@
1
+ export const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
@@ -0,0 +1,6 @@
1
+ export var PdfViewerInteractionMode;
2
+ (function (PdfViewerInteractionMode) {
3
+ PdfViewerInteractionMode[PdfViewerInteractionMode["TextSelection"] = 0] = "TextSelection";
4
+ PdfViewerInteractionMode[PdfViewerInteractionMode["Pan"] = 1] = "Pan";
5
+ })(PdfViewerInteractionMode || (PdfViewerInteractionMode = {}));
6
+ ;