-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathConfig.ts
396 lines (365 loc) · 14 KB
/
Config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
export const Config = {
// Buttons define the various kinds of buttons for the viewer
Buttons: {
editToolButton: 'editToolButton',
viewControlsButton: 'viewControlsButton',
freeHandToolButton: 'freeHandToolButton',
highlightToolButton: 'highlightToolButton',
underlineToolButton: 'underlineToolButton',
squigglyToolButton: 'squigglyToolButton',
strikeoutToolButton: 'strikeoutToolButton',
rectangleToolButton: 'rectangleToolButton',
ellipseToolButton: 'ellipseToolButton',
lineToolButton: 'lineToolButton',
arrowToolButton: 'arrowToolButton',
polylineToolButton: 'polylineToolButton',
polygonToolButton: 'polygonToolButton',
cloudToolButton: 'cloudToolButton',
signatureToolButton: 'signatureToolButton',
freeTextToolButton: 'freeTextToolButton',
stickyToolButton: 'stickyToolButton',
calloutToolButton: 'calloutToolButton',
stampToolButton: 'stampToolButton',
toolsButton: 'toolsButton',
searchButton: 'searchButton',
shareButton: 'shareButton',
editPagesButton: 'editPagesButton',
viewLayersButton: 'viewLayersButton',
printButton: 'printButton',
closeButton: 'closeButton',
saveCopyButton: 'saveCopyButton',
saveIdenticalCopyButton: 'saveIdenticalCopyButton',
saveFlattenedCopyButton: 'saveFlattenedCopyButton',
formToolsButton: 'formToolsButton',
fillSignToolsButton: 'fillSignToolsButton',
moreItemsButton: 'moreItemsButton',
digitalSignatureButton: 'digitalSignatureButton',
thumbnailsButton: 'thumbnailsButton',
listsButton: 'listsButton',
thumbnailSlider: 'thumbnailSlider',
outlineListButton: 'outlineListButton',
annotationListButton: 'annotationListButton',
userBookmarkListButton: 'userBookmarkListButton',
reflowButton: 'reflowButton',
editMenuButton: 'editMenuButton',
cropPageButton: 'cropPageButton',
undo: 'undo',
redo: 'redo',
addPageButton: 'addPageButton',
insertPageButton: 'insertPageButton',
saveCroppedCopyButton: 'saveCroppedCopyButton',
// iOS only
InsertBlankPage: "insertBlankPageButton",
InsertFromImage: "insertFromImageButton",
InsertFromDocument: "insertFromDocumentButton",
InsertFromPhoto: "insertFromPhotoButton",
InsertFromScanner: "insertFromScannerButton",
// Android only
saveReducedCopyButton: 'saveReducedCopyButton',
savePasswordCopyButton: 'savePasswordCopyButton',
tabsButton: 'tabsButton',
fileAttachmentButton: 'fileAttachmentButton',
},
// Tools define the various kinds of tools for the viewer
Tools: {
annotationEdit: 'AnnotationEdit',
textSelect: 'TextSelect',
multiSelect: 'MultiSelect',
pan: 'Pan',
annotationEraserTool: 'AnnotationEraserTool',
annotationCountTool: 'AnnotationCountTool',
annotationCreateSticky: 'AnnotationCreateSticky',
annotationCreateFreeHand: 'AnnotationCreateFreeHand',
annotationCreateTextHighlight: 'AnnotationCreateTextHighlight',
annotationCreateTextUnderline: 'AnnotationCreateTextUnderline',
annotationCreateTextSquiggly: 'AnnotationCreateTextSquiggly',
annotationCreateTextStrikeout: 'AnnotationCreateTextStrikeout',
annotationCreateFreeText: 'AnnotationCreateFreeText',
annotationCreateCallout: 'AnnotationCreateCallout',
annotationCreateSignature: 'AnnotationCreateSignature',
annotationCreateLine: 'AnnotationCreateLine',
annotationCreateArrow: 'AnnotationCreateArrow',
annotationCreatePolyline: 'AnnotationCreatePolyline',
annotationCreateStamp: 'AnnotationCreateStamp',
annotationCreateRubberStamp: 'AnnotationCreateRubberStamp',
annotationCreateRectangle: 'AnnotationCreateRectangle',
annotationCreateEllipse: 'AnnotationCreateEllipse',
annotationCreatePolygon: 'AnnotationCreatePolygon',
annotationCreatePolygonCloud: 'AnnotationCreatePolygonCloud',
annotationCreateDistanceMeasurement: 'AnnotationCreateDistanceMeasurement',
annotationCreatePerimeterMeasurement: 'AnnotationCreatePerimeterMeasurement',
annotationCreateAreaMeasurement: 'AnnotationCreateAreaMeasurement',
annotationCreateFileAttachment: 'AnnotationCreateFileAttachment',
annotationCreateSound: 'AnnotationCreateSound',
annotationCreateRedaction: 'AnnotationCreateRedaction',
annotationCreateLink: 'AnnotationCreateLink',
annotationCreateRedactionText: 'AnnotationCreateRedactionText',
annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter',
annotationCreateSmartPen: 'AnnotationCreateSmartPen',
annotationCreateFreeTextDate: 'AnnotationCreateFreeTextDate',
formCreateTextField: 'FormCreateTextField',
formCreateCheckboxField: 'FormCreateCheckboxField',
formCreateSignatureField: 'FormCreateSignatureField',
formCreateRadioField: 'FormCreateRadioField',
formCreateComboBoxField: 'FormCreateComboBoxField',
formCreateListBoxField: 'FormCreateListBoxField',
formFill: 'FormFill',
annotationCreateCheckMarkStamp: 'AnnotationCreateCheckMarkStamp',
annotationCreateCrossMarkStamp: 'AnnotationCreateCrossMarkStamp',
annotationCreateDotStamp: 'AnnotationCreateDotStamp',
insertPage: 'InsertPage',
// iOS only.
pencilKitDrawing: 'PencilKitDrawing',
// Android only.
annotationCreateLinkText: 'AnnotationCreateLinkText',
annotationCreateRectAreaMeasurement: 'AnnotationCreateRectAreaMeasurement',
},
// FitMode define how a page should fit relative to the viewer, alternatively, the default zoom level
FitMode: {
FitPage: 'FitPage',
FitWidth: 'FitWidth',
FitHeight: 'FitHeight',
Zoom: 'Zoom',
},
// LayoutMode defines the layout mode of the viewer
LayoutMode: {
Single: 'Single',
Continuous: 'Continuous',
Facing: 'Facing',
FacingContinuous: 'FacingContinuous',
FacingCover: 'FacingCover',
FacingCoverContinuous: 'FacingCoverContinuous',
},
// FieldFlags define the property flags for a form field
FieldFlags: {
ReadOnly: 0,
Required: 1,
},
// AnnotationMenu defines the menu items when an annotation is selected
AnnotationMenu: {
style: 'style',
note: 'note',
copy: 'copy',
duplicate: 'duplicate',
delete: 'delete',
flatten: 'flatten',
editText: 'editText',
editInk: 'editInk',
search: 'search',
share: 'share',
markupType: 'markupType',
read: 'read',
screenCapture: 'screenCapture',
playSound: 'playSound',
openAttachment: 'openAttachment',
calibrate: 'calibrate',
group: 'group',
ungroup: 'ungroup',
},
// EraserType defines the type of eraser that will be used when eraser is selected
EraserType: {
annotationEraser: 'annotationEraser',
hybrideEraser: 'hybrideEraser',
inkEraser: 'inkEraser'
},
// LongPressMenu defines the menu items when a long press on empty space or text occurs
LongPressMenu: {
copy: 'copy',
paste: 'paste',
search: 'search',
share: 'share',
read: 'read',
},
// Actions define potentially overridable action to the viewer
Actions: {
linkPress: 'linkPress',
stickyNoteShowPopUp: 'stickyNoteShowPopUp',
},
// AnnotationFlags define the flags for any annotation in the document
AnnotationFlags: {
hidden: "hidden",
invisible: "invisible",
locked: "locked",
lockedContents: "lockedContents",
noRotate: "noRotate",
noView: "noView",
noZoom: "noZoom",
print: "print",
readOnly: "readOnly",
toggleNoView: "toggleNoView"
},
// DefaultToolbars define a set of pre-designed toolbars for easier customization
DefaultToolbars: {
View: "PDFTron_View",
Annotate: "PDFTron_Annotate",
Draw: "PDFTron_Draw",
Insert: "PDFTron_Insert",
FillAndSign: "PDFTron_Fill_and_Sign",
PrepareForm: "PDFTron_Prepare_Form",
Measure: "PDFTron_Measure",
Pens: "PDFTron_Pens",
Redaction: "PDFTron_Redact",
Favorite: "PDFTron_Favorite"
},
// ToolbarIcons define default toolbar icons for use for potential custom toolbars
ToolbarIcons: {
View: "PDFTron_View",
Annotate: "PDFTron_Annotate",
Draw: "PDFTron_Draw",
Insert: "PDFTron_Insert",
FillAndSign: "PDFTron_Fill_and_Sign",
PrepareForm: "PDFTron_Prepare_Form",
Measure: "PDFTron_Measure",
Pens: "PDFTron_Pens",
Redaction: "PDFTron_Redact",
Favorite: "PDFTron_Favorite"
},
// CustomToolbarKey defines the necessary keys for a custom toolbar
CustomToolbarKey: {
Id: "id",
Name: "name",
Icon: "icon",
Items: "items"
},
// CustomToolItemKey defines the necessary keys for a custom tool inside a custom toolbar
CustomToolItemKey: {
Id: "id",
Name: "name",
Icon: "icon"
},
// ThumbnailFilterMode defines filter modes in the thumbnails browser
ThumbnailFilterMode: {
Annotated: "annotated",
Bookmarked: "bookmarked",
},
// ThumbnailsViewItem defines actionss in the thumbnails browser
ThumbnailsViewItem: {
InsertBlankPage: "thumbnailsInsertPages",
ExportPages: "thumbnailsExportPages",
InsertFromImage: "thumbnailsInsertFromImage",
InsertFromDocument: "thumbnailsInsertFromDocument",
InsertFromPhoto: "thumbnailsInsertFromPhoto",
DuplicatePages: "thumbnailsDuplicatePages",
RotatePages: "thumbnailsRotatePages",
DeletePages: "thumbnailsDeletePages",
InsertFromScanner: "thumbnailsInsertFromScanner"
},
// Conversion defines conversion sources and destinations
Conversion: {
Screen: "screen",
Canvas: "canvas",
Page: "page",
},
// ViewModePickerItem defines view mode items in the view mode dialog
ViewModePickerItem: {
Crop: "viewModeCrop",
Rotation: "viewModeRotation",
ColorMode: "viewModeColorMode",
ReaderModeSettings: "viewModeReaderModeSettings",
},
// ZoomLimitMode defines the limit mode for zoom in the current document viewer
ZoomLimitMode: {
None: "none",
Absolute: "absolute",
Relative: "relative",
},
// OverprintMode defines when overprint would be applied in the viewer
OverprintMode: {
On: "on",
Off: "off",
OnlyPDFX: "pdfx", // only apply to PDF/X files
},
// ColorPostProcessMode defines color modifications after rendering in the viewer
ColorPostProcessMode: {
None: "none",
Invert: "invert",
GradientMap: "gradientMap",
NightMode: "nightMode"
},
// ReflowOrientation defines the scrolling direction when in reflow viewing mode
ReflowOrientation: {
Horizontal: 'horizontal',
Vertical: 'vertical',
},
// Export to format
ExportFormat: {
BMP: "BMP",
JPEG: "JPEG",
PNG: "PNG",
},
// AnnotationManagerEditMode determines whose changes can be edited.
AnnotationManagerEditMode: {
Own: "own",
All: "all",
},
// AnnotationManagerUndoMode determines whose changes can be undone.
AnnotationManagerUndoMode: {
Own: "own",
All: "all",
},
ThemeOptions: {
ThemeDark: "theme_dark",
ThemeLight: "theme_light",
},
} as const;
/**
* A generic used to create the custom types defined in the module below.
*
* The variable `T` represents the type information being passed into the generic.
* This generic accepts type information about the `Config` object above. We pass this
* information in using `typeof Config.*`, * is any object nested in the `Config` object.
*
* `keyof T` creates a union of the object's keys e.g
* `keyof typeof Config.ReflowOrientation == 'Horizonal' | 'Vertical'`
*
* `T[]` is the indexed access type and takes the union produced by a `keyof T` and outputs
* a union of value types corresponding to those keys, e.g.
* `ValueOf<typeof Config.ReflowOrientation> == "horizontal" | "vertical"`
*
* The above union is made up of string literal types because the `as const` operator sets the
* properties of the `Config` object to have literal types.
*
* You can learn more about these special operators here:
* - {@link https://www.typescriptlang.org/docs/handbook/2/typeof-types.html Typeof}
* - {@link https://www.typescriptlang.org/docs/handbook/2/keyof-types.html Keyof}
* - {@link https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html Index Acess Types}
* - {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions Const Assertions}
*/
type ValueOf<T> = T[keyof T];
/**
* A module containing custom types formed from the constants in the Config object.
*
* These types are used for props such as `disabledElements` and methods such as `exportAsImage`
*/
export module Config {
export type Buttons = ValueOf<typeof Config.Buttons>;
export type Tools = ValueOf<typeof Config.Tools>;
export type FitMode = ValueOf<typeof Config.FitMode>;
export type LayoutMode = ValueOf<typeof Config.LayoutMode>;
export type FieldFlags = ValueOf<typeof Config.FieldFlags>;
export type AnnotationMenu = ValueOf<typeof Config.AnnotationMenu>;
export type EraserType = ValueOf<typeof Config.EraserType>;
export type LongPressMenu = ValueOf<typeof Config.LongPressMenu>;
export type Actions = ValueOf<typeof Config.Actions>;
export type AnnotationFlags = ValueOf<typeof Config.AnnotationFlags>;
export type DefaultToolbars = ValueOf<typeof Config.DefaultToolbars>;
export type ToolbarIcons = ValueOf<typeof Config.ToolbarIcons>;
export type ThumbnailFilterMode = ValueOf<typeof Config.ThumbnailFilterMode>;
export type Conversion = ValueOf<typeof Config.Conversion>;
export type ViewModePickerItem = ValueOf<typeof Config.ViewModePickerItem>;
export type ThumbnailsViewItem = ValueOf<typeof Config.ThumbnailsViewItem>;
export type ZoomLimitMode = ValueOf<typeof Config.ZoomLimitMode>;
export type OverprintMode = ValueOf<typeof Config.OverprintMode>;
export type ColorPostProcessMode = ValueOf<typeof Config.ColorPostProcessMode>;
export type ReflowOrientation = ValueOf<typeof Config.ReflowOrientation>;
export type ExportFormat = ValueOf<typeof Config.ExportFormat>;
export type AnnotationManagerEditMode = ValueOf<typeof Config.AnnotationManagerEditMode>;
export type AnnotationManagerUndoMode = ValueOf<typeof Config.AnnotationManagerUndoMode>;
export type CustomToolbarKey = {
id: string;
name: string;
icon: ToolbarIcons;
items: (Tools | Buttons)[];
};
export type ThemeOptions = ValueOf<typeof Config.ThemeOptions>;
}