Skip to content

Commit 276b461

Browse files
feat: update pdf.js types to commit 2ae628f
1 parent 7509af7 commit 276b461

90 files changed

Lines changed: 8810 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
export type PDFPageProxy = import("./api").PDFPageProxy;
2+
export type PageViewport = import("./display_utils").PageViewport;
3+
export type TextAccessibilityManager = import("../../web/text_accessibility.js").TextAccessibilityManager;
4+
export type IDownloadManager = import("../../web/interfaces").IDownloadManager;
5+
export type IPDFLinkService = import("../../web/interfaces").IPDFLinkService;
6+
export type AnnotationEditorUIManager = any;
7+
export type StructTreeLayerBuilder = import("../../web/struct_tree_layer_builder.js").StructTreeLayerBuilder;
8+
export type AnnotationElementParameters = {
9+
data: Object;
10+
layer: HTMLDivElement;
11+
linkService: IPDFLinkService;
12+
downloadManager?: import("../../web/interfaces").IDownloadManager | undefined;
13+
annotationStorage?: AnnotationStorage | undefined;
14+
/**
15+
* - Path for image resources, mainly
16+
* for annotation icons. Include trailing slash.
17+
*/
18+
imageResourcesPath?: string | undefined;
19+
renderForms: boolean;
20+
svgFactory: Object;
21+
enableScripting?: boolean | undefined;
22+
hasJSActions?: boolean | undefined;
23+
fieldObjects?: Object | undefined;
24+
};
25+
export type AnnotationLayerParameters = {
26+
viewport: PageViewport;
27+
div: HTMLDivElement;
28+
annotations: any[];
29+
page: PDFPageProxy;
30+
linkService: IPDFLinkService;
31+
downloadManager?: import("../../web/interfaces").IDownloadManager | undefined;
32+
annotationStorage?: AnnotationStorage | undefined;
33+
/**
34+
* - Path for image resources, mainly
35+
* for annotation icons. Include trailing slash.
36+
*/
37+
imageResourcesPath?: string | undefined;
38+
renderForms: boolean;
39+
/**
40+
* - Enable embedded script execution.
41+
*/
42+
enableScripting?: boolean | undefined;
43+
/**
44+
* - Some fields have JS actions.
45+
* The default value is `false`.
46+
*/
47+
hasJSActions?: boolean | undefined;
48+
fieldObjects?: {
49+
[x: string]: Object[];
50+
} | null | undefined;
51+
annotationCanvasMap?: Map<string, HTMLCanvasElement> | undefined;
52+
accessibilityManager?: import("../../web/text_accessibility.js").TextAccessibilityManager | undefined;
53+
annotationEditorUIManager?: AnnotationEditorUIManager;
54+
structTreeLayer?: import("../../web/struct_tree_layer_builder.js").StructTreeLayerBuilder | undefined;
55+
};
56+
/**
57+
* @typedef {Object} AnnotationLayerParameters
58+
* @property {PageViewport} viewport
59+
* @property {HTMLDivElement} div
60+
* @property {Array} annotations
61+
* @property {PDFPageProxy} page
62+
* @property {IPDFLinkService} linkService
63+
* @property {IDownloadManager} [downloadManager]
64+
* @property {AnnotationStorage} [annotationStorage]
65+
* @property {string} [imageResourcesPath] - Path for image resources, mainly
66+
* for annotation icons. Include trailing slash.
67+
* @property {boolean} renderForms
68+
* @property {boolean} [enableScripting] - Enable embedded script execution.
69+
* @property {boolean} [hasJSActions] - Some fields have JS actions.
70+
* The default value is `false`.
71+
* @property {Object<string, Array<Object>> | null} [fieldObjects]
72+
* @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]
73+
* @property {TextAccessibilityManager} [accessibilityManager]
74+
* @property {AnnotationEditorUIManager} [annotationEditorUIManager]
75+
* @property {StructTreeLayerBuilder} [structTreeLayer]
76+
*/
77+
/**
78+
* Manage the layer containing all the annotations.
79+
*/
80+
export class AnnotationLayer {
81+
/**
82+
* @private
83+
*/
84+
private static get _defaultBorderStyle();
85+
constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, viewport, structTreeLayer, }: {
86+
div: any;
87+
accessibilityManager: any;
88+
annotationCanvasMap: any;
89+
annotationEditorUIManager: any;
90+
page: any;
91+
viewport: any;
92+
structTreeLayer: any;
93+
});
94+
div: any;
95+
page: any;
96+
viewport: any;
97+
zIndex: number;
98+
_annotationEditorUIManager: any;
99+
popupShow: any[] | undefined;
100+
hasEditableAnnotations(): boolean;
101+
/**
102+
* Render a new annotation layer with all annotation elements.
103+
*
104+
* @param {AnnotationLayerParameters} params
105+
* @memberof AnnotationLayer
106+
*/
107+
render(params: AnnotationLayerParameters): Promise<void>;
108+
/**
109+
* Add link annotations to the annotation layer.
110+
*
111+
* @param {Array<Object>} annotations
112+
* @param {IPDFLinkService} linkService
113+
* @memberof AnnotationLayer
114+
*/
115+
addLinkAnnotations(annotations: Array<Object>, linkService: IPDFLinkService): Promise<void>;
116+
/**
117+
* Update the annotation elements on existing annotation layer.
118+
*
119+
* @param {AnnotationLayerParameters} viewport
120+
* @memberof AnnotationLayer
121+
*/
122+
update({ viewport }: AnnotationLayerParameters): void;
123+
getEditableAnnotations(): any[];
124+
getEditableAnnotation(id: any): any;
125+
#private;
126+
}
127+
export class FreeTextAnnotationElement extends AnnotationElement {
128+
constructor(parameters: any);
129+
textContent: any;
130+
textPosition: any;
131+
annotationEditorType: number;
132+
render(): HTMLElement | undefined;
133+
}
134+
export class HighlightAnnotationElement extends AnnotationElement {
135+
constructor(parameters: any);
136+
annotationEditorType: number;
137+
render(): HTMLElement | undefined;
138+
}
139+
export class InkAnnotationElement extends AnnotationElement {
140+
constructor(parameters: any);
141+
containerClassName: string;
142+
svgElementName: string;
143+
annotationEditorType: number;
144+
render(): HTMLElement | undefined;
145+
getElementsToTriggerPopup(): any[];
146+
#private;
147+
}
148+
export class StampAnnotationElement extends AnnotationElement {
149+
constructor(parameters: any);
150+
annotationEditorType: number;
151+
render(): HTMLElement | undefined;
152+
}
153+
import { AnnotationStorage } from "./annotation_storage.js";
154+
declare class AnnotationElement {
155+
static _hasPopupData({ contentsObj, richText }: {
156+
contentsObj: any;
157+
richText: any;
158+
}): boolean;
159+
constructor(parameters: any, { isRenderable, ignoreBorder, createQuadrilaterals, }?: {
160+
isRenderable?: boolean | undefined;
161+
ignoreBorder?: boolean | undefined;
162+
createQuadrilaterals?: boolean | undefined;
163+
});
164+
isRenderable: boolean;
165+
data: any;
166+
layer: any;
167+
linkService: any;
168+
downloadManager: any;
169+
imageResourcesPath: any;
170+
renderForms: any;
171+
svgFactory: any;
172+
annotationStorage: any;
173+
enableScripting: any;
174+
hasJSActions: any;
175+
_fieldObjects: any;
176+
parent: any;
177+
container: HTMLElement | undefined;
178+
get _isEditable(): any;
179+
get hasPopupData(): boolean;
180+
updateEdited(params: any): void;
181+
popup: any;
182+
resetEdited(): void;
183+
/**
184+
* Create an empty container for the annotation's HTML element.
185+
*
186+
* @private
187+
* @param {boolean} ignoreBorder
188+
* @memberof AnnotationElement
189+
* @returns {HTMLElement} A section element.
190+
*/
191+
private _createContainer;
192+
setRotation(angle: any, container?: HTMLElement | undefined): void;
193+
get _commonActions(): any;
194+
_dispatchEventFromSandbox(actions: any, jsEvent: any): void;
195+
_setDefaultPropertiesFromJS(element: any): void;
196+
/**
197+
* Create quadrilaterals from the annotation's quadpoints.
198+
*
199+
* @private
200+
* @memberof AnnotationElement
201+
*/
202+
private _createQuadrilaterals;
203+
/**
204+
* Create a popup for the annotation's HTML element. This is used for
205+
* annotations that do not have a Popup entry in the dictionary, but
206+
* are of a type that works with popups (such as Highlight annotations).
207+
*
208+
* @param {Object} [popupData] - The data for the popup, if any.
209+
*
210+
* @private
211+
* @memberof AnnotationElement
212+
*/
213+
private _createPopup;
214+
get hasPopupElement(): boolean;
215+
/**
216+
* Render the annotation's HTML element(s).
217+
*
218+
* @public
219+
* @memberof AnnotationElement
220+
*/
221+
public render(): void;
222+
/**
223+
* @private
224+
* @returns {Array}
225+
*/
226+
private _getElementsByName;
227+
show(): void;
228+
hide(): void;
229+
/**
230+
* Get the HTML element(s) which can trigger a popup when clicked or hovered.
231+
*
232+
* @public
233+
* @memberof AnnotationElement
234+
* @returns {Array<HTMLElement>|HTMLElement} An array of elements or an
235+
* element.
236+
*/
237+
public getElementsToTriggerPopup(): Array<HTMLElement> | HTMLElement;
238+
addHighlightArea(): void;
239+
_editOnDoubleClick(): void;
240+
get width(): number;
241+
get height(): number;
242+
#private;
243+
}
244+
export {};
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* Key/value storage for annotation data in forms.
3+
*/
4+
export class AnnotationStorage {
5+
onSetModified: any;
6+
onResetModified: any;
7+
onAnnotationEditor: any;
8+
/**
9+
* Get the value for a given key if it exists, or return the default value.
10+
* @param {string} key
11+
* @param {Object} defaultValue
12+
* @returns {Object}
13+
*/
14+
getValue(key: string, defaultValue: Object): Object;
15+
/**
16+
* Get the value for a given key.
17+
* @param {string} key
18+
* @returns {Object}
19+
*/
20+
getRawValue(key: string): Object;
21+
/**
22+
* Remove a value from the storage.
23+
* @param {string} key
24+
*/
25+
remove(key: string): void;
26+
/**
27+
* Set the value for a given key
28+
* @param {string} key
29+
* @param {Object} value
30+
*/
31+
setValue(key: string, value: Object): void;
32+
/**
33+
* Check if the storage contains the given key.
34+
* @param {string} key
35+
* @returns {boolean}
36+
*/
37+
has(key: string): boolean;
38+
get size(): number;
39+
resetModified(): void;
40+
/**
41+
* @returns {PrintAnnotationStorage}
42+
*/
43+
get print(): PrintAnnotationStorage;
44+
/**
45+
* PLEASE NOTE: Only intended for usage within the API itself.
46+
* @ignore
47+
*/
48+
get serializable(): Readonly<{
49+
map: null;
50+
hash: "";
51+
transfer: undefined;
52+
}> | {
53+
map: Map<any, any>;
54+
hash: string;
55+
transfer: any[];
56+
};
57+
get editorStats(): any;
58+
resetModifiedIds(): void;
59+
/**
60+
* @returns {{ids: Set<string>, hash: string}}
61+
*/
62+
get modifiedIds(): {
63+
ids: Set<string>;
64+
hash: string;
65+
};
66+
[Symbol.iterator](): MapIterator<[any, any]>;
67+
#private;
68+
}
69+
/**
70+
* A special `AnnotationStorage` for use during printing, where the serializable
71+
* data is *frozen* upon initialization, to prevent scripting from modifying its
72+
* contents. (Necessary since printing is triggered synchronously in browsers.)
73+
*/
74+
export class PrintAnnotationStorage extends AnnotationStorage {
75+
constructor(parent: any);
76+
/**
77+
* PLEASE NOTE: Only intended for usage within the API itself.
78+
* @ignore
79+
*/
80+
get serializable(): {
81+
map: any;
82+
hash: any;
83+
transfer: any;
84+
};
85+
get modifiedIds(): any;
86+
#private;
87+
}
88+
export const SerializableEmpty: Readonly<{
89+
map: null;
90+
hash: "";
91+
transfer: undefined;
92+
}>;

0 commit comments

Comments
 (0)