From 4f9aa56ed1456968bb2558c52843b597f6680e4b Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 22 Jul 2021 17:31:30 -0700 Subject: [PATCH 001/226] Add TS Support: * Created declaration files * Finished declarations for Config.js --- index.d.ts | 0 package.json | 1 + src/Config/config.d.ts | 264 ++++++++++++++++++++++++++++ src/Config/package.json | 3 +- src/DocumentView/document_view.d.ts | 114 ++++++++++++ src/DocumentView/package.json | 3 +- 6 files changed, 383 insertions(+), 2 deletions(-) create mode 100644 index.d.ts create mode 100644 src/Config/config.d.ts create mode 100644 src/DocumentView/document_view.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json index 99a8bf620..880de7f02 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "version": "2.0.3-beta.144", "description": "React Native Pdftron", "main": "index.js", + "typings": "./index.d.ts", "scripts": { "copy-to-repo": "cd scripts && python3 fileCopy.py toRepo && cd ..", "copy-to-node-modules": "cd scripts && python3 fileCopy.py toModule && cd .." diff --git a/src/Config/config.d.ts b/src/Config/config.d.ts new file mode 100644 index 000000000..6f049d59f --- /dev/null +++ b/src/Config/config.d.ts @@ -0,0 +1,264 @@ +export interface Buttons { + editToolButton: string; + viewControlsButton: string; + freeHandToolButton: string; + highlightToolButton: string; + underlineToolButton: string; + squigglyToolButton: string; + strikeoutToolButton: string; + rectangleToolButton: string; + ellipseToolButton: string; + lineToolButton: string; + arrowToolButton: string; + polylineToolButton: string; + polygonToolButton: string; + cloudToolButton: string; + signatureToolButton: string; + freeTextToolButton: string; + stickyToolButton: string; + calloutToolButton: string; + stampToolButton: string; + toolsButton: string; + searchButton: string; + shareButton: string; + editPagesButton: string; + viewLayersButton: string; + printButton: string; + closeButton: string; + saveCopyButton: string; + formToolsButton: string; + fillSignToolsButton: string; + moreItemsButton: string; + digitalSignatureButton: string; + thumbnailsButton: string; + listsButton: string; + thumbnailSlider: string; + outlineListButton: string; + annotationListButton: string; + userBookmarkListButton: string; + reflowButton: string; + editMenuButton: string; + cropPageButton: string; + undo: string; + redo: string; + addPageButton: string; +} + +export interface Tools { + annotationEdit: string; + textSelect: string; + pan: string; + annotationEraserTool: string; + annotationCreateSticky: string; + annotationCreateFreeHand: string; + annotationCreateTextHighlight: string; + annotationCreateTextUnderline: string; + annotationCreateTextSquiggly: string; + annotationCreateTextStrikeout: string; + annotationCreateFreeText: string; + annotationCreateCallout: string; + annotationCreateSignature: string; + annotationCreateLine: string; + annotationCreateArrow: string; + annotationCreatePolyline: string; + annotationCreateStamp: string; + annotationCreateRubberStamp: string; + annotationCreateRectangle: string; + annotationCreateEllipse: string; + annotationCreatePolygon: string; + annotationCreatePolygonCloud: string; + annotationCreateDistanceMeasurement: string; + annotationCreatePerimeterMeasurement: string; + annotationCreateAreaMeasurement: string; + annotationCreateFileAttachment: string; + annotationCreateSound: string; + annotationCreateRedaction: string; + annotationCreateLink: string; + annotationCreateRedactionText: string; + annotationCreateLinkText: string; + annotationCreateFreeHighlighter: string; + formCreateTextField: string; + formCreateCheckboxField: string; + formCreateSignatureField: string; + formCreateRadioField: string; + formCreateComboBoxField: string; + formCreateListBoxField: string; + pencilKitDrawing: string; +} + +export interface FitMode { + FitPage: string; + FitWidth: string; + FitHeight: string; + Zoom: string; +} + +export interface LayoutMode { + Single: string; + Continuous: string; + Facing: string, + FacingContinuous: string, + FacingCover: string, + FacingCoverContinuous: string, +} + +export interface FieldFlags { + ReadOnly: number; + Required: number; +} + +export interface AnnotationMenu { + style: string; + note: string; + copy: string; + delete: string; + flatten: string; + editText: string; + editInk: string; + search: string; + share: string; + markupType: string; + read: string; + screenCapture: string; + playSound: string; + openAttachment: string; + calibrate: string; +} + +export interface EraserType{ + annotationEraser: string; + hybrideEraser: string; + inkEraser: string; +} + +export interface LongPressMenu { + copy: string; + paste: string; + search: string; + share: string; + read: string; +} + +export interface Actions { + linkPress: string; + stickyNoteShowPopUp: string; +} + +export interface AnnotationFlags { + hidden: string; + invisible: string; + locked: string; + lockedContents: string; + noRotate: string; + noView: string; + noZoom: string; + print: string; + readOnly: string; + toggleNoView: string; +} + +export interface DefaultToolbars { + View:string; + Annotate:string; + Draw:string; + Insert:string; + FillAndSign: string, + PrepareForm: string, + Measure:string; + Pens:string; + Redaction:string; + Favorite:string; + } + +export interface ToolbarIcons { + View:string; + Annotate:string; + Draw:string; + Insert:string; + FillAndSign: string; + PrepareForm: string; + Measure:string; + Pens:string; + Redaction:string; + Favorite:string; +} + +export interface CustomToolbarKey { + Id: string; + Name: string; + Icon: string; + Items: string; +} + +export interface ThumbnailFilterMode { + Annotated: string; + Bookmarked: string; +} + +export interface Conversion { + Screen: string; + Canvas: string; + Page: string; +} + +export interface ViewModePickerItem { + Crop: string; + Rotation: string; + ColorMode: string; +} + +export interface ZoomLimitMode { + None: string; + Absolute: string; + Relative: string; +} + +export interface OverprintMode { + On: string; + Off: string; + OnlyPDFX: string; +} + +export interface ColorPostProcessMode { + None: string; + Invert: string; + GradientMap: string; + NightMode: string +} + +export interface ReflowOrientation { + Horizontal: string; + Vertical: string; + } + +export interface ExportFormat { + BMP: string; + JPEG: string; + PNG: string; +} + +export interface ConfigOptions { + Buttons: Buttons; + Tools: Tools; + FitMode: FitMode; + LayoutMode: LayoutMode; + FieldFlags: FieldFlags; + AnnotationMenu: AnnotationMenu; + EraserType: EraserType; + LongPressMenu: LongPressMenu; + Actions: Actions; + AnnotationFlags: AnnotationFlags; + DefaultToolbars: DefaultToolbars; + ToolbarIcons: ToolbarIcons; + CustomToolbarKey: CustomToolbarKey; + ThumbnailFilterMode: ThumbnailFilterMode; + Conversion: Conversion; + ViewPickerItemMode: ViewModePickerItem; + ZoomLimitMode: ZoomLimitMode; + OverprintMode: OverprintMode; + ColorPostProcessMode: ColorPostProcessMode; + ReflowOrientation: ReflowOrientation; + ExportFormat: ExportFormat; +} + +export const Config : ConfigOptions; \ No newline at end of file diff --git a/src/Config/package.json b/src/Config/package.json index 7d1405838..08df88038 100644 --- a/src/Config/package.json +++ b/src/Config/package.json @@ -2,5 +2,6 @@ "name": "Config", "version": "0.0.0", "private": true, - "main": "./Config" + "main": "./Config", + "typings": "./config.d.ts" } \ No newline at end of file diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts new file mode 100644 index 000000000..c9ff2589b --- /dev/null +++ b/src/DocumentView/document_view.d.ts @@ -0,0 +1,114 @@ +import { PureComponent } from "react"; +import { ViewProps } from "react-native"; +import { AnnotationMenu, Tools} from "react-native-pdftron/src/Config/config"; + +export interface Annotation { + id: string; + pageNumber: number; + type: string; + rect: object +} + +export interface Field { + fieldName: string; + fieldValue: string; +} + +export interface DocumentViewProps { + document: string; + password?: string; + initialPageNumber?: number; + pageNumber?: number; + customHeaders?: object; + leadingNavButtonIcon?: string; + showLeadingNavButton?: boolean; + onLeadingNavButtonPressed?: () => void; + onDocumentLoaded?: (event: {path : string}) => void; + onDocumentError?: (event: {error: string}) => void; + onPageChanged?: (event: {previousPageNumber: number, pageNumber: number}) => void; + onScrollChanged?: (event: {horizontal: number, vertical: number}) => void; + onZoomChanged?: (event: {zoom: number}) => void; + onZoomFinished?: (event: {zoom: number}) => void; + zoom?: number; + disabledElements: array; + disabledTools: array; + longPressMenuItems: array; + overrideLongPressMenuBehavior: array; + onLongPressMenuPress?: (event: {longPressMenu: string, longPressText: string}) => void; + longPressMenuEnabled?: boolean; + annotationMenuItems: array; + overrideAnnotationMenuBehavior: array; + onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; + hideAnnotationMenu: array; + overrideBehavior: array; + onBehaviorActivated?: (event: {action: string, data: object}) => void; + topToolbarEnabled?: boolean; + bottomToolbarEnabled?: boolean; + hideToolbarsOnTap?: boolean; + documentSliderEnabled?: boolean; + pageIndicatorEnabled?: boolean; + keyboardShortcutsEnabled?: boolean; + onAnnotationsSelected?: (event: {annotations: Array}) => void ; + onAnnotationChanged: (event: {action: string, annotations: Array}) => void; + onFormFieldValueChanged?: (event: {fields: Array}) => void; + readOnly?: boolean; + thumbnailViewEditingEnabled?: boolean; + fitMode?: string; + layoutMode?: string; + onLayoutChanged?: () => void; + padStatusBar?: boolean; + continuousAnnotationEditing?: boolean; + selectAnnotationAfterCreation?: boolean; + annotationAuthor?: string; + showSavedSignatures?: boolean; + isBase64String?: boolean; + collabEnabled?: boolean; + currentUser?: string; + currentUserName?: string; + onExportAnnotationCommand?: () => void; + autoSaveEnabled?: boolean; + pageChangeOnTap?: boolean; + followSystemDarkMode?: boolean; + useStylusAsPen?: boolean; + multiTabEnabled?: boolean; + tabTitle?: string; + maxTabCount?: number; + signSignatureFieldsWithStamps?: boolean; + annotationPermissionCheckEnabled?: boolean; + annotationToolbars?: array; + hideDefaultAnnotationToolbars: array; + topAppNavBarRightBar: array; + bottomToolbar: array; + hideAnnotationToolbarSwitcher?: boolean; + hideTopToolbars: boolean; + hideTopAppNavBar: boolean; + onBookmarkChanged: func; + hideThumbnailFilterModes: array; + onToolChanged: func; + horizontalScrollPos: number; + verticalScrollPos: number; + onTextSearchStart: func; + onTextSearchResult: func; + hideViewModeItems: array; + pageStackEnabled: boolean; + showQuickNavigationButton: boolean; + photoPickerEnabled: boolean; + autoResizeFreeTextEnabled: boolean; + annotationsListEditingEnabled: boolean; + showNavigationListAsSidePanelOnLargeDevices: boolean; + restrictDownloadUsage: boolean; + userBookmarksListEditingEnabled: boolean; + imageInReflowEnabled: boolean; + reflowOrientation: string; + onUndoRedoStateChanged: func; + tabletLayoutEnabled: boolean; + initialToolbar: string; + inkMultiStrokeEnabled: boolean; + defaultEraserType: string; + exportPath: string; + openUrlPath: string; + saveStateEnabled: boolean; + openSavedCopyInNewTab: boolean; +} + +export class DocumentView extends PureComponent{}; \ No newline at end of file diff --git a/src/DocumentView/package.json b/src/DocumentView/package.json index cdded820d..a923b44d7 100644 --- a/src/DocumentView/package.json +++ b/src/DocumentView/package.json @@ -2,5 +2,6 @@ "name": "DocumentView", "version": "0.0.0", "private": true, - "main": "./DocumentView" + "main": "./DocumentView", + "typings": "./document_view.d.ts" } \ No newline at end of file From 82a4d52ff228f02c3e55288f282b09fd4a967be8 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 22 Jul 2021 18:36:55 -0700 Subject: [PATCH 002/226] Completed the TS types for the DocumentView component --- index.d.ts | 2 + src/DocumentView/document_view.d.ts | 101 +++++++++++++++------------- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/index.d.ts b/index.d.ts index e69de29bb..8c36875b0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -0,0 +1,2 @@ +export {Config, ConfigOptions} from "./src/Config/config"; +export {DocumentView, DocumentViewProps, Annotation, Field, TextSelectionResult, Quads, Coords} from "./src/DocumentView/document_view"; \ No newline at end of file diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index c9ff2589b..bd93c5147 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -1,7 +1,5 @@ import { PureComponent } from "react"; import { ViewProps } from "react-native"; -import { AnnotationMenu, Tools} from "react-native-pdftron/src/Config/config"; - export interface Annotation { id: string; pageNumber: number; @@ -14,6 +12,19 @@ export interface Field { fieldValue: string; } +export interface Coords { + x: number; + y: number; +} + +export type Quads = [Coords, Coords, Coords, Coords]; + +export interface TextSelectionResult { + html: string; + pageNumber: number; + quads: Array +} + export interface DocumentViewProps { document: string; password?: string; @@ -30,17 +41,17 @@ export interface DocumentViewProps { onZoomChanged?: (event: {zoom: number}) => void; onZoomFinished?: (event: {zoom: number}) => void; zoom?: number; - disabledElements: array; - disabledTools: array; - longPressMenuItems: array; - overrideLongPressMenuBehavior: array; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; onLongPressMenuPress?: (event: {longPressMenu: string, longPressText: string}) => void; longPressMenuEnabled?: boolean; - annotationMenuItems: array; - overrideAnnotationMenuBehavior: array; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; - hideAnnotationMenu: array; - overrideBehavior: array; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; onBehaviorActivated?: (event: {action: string, data: object}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; @@ -49,7 +60,7 @@ export interface DocumentViewProps { pageIndicatorEnabled?: boolean; keyboardShortcutsEnabled?: boolean; onAnnotationsSelected?: (event: {annotations: Array}) => void ; - onAnnotationChanged: (event: {action: string, annotations: Array}) => void; + onAnnotationChanged?: (event: {action: string, annotations: Array}) => void; onFormFieldValueChanged?: (event: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; @@ -65,7 +76,7 @@ export interface DocumentViewProps { collabEnabled?: boolean; currentUser?: string; currentUserName?: string; - onExportAnnotationCommand?: () => void; + onExportAnnotationCommand?: (event: {action: string, xfdfCommand: string, annotations: Array}) => void; autoSaveEnabled?: boolean; pageChangeOnTap?: boolean; followSystemDarkMode?: boolean; @@ -75,40 +86,40 @@ export interface DocumentViewProps { maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: array; - hideDefaultAnnotationToolbars: array; - topAppNavBarRightBar: array; - bottomToolbar: array; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; hideAnnotationToolbarSwitcher?: boolean; - hideTopToolbars: boolean; - hideTopAppNavBar: boolean; - onBookmarkChanged: func; - hideThumbnailFilterModes: array; - onToolChanged: func; - horizontalScrollPos: number; - verticalScrollPos: number; - onTextSearchStart: func; - onTextSearchResult: func; - hideViewModeItems: array; - pageStackEnabled: boolean; - showQuickNavigationButton: boolean; - photoPickerEnabled: boolean; - autoResizeFreeTextEnabled: boolean; - annotationsListEditingEnabled: boolean; - showNavigationListAsSidePanelOnLargeDevices: boolean; - restrictDownloadUsage: boolean; - userBookmarksListEditingEnabled: boolean; - imageInReflowEnabled: boolean; - reflowOrientation: string; - onUndoRedoStateChanged: func; - tabletLayoutEnabled: boolean; - initialToolbar: string; - inkMultiStrokeEnabled: boolean; - defaultEraserType: string; - exportPath: string; - openUrlPath: string; - saveStateEnabled: boolean; - openSavedCopyInNewTab: boolean; + hideTopToolbars?: boolean; + hideTopAppNavBar?: boolean; + onBookmarkChanged?: (event: {bookmarkJson: string}) => void; + hideThumbnailFilterModes?: Array; + onToolChanged?: (event: {previousTool: string, tool: string}) => void; + horizontalScrollPos?: number; + verticalScrollPos?: number; + onTextSearchStart?: () => void; + onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult}) => void; + hideViewModeItems?: Array; + pageStackEnabled?: boolean; + showQuickNavigationButton?: boolean; + photoPickerEnabled?: boolean; + autoResizeFreeTextEnabled?: boolean; + annotationsListEditingEnabled?: boolean; + showNavigationListAsSidePanelOnLargeDevices?: boolean; + restrictDownloadUsage?: boolean; + userBookmarksListEditingEnabled?: boolean; + imageInReflowEnabled?: boolean; + reflowOrientation?: string; + onUndoRedoStateChanged?: () => void; + tabletLayoutEnabled?: boolean; + initialToolbar?: string; + inkMultiStrokeEnabled?: boolean; + defaultEraserType?: string; + exportPath?: string; + openUrlPath?: string; + saveStateEnabled?: boolean; + openSavedCopyInNewTab?: boolean; } export class DocumentView extends PureComponent{}; \ No newline at end of file From 12086002f8323e918a08ab881ae724c4a481a5e1 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 23 Jul 2021 09:00:50 -0700 Subject: [PATCH 003/226] Updates to the typings of DocumentView.js --- index.d.ts | 2 +- src/DocumentView/document_view.d.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 8c36875b0..3972e1ad3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,2 +1,2 @@ export {Config, ConfigOptions} from "./src/Config/config"; -export {DocumentView, DocumentViewProps, Annotation, Field, TextSelectionResult, Quads, Coords} from "./src/DocumentView/document_view"; \ No newline at end of file +export {DocumentView, DocumentViewProps, Annotation, Field, TextSelectionResult, Quad, Coords} from "./src/DocumentView/document_view"; \ No newline at end of file diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index bd93c5147..c00177fe4 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -17,15 +17,15 @@ export interface Coords { y: number; } -export type Quads = [Coords, Coords, Coords, Coords]; +export type Quad = [Coords, Coords, Coords, Coords]; export interface TextSelectionResult { html: string; pageNumber: number; - quads: Array + quads: Array | null; } -export interface DocumentViewProps { +export interface DocumentViewProps extends ViewProps{ document: string; password?: string; initialPageNumber?: number; @@ -122,4 +122,4 @@ export interface DocumentViewProps { openSavedCopyInNewTab?: boolean; } -export class DocumentView extends PureComponent{}; \ No newline at end of file +export class DocumentView extends PureComponent{}; \ No newline at end of file From 7fd93de65743aa5f87d55752c9502191207b4847 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 12:03:22 -0700 Subject: [PATCH 004/226] Use literals in config, add options file --- src/Config/config.d.ts | 22 +++++++++++----------- src/Config/config.options.d.ts | 5 +++++ 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 src/Config/config.options.d.ts diff --git a/src/Config/config.d.ts b/src/Config/config.d.ts index 6f049d59f..47ce3f5a7 100644 --- a/src/Config/config.d.ts +++ b/src/Config/config.d.ts @@ -144,17 +144,17 @@ export interface Actions { stickyNoteShowPopUp: string; } -export interface AnnotationFlags { - hidden: string; - invisible: string; - locked: string; - lockedContents: string; - noRotate: string; - noView: string; - noZoom: string; - print: string; - readOnly: string; - toggleNoView: string; +export type AnnotationFlags = { + hidden: "hidden", + invisible: "invisible", + locked: "locked", + lockedContents: "lockedContents", + noRotate: "noRotate", + noView: "noView", + noZoom: "noZoom", + print: "print", + readOnly: "readOnly", + toggleNoView: "toggleNoView" } export interface DefaultToolbars { diff --git a/src/Config/config.options.d.ts b/src/Config/config.options.d.ts new file mode 100644 index 000000000..39ce942bb --- /dev/null +++ b/src/Config/config.options.d.ts @@ -0,0 +1,5 @@ +import ConfigOptions from "./config"; + +type ValueOf = T[keyof T]; + +export type AnnotationFlagsOptions = ValueOf; \ No newline at end of file From f46f85afde388012bcad62aaba2a396aa3efbad5 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 12:29:37 -0700 Subject: [PATCH 005/226] Add DocumentView methods --- src/DocumentView/document_view.d.ts | 82 +++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index c00177fe4..055f8480f 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -1,13 +1,38 @@ +import { number } from "prop-types"; import { PureComponent } from "react"; import { ViewProps } from "react-native"; +import { Config } from "../Config/config"; export interface Annotation { id: string; pageNumber: number; type: string; - rect: object + rect: Rect +} + +export interface Rect { + x1: number; + y1: number; + x2: number; + y2: number; +} + +export interface Color { + red: number; + green: number; + blue: number; +} + +export interface CropBox extends Rect { + width: number; + height: number; } export interface Field { + fieldName: string; + fieldValue: string | boolean | number; +} + +export interface FieldWithStringValue { fieldName: string; fieldValue: string; } @@ -25,6 +50,23 @@ export interface TextSelectionResult { quads: Array | null; } +export interface AnnotationFlag { + id: string; + pageNumber: int; + flag: Config.AnnotationFlagsSet; + flagValue: boolean; +} + +export interface Properties { + rect?: Rect; + contents?: string; + subject?: string; + title?: string; + contentRect?: Rect; + customData?: object; + strokeColor?: Color; +} + export interface DocumentViewProps extends ViewProps{ document: string; password?: string; @@ -61,7 +103,7 @@ export interface DocumentViewProps extends ViewProps{ keyboardShortcutsEnabled?: boolean; onAnnotationsSelected?: (event: {annotations: Array}) => void ; onAnnotationChanged?: (event: {action: string, annotations: Array}) => void; - onFormFieldValueChanged?: (event: {fields: Array}) => void; + onFormFieldValueChanged?: (event: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; fitMode?: string; @@ -122,4 +164,38 @@ export interface DocumentViewProps extends ViewProps{ openSavedCopyInNewTab?: boolean; } -export class DocumentView extends PureComponent{}; \ No newline at end of file +export class DocumentView extends PureComponent{ + getDocumentPath: () => Promise | string; + setToolMode: (toolMode: string) => Promise; + commitTool: () => Promise | boolean; + getPageCount: () => Promise | number; + importBookmarkJson: (bookmarkJson: string) => Promise; + importAnnotationCommand: (xfdfCommand: string, initialLoad: boolean) => Promise; + importAnnotations: (xfdf: string) => Promise; + exportAnnotations: (options?: {annotList: Array}) => Promise | string; + flattenAnnotations: (formsOnly: boolean) => Promise; + deleteAnnotations: (annotations: Array) => Promise; + saveDocument: () => Promise | string; + setFlagForFields: (fields: Array, flag: number, value: boolean) => Promise; + getField: (fieldName: string) => Promise | {fieldName: string, fieldValue?: any, fieldType?: string}; + setValueForFields: (fieldsMap: Map<{fieldName: string, fieldValue: any}>) => Promise; + setValuesForFields: (fieldsMap: Map<{fieldName: string, fieldValue: any}>) => Promise; + handleBackButton: () => Promise | boolean; + setFlagForAnnotations: (annotationFlagList: Array) => Promise; + setFlagsForAnnotations: (annotationFlagList: Array) => Promise; + selectAnnotation: (id: string, pageNumber: number) => Promise; + setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: Properties) => Promise; + setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: Properties) => Promise; + getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | Properties; + setDrawAnnotations: (drawAnnotations: boolean) => Promise; + setVisibilityForAnnotation: (id: string, pageNumber: number, visibility: boolean) => Promise; + setHighlightFields: (highlightFields: boolean) => Promise; + getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | Annotation; + getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Array; + getAnnotationsOnPage: (pageNumber: number) => Promise | Array; + getCustomDataForAnnotation: (annotationID: string, pageNumber: integer, key: string) => Promise | string; + getPageCropBox: (pageNumber: number) => Promise | CropBox; + setCurrentPage: (pageNumber: number) => Promise | boolean; + getVisiblePages: () => Promise | Array; + // not done adding methods +}; \ No newline at end of file From c0e56b7b04765bc60a1a8d07c06d816db86d07d6 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 12:44:19 -0700 Subject: [PATCH 006/226] Add DocumentView methods --- src/DocumentView/document_view.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 055f8480f..4c6ef98d9 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -197,5 +197,21 @@ export class DocumentView extends PureComponent{ getPageCropBox: (pageNumber: number) => Promise | CropBox; setCurrentPage: (pageNumber: number) => Promise | boolean; getVisiblePages: () => Promise | Array; + gotoPreviousPage: () => Promise | boolean; + gotoNextPage: () => Promise | boolean; + gotoFirstPage: () => Promise | boolean; + gotoLastPage: () => Promise | boolean; + showGoToPageView: () => Promise; + closeAllTabs: () => Promise; + getZoom: () => Promise | number; + setZoomLimits: (zoomLimitMode: string, minimum: number, maximum: number) => Promise; + zoomWithCenter: (zoom: number, x: number, y: number) => Promise; + zoomToRect: (pageNumber: number, rect: Rect) => Promise; + smartZoom: (x: number, y: number, animated: boolean) => Promise; + getScrollPos: () => Promise | {horizontal: number, vertical: number}; + getCanvasSize: () => Promise | {width: number, height: number}; + getPageRotation: () => Promise | number; + rotateClockwise: () => Promise; + rotateCounterClockwise: () => Promise; // not done adding methods }; \ No newline at end of file From 93a716bdb8920a2eeb32f0f15e66af5a1dcb78b6 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 23 Jul 2021 14:09:00 -0700 Subject: [PATCH 007/226] Updated typings for Config.js --- index.d.ts | 18 ++ src/Config/config.d.ts | 356 ++++++++++++++++----------------- src/Config/config.options.d.ts | 22 +- 3 files changed, 217 insertions(+), 179 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3972e1ad3..42342bdfb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,2 +1,20 @@ +export interface Pdftron { + initialize(licenseKey: string) : void; + enableJavaScript(enabled: boolean) : void; + getVersion() : Promise; + gtPlatformVersion() : Promise; + getSystemFontList() : Promise; + clearRubberStampCache() : Promise; + encryptDocument(filePath: string, password: string, currentPassword: string) : Promise; + pdfFromOfficeTemplate(docxPath: string, json: object) : Promise; +}; + +export const RNPdftron : Pdftron; + export {Config, ConfigOptions} from "./src/Config/config"; +export {ButtonsOptions, ToolsOptions, FitModeOptions, LayoutModeOptions, + FieldFlagsOptions, AnnotationMenuOptions, ExportFormatOptions, LongPressMenuOptions, + ActionsOptions, AnnotationFlagsOptions, DefaultToolbarsOptions, ToolbarIconsOptions, + CustomToolbarKeyOptions, ThumbnailFilterModeOptions, ConversionOptions, ViewModePickerItemOptions, + ZoomLimitModeOptions, OverprintModeOptions, ColorPostProcessModeOptions, ReflowOrientationOptions, ExportFormatOptions} from "./src/Config/config.options"; export {DocumentView, DocumentViewProps, Annotation, Field, TextSelectionResult, Quad, Coords} from "./src/DocumentView/document_view"; \ No newline at end of file diff --git a/src/Config/config.d.ts b/src/Config/config.d.ts index 47ce3f5a7..679f3a8ce 100644 --- a/src/Config/config.d.ts +++ b/src/Config/config.d.ts @@ -1,240 +1,240 @@ export interface Buttons { - editToolButton: string; - viewControlsButton: string; - freeHandToolButton: string; - highlightToolButton: string; - underlineToolButton: string; - squigglyToolButton: string; - strikeoutToolButton: string; - rectangleToolButton: string; - ellipseToolButton: string; - lineToolButton: string; - arrowToolButton: string; - polylineToolButton: string; - polygonToolButton: string; - cloudToolButton: string; - signatureToolButton: string; - freeTextToolButton: string; - stickyToolButton: string; - calloutToolButton: string; - stampToolButton: string; - toolsButton: string; - searchButton: string; - shareButton: string; - editPagesButton: string; - viewLayersButton: string; - printButton: string; - closeButton: string; - saveCopyButton: string; - formToolsButton: string; - fillSignToolsButton: string; - moreItemsButton: string; - digitalSignatureButton: string; - thumbnailsButton: string; - listsButton: string; - thumbnailSlider: string; - outlineListButton: string; - annotationListButton: string; - userBookmarkListButton: string; - reflowButton: string; - editMenuButton: string; - cropPageButton: string; - undo: string; - redo: string; - addPageButton: string; + 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'; + 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'; } export interface Tools { - annotationEdit: string; - textSelect: string; - pan: string; - annotationEraserTool: string; - annotationCreateSticky: string; - annotationCreateFreeHand: string; - annotationCreateTextHighlight: string; - annotationCreateTextUnderline: string; - annotationCreateTextSquiggly: string; - annotationCreateTextStrikeout: string; - annotationCreateFreeText: string; - annotationCreateCallout: string; - annotationCreateSignature: string; - annotationCreateLine: string; - annotationCreateArrow: string; - annotationCreatePolyline: string; - annotationCreateStamp: string; - annotationCreateRubberStamp: string; - annotationCreateRectangle: string; - annotationCreateEllipse: string; - annotationCreatePolygon: string; - annotationCreatePolygonCloud: string; - annotationCreateDistanceMeasurement: string; - annotationCreatePerimeterMeasurement: string; - annotationCreateAreaMeasurement: string; - annotationCreateFileAttachment: string; - annotationCreateSound: string; - annotationCreateRedaction: string; - annotationCreateLink: string; - annotationCreateRedactionText: string; - annotationCreateLinkText: string; - annotationCreateFreeHighlighter: string; - formCreateTextField: string; - formCreateCheckboxField: string; - formCreateSignatureField: string; - formCreateRadioField: string; - formCreateComboBoxField: string; - formCreateListBoxField: string; - pencilKitDrawing: string; + annotationEdit: 'AnnotationEdit'; + textSelect: 'TextSelect'; + pan: 'Pan'; + annotationEraserTool: 'AnnotationEraserTool'; + 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'; + annotationCreateLinkText: 'AnnotationCreateLinkText'; + annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter'; + formCreateTextField: 'FormCreateTextField'; + formCreateCheckboxField: 'FormCreateCheckboxField'; + formCreateSignatureField: 'FormCreateSignatureField'; + formCreateRadioField: 'FormCreateRadioField'; + formCreateComboBoxField: 'FormCreateComboBoxField'; + formCreateListBoxField: 'FormCreateListBoxField'; + pencilKitDrawing: 'PencilKitDrawing'; } export interface FitMode { - FitPage: string; - FitWidth: string; - FitHeight: string; - Zoom: string; + FitPage: 'FitPage'; + FitWidth: 'FitWidth'; + FitHeight: 'FitHeight'; + Zoom: 'Zoom'; } export interface LayoutMode { - Single: string; - Continuous: string; - Facing: string, - FacingContinuous: string, - FacingCover: string, - FacingCoverContinuous: string, + Single: 'Single'; + Continuous: 'Continuous'; + Facing: 'Facing'; + FacingContinuous: 'FacingContinuous'; + FacingCover: 'FacingCover'; + FacingCoverContinuous: 'FacingCoverContinuous'; } export interface FieldFlags { - ReadOnly: number; - Required: number; + ReadOnly: 0; + Required: 1; } export interface AnnotationMenu { - style: string; - note: string; - copy: string; - delete: string; - flatten: string; - editText: string; - editInk: string; - search: string; - share: string; - markupType: string; - read: string; - screenCapture: string; - playSound: string; - openAttachment: string; - calibrate: string; + style: 'style'; + note: 'note'; + copy: 'copy'; + delete: 'delete'; + flatten: 'flatten'; + editText: 'editText'; + editInk: 'editInk'; + search: 'search'; + share: 'share'; + markupType: 'markupType'; + read: 'read'; + screenCapture: 'screenCapture'; + playSound: 'playSound'; + openAttachment: 'openAttachment'; + calibrate: 'calibrate'; } export interface EraserType{ - annotationEraser: string; - hybrideEraser: string; - inkEraser: string; + annotationEraser: 'annotationEraser'; + hybrideEraser: 'hybrideEraser'; + inkEraser: 'inkEraser'; } export interface LongPressMenu { - copy: string; - paste: string; - search: string; - share: string; - read: string; + copy: 'copy'; + paste: 'paste'; + search: 'search'; + share: 'share'; + read: 'read'; } export interface Actions { - linkPress: string; - stickyNoteShowPopUp: string; + linkPress: 'linkPress'; + stickyNoteShowPopUp: 'stickyNoteShowPopUp'; } -export type AnnotationFlags = { - hidden: "hidden", - invisible: "invisible", - locked: "locked", - lockedContents: "lockedContents", - noRotate: "noRotate", - noView: "noView", - noZoom: "noZoom", - print: "print", - readOnly: "readOnly", - toggleNoView: "toggleNoView" +export interface AnnotationFlags { + hidden: "hidden"; + invisible: "invisible"; + locked: "locked"; + lockedContents: "lockedContents"; + noRotate: "noRotate"; + noView: "noView"; + noZoom: "noZoom"; + print: "print"; + readOnly: "readOnly"; + toggleNoView: "toggleNoView"; } export interface DefaultToolbars { - View:string; - Annotate:string; - Draw:string; - Insert:string; - FillAndSign: string, - PrepareForm: string, - Measure:string; - Pens:string; - Redaction:string; - Favorite:string; + 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"; } export interface ToolbarIcons { - View:string; - Annotate:string; - Draw:string; - Insert:string; - FillAndSign: string; - PrepareForm: string; - Measure:string; - Pens:string; - Redaction:string; - Favorite:string; + 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"; } export interface CustomToolbarKey { - Id: string; - Name: string; - Icon: string; - Items: string; + Id: "id"; + Name: "name"; + Icon: "icon"; + Items: "items"; } export interface ThumbnailFilterMode { - Annotated: string; - Bookmarked: string; + Annotated: "annotated"; + Bookmarked: "bookmarked"; } export interface Conversion { - Screen: string; - Canvas: string; - Page: string; + Screen: "screen"; + Canvas: "canvas"; + Page: "page"; } export interface ViewModePickerItem { - Crop: string; - Rotation: string; - ColorMode: string; + Crop: "viewModeCrop"; + Rotation: "viewModeRotation"; + ColorMode: "viewModeColorMode"; } export interface ZoomLimitMode { - None: string; - Absolute: string; - Relative: string; + None: "none"; + Absolute: "absolute"; + Relative: "relative"; } export interface OverprintMode { - On: string; - Off: string; - OnlyPDFX: string; + On: "on"; + Off: "off"; + OnlyPDFX: "pdfx"; } export interface ColorPostProcessMode { - None: string; - Invert: string; - GradientMap: string; - NightMode: string + None: "none"; + Invert: "invert"; + GradientMap: "gradientMap"; + NightMode: "nightMode"; } export interface ReflowOrientation { - Horizontal: string; - Vertical: string; + Horizontal: 'horizontal'; + Vertical: 'vertical'; } export interface ExportFormat { - BMP: string; - JPEG: string; - PNG: string; + BMP: "BMP"; + JPEG: "JPEG"; + PNG: "PNG"; } export interface ConfigOptions { @@ -253,7 +253,7 @@ export interface ConfigOptions { CustomToolbarKey: CustomToolbarKey; ThumbnailFilterMode: ThumbnailFilterMode; Conversion: Conversion; - ViewPickerItemMode: ViewModePickerItem; + ViewModePickerItem: ViewModePickerItem; ZoomLimitMode: ZoomLimitMode; OverprintMode: OverprintMode; ColorPostProcessMode: ColorPostProcessMode; diff --git a/src/Config/config.options.d.ts b/src/Config/config.options.d.ts index 39ce942bb..85f5c6ea5 100644 --- a/src/Config/config.options.d.ts +++ b/src/Config/config.options.d.ts @@ -2,4 +2,24 @@ import ConfigOptions from "./config"; type ValueOf = T[keyof T]; -export type AnnotationFlagsOptions = ValueOf; \ No newline at end of file +export type ButtonsOptions = ValueOf; +export type ToolsOptions = ValueOf; +export type FitModeOptions = ValueOf; +export type LayoutModeOptions = ValueOf; +export type FieldFlagsOptions = ValueOf; +export type AnnotationMenuOptions = ValueOf; +export type EraserTypeOptions = ValueOf; +export type LongPressMenuOptions = ValueOf; +export type ActionsOptions = ValueOf; +export type AnnotationFlagsOptions = ValueOf; +export type DefaultToolbarsOptions = ValueOf; +export type ToolbarIconsOptions = ValueOf; +export type CustomToolbarKeyOptions = ValueOf; +export type ThumbnailFilterModeOptions = ValueOf; +export type ConversionOptions = ValueOf; +export type ViewModePickerItemOptions = ValueOf; +export type ZoomLimitModeOptions = ValueOf; +export type OverprintModeOptions = ValueOf; +export type ColorPostProcessModeOptions = ValueOf; +export type ReflowOrientationOptions = ValueOf; +export type ExportFormatOptions = ValueOf; \ No newline at end of file From cc6f16791ee9200b330fd7d58cf9666f20c6c654 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 14:21:58 -0700 Subject: [PATCH 008/226] Add DocumentView methods --- src/DocumentView/document_view.d.ts | 46 ++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 4c6ef98d9..1962f3dbd 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -1,3 +1,4 @@ +import { ConfigAPI } from "@babel/core"; import { number } from "prop-types"; import { PureComponent } from "react"; import { ViewProps } from "react-native"; @@ -37,17 +38,18 @@ export interface FieldWithStringValue { fieldValue: string; } -export interface Coords { +export interface Point { x: number; y: number; } -export type Quad = [Coords, Coords, Coords, Coords]; +export type Quad = [Point, Point, Point, Point]; export interface TextSelectionResult { - html: string; - pageNumber: number; - quads: Array | null; + html: string; + unicode: string; + pageNumber: number; + quads: Array; } export interface AnnotationFlag { @@ -141,7 +143,7 @@ export interface DocumentViewProps extends ViewProps{ horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; - onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult}) => void; + onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult?}) => void; hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; @@ -213,5 +215,35 @@ export class DocumentView extends PureComponent{ getPageRotation: () => Promise | number; rotateClockwise: () => Promise; rotateCounterClockwise: () => Promise; - // not done adding methods + convertScreenPointsToPagePoints: (points: Array) => Promise | Array; + convertPagePointsToScreenPoints: (points: Array) => Promise | Array; + getPageNumberFromScreenPoint: (x: number, y: number) => Promise | number; + setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; + setImageSmoothing: (imageSmoothing: boolean) => Promise; + setOverprint: (overprint: string) => Promise; + setColorPostProcessMode: (colorPostProcessMode: string) => Promise; + setColorPostProcessColors: (whiteColor: Color, blackColor: Color) => Promise; + findText: (searchString: string, matchCase: bool, matchWholeWord: bool, searchUp: bool, regExp: bool) => Promise; + cancelFindText: () => Promise; + getSelection: (pageNumber: number) => Promise | TextSelectionResult; + hasSelection: () => Promise | boolean; + clearSelection: () => Promise; + getSelectionPageRange: () => Promise | {begin: number, end: number}; + hasSelectionOnPage: (pageNumber: number) => Promise | boolean; + selectInRect: (rect: Rect) => Promise | boolean; + isThereTextInRect: (rect: Rect) => Promise | boolean; + selectAll: () => Promise; + setUrlExtraction: (urlExtraction: boolean) => Promise; + setPageBorderVisibility: (pageBorderVisibility: boolean) => Promise; + setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; + setDefaultPageColor: (defaultPageColor: Color) => Promise; + setBackgroundColor: (backgroundColor: Color) => Promise; + exportAsImage: (pageNumber: number, dpi: number, exportFormat: string) => Promise | string; + undo: () => Promise; + redo: () => Promise; + canUndo: () => Promise | boolean; + canRedo: () => Promise | boolean; + showCrop: () => Promise; + setCurrentToolbar: (toolbar: string) => Promise; + openThumbnailsView: () => Promise; }; \ No newline at end of file From ac98ff605fce13993677c23ff82363740ab38381 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 23 Jul 2021 15:38:48 -0700 Subject: [PATCH 009/226] Completed the typings for RNPdftron --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 42342bdfb..d772c1c96 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,13 +7,13 @@ export interface Pdftron { clearRubberStampCache() : Promise; encryptDocument(filePath: string, password: string, currentPassword: string) : Promise; pdfFromOfficeTemplate(docxPath: string, json: object) : Promise; -}; +} export const RNPdftron : Pdftron; export {Config, ConfigOptions} from "./src/Config/config"; export {ButtonsOptions, ToolsOptions, FitModeOptions, LayoutModeOptions, - FieldFlagsOptions, AnnotationMenuOptions, ExportFormatOptions, LongPressMenuOptions, + FieldFlagsOptions, AnnotationMenuOptions, LongPressMenuOptions, ActionsOptions, AnnotationFlagsOptions, DefaultToolbarsOptions, ToolbarIconsOptions, CustomToolbarKeyOptions, ThumbnailFilterModeOptions, ConversionOptions, ViewModePickerItemOptions, ZoomLimitModeOptions, OverprintModeOptions, ColorPostProcessModeOptions, ReflowOrientationOptions, ExportFormatOptions} from "./src/Config/config.options"; From dcd5db9ab7ff0b453963941520a6e29a4754dd62 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 15:57:52 -0700 Subject: [PATCH 010/226] Refactor options --- src/Config/config.d.ts | 4 +-- src/Config/config.options.d.ts | 44 ++++++++++++++--------------- src/DocumentView/document_view.d.ts | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Config/config.d.ts b/src/Config/config.d.ts index 679f3a8ce..7e8a638f0 100644 --- a/src/Config/config.d.ts +++ b/src/Config/config.d.ts @@ -237,7 +237,7 @@ export interface ExportFormat { PNG: "PNG"; } -export interface ConfigOptions { +export interface Config { Buttons: Buttons; Tools: Tools; FitMode: FitMode; @@ -261,4 +261,4 @@ export interface ConfigOptions { ExportFormat: ExportFormat; } -export const Config : ConfigOptions; \ No newline at end of file +export const Config : Config; \ No newline at end of file diff --git a/src/Config/config.options.d.ts b/src/Config/config.options.d.ts index 85f5c6ea5..59f03aeac 100644 --- a/src/Config/config.options.d.ts +++ b/src/Config/config.options.d.ts @@ -1,25 +1,25 @@ -import ConfigOptions from "./config"; +import Config from "./config"; type ValueOf = T[keyof T]; -export type ButtonsOptions = ValueOf; -export type ToolsOptions = ValueOf; -export type FitModeOptions = ValueOf; -export type LayoutModeOptions = ValueOf; -export type FieldFlagsOptions = ValueOf; -export type AnnotationMenuOptions = ValueOf; -export type EraserTypeOptions = ValueOf; -export type LongPressMenuOptions = ValueOf; -export type ActionsOptions = ValueOf; -export type AnnotationFlagsOptions = ValueOf; -export type DefaultToolbarsOptions = ValueOf; -export type ToolbarIconsOptions = ValueOf; -export type CustomToolbarKeyOptions = ValueOf; -export type ThumbnailFilterModeOptions = ValueOf; -export type ConversionOptions = ValueOf; -export type ViewModePickerItemOptions = ValueOf; -export type ZoomLimitModeOptions = ValueOf; -export type OverprintModeOptions = ValueOf; -export type ColorPostProcessModeOptions = ValueOf; -export type ReflowOrientationOptions = ValueOf; -export type ExportFormatOptions = ValueOf; \ No newline at end of file +export type Buttons = ValueOf; +export type Tools = ValueOf; +export type FitMode = ValueOf; +export type LayoutMode = ValueOf; +export type FieldFlags = ValueOf; +export type AnnotationMenu = ValueOf; +export type EraserType = ValueOf; +export type LongPressMenu = ValueOf; +export type Actions = ValueOf; +export type AnnotationFlags = ValueOf; +export type DefaultToolbars = ValueOf; +export type ToolbarIcons = ValueOf; +export type CustomToolbarKey = ValueOf; +export type ThumbnailFilterMode = ValueOf; +export type Conversion = ValueOf; +export type ViewModePickerItem = ValueOf; +export type ZoomLimitMode = ValueOf; +export type OverprintMode = ValueOf; +export type ColorPostProcessMode = ValueOf; +export type ReflowOrientation = ValueOf; +export type ExportFormat = ValueOf; \ No newline at end of file diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 1962f3dbd..dfa82b3f8 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -2,12 +2,12 @@ import { ConfigAPI } from "@babel/core"; import { number } from "prop-types"; import { PureComponent } from "react"; import { ViewProps } from "react-native"; -import { Config } from "../Config/config"; +import * as ConfigOptions from "react-native-pdftron/src/Config/config.options"; export interface Annotation { id: string; pageNumber: number; type: string; - rect: Rect + rect: Rect; } export interface Rect { From b93278cbd29dc54b0d4cd5a6f024cd45309f967e Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 23 Jul 2021 16:42:49 -0700 Subject: [PATCH 011/226] Updated: * Typings of the DocumentView props * API docs of onDocumentLoaded and onDocumentError --- API.md | 14 +++++- src/DocumentView/document_view.d.ts | 71 ++++++++++++++--------------- 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/API.md b/API.md index d85fcc269..1cec561f5 100644 --- a/API.md +++ b/API.md @@ -289,6 +289,12 @@ function, optional This function is called when the document finishes loading. +Parameters: + +Name | Type | Description +--- | --- | --- +path | string | File path that the document has been saved to + ```js { @@ -302,6 +308,12 @@ function, optional This function is called when document opening encounters an error. +Parameters: + +Name | Type | Description +--- | --- | --- +error | string | Error message produced + ```js { @@ -2361,7 +2373,7 @@ Parameters: Name | Type | Description --- | --- | --- -zoomLimitMode | String | one of the constants in `Config.ZoomLimitMode`, defines whether bounds are relative to the standard zoom scale in the current viewer or absolute +zoomLimitMode | String | one of the constants in [`Config.ZoomLimitMode`](./src/Config/Config.js), defines whether bounds are relative to the standard zoom scale in the current viewer or absolute minimum | double | the lower bound of the zoom limit range maximum | double | the upper bound of the zoom limit range diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index dfa82b3f8..3f18ac712 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -1,13 +1,12 @@ -import { ConfigAPI } from "@babel/core"; -import { number } from "prop-types"; + import { PureComponent } from "react"; import { ViewProps } from "react-native"; import * as ConfigOptions from "react-native-pdftron/src/Config/config.options"; export interface Annotation { id: string; - pageNumber: number; - type: string; - rect: Rect; + pageNumber?: number; + type?: string; + rect?: Rect; } export interface Rect { @@ -54,12 +53,12 @@ export interface TextSelectionResult { export interface AnnotationFlag { id: string; - pageNumber: int; - flag: Config.AnnotationFlagsSet; + pageNumber: number; + flag: ConfigOptions.AnnotationFlags; flagValue: boolean; } -export interface Properties { +export interface AnnotationProperties { rect?: Rect; contents?: string; subject?: string; @@ -69,7 +68,7 @@ export interface Properties { strokeColor?: Color; } -export interface DocumentViewProps extends ViewProps{ +export interface DocumentViewProps extends ViewProps { document: string; password?: string; initialPageNumber?: number; @@ -85,17 +84,17 @@ export interface DocumentViewProps extends ViewProps{ onZoomChanged?: (event: {zoom: number}) => void; onZoomFinished?: (event: {zoom: number}) => void; zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; onLongPressMenuPress?: (event: {longPressMenu: string, longPressText: string}) => void; longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; onBehaviorActivated?: (event: {action: string, data: object}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; @@ -130,21 +129,21 @@ export interface DocumentViewProps extends ViewProps{ maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; hideAnnotationToolbarSwitcher?: boolean; hideTopToolbars?: boolean; hideTopAppNavBar?: boolean; onBookmarkChanged?: (event: {bookmarkJson: string}) => void; - hideThumbnailFilterModes?: Array; + hideThumbnailFilterModes?: Array; onToolChanged?: (event: {previousTool: string, tool: string}) => void; horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; - onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult?}) => void; - hideViewModeItems?: Array; + onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult}) => void; + hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; photoPickerEnabled?: boolean; @@ -166,7 +165,7 @@ export interface DocumentViewProps extends ViewProps{ openSavedCopyInNewTab?: boolean; } -export class DocumentView extends PureComponent{ +export class DocumentView extends PureComponent { getDocumentPath: () => Promise | string; setToolMode: (toolMode: string) => Promise; commitTool: () => Promise | boolean; @@ -180,22 +179,22 @@ export class DocumentView extends PureComponent{ saveDocument: () => Promise | string; setFlagForFields: (fields: Array, flag: number, value: boolean) => Promise; getField: (fieldName: string) => Promise | {fieldName: string, fieldValue?: any, fieldType?: string}; - setValueForFields: (fieldsMap: Map<{fieldName: string, fieldValue: any}>) => Promise; - setValuesForFields: (fieldsMap: Map<{fieldName: string, fieldValue: any}>) => Promise; + setValueForFields: (fieldsMap: Map) => Promise; + setValuesForFields: (fieldsMap: Map) => Promise; handleBackButton: () => Promise | boolean; setFlagForAnnotations: (annotationFlagList: Array) => Promise; setFlagsForAnnotations: (annotationFlagList: Array) => Promise; selectAnnotation: (id: string, pageNumber: number) => Promise; - setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: Properties) => Promise; - setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: Properties) => Promise; - getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | Properties; + setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotationProperties) => Promise; + setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotationProperties) => Promise; + getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | AnnotationProperties; setDrawAnnotations: (drawAnnotations: boolean) => Promise; setVisibilityForAnnotation: (id: string, pageNumber: number, visibility: boolean) => Promise; setHighlightFields: (highlightFields: boolean) => Promise; getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | Annotation; getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Array; getAnnotationsOnPage: (pageNumber: number) => Promise | Array; - getCustomDataForAnnotation: (annotationID: string, pageNumber: integer, key: string) => Promise | string; + getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | string; getPageCropBox: (pageNumber: number) => Promise | CropBox; setCurrentPage: (pageNumber: number) => Promise | boolean; getVisiblePages: () => Promise | Array; @@ -206,7 +205,7 @@ export class DocumentView extends PureComponent{ showGoToPageView: () => Promise; closeAllTabs: () => Promise; getZoom: () => Promise | number; - setZoomLimits: (zoomLimitMode: string, minimum: number, maximum: number) => Promise; + setZoomLimits: (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number) => Promise; zoomWithCenter: (zoom: number, x: number, y: number) => Promise; zoomToRect: (pageNumber: number, rect: Rect) => Promise; smartZoom: (x: number, y: number, animated: boolean) => Promise; @@ -221,9 +220,9 @@ export class DocumentView extends PureComponent{ setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; setImageSmoothing: (imageSmoothing: boolean) => Promise; setOverprint: (overprint: string) => Promise; - setColorPostProcessMode: (colorPostProcessMode: string) => Promise; + setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; setColorPostProcessColors: (whiteColor: Color, blackColor: Color) => Promise; - findText: (searchString: string, matchCase: bool, matchWholeWord: bool, searchUp: bool, regExp: bool) => Promise; + findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; getSelection: (pageNumber: number) => Promise | TextSelectionResult; hasSelection: () => Promise | boolean; @@ -238,7 +237,7 @@ export class DocumentView extends PureComponent{ setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; setDefaultPageColor: (defaultPageColor: Color) => Promise; setBackgroundColor: (backgroundColor: Color) => Promise; - exportAsImage: (pageNumber: number, dpi: number, exportFormat: string) => Promise | string; + exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | string; undo: () => Promise; redo: () => Promise; canUndo: () => Promise | boolean; @@ -246,4 +245,4 @@ export class DocumentView extends PureComponent{ showCrop: () => Promise; setCurrentToolbar: (toolbar: string) => Promise; openThumbnailsView: () => Promise; -}; \ No newline at end of file +} \ No newline at end of file From eff4504eedc8a37dc25c427a623f575238fd512e Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 17:11:39 -0700 Subject: [PATCH 012/226] Use literals in method params --- src/DocumentView/document_view.d.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 3f18ac712..98a9a6e00 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -22,6 +22,8 @@ export interface Color { blue: number; } +export type RotationDegree = 0 | 90 | 180 | 270; + export interface CropBox extends Rect { width: number; height: number; @@ -42,6 +44,10 @@ export interface Point { y: number; } +export interface PointWithPage extends Point { + pageNumber?: number; +} + export type Quad = [Point, Point, Point, Point]; export interface TextSelectionResult { @@ -167,7 +173,7 @@ export interface DocumentViewProps extends ViewProps { export class DocumentView extends PureComponent { getDocumentPath: () => Promise | string; - setToolMode: (toolMode: string) => Promise; + setToolMode: (toolMode: ConfigOptions.Tools) => Promise; commitTool: () => Promise | boolean; getPageCount: () => Promise | number; importBookmarkJson: (bookmarkJson: string) => Promise; @@ -177,7 +183,7 @@ export class DocumentView extends PureComponent { flattenAnnotations: (formsOnly: boolean) => Promise; deleteAnnotations: (annotations: Array) => Promise; saveDocument: () => Promise | string; - setFlagForFields: (fields: Array, flag: number, value: boolean) => Promise; + setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; getField: (fieldName: string) => Promise | {fieldName: string, fieldValue?: any, fieldType?: string}; setValueForFields: (fieldsMap: Map) => Promise; setValuesForFields: (fieldsMap: Map) => Promise; @@ -211,20 +217,20 @@ export class DocumentView extends PureComponent { smartZoom: (x: number, y: number, animated: boolean) => Promise; getScrollPos: () => Promise | {horizontal: number, vertical: number}; getCanvasSize: () => Promise | {width: number, height: number}; - getPageRotation: () => Promise | number; + getPageRotation: () => Promise | RotationDegree; rotateClockwise: () => Promise; rotateCounterClockwise: () => Promise; - convertScreenPointsToPagePoints: (points: Array) => Promise | Array; - convertPagePointsToScreenPoints: (points: Array) => Promise | Array; + convertScreenPointsToPagePoints: (points: Array) => Promise | Array; + convertPagePointsToScreenPoints: (points: Array) => Promise | Array; getPageNumberFromScreenPoint: (x: number, y: number) => Promise | number; setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; setImageSmoothing: (imageSmoothing: boolean) => Promise; - setOverprint: (overprint: string) => Promise; + setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; setColorPostProcessColors: (whiteColor: Color, blackColor: Color) => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | TextSelectionResult; + getSelection: (pageNumber: number) => Promise | TextSelectionResult?; hasSelection: () => Promise | boolean; clearSelection: () => Promise; getSelectionPageRange: () => Promise | {begin: number, end: number}; From 5c508c18dedbca9e9d3417f46ac7d70439eb24cf Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 23 Jul 2021 17:20:32 -0700 Subject: [PATCH 013/226] PDFViewCtrl TS support --- src/PDFViewCtrl/pdf_view_ctrl.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/PDFViewCtrl/pdf_view_ctrl.d.ts diff --git a/src/PDFViewCtrl/pdf_view_ctrl.d.ts b/src/PDFViewCtrl/pdf_view_ctrl.d.ts new file mode 100644 index 000000000..dad3fec7c --- /dev/null +++ b/src/PDFViewCtrl/pdf_view_ctrl.d.ts @@ -0,0 +1,8 @@ +import { PureComponent } from 'react'; +import PropTypes from 'prop-types'; + +export interface PDFViewCtrlProps extends ViewProps { + document: PropTypes.string; +} + +export class PDFViewCtrl extends PureComponent {} \ No newline at end of file From 9d743a96016ae7ec9038617a227d472e6cc08175 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 23 Jul 2021 17:23:55 -0700 Subject: [PATCH 014/226] Fixed typings for PDFViewCtrl --- src/PDFViewCtrl/package.json | 3 ++- src/PDFViewCtrl/pdf_view_ctrl.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PDFViewCtrl/package.json b/src/PDFViewCtrl/package.json index 6294c1e73..50d575bb0 100644 --- a/src/PDFViewCtrl/package.json +++ b/src/PDFViewCtrl/package.json @@ -2,5 +2,6 @@ "name": "PDFViewCtrl", "version": "0.0.0", "private": true, - "main": "./PDFViewCtrl" + "main": "./PDFViewCtrl", + "typings": "./pdf_view_ctrl.d.ts" } \ No newline at end of file diff --git a/src/PDFViewCtrl/pdf_view_ctrl.d.ts b/src/PDFViewCtrl/pdf_view_ctrl.d.ts index dad3fec7c..a99e3167d 100644 --- a/src/PDFViewCtrl/pdf_view_ctrl.d.ts +++ b/src/PDFViewCtrl/pdf_view_ctrl.d.ts @@ -1,8 +1,8 @@ import { PureComponent } from 'react'; -import PropTypes from 'prop-types'; +import { ViewProps } from 'react-native'; export interface PDFViewCtrlProps extends ViewProps { - document: PropTypes.string; + document: string; } export class PDFViewCtrl extends PureComponent {} \ No newline at end of file From 7c4ea889221d909c699ad937947749696d97e963 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Mon, 26 Jul 2021 08:24:48 -0700 Subject: [PATCH 015/226] Changes to index.d.ts and document_view.d.ts * Added export for PDFViewCtrl in index.d.ts * Fixed config.options.d.ts exports in index.d.ts * Added exports for the remainig interfaces within document_view.d.ts * Fixed error in document_view.d.ts --- index.d.ts | 17 ++++++++++------- src/DocumentView/document_view.d.ts | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index d772c1c96..c127f7000 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,10 +11,13 @@ export interface Pdftron { export const RNPdftron : Pdftron; -export {Config, ConfigOptions} from "./src/Config/config"; -export {ButtonsOptions, ToolsOptions, FitModeOptions, LayoutModeOptions, - FieldFlagsOptions, AnnotationMenuOptions, LongPressMenuOptions, - ActionsOptions, AnnotationFlagsOptions, DefaultToolbarsOptions, ToolbarIconsOptions, - CustomToolbarKeyOptions, ThumbnailFilterModeOptions, ConversionOptions, ViewModePickerItemOptions, - ZoomLimitModeOptions, OverprintModeOptions, ColorPostProcessModeOptions, ReflowOrientationOptions, ExportFormatOptions} from "./src/Config/config.options"; -export {DocumentView, DocumentViewProps, Annotation, Field, TextSelectionResult, Quad, Coords} from "./src/DocumentView/document_view"; \ No newline at end of file +export {Config} from "./src/Config/config"; + +export {Buttons, Tools, FitMode, LayoutMode, FieldFlags, AnnotationMenu, LongPressMenu, Actions, AnnotationFlags, + DefaultToolbars, ToolbarIcons, CustomToolbarKey, ThumbnailFilterMode, Conversion, ViewModePickerItem, + ZoomLimitMode, OverprintMode, ColorPostProcessMode, ReflowOrientation, ExportFormat} from "./src/Config/config.options"; + +export {DocumentView, DocumentViewProps, Annotation, AnnotationFlag, AnnotationProperties, Rect, CropBox, + Field, FieldWithStringValue, Color, RotationDegree, TextSelectionResult, Quad, Point, PointWithPage} from "./src/DocumentView/document_view"; + +export {PDFViewCtrl, PDFViewCtrlProps} from "./src/PDFViewCtrl/pdf_view_ctrl"; \ No newline at end of file diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 98a9a6e00..1771924b9 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -230,7 +230,7 @@ export class DocumentView extends PureComponent { setColorPostProcessColors: (whiteColor: Color, blackColor: Color) => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | TextSelectionResult?; + getSelection: (pageNumber: number) => Promise | TextSelectionResult; hasSelection: () => Promise | boolean; clearSelection: () => Promise; getSelectionPageRange: () => Promise | {begin: number, end: number}; From 76dd86167b50d5d8f03ca9f741ded64e73fd0635 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Mon, 26 Jul 2021 12:13:19 -0700 Subject: [PATCH 016/226] Refactor exports and fix a type --- index.d.ts | 9 +++------ src/Config/config.d.ts | 4 ++-- src/DocumentView/document_view.d.ts | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index c127f7000..8c4ac4126 100644 --- a/index.d.ts +++ b/index.d.ts @@ -13,11 +13,8 @@ export const RNPdftron : Pdftron; export {Config} from "./src/Config/config"; -export {Buttons, Tools, FitMode, LayoutMode, FieldFlags, AnnotationMenu, LongPressMenu, Actions, AnnotationFlags, - DefaultToolbars, ToolbarIcons, CustomToolbarKey, ThumbnailFilterMode, Conversion, ViewModePickerItem, - ZoomLimitMode, OverprintMode, ColorPostProcessMode, ReflowOrientation, ExportFormat} from "./src/Config/config.options"; +export * as ConfigOptions from "./src/Config/config.options"; -export {DocumentView, DocumentViewProps, Annotation, AnnotationFlag, AnnotationProperties, Rect, CropBox, - Field, FieldWithStringValue, Color, RotationDegree, TextSelectionResult, Quad, Point, PointWithPage} from "./src/DocumentView/document_view"; +export {DocumentView} from "./src/DocumentView/document_view"; -export {PDFViewCtrl, PDFViewCtrlProps} from "./src/PDFViewCtrl/pdf_view_ctrl"; \ No newline at end of file +export {PDFViewCtrl} from "./src/PDFViewCtrl/pdf_view_ctrl"; \ No newline at end of file diff --git a/src/Config/config.d.ts b/src/Config/config.d.ts index 7e8a638f0..36831ad0e 100644 --- a/src/Config/config.d.ts +++ b/src/Config/config.d.ts @@ -237,7 +237,7 @@ export interface ExportFormat { PNG: "PNG"; } -export interface Config { +export interface ConfigIF { Buttons: Buttons; Tools: Tools; FitMode: FitMode; @@ -261,4 +261,4 @@ export interface Config { ExportFormat: ExportFormat; } -export const Config : Config; \ No newline at end of file +export const Config: ConfigIF; \ No newline at end of file diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 1771924b9..33f85e3ed 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -148,7 +148,7 @@ export interface DocumentViewProps extends ViewProps { horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; - onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult}) => void; + onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult | null}) => void; hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; @@ -230,7 +230,7 @@ export class DocumentView extends PureComponent { setColorPostProcessColors: (whiteColor: Color, blackColor: Color) => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | TextSelectionResult; + getSelection: (pageNumber: number) => Promise | TextSelectionResult | null; hasSelection: () => Promise | boolean; clearSelection: () => Promise; getSelectionPageRange: () => Promise | {begin: number, end: number}; From 995b522c4bf2066407801907685ea8ca6822d80d Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 12:14:47 -0700 Subject: [PATCH 017/226] specify object interface for onBehaviorActivated --- src/DocumentView/document_view.d.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 33f85e3ed..6659554bf 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -74,6 +74,17 @@ export interface AnnotationProperties { strokeColor?: Color; } +export interface LinkPressData { + url: string; +} + +export interface StickyNoteData { + id: string; + pageNumber: number; + type: string; + rect: Rect; +} + export interface DocumentViewProps extends ViewProps { document: string; password?: string; @@ -101,7 +112,7 @@ export interface DocumentViewProps extends ViewProps { onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; hideAnnotationMenu?: Array; overrideBehavior?: Array; - onBehaviorActivated?: (event: {action: string, data: object}) => void; + onBehaviorActivated?: (event: {action: string, data: LinkPressData | StickyNoteData}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; From 3d58ce1199855e1578a4fd341cbd81b324d96fe8 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 27 Jul 2021 12:36:47 -0700 Subject: [PATCH 018/226] Fixed onDocumentLoaded and onDocumentError typing --- src/DocumentView/document_view.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DocumentView/document_view.d.ts b/src/DocumentView/document_view.d.ts index 6659554bf..1a6666286 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/DocumentView/document_view.d.ts @@ -94,8 +94,8 @@ export interface DocumentViewProps extends ViewProps { leadingNavButtonIcon?: string; showLeadingNavButton?: boolean; onLeadingNavButtonPressed?: () => void; - onDocumentLoaded?: (event: {path : string}) => void; - onDocumentError?: (event: {error: string}) => void; + onDocumentLoaded?: (path : string) => void; + onDocumentError?: (error: string) => void; onPageChanged?: (event: {previousPageNumber: number, pageNumber: number}) => void; onScrollChanged?: (event: {horizontal: number, vertical: number}) => void; onZoomChanged?: (event: {zoom: number}) => void; From 039d16bf20071f1aaf742233c7b7a2162133bfce Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 13:08:35 -0700 Subject: [PATCH 019/226] move types to own folder --- index.d.ts | 10 +- src/types/AnnotOptions.d.ts | 82 ++++++++++ src/{Config/config.d.ts => types/Config.d.ts} | 0 .../ConfigOptions.d.ts} | 0 .../DocumentView.d.ts} | 141 ++++-------------- .../PDFViewCtrl.d.ts} | 0 6 files changed, 118 insertions(+), 115 deletions(-) create mode 100644 src/types/AnnotOptions.d.ts rename src/{Config/config.d.ts => types/Config.d.ts} (100%) rename src/{Config/config.options.d.ts => types/ConfigOptions.d.ts} (100%) rename src/{DocumentView/document_view.d.ts => types/DocumentView.d.ts} (71%) rename src/{PDFViewCtrl/pdf_view_ctrl.d.ts => types/PDFViewCtrl.d.ts} (100%) diff --git a/index.d.ts b/index.d.ts index 8c4ac4126..2670737d0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,10 +11,12 @@ export interface Pdftron { export const RNPdftron : Pdftron; -export {Config} from "./src/Config/config"; +export {Config} from "./src/types/Config"; -export * as ConfigOptions from "./src/Config/config.options"; +export * as ConfigOptions from "./src/types/ConfigOptions"; -export {DocumentView} from "./src/DocumentView/document_view"; +export {DocumentView} from "./src/types/DocumentView"; + +export * as AnnotOptions from "./src/types/AnnotOptions"; -export {PDFViewCtrl} from "./src/PDFViewCtrl/pdf_view_ctrl"; \ No newline at end of file +export {PDFViewCtrl} from "./src/types/PDFViewCtrl"; \ No newline at end of file diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts new file mode 100644 index 000000000..60d37ca61 --- /dev/null +++ b/src/types/AnnotOptions.d.ts @@ -0,0 +1,82 @@ +export interface Annotation { + id: string; + pageNumber?: number; + type?: string; + rect?: Rect; +} + +export interface Rect { + x1: number; + y1: number; + x2: number; + y2: number; +} + +export interface Color { + red: number; + green: number; + blue: number; +} + +export type RotationDegree = 0 | 90 | 180 | 270; + +export interface CropBox extends Rect { + width: number; + height: number; +} + +export interface Field { + fieldName: string; + fieldValue: string | boolean | number; +} + +export interface FieldWithStringValue { + fieldName: string; + fieldValue: string; +} + +export interface Point { + x: number; + y: number; +} + +export interface PointWithPage extends Point { + pageNumber?: number; +} + +export type Quad = [Point, Point, Point, Point]; + +export interface TextSelectionResult { + html: string; + unicode: string; + pageNumber: number; + quads: Array; +} + +export interface AnnotationFlag { + id: string; + pageNumber: number; + flag: ConfigOptions.AnnotationFlags; + flagValue: boolean; +} + +export interface AnnotationProperties { + rect?: Rect; + contents?: string; + subject?: string; + title?: string; + contentRect?: Rect; + customData?: object; + strokeColor?: Color; +} + +export interface LinkPressData { + url: string; +} + +export interface StickyNoteData { + id: string; + pageNumber: number; + type: string; + rect: Rect; +} \ No newline at end of file diff --git a/src/Config/config.d.ts b/src/types/Config.d.ts similarity index 100% rename from src/Config/config.d.ts rename to src/types/Config.d.ts diff --git a/src/Config/config.options.d.ts b/src/types/ConfigOptions.d.ts similarity index 100% rename from src/Config/config.options.d.ts rename to src/types/ConfigOptions.d.ts diff --git a/src/DocumentView/document_view.d.ts b/src/types/DocumentView.d.ts similarity index 71% rename from src/DocumentView/document_view.d.ts rename to src/types/DocumentView.d.ts index 1a6666286..70185f44e 100644 --- a/src/DocumentView/document_view.d.ts +++ b/src/types/DocumentView.d.ts @@ -1,89 +1,8 @@ import { PureComponent } from "react"; import { ViewProps } from "react-native"; -import * as ConfigOptions from "react-native-pdftron/src/Config/config.options"; -export interface Annotation { - id: string; - pageNumber?: number; - type?: string; - rect?: Rect; -} - -export interface Rect { - x1: number; - y1: number; - x2: number; - y2: number; -} - -export interface Color { - red: number; - green: number; - blue: number; -} - -export type RotationDegree = 0 | 90 | 180 | 270; - -export interface CropBox extends Rect { - width: number; - height: number; -} - -export interface Field { - fieldName: string; - fieldValue: string | boolean | number; -} - -export interface FieldWithStringValue { - fieldName: string; - fieldValue: string; -} - -export interface Point { - x: number; - y: number; -} - -export interface PointWithPage extends Point { - pageNumber?: number; -} - -export type Quad = [Point, Point, Point, Point]; - -export interface TextSelectionResult { - html: string; - unicode: string; - pageNumber: number; - quads: Array; -} - -export interface AnnotationFlag { - id: string; - pageNumber: number; - flag: ConfigOptions.AnnotationFlags; - flagValue: boolean; -} - -export interface AnnotationProperties { - rect?: Rect; - contents?: string; - subject?: string; - title?: string; - contentRect?: Rect; - customData?: object; - strokeColor?: Color; -} - -export interface LinkPressData { - url: string; -} - -export interface StickyNoteData { - id: string; - pageNumber: number; - type: string; - rect: Rect; -} +import * as ConfigOptions from "react-native-pdftron/src/types/ConfigOptions"; +import * as AnnotOptions from "./AnnotOptions" export interface DocumentViewProps extends ViewProps { document: string; @@ -109,19 +28,19 @@ export interface DocumentViewProps extends ViewProps { longPressMenuEnabled?: boolean; annotationMenuItems?: Array; overrideAnnotationMenuBehavior?: Array; - onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; + onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; hideAnnotationMenu?: Array; overrideBehavior?: Array; - onBehaviorActivated?: (event: {action: string, data: LinkPressData | StickyNoteData}) => void; + onBehaviorActivated?: (event: {action: string, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; documentSliderEnabled?: boolean; pageIndicatorEnabled?: boolean; keyboardShortcutsEnabled?: boolean; - onAnnotationsSelected?: (event: {annotations: Array}) => void ; - onAnnotationChanged?: (event: {action: string, annotations: Array}) => void; - onFormFieldValueChanged?: (event: {fields: Array}) => void; + onAnnotationsSelected?: (event: {annotations: Array}) => void ; + onAnnotationChanged?: (event: {action: string, annotations: Array}) => void; + onFormFieldValueChanged?: (event: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; fitMode?: string; @@ -136,7 +55,7 @@ export interface DocumentViewProps extends ViewProps { collabEnabled?: boolean; currentUser?: string; currentUserName?: string; - onExportAnnotationCommand?: (event: {action: string, xfdfCommand: string, annotations: Array}) => void; + onExportAnnotationCommand?: (event: {action: string, xfdfCommand: string, annotations: Array}) => void; autoSaveEnabled?: boolean; pageChangeOnTap?: boolean; followSystemDarkMode?: boolean; @@ -159,7 +78,7 @@ export interface DocumentViewProps extends ViewProps { horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; - onTextSearchResult?: (event: {found: boolean, textSelection: TextSelectionResult | null}) => void; + onTextSearchResult?: (event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; @@ -190,29 +109,29 @@ export class DocumentView extends PureComponent { importBookmarkJson: (bookmarkJson: string) => Promise; importAnnotationCommand: (xfdfCommand: string, initialLoad: boolean) => Promise; importAnnotations: (xfdf: string) => Promise; - exportAnnotations: (options?: {annotList: Array}) => Promise | string; + exportAnnotations: (options?: {annotList: Array}) => Promise | string; flattenAnnotations: (formsOnly: boolean) => Promise; - deleteAnnotations: (annotations: Array) => Promise; + deleteAnnotations: (annotations: Array) => Promise; saveDocument: () => Promise | string; setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; getField: (fieldName: string) => Promise | {fieldName: string, fieldValue?: any, fieldType?: string}; setValueForFields: (fieldsMap: Map) => Promise; setValuesForFields: (fieldsMap: Map) => Promise; handleBackButton: () => Promise | boolean; - setFlagForAnnotations: (annotationFlagList: Array) => Promise; - setFlagsForAnnotations: (annotationFlagList: Array) => Promise; + setFlagForAnnotations: (annotationFlagList: Array) => Promise; + setFlagsForAnnotations: (annotationFlagList: Array) => Promise; selectAnnotation: (id: string, pageNumber: number) => Promise; - setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotationProperties) => Promise; - setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotationProperties) => Promise; - getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | AnnotationProperties; + setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; + setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; + getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | AnnotOptions.AnnotationProperties; setDrawAnnotations: (drawAnnotations: boolean) => Promise; setVisibilityForAnnotation: (id: string, pageNumber: number, visibility: boolean) => Promise; setHighlightFields: (highlightFields: boolean) => Promise; - getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | Annotation; - getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Array; - getAnnotationsOnPage: (pageNumber: number) => Promise | Array; + getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | AnnotOptions.Annotation; + getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Array; + getAnnotationsOnPage: (pageNumber: number) => Promise | Array; getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | string; - getPageCropBox: (pageNumber: number) => Promise | CropBox; + getPageCropBox: (pageNumber: number) => Promise | AnnotOptions.CropBox; setCurrentPage: (pageNumber: number) => Promise | boolean; getVisiblePages: () => Promise | Array; gotoPreviousPage: () => Promise | boolean; @@ -224,36 +143,36 @@ export class DocumentView extends PureComponent { getZoom: () => Promise | number; setZoomLimits: (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number) => Promise; zoomWithCenter: (zoom: number, x: number, y: number) => Promise; - zoomToRect: (pageNumber: number, rect: Rect) => Promise; + zoomToRect: (pageNumber: number, rect: AnnotOptions.Rect) => Promise; smartZoom: (x: number, y: number, animated: boolean) => Promise; getScrollPos: () => Promise | {horizontal: number, vertical: number}; getCanvasSize: () => Promise | {width: number, height: number}; - getPageRotation: () => Promise | RotationDegree; + getPageRotation: () => Promise | AnnotOptions.RotationDegree; rotateClockwise: () => Promise; rotateCounterClockwise: () => Promise; - convertScreenPointsToPagePoints: (points: Array) => Promise | Array; - convertPagePointsToScreenPoints: (points: Array) => Promise | Array; + convertScreenPointsToPagePoints: (points: Array) => Promise | Array; + convertPagePointsToScreenPoints: (points: Array) => Promise | Array; getPageNumberFromScreenPoint: (x: number, y: number) => Promise | number; setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; setImageSmoothing: (imageSmoothing: boolean) => Promise; setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; - setColorPostProcessColors: (whiteColor: Color, blackColor: Color) => Promise; + setColorPostProcessColors: (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color) => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | TextSelectionResult | null; + getSelection: (pageNumber: number) => Promise | AnnotOptions.TextSelectionResult | null; hasSelection: () => Promise | boolean; clearSelection: () => Promise; getSelectionPageRange: () => Promise | {begin: number, end: number}; hasSelectionOnPage: (pageNumber: number) => Promise | boolean; - selectInRect: (rect: Rect) => Promise | boolean; - isThereTextInRect: (rect: Rect) => Promise | boolean; + selectInRect: (rect: AnnotOptions.Rect) => Promise | boolean; + isThereTextInRect: (rect: AnnotOptions.Rect) => Promise | boolean; selectAll: () => Promise; setUrlExtraction: (urlExtraction: boolean) => Promise; setPageBorderVisibility: (pageBorderVisibility: boolean) => Promise; setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; - setDefaultPageColor: (defaultPageColor: Color) => Promise; - setBackgroundColor: (backgroundColor: Color) => Promise; + setDefaultPageColor: (defaultPageColor: AnnotOptions.Color) => Promise; + setBackgroundColor: (backgroundColor: AnnotOptions.Color) => Promise; exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | string; undo: () => Promise; redo: () => Promise; diff --git a/src/PDFViewCtrl/pdf_view_ctrl.d.ts b/src/types/PDFViewCtrl.d.ts similarity index 100% rename from src/PDFViewCtrl/pdf_view_ctrl.d.ts rename to src/types/PDFViewCtrl.d.ts From aee36c26c3c1d7f71adae3b2347daddfb8d11a18 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 13:18:56 -0700 Subject: [PATCH 020/226] Edit filepaths --- src/types/ConfigOptions.d.ts | 2 +- src/types/DocumentView.d.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/types/ConfigOptions.d.ts b/src/types/ConfigOptions.d.ts index 59f03aeac..61b89dc24 100644 --- a/src/types/ConfigOptions.d.ts +++ b/src/types/ConfigOptions.d.ts @@ -1,4 +1,4 @@ -import Config from "./config"; +import Config from "./Config"; type ValueOf = T[keyof T]; diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 70185f44e..3c860f7e4 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -1,8 +1,8 @@ import { PureComponent } from "react"; import { ViewProps } from "react-native"; -import * as ConfigOptions from "react-native-pdftron/src/types/ConfigOptions"; -import * as AnnotOptions from "./AnnotOptions" +import * as ConfigOptions from "./ConfigOptions"; +import * as AnnotOptions from "./AnnotOptions"; export interface DocumentViewProps extends ViewProps { document: string; @@ -31,7 +31,7 @@ export interface DocumentViewProps extends ViewProps { onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; hideAnnotationMenu?: Array; overrideBehavior?: Array; - onBehaviorActivated?: (event: {action: string, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; + onBehaviorActivated?: (event: {action: ConfigOptions.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; From 85aee6365fd538fe8ace1b02ce816cd00e104d20 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 14:13:59 -0700 Subject: [PATCH 021/226] Edit mode prop types --- src/types/DocumentView.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 3c860f7e4..ca84d14f3 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -43,8 +43,8 @@ export interface DocumentViewProps extends ViewProps { onFormFieldValueChanged?: (event: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; - fitMode?: string; - layoutMode?: string; + fitMode?: ConfigOptions.FitMode; + layoutMode?: ConfigOptions.LayoutMode; onLayoutChanged?: () => void; padStatusBar?: boolean; continuousAnnotationEditing?: boolean; From 8f0496ad1c475b7fee0fb681e8f136487fb41431 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 14:28:00 -0700 Subject: [PATCH 022/226] Edit onToolChanged types --- src/types/DocumentView.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index ca84d14f3..172ae5ace 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -74,7 +74,7 @@ export interface DocumentViewProps extends ViewProps { hideTopAppNavBar?: boolean; onBookmarkChanged?: (event: {bookmarkJson: string}) => void; hideThumbnailFilterModes?: Array; - onToolChanged?: (event: {previousTool: string, tool: string}) => void; + onToolChanged?: (event: {previousTool: ConfigOptions.Tools | "unknown tool", tool: ConfigOptions.Tools | "unknown tool"}) => void; horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; From f515f012894ea7f69c779e03119d5a481cc7ac89 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 27 Jul 2021 14:36:09 -0700 Subject: [PATCH 023/226] Updated package.json files --- src/Config/package.json | 2 +- src/DocumentView/package.json | 2 +- src/PDFViewCtrl/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Config/package.json b/src/Config/package.json index 08df88038..f7c0a9707 100644 --- a/src/Config/package.json +++ b/src/Config/package.json @@ -3,5 +3,5 @@ "version": "0.0.0", "private": true, "main": "./Config", - "typings": "./config.d.ts" + "typings": "../types/config.d.ts" } \ No newline at end of file diff --git a/src/DocumentView/package.json b/src/DocumentView/package.json index a923b44d7..1d1a49f10 100644 --- a/src/DocumentView/package.json +++ b/src/DocumentView/package.json @@ -3,5 +3,5 @@ "version": "0.0.0", "private": true, "main": "./DocumentView", - "typings": "./document_view.d.ts" + "typings": "../types/document_view.d.ts" } \ No newline at end of file diff --git a/src/PDFViewCtrl/package.json b/src/PDFViewCtrl/package.json index 50d575bb0..a55444ea6 100644 --- a/src/PDFViewCtrl/package.json +++ b/src/PDFViewCtrl/package.json @@ -3,5 +3,5 @@ "version": "0.0.0", "private": true, "main": "./PDFViewCtrl", - "typings": "./pdf_view_ctrl.d.ts" + "typings": "../types/pdf_view_ctrl.d.ts" } \ No newline at end of file From 9e9fb8e714c68b1d0f4dd0ba08e08e26247285dc Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 27 Jul 2021 14:46:20 -0700 Subject: [PATCH 024/226] Added missing import in AnnotOptions.d.ts --- src/types/AnnotOptions.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts index 60d37ca61..6a370ce70 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -1,3 +1,5 @@ +import * as ConfigOptions from './ConfigOptions'; + export interface Annotation { id: string; pageNumber?: number; From 0ff161f9a5e228010354babfbd480e7ac396edcb Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 14:51:34 -0700 Subject: [PATCH 025/226] edit reflowOrientation type --- src/types/DocumentView.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 172ae5ace..656821f71 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -89,7 +89,7 @@ export interface DocumentViewProps extends ViewProps { restrictDownloadUsage?: boolean; userBookmarksListEditingEnabled?: boolean; imageInReflowEnabled?: boolean; - reflowOrientation?: string; + reflowOrientation?: ConfigOptions.ReflowOrientation; onUndoRedoStateChanged?: () => void; tabletLayoutEnabled?: boolean; initialToolbar?: string; From 63df86d6ca510db9dcea66248d46d3398faeecf8 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 15:13:19 -0700 Subject: [PATCH 026/226] edit defaultEraserType type --- src/types/DocumentView.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 656821f71..ad17fa130 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -94,7 +94,7 @@ export interface DocumentViewProps extends ViewProps { tabletLayoutEnabled?: boolean; initialToolbar?: string; inkMultiStrokeEnabled?: boolean; - defaultEraserType?: string; + defaultEraserType?: ConfigOptions.EraserType; exportPath?: string; openUrlPath?: string; saveStateEnabled?: boolean; From c0fa9a5ad4ebb4de53e590a38804baeb88fe7a89 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 15:54:12 -0700 Subject: [PATCH 027/226] Use promises for method return types --- src/types/Config.d.ts | 2 +- src/types/DocumentView.d.ts | 71 +++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/types/Config.d.ts b/src/types/Config.d.ts index 36831ad0e..234f3698a 100644 --- a/src/types/Config.d.ts +++ b/src/types/Config.d.ts @@ -125,7 +125,7 @@ export interface AnnotationMenu { calibrate: 'calibrate'; } -export interface EraserType{ +export interface EraserType { annotationEraser: 'annotationEraser'; hybrideEraser: 'hybrideEraser'; inkEraser: 'inkEraser'; diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index ad17fa130..da914a25e 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -101,58 +101,59 @@ export interface DocumentViewProps extends ViewProps { openSavedCopyInNewTab?: boolean; } + export class DocumentView extends PureComponent { - getDocumentPath: () => Promise | string; + getDocumentPath: () => Promise | Promise; setToolMode: (toolMode: ConfigOptions.Tools) => Promise; - commitTool: () => Promise | boolean; - getPageCount: () => Promise | number; + commitTool: () => Promise | Promise; + getPageCount: () => Promise | Promise; importBookmarkJson: (bookmarkJson: string) => Promise; importAnnotationCommand: (xfdfCommand: string, initialLoad: boolean) => Promise; importAnnotations: (xfdf: string) => Promise; - exportAnnotations: (options?: {annotList: Array}) => Promise | string; + exportAnnotations: (options?: {annotList: Array}) => Promise | Promise; flattenAnnotations: (formsOnly: boolean) => Promise; deleteAnnotations: (annotations: Array) => Promise; - saveDocument: () => Promise | string; + saveDocument: () => Promise | Promise; setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; - getField: (fieldName: string) => Promise | {fieldName: string, fieldValue?: any, fieldType?: string}; + getField: (fieldName: string) => Promise | Promise<{fieldName: string, fieldValue?: any, fieldType?: string}>; setValueForFields: (fieldsMap: Map) => Promise; setValuesForFields: (fieldsMap: Map) => Promise; - handleBackButton: () => Promise | boolean; + handleBackButton: () => Promise | Promise; setFlagForAnnotations: (annotationFlagList: Array) => Promise; setFlagsForAnnotations: (annotationFlagList: Array) => Promise; selectAnnotation: (id: string, pageNumber: number) => Promise; setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; - getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | AnnotOptions.AnnotationProperties; + getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | Promise; setDrawAnnotations: (drawAnnotations: boolean) => Promise; setVisibilityForAnnotation: (id: string, pageNumber: number, visibility: boolean) => Promise; setHighlightFields: (highlightFields: boolean) => Promise; - getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | AnnotOptions.Annotation; - getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Array; - getAnnotationsOnPage: (pageNumber: number) => Promise | Array; - getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | string; - getPageCropBox: (pageNumber: number) => Promise | AnnotOptions.CropBox; - setCurrentPage: (pageNumber: number) => Promise | boolean; - getVisiblePages: () => Promise | Array; - gotoPreviousPage: () => Promise | boolean; - gotoNextPage: () => Promise | boolean; - gotoFirstPage: () => Promise | boolean; - gotoLastPage: () => Promise | boolean; + getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | Promise; + getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Promise>; + getAnnotationsOnPage: (pageNumber: number) => Promise | Promise>; + getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | Promise; + getPageCropBox: (pageNumber: number) => Promise | Promise; + setCurrentPage: (pageNumber: number) => Promise | Promise; + getVisiblePages: () => Promise | Promise>; + gotoPreviousPage: () => Promise | Promise; + gotoNextPage: () => Promise | Promise; + gotoFirstPage: () => Promise | Promise; + gotoLastPage: () => Promise | Promise; showGoToPageView: () => Promise; closeAllTabs: () => Promise; - getZoom: () => Promise | number; + getZoom: () => Promise | Promise; setZoomLimits: (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number) => Promise; zoomWithCenter: (zoom: number, x: number, y: number) => Promise; zoomToRect: (pageNumber: number, rect: AnnotOptions.Rect) => Promise; smartZoom: (x: number, y: number, animated: boolean) => Promise; - getScrollPos: () => Promise | {horizontal: number, vertical: number}; - getCanvasSize: () => Promise | {width: number, height: number}; - getPageRotation: () => Promise | AnnotOptions.RotationDegree; + getScrollPos: () => Promise | Promise<{horizontal: number, vertical: number}>; + getCanvasSize: () => Promise | Promise<{width: number, height: number}>; + getPageRotation: () => Promise | Promise; rotateClockwise: () => Promise; rotateCounterClockwise: () => Promise; - convertScreenPointsToPagePoints: (points: Array) => Promise | Array; - convertPagePointsToScreenPoints: (points: Array) => Promise | Array; - getPageNumberFromScreenPoint: (x: number, y: number) => Promise | number; + convertScreenPointsToPagePoints: (points: Array) => Promise | Promise>; + convertPagePointsToScreenPoints: (points: Array) => Promise | Promise>; + getPageNumberFromScreenPoint: (x: number, y: number) => Promise | Promise; setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; setImageSmoothing: (imageSmoothing: boolean) => Promise; setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; @@ -160,24 +161,24 @@ export class DocumentView extends PureComponent { setColorPostProcessColors: (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color) => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | AnnotOptions.TextSelectionResult | null; - hasSelection: () => Promise | boolean; + getSelection: (pageNumber: number) => Promise | Promise>; + hasSelection: () => Promise | Promise; clearSelection: () => Promise; - getSelectionPageRange: () => Promise | {begin: number, end: number}; - hasSelectionOnPage: (pageNumber: number) => Promise | boolean; - selectInRect: (rect: AnnotOptions.Rect) => Promise | boolean; - isThereTextInRect: (rect: AnnotOptions.Rect) => Promise | boolean; + getSelectionPageRange: () => Promise | Promise<{begin: number, end: number}>; + hasSelectionOnPage: (pageNumber: number) => Promise | Promise; + selectInRect: (rect: AnnotOptions.Rect) => Promise | Promise; + isThereTextInRect: (rect: AnnotOptions.Rect) => Promise | Promise; selectAll: () => Promise; setUrlExtraction: (urlExtraction: boolean) => Promise; setPageBorderVisibility: (pageBorderVisibility: boolean) => Promise; setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; setDefaultPageColor: (defaultPageColor: AnnotOptions.Color) => Promise; setBackgroundColor: (backgroundColor: AnnotOptions.Color) => Promise; - exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | string; + exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | Promise; undo: () => Promise; redo: () => Promise; - canUndo: () => Promise | boolean; - canRedo: () => Promise | boolean; + canUndo: () => Promise | Promise; + canRedo: () => Promise | Promise; showCrop: () => Promise; setCurrentToolbar: (toolbar: string) => Promise; openThumbnailsView: () => Promise; From 4223cda1b40e01633a6baf8426f53b16699d4da1 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 16:13:11 -0700 Subject: [PATCH 028/226] make initialLoad optional --- src/types/DocumentView.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index da914a25e..12181512f 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -108,7 +108,7 @@ export class DocumentView extends PureComponent { commitTool: () => Promise | Promise; getPageCount: () => Promise | Promise; importBookmarkJson: (bookmarkJson: string) => Promise; - importAnnotationCommand: (xfdfCommand: string, initialLoad: boolean) => Promise; + importAnnotationCommand: (xfdfCommand: string, initialLoad?: boolean) => Promise; importAnnotations: (xfdf: string) => Promise; exportAnnotations: (options?: {annotList: Array}) => Promise | Promise; flattenAnnotations: (formsOnly: boolean) => Promise; From 7955a64b0ede61ab7a4afee433019edaccd28b90 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 27 Jul 2021 16:33:17 -0700 Subject: [PATCH 029/226] Updated interfaces * Rect to include width and height optional properties * Annotation to include pageRect and screenRect optional properties --- src/types/AnnotOptions.d.ts | 9 ++++----- src/types/DocumentView.d.ts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts index 6a370ce70..060808d0e 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -5,9 +5,13 @@ export interface Annotation { pageNumber?: number; type?: string; rect?: Rect; + pageRect?: Rect; + screenRect?: Rect; } export interface Rect { + height?: number; + width?: number; x1: number; y1: number; x2: number; @@ -22,11 +26,6 @@ export interface Color { export type RotationDegree = 0 | 90 | 180 | 270; -export interface CropBox extends Rect { - width: number; - height: number; -} - export interface Field { fieldName: string; fieldValue: string | boolean | number; diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 12181512f..d8c2e2c24 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -132,7 +132,7 @@ export class DocumentView extends PureComponent { getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Promise>; getAnnotationsOnPage: (pageNumber: number) => Promise | Promise>; getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | Promise; - getPageCropBox: (pageNumber: number) => Promise | Promise; + getPageCropBox: (pageNumber: number) => Promise | Promise; setCurrentPage: (pageNumber: number) => Promise | Promise; getVisiblePages: () => Promise | Promise>; gotoPreviousPage: () => Promise | Promise; From 37d2d0cd61002a05e226a5e7c83d59a7c24a56bd Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 16:41:11 -0700 Subject: [PATCH 030/226] make CropBox from Rect --- src/types/AnnotOptions.d.ts | 2 ++ src/types/DocumentView.d.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts index 060808d0e..8aa53377f 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -18,6 +18,8 @@ export interface Rect { y2: number; } +export interface CropBox extends Required {}; + export interface Color { red: number; green: number; diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index d8c2e2c24..12181512f 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -132,7 +132,7 @@ export class DocumentView extends PureComponent { getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Promise>; getAnnotationsOnPage: (pageNumber: number) => Promise | Promise>; getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | Promise; - getPageCropBox: (pageNumber: number) => Promise | Promise; + getPageCropBox: (pageNumber: number) => Promise | Promise; setCurrentPage: (pageNumber: number) => Promise | Promise; getVisiblePages: () => Promise | Promise>; gotoPreviousPage: () => Promise | Promise; From d382162d8661d130aade04a733a387e34ecfabf9 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 27 Jul 2021 16:51:31 -0700 Subject: [PATCH 031/226] Updated definition of CropBox --- src/types/AnnotOptions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts index 8aa53377f..7b1aa4241 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -18,7 +18,7 @@ export interface Rect { y2: number; } -export interface CropBox extends Required {}; +export type CropBox = Required; export interface Color { red: number; From f7fbc9aabd735ef7a6fdbf02ab004667c883a840 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 17:14:32 -0700 Subject: [PATCH 032/226] Add types from latest master updates --- src/types/DocumentView.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 12181512f..e68d90381 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -97,6 +97,7 @@ export interface DocumentViewProps extends ViewProps { defaultEraserType?: ConfigOptions.EraserType; exportPath?: string; openUrlPath?: string; + hideScrollbars?: boolean; saveStateEnabled?: boolean; openSavedCopyInNewTab?: boolean; } @@ -159,6 +160,8 @@ export class DocumentView extends PureComponent { setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; setColorPostProcessColors: (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color) => Promise; + startSearchMode: (searchString: string, matchCase: boolean, matchWholeWord: boolean) => Promise; + exitSearchMode: () => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; getSelection: (pageNumber: number) => Promise | Promise>; From cd364070ca540894894f1fc16efb3f08c35043c9 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 27 Jul 2021 17:27:25 -0700 Subject: [PATCH 033/226] Use Record utility --- src/types/DocumentView.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index e68d90381..3e843cc32 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -117,8 +117,8 @@ export class DocumentView extends PureComponent { saveDocument: () => Promise | Promise; setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; getField: (fieldName: string) => Promise | Promise<{fieldName: string, fieldValue?: any, fieldType?: string}>; - setValueForFields: (fieldsMap: Map) => Promise; - setValuesForFields: (fieldsMap: Map) => Promise; + setValueForFields: (fieldsMap: Record) => Promise; + setValuesForFields: (fieldsMap: Record) => Promise; handleBackButton: () => Promise | Promise; setFlagForAnnotations: (annotationFlagList: Array) => Promise; setFlagsForAnnotations: (annotationFlagList: Array) => Promise; From f9d54e73d4cb877a40f70d0e09d30d6a68fa4c89 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 28 Jul 2021 11:26:05 -0700 Subject: [PATCH 034/226] Remove redundant null --- src/types/DocumentView.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 3e843cc32..f320a16b3 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -164,7 +164,7 @@ export class DocumentView extends PureComponent { exitSearchMode: () => Promise; findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | Promise>; + getSelection: (pageNumber: number) => Promise | Promise; hasSelection: () => Promise | Promise; clearSelection: () => Promise; getSelectionPageRange: () => Promise | Promise<{begin: number, end: number}>; From 90143cdcfbc373bb50e8b4cec38d459e4eaf88da Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 28 Jul 2021 12:49:24 -0700 Subject: [PATCH 035/226] Add save copy option buttons --- src/types/Config.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/Config.d.ts b/src/types/Config.d.ts index 234f3698a..59771f1e1 100644 --- a/src/types/Config.d.ts +++ b/src/types/Config.d.ts @@ -26,6 +26,8 @@ export interface Buttons { printButton: 'printButton'; closeButton: 'closeButton'; saveCopyButton: 'saveCopyButton'; + saveIdenticalCopyButton: 'saveIdenticalCopyButton'; + saveFlattenedCopyButton: 'saveFlattenedCopyButton'; formToolsButton: 'formToolsButton'; fillSignToolsButton: 'fillSignToolsButton'; moreItemsButton: 'moreItemsButton'; @@ -42,6 +44,11 @@ export interface Buttons { undo: 'undo'; redo: 'redo'; addPageButton: 'addPageButton'; + + // Android only + saveReducedCopyButton: 'saveReducedCopyButton'; + saveCroppedCopyButton: 'saveCroppedCopyButton'; + savePasswordCopyButton: 'savePasswordCopyButton'; } export interface Tools { From 69cb599b85fbc11113ab2a0fe94651ff2c864ccc Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Wed, 28 Jul 2021 13:36:57 -0700 Subject: [PATCH 036/226] Redefined CustomToolbarKey in ConfigOptions.d.ts --- src/types/ConfigOptions.d.ts | 9 +++++++-- src/types/DocumentView.d.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/types/ConfigOptions.d.ts b/src/types/ConfigOptions.d.ts index 61b89dc24..96d02e487 100644 --- a/src/types/ConfigOptions.d.ts +++ b/src/types/ConfigOptions.d.ts @@ -14,7 +14,6 @@ export type Actions = ValueOf; export type AnnotationFlags = ValueOf; export type DefaultToolbars = ValueOf; export type ToolbarIcons = ValueOf; -export type CustomToolbarKey = ValueOf; export type ThumbnailFilterMode = ValueOf; export type Conversion = ValueOf; export type ViewModePickerItem = ValueOf; @@ -22,4 +21,10 @@ export type ZoomLimitMode = ValueOf; export type OverprintMode = ValueOf; export type ColorPostProcessMode = ValueOf; export type ReflowOrientation = ValueOf; -export type ExportFormat = ValueOf; \ No newline at end of file +export type ExportFormat = ValueOf; + +export type CustomToolbarKey = { + [Property in keyof Config.CustomToolbarKey as `${Lowercase}`] : Config.CustomToolbarKey[Property] extends "items" ? + Array : Config.CustomToolbarKey[Property] extends "icon" ? + ToolbarIcons : string; +} \ No newline at end of file diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index f320a16b3..ba2b94102 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -65,7 +65,7 @@ export interface DocumentViewProps extends ViewProps { maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; + annotationToolbars?: Array; hideDefaultAnnotationToolbars?: Array; topAppNavBarRightBar?: Array; bottomToolbar?: Array; From fd247eb354a89ca21268d64142d58653bba98e2a Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Wed, 28 Jul 2021 15:14:51 -0700 Subject: [PATCH 037/226] Added pageRect and screenRect to stickyNoteData --- src/types/AnnotOptions.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts index 7b1aa4241..ec66ebe95 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -81,5 +81,7 @@ export interface StickyNoteData { id: string; pageNumber: number; type: string; - rect: Rect; + rect?: Rect; + pageRect?: Rect; + screenRect?: Rect; } \ No newline at end of file From 71b8f6947c401828b7e2b2c5ee9daa0fdf46176b Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 28 Jul 2021 17:06:33 -0700 Subject: [PATCH 038/226] fix typo --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 2670737d0..894199e44 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,7 +2,7 @@ export interface Pdftron { initialize(licenseKey: string) : void; enableJavaScript(enabled: boolean) : void; getVersion() : Promise; - gtPlatformVersion() : Promise; + getPlatformVersion() : Promise; getSystemFontList() : Promise; clearRubberStampCache() : Promise; encryptDocument(filePath: string, password: string, currentPassword: string) : Promise; From 2cbf595891ec33d747c4c1142eae1b14adadab66 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Sat, 31 Jul 2021 17:58:30 -0700 Subject: [PATCH 039/226] Use parameter destructuring --- src/types/DocumentView.d.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index ba2b94102..9a5cf4a38 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -15,32 +15,32 @@ export interface DocumentViewProps extends ViewProps { onLeadingNavButtonPressed?: () => void; onDocumentLoaded?: (path : string) => void; onDocumentError?: (error: string) => void; - onPageChanged?: (event: {previousPageNumber: number, pageNumber: number}) => void; - onScrollChanged?: (event: {horizontal: number, vertical: number}) => void; - onZoomChanged?: (event: {zoom: number}) => void; - onZoomFinished?: (event: {zoom: number}) => void; + onPageChanged?: ({previousPageNumber, pageNumber}: {previousPageNumber: number, pageNumber: number}) => void; + onScrollChanged?: ({horizontal, vertical}: {horizontal: number, vertical: number}) => void; + onZoomChanged?: ({zoom}: {zoom: number}) => void; + onZoomFinished?: ({zoom}: {zoom: number}) => void; zoom?: number; disabledElements?: Array; disabledTools?: Array; longPressMenuItems?: Array; overrideLongPressMenuBehavior?: Array; - onLongPressMenuPress?: (event: {longPressMenu: string, longPressText: string}) => void; + onLongPressMenuPress?: ({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void; longPressMenuEnabled?: boolean; annotationMenuItems?: Array; overrideAnnotationMenuBehavior?: Array; - onAnnotationMenuPress?: (event: {annotationMenu: string, annotations: Array}) => void; + onAnnotationMenuPress?: ({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void; hideAnnotationMenu?: Array; overrideBehavior?: Array; - onBehaviorActivated?: (event: {action: ConfigOptions.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; + onBehaviorActivated?: ({action, data}: {action: ConfigOptions.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; documentSliderEnabled?: boolean; pageIndicatorEnabled?: boolean; keyboardShortcutsEnabled?: boolean; - onAnnotationsSelected?: (event: {annotations: Array}) => void ; - onAnnotationChanged?: (event: {action: string, annotations: Array}) => void; - onFormFieldValueChanged?: (event: {fields: Array}) => void; + onAnnotationsSelected?: ({annotations}: {annotations: Array}) => void ; + onAnnotationChanged?: ({action, annotations}: {action: string, annotations: Array}) => void; + onFormFieldValueChanged?: ({fields}: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; fitMode?: ConfigOptions.FitMode; @@ -55,7 +55,7 @@ export interface DocumentViewProps extends ViewProps { collabEnabled?: boolean; currentUser?: string; currentUserName?: string; - onExportAnnotationCommand?: (event: {action: string, xfdfCommand: string, annotations: Array}) => void; + onExportAnnotationCommand?: ({action, xfdfCommand, annotations}: {action: string, xfdfCommand: string, annotations: Array}) => void; autoSaveEnabled?: boolean; pageChangeOnTap?: boolean; followSystemDarkMode?: boolean; @@ -72,13 +72,13 @@ export interface DocumentViewProps extends ViewProps { hideAnnotationToolbarSwitcher?: boolean; hideTopToolbars?: boolean; hideTopAppNavBar?: boolean; - onBookmarkChanged?: (event: {bookmarkJson: string}) => void; + onBookmarkChanged?: ({bookmarkJson}: {bookmarkJson: string}) => void; hideThumbnailFilterModes?: Array; - onToolChanged?: (event: {previousTool: ConfigOptions.Tools | "unknown tool", tool: ConfigOptions.Tools | "unknown tool"}) => void; + onToolChanged?: ({previousTool, tool}: {previousTool: ConfigOptions.Tools | "unknown tool", tool: ConfigOptions.Tools | "unknown tool"}) => void; horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; - onTextSearchResult?: (event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; + onTextSearchResult?: ({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; From c46ff35aaa48bdbd11bb60ee91c0c21bea247a11 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 3 Aug 2021 16:51:24 -0700 Subject: [PATCH 040/226] migrate js files to ts, tsx --- index.ts | 24 + package-lock.json | 77 +++ package.json | 5 + tsconfig.json | 14 + types/AnnotOptions/AnnotOptions.ts | 87 +++ types/Config/Config.ts | 300 +++++++++ types/DocumentView/DocumentView.tsx | 938 ++++++++++++++++++++++++++++ types/PDFViewCtrl/PDFViewCtrl.tsx | 41 ++ 8 files changed, 1486 insertions(+) create mode 100644 index.ts create mode 100644 package-lock.json create mode 100644 tsconfig.json create mode 100644 types/AnnotOptions/AnnotOptions.ts create mode 100644 types/Config/Config.ts create mode 100644 types/DocumentView/DocumentView.tsx create mode 100644 types/PDFViewCtrl/PDFViewCtrl.tsx diff --git a/index.ts b/index.ts new file mode 100644 index 000000000..df28b2fbb --- /dev/null +++ b/index.ts @@ -0,0 +1,24 @@ +import { NativeModules } from 'react-native'; +import { PDFViewCtrl } from 'react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from 'react-native-pdftron/types/DocumentView/DocumentView'; +import { Config } from 'react-native-pdftron/types/Config/Config'; + +export interface Pdftron { + initialize?(licenseKey: string) : void; + enableJavaScript?(enabled: boolean) : void; + getVersion?() : Promise; + getPlatformVersion?() : Promise; + getSystemFontList?() : Promise; + clearRubberStampCache?() : Promise; + encryptDocument?(filePath: string, password: string, currentPassword: string) : Promise; + pdfFromOfficeTemplate?(docxPath: string, json: object) : Promise; +} + +const RNPdftron : Pdftron = NativeModules; + +export { + RNPdftron, + PDFViewCtrl, + DocumentView, + Config +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..a276e8e02 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,77 @@ +{ + "name": "react-native-pdftron", + "version": "2.0.3-beta.149", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/prop-types": { + "version": "15.7.4", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz", + "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==" + }, + "@types/react": { + "version": "17.0.15", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.15.tgz", + "integrity": "sha512-uTKHDK9STXFHLaKv6IMnwp52fm0hwU+N89w/p9grdUqcFA6WuqDyPhaWopbNyE1k/VhgzmHl8pu1L4wITtmlLw==", + "requires": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "@types/react-native": { + "version": "0.64.12", + "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.64.12.tgz", + "integrity": "sha512-sw6WGSaL219zqrgdb4kQUtFB9iGXC/LmecLZ+UUWEgwYvD0YH81FqWYmONa2HuTkOFAsxu2bK4DspkWRUHIABQ==", + "requires": { + "@types/react": "*" + } + }, + "@types/scheduler": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", + "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==" + }, + "csstype": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.8.tgz", + "integrity": "sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "typescript": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==" + } + } +} diff --git a/package.json b/package.json index 0784b9f83..f4688ac32 100644 --- a/package.json +++ b/package.json @@ -28,5 +28,10 @@ }, "devDependencies": { "react": "*" + }, + "dependencies": { + "@types/react": "^17.0.15", + "@types/react-native": "^0.64.12", + "typescript": "^4.3.5" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..c639e1d8c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "moduleResolution": "Node", + "target": "ESNext", + "jsx": "react-native", + "esModuleInterop": true, + "outDir": "./src", + "skipLibCheck": true, + "declaration": true, + "rootDirs": ["types/", "./"] + }, + "include": ["types/**/*", "../index.ts"], + "exclude": ["node_modules", "**/*.spec.ts"] +} \ No newline at end of file diff --git a/types/AnnotOptions/AnnotOptions.ts b/types/AnnotOptions/AnnotOptions.ts new file mode 100644 index 000000000..06ec71cd3 --- /dev/null +++ b/types/AnnotOptions/AnnotOptions.ts @@ -0,0 +1,87 @@ +import * as Config from 'react-native-pdftron/types/Config/Config'; + +export interface Annotation { + id: string; + pageNumber?: number; + type?: string; + rect?: Rect; + pageRect?: Rect; + screenRect?: Rect; +} + +export interface Rect { + height?: number; + width?: number; + x1: number; + y1: number; + x2: number; + y2: number; +} + +export type CropBox = Required; + +export interface Color { + red: number; + green: number; + blue: number; +} + +export type RotationDegree = 0 | 90 | 180 | 270; + +export interface Field { + fieldName: string; + fieldValue: string | boolean | number; +} + +export interface FieldWithStringValue { + fieldName: string; + fieldValue: string; +} + +export interface Point { + x: number; + y: number; +} + +export interface PointWithPage extends Point { + pageNumber?: number; +} + +export type Quad = [Point, Point, Point, Point]; + +export interface TextSelectionResult { + html: string; + unicode: string; + pageNumber: number; + quads: Array; +} + +export interface AnnotationFlag { + id: string; + pageNumber: number; + flag: Config.AnnotationFlags; + flagValue: boolean; +} + +export interface AnnotationProperties { + rect?: Rect; + contents?: string; + subject?: string; + title?: string; + contentRect?: Rect; + customData?: object; + strokeColor?: Color; +} + +export interface LinkPressData { + url: string; +} + +export interface StickyNoteData { + id: string; + pageNumber: number; + type: string; + rect?: Rect; + pageRect?: Rect; + screenRect?: Rect; +} \ No newline at end of file diff --git a/types/Config/Config.ts b/types/Config/Config.ts new file mode 100644 index 000000000..2c9fdbef5 --- /dev/null +++ b/types/Config/Config.ts @@ -0,0 +1,300 @@ +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', + + // Android only + saveReducedCopyButton: 'saveReducedCopyButton', + saveCroppedCopyButton: 'saveCroppedCopyButton', + savePasswordCopyButton: 'savePasswordCopyButton', + }, + + // Tools define the various kinds of tools for the viewer + Tools: { + annotationEdit: 'AnnotationEdit', + textSelect: 'TextSelect', + pan: 'Pan', + annotationEraserTool: 'AnnotationEraserTool', + 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', + annotationCreateLinkText: 'AnnotationCreateLinkText', + annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter', + formCreateTextField: 'FormCreateTextField', + formCreateCheckboxField: 'FormCreateCheckboxField', + formCreateSignatureField: 'FormCreateSignatureField', + formCreateRadioField: 'FormCreateRadioField', + formCreateComboBoxField: 'FormCreateComboBoxField', + formCreateListBoxField: 'FormCreateListBoxField', + + // iOS only. + pencilKitDrawing: 'PencilKitDrawing', + }, + + // 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', + delete: 'delete', + flatten: 'flatten', + editText: 'editText', + editInk: 'editInk', + search: 'search', + share: 'share', + markupType: 'markupType', + read: 'read', + screenCapture: 'screenCapture', + playSound: 'playSound', + openAttachment: 'openAttachment', + calibrate: 'calibrate', + }, + + // EraserType defines the type of earse 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" + }, + + // ThumbnailFilterMode defines filter modes in the thumbnails browser + ThumbnailFilterMode: { + Annotated: "annotated", + Bookmarked: "bookmarked", + }, + + // 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", + }, + + // 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", + }, +} as const; + +type ValueOf = T[keyof T]; + +export type Buttons = ValueOf; +export type Tools = ValueOf; +export type FitMode = ValueOf; +export type LayoutMode = ValueOf; +export type FieldFlags = ValueOf; +export type AnnotationMenu = ValueOf; +export type EraserType = ValueOf; +export type LongPressMenu = ValueOf; +export type Actions = ValueOf; +export type AnnotationFlags = ValueOf; +export type DefaultToolbars = ValueOf; +export type ToolbarIcons = ValueOf; +export type ThumbnailFilterMode = ValueOf; +export type Conversion = ValueOf; +export type ViewModePickerItem = ValueOf; +export type ZoomLimitMode = ValueOf; +export type OverprintMode = ValueOf; +export type ColorPostProcessMode = ValueOf; +export type ReflowOrientation = ValueOf; +export type ExportFormat = ValueOf; +export type CustomToolbarKey = { + id : string; + name: string; + icon: ToolbarIcons; + items: (Tools | Buttons)[]; +} \ No newline at end of file diff --git a/types/DocumentView/DocumentView.tsx b/types/DocumentView/DocumentView.tsx new file mode 100644 index 000000000..5f1489b2f --- /dev/null +++ b/types/DocumentView/DocumentView.tsx @@ -0,0 +1,938 @@ +import React, { PureComponent } from 'react'; +import { + requireNativeComponent, + ViewProps, + Platform, + Alert, + NativeModules, + findNodeHandle, +} from 'react-native'; +const { DocumentViewManager } = NativeModules; +import * as Config from "react-native-pdftron/types/Config/Config"; +import * as AnnotOptions from "react-native-pdftron/types/AnnotOptions/AnnotOptions"; + +export interface DocumentViewProps extends ViewProps { + document: string; + password?: string; + initialPageNumber?: number; + pageNumber?: number; + customHeaders?: object; + leadingNavButtonIcon?: string; + showLeadingNavButton?: boolean; + onLeadingNavButtonPressed?: () => void; + onDocumentLoaded?: (path : string) => void; + onDocumentError?: (error: string) => void; + onPageChanged?: ({previousPageNumber, pageNumber}: {previousPageNumber: number, pageNumber: number}) => void; + onScrollChanged?: ({horizontal, vertical}: {horizontal: number, vertical: number}) => void; + onZoomChanged?: ({zoom}: {zoom: number}) => void; + onZoomFinished?: ({zoom}: {zoom: number}) => void; + zoom?: number; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; + onLongPressMenuPress?: ({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void; + longPressMenuEnabled?: boolean; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; + onAnnotationMenuPress?: ({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; + onBehaviorActivated?: ({action, data}: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; + topToolbarEnabled?: boolean; + bottomToolbarEnabled?: boolean; + hideToolbarsOnTap?: boolean; + documentSliderEnabled?: boolean; + pageIndicatorEnabled?: boolean; + keyboardShortcutsEnabled?: boolean; + onAnnotationsSelected?: ({annotations}: {annotations: Array}) => void ; + onAnnotationChanged?: ({action, annotations}: {action: string, annotations: Array}) => void; + onFormFieldValueChanged?: ({fields}: {fields: Array}) => void; + readOnly?: boolean; + thumbnailViewEditingEnabled?: boolean; + fitMode?: Config.FitMode; + layoutMode?: Config.LayoutMode; + onLayoutChanged?: () => void; + padStatusBar?: boolean; + continuousAnnotationEditing?: boolean; + selectAnnotationAfterCreation?: boolean; + annotationAuthor?: string; + showSavedSignatures?: boolean; + isBase64String?: boolean; + collabEnabled?: boolean; + currentUser?: string; + currentUserName?: string; + onExportAnnotationCommand?: ({action, xfdfCommand, annotations}: {action: string, xfdfCommand: string, annotations: Array}) => void; + autoSaveEnabled?: boolean; + pageChangeOnTap?: boolean; + followSystemDarkMode?: boolean; + useStylusAsPen?: boolean; + multiTabEnabled?: boolean; + tabTitle?: string; + maxTabCount?: number; + signSignatureFieldsWithStamps?: boolean; + annotationPermissionCheckEnabled?: boolean; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; + hideAnnotationToolbarSwitcher?: boolean; + hideTopToolbars?: boolean; + hideTopAppNavBar?: boolean; + onBookmarkChanged?: ({bookmarkJson}: {bookmarkJson: string}) => void; + hideThumbnailFilterModes?: Array; + onToolChanged?: ({previousTool, tool}: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void; + horizontalScrollPos?: number; + verticalScrollPos?: number; + onTextSearchStart?: () => void; + onTextSearchResult?: ({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; + hideViewModeItems?: Array; + pageStackEnabled?: boolean; + showQuickNavigationButton?: boolean; + photoPickerEnabled?: boolean; + autoResizeFreeTextEnabled?: boolean; + annotationsListEditingEnabled?: boolean; + showNavigationListAsSidePanelOnLargeDevices?: boolean; + restrictDownloadUsage?: boolean; + userBookmarksListEditingEnabled?: boolean; + imageInReflowEnabled?: boolean; + reflowOrientation?: Config.ReflowOrientation; + onUndoRedoStateChanged?: () => void; + tabletLayoutEnabled?: boolean; + initialToolbar?: string; + inkMultiStrokeEnabled?: boolean; + defaultEraserType?: Config.EraserType; + exportPath?: string; + openUrlPath?: string; + hideScrollbars?: boolean; + saveStateEnabled?: boolean; + openSavedCopyInNewTab?: boolean; + + onChange?(event): void; +} + + +export class DocumentView extends PureComponent { + + _viewerRef; + + onChange = (event) => { + if (event.nativeEvent.onLeadingNavButtonPressed) { + if (this.props.onLeadingNavButtonPressed) { + this.props.onLeadingNavButtonPressed(); + } + } else if (event.nativeEvent.onDocumentLoaded) { + if (this.props.onDocumentLoaded) { + this.props.onDocumentLoaded(event.nativeEvent.onDocumentLoaded); + } + } else if (event.nativeEvent.onPageChanged) { + if (this.props.onPageChanged) { + this.props.onPageChanged({ + 'previousPageNumber': event.nativeEvent.previousPageNumber, + 'pageNumber': event.nativeEvent.pageNumber, + }); + } + } else if (event.nativeEvent.onScrollChanged) { + if (this.props.onScrollChanged) { + this.props.onScrollChanged({ + 'horizontal': event.nativeEvent.horizontal, + 'vertical': event.nativeEvent.vertical, + }); + } + } else if (event.nativeEvent.onZoomChanged) { + if (this.props.onZoomChanged) { + this.props.onZoomChanged({ + 'zoom': event.nativeEvent.zoom, + }); + } + } else if (event.nativeEvent.onZoomFinished) { + if (this.props.onZoomFinished) { + this.props.onZoomFinished({ + 'zoom': event.nativeEvent.zoom, + }); + } + } else if (event.nativeEvent.onLayoutChanged) { + if (this.props.onLayoutChanged) { + this.props.onLayoutChanged(); + } + } else if (event.nativeEvent.onAnnotationChanged) { + if (this.props.onAnnotationChanged) { + this.props.onAnnotationChanged({ + 'action': event.nativeEvent.action, + 'annotations': event.nativeEvent.annotations, + }); + } + } else if (event.nativeEvent.onAnnotationsSelected) { + if (this.props.onAnnotationsSelected) { + this.props.onAnnotationsSelected({ + 'annotations': event.nativeEvent.annotations, + }); + } + } else if (event.nativeEvent.onFormFieldValueChanged) { + if (this.props.onFormFieldValueChanged) { + this.props.onFormFieldValueChanged({ + 'fields': event.nativeEvent.fields, + }); + } + } else if (event.nativeEvent.onDocumentError) { + if (this.props.onDocumentError) { + this.props.onDocumentError(event.nativeEvent.onDocumentError); + } else { + const msg = event.nativeEvent.onDocumentError ? event.nativeEvent.onDocumentError : 'Unknown error'; + Alert.alert( + 'Alert', + msg, + [ + { text: 'OK' } + ], + { cancelable: true } + ); + } + } else if (event.nativeEvent.onExportAnnotationCommand) { + if (this.props.onExportAnnotationCommand) { + this.props.onExportAnnotationCommand({ + 'action': event.nativeEvent.action, + 'xfdfCommand': event.nativeEvent.xfdfCommand, + 'annotations': event.nativeEvent.annotations, + }); + } + } else if (event.nativeEvent.onAnnotationMenuPress) { + if (this.props.onAnnotationMenuPress) { + this.props.onAnnotationMenuPress({ + 'annotationMenu': event.nativeEvent.annotationMenu, + 'annotations': event.nativeEvent.annotations, + }); + } + } else if (event.nativeEvent.onLongPressMenuPress) { + if (this.props.onLongPressMenuPress) { + this.props.onLongPressMenuPress({ + 'longPressMenu': event.nativeEvent.longPressMenu, + 'longPressText': event.nativeEvent.longPressText, + }); + } + } else if (event.nativeEvent.onBehaviorActivated) { + if (this.props.onBehaviorActivated) { + this.props.onBehaviorActivated({ + 'action': event.nativeEvent.action, + 'data': event.nativeEvent.data, + }); + } + } else if (event.nativeEvent.onBookmarkChanged) { + if (this.props.onBookmarkChanged) { + this.props.onBookmarkChanged({ + 'bookmarkJson': event.nativeEvent.bookmarkJson, + }); + } + } else if (event.nativeEvent.onToolChanged) { + if (this.props.onToolChanged) { + this.props.onToolChanged({ + 'previousTool': event.nativeEvent.previousTool, + 'tool': event.nativeEvent.tool, + }); + } + } else if (event.nativeEvent.onTextSearchStart) { + if (this.props.onTextSearchStart) { + this.props.onTextSearchStart(); + } + } else if (event.nativeEvent.onTextSearchResult) { + if (this.props.onTextSearchResult) { + this.props.onTextSearchResult({ + 'found': event.nativeEvent.found, + 'textSelection': event.nativeEvent.textSelection, + }); + } + } else if (event.nativeEvent.onUndoRedoStateChanged) { + if (this.props.onUndoRedoStateChanged) { + this.props.onUndoRedoStateChanged(); + } + } + } + + getDocumentPath = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getDocumentPath(tag); + } + return Promise.resolve(); + } + + setToolMode = (toolMode) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setToolMode(tag, toolMode); + } + return Promise.resolve(); + } + + commitTool = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.commitTool(tag); + } + return Promise.resolve(); + } + + getPageCount = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageCount(tag); + } + return Promise.resolve(); + } + + importBookmarkJson = (bookmarkJson) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.importBookmarkJson(tag, bookmarkJson); + } + return Promise.resolve(); + } + + importAnnotationCommand = (xfdfCommand, initialLoad) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + if (initialLoad === undefined) { + initialLoad = false; + } + return DocumentViewManager.importAnnotationCommand( + tag, + xfdfCommand, + initialLoad, + ); + } + return Promise.resolve(); + } + + importAnnotations = (xfdf) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.importAnnotations(tag, xfdf); + } + return Promise.resolve(); + } + + exportAnnotations = (options) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.exportAnnotations(tag, options); + } + return Promise.resolve(); + } + + flattenAnnotations = (formsOnly) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.flattenAnnotations(tag, formsOnly); + } + return Promise.resolve(); + } + + deleteAnnotations = (annotations) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.deleteAnnotations(tag, annotations); + } + return Promise.resolve(); + } + + saveDocument = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.saveDocument(tag); + } + return Promise.resolve(); + } + + setFlagForFields = (fields, flag, value) => { + const tag = findNodeHandle(this._viewerRef); + if(tag != null) { + return DocumentViewManager.setFlagForFields(tag, fields, flag, value); + } + return Promise.resolve(); + } + + getField = (fieldName) => { + const tag = findNodeHandle(this._viewerRef); + if(tag != null) { + return DocumentViewManager.getField(tag, fieldName); + } + return Promise.resolve(); + } + + /** + * note: this function exists for supporting the old version. It simply calls setValuesForFields. + * + */ + setValueForFields = (fieldsMap) => { + return this.setValuesForFields(fieldsMap); + } + + setValuesForFields = (fieldsMap) => { + const tag = findNodeHandle(this._viewerRef); + if(tag != null) { + return DocumentViewManager.setValuesForFields(tag, fieldsMap); + } + return Promise.resolve(); + } + + handleBackButton = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.handleBackButton(tag); + } + return Promise.resolve(); + } + + + /** + * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. + * + */ + setFlagForAnnotations = (annotationFlagList) => { + return this.setFlagsForAnnotations(annotationFlagList); + } + + setFlagsForAnnotations = (annotationFlagList) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setFlagsForAnnotations(tag, annotationFlagList); + } + return Promise.resolve(); + } + + selectAnnotation = (id, pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.selectAnnotation(tag, id, pageNumber); + } + return Promise.resolve(); + } + + /** + * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. + * + */ + setPropertyForAnnotation = (id, pageNumber, propertyMap) => { + return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); // check this._viewerRef + } + + setPropertiesForAnnotation = (id, pageNumber, propertyMap) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setPropertiesForAnnotation(tag, id, pageNumber, propertyMap); + } + return Promise.resolve(); + } + + getPropertiesForAnnotation = (id, pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); + } + return Promise.resolve(); + } + + setDrawAnnotations = (drawAnnotations) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setDrawAnnotations(tag, drawAnnotations); + } + return Promise.resolve(); + } + + setVisibilityForAnnotation = (id, pageNumber, visibility) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + DocumentViewManager.setVisibilityForAnnotation(tag, id, pageNumber, visibility); + } + return Promise.resolve(); + } + + setHighlightFields = (highlightFields) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + DocumentViewManager.setHighlightFields(tag, highlightFields); + } + return Promise.resolve(); + } + + getAnnotationAtPoint = (x, y, distanceThreshold, minimumLineWeight) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); + } + return Promise.resolve(); + } + + getAnnotationListAt = (x1, y1, x2, y2) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); + } + return Promise.resolve(); + } + + getAnnotationsOnPage = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); + } + return Promise.resolve(); + } + + getCustomDataForAnnotation = (annotationID, pageNumber, key) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); + } + return Promise.resolve(); + } + + getPageCropBox = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageCropBox(tag, pageNumber); + } + return Promise.resolve(); + } + + setCurrentPage = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setCurrentPage(tag, pageNumber); + } + return Promise.resolve(); + } + + getVisiblePages = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getVisiblePages(tag); + } + return Promise.resolve(); + } + + gotoPreviousPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoPreviousPage(tag); + } + return Promise.resolve(); + } + + gotoNextPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoNextPage(tag); + } + return Promise.resolve(); + } + + gotoFirstPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoFirstPage(tag); + } + return Promise.resolve(); + } + + gotoLastPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoLastPage(tag); + } + return Promise.resolve(); + } + + showGoToPageView = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.showGoToPageView(tag); + } + return Promise.resolve(); + } + + closeAllTabs = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.closeAllTabs(tag); + } + return Promise.resolve(); + } + + getZoom = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getZoom(tag); + } + return Promise.resolve(); + } + + setZoomLimits = (zoomLimitMode, minimum, maximum) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); + } + return Promise.resolve(); + } + + zoomWithCenter = (zoom, x, y) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.zoomWithCenter(tag, zoom, x, y); + } + return Promise.resolve(); + } + + zoomToRect = (pageNumber, rect) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.zoomToRect(tag, pageNumber, rect); + } + return Promise.resolve(); + } + + smartZoom = (x, y, animated) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.smartZoom(tag, x, y, animated); + } + return Promise.resolve(); + } + + getScrollPos = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getScrollPos(tag); + } + return Promise.resolve(); + } + + getCanvasSize = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getCanvasSize(tag); + } + return Promise.resolve(); + } + + getPageRotation = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageRotation(tag); + } + return Promise.resolve(); + } + + rotateClockwise = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.rotateClockwise(tag); + } + return Promise.resolve(); + } + + rotateCounterClockwise = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.rotateCounterClockwise(tag); + } + return Promise.resolve(); + } + + + convertScreenPointsToPagePoints = (points) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); + } + return Promise.resolve(); + } + + convertPagePointsToScreenPoints = (points) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); + } + return Promise.resolve(); + } + + getPageNumberFromScreenPoint = (x, y) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); + } + return Promise.resolve(); + } + + setProgressiveRendering = (progressiveRendering, initialDelay, interval) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setProgressiveRendering(tag, progressiveRendering, initialDelay, interval); + } + return Promise.resolve(); + } + + setImageSmoothing = (imageSmoothing) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setImageSmoothing(tag, imageSmoothing); + } + return Promise.resolve(); + } + + setOverprint = (overprint) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setOverprint(tag, overprint); + } + return Promise.resolve(); + } + + setColorPostProcessMode = (colorPostProcessMode) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); + } + return Promise.resolve(); + } + + setColorPostProcessColors = (whiteColor, blackColor) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setColorPostProcessColors(tag, whiteColor, blackColor); + } + return Promise.resolve(); + } + + startSearchMode = (searchString, matchCase, matchWholeWord) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.startSearchMode(tag, searchString, matchCase, matchWholeWord); + } + return Promise.resolve(); + } + + exitSearchMode = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.exitSearchMode(tag); + } + return Promise.resolve(); + } + + findText = (searchString, matchCase, matchWholeWord, searchUp, regExp) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.findText(tag, searchString, matchCase, matchWholeWord, searchUp, regExp); + } + return Promise.resolve(); + } + + cancelFindText = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.cancelFindText(tag); + } + return Promise.resolve(); + } + + getSelection = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getSelection(tag, pageNumber); + } + return Promise.resolve(); + } + + hasSelection = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.hasSelection(tag); + } + return Promise.resolve(); + } + + clearSelection = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.clearSelection(tag); + } + return Promise.resolve(); + } + + getSelectionPageRange = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getSelectionPageRange(tag); + } + return Promise.resolve(); + } + + hasSelectionOnPage = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); + } + return Promise.resolve(); + } + + + selectInRect = (rect) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.selectInRect(tag, rect); + } + return Promise.resolve(); + } + + isThereTextInRect = (rect) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.isThereTextInRect(tag, rect); + } + return Promise.resolve(); + } + + selectAll = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.selectAll(tag); + } + return Promise.resolve(); + } + + + setUrlExtraction = (urlExtraction) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setUrlExtraction(tag, urlExtraction); + } + return Promise.resolve(); + } + + setPageBorderVisibility = (pageBorderVisibility) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setPageBorderVisibility(tag, pageBorderVisibility); + } + return Promise.resolve(); + } + + setPageTransparencyGrid = (pageTransparencyGrid) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setPageTransparencyGrid(tag, pageTransparencyGrid); + } + return Promise.resolve(); + } + + setDefaultPageColor = (defaultPageColor) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setDefaultPageColor(tag, defaultPageColor); + } + return Promise.resolve(); + } + + setBackgroundColor = (backgroundColor) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setBackgroundColor(tag, backgroundColor); + } + return Promise.resolve(); + } + + exportAsImage = (pageNumber, dpi, exportFormat) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); + } + return Promise.resolve(); + } + + undo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.undo(tag); + } + return Promise.resolve(); + } + + redo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.redo(tag); + } + return Promise.resolve(); + } + + canUndo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.canUndo(tag); + } + return Promise.resolve(); + } + + canRedo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.canRedo(tag); + } + return Promise.resolve(); + } + + showCrop = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.showCrop(tag); + } + return Promise.resolve(); + } + + setCurrentToolbar = (toolbar) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setCurrentToolbar(tag, toolbar); + } + return Promise.resolve(); + } + + openThumbnailsView = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.openThumbnailsView(tag); + } + return Promise.resolve(); + } + + _setNativeRef = (ref) => { // check ref type. + this._viewerRef = ref; + }; + + render() { + return ( + + ) + } +} + +const name = Platform.OS === 'ios' ? 'RNTPTDocumentView' : 'RCTDocumentView'; + + +const RCTDocumentView = requireNativeComponent( // https://github.com/facebook/react-native/issues/28351 + name, + // @ts-ignore + DocumentView, + { + nativeOnly: { + onChange: true + } + } +); diff --git a/types/PDFViewCtrl/PDFViewCtrl.tsx b/types/PDFViewCtrl/PDFViewCtrl.tsx new file mode 100644 index 000000000..48ef4e737 --- /dev/null +++ b/types/PDFViewCtrl/PDFViewCtrl.tsx @@ -0,0 +1,41 @@ +import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; +import { + requireNativeComponent, + ViewProps, + ViewPropTypes, + Dimensions, + Platform +} from 'react-native'; + +const { height, width } = Dimensions.get('window'); + +export interface PDFViewCtrlProps extends ViewProps { // needed to add style to props + document: string; + style?: object; +} + +export class PDFViewCtrl extends PureComponent { + + render() { + return ( + + ) + } +} + +var iface = { + name: 'PDFViewCtrl', + propTypes: { + document: PropTypes.string, + ...ViewPropTypes, // include the default view properties + }, +}; + +const name = Platform.OS === 'ios' ? 'RNTPTPDFViewCtrl' : 'RCTPDFViewCtrl'; + +// @ts-ignore +const RCTPDFViewCtrl = requireNativeComponent(name, PDFViewCtrl, iface); // https://github.com/facebook/react-native/issues/28351 \ No newline at end of file From 1390bb33c271aedad8177601c4cfbc0b1543e84d Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 3 Aug 2021 17:20:23 -0700 Subject: [PATCH 041/226] move d.ts files move d.ts files --- index.d.ts | 8 ++++---- src/types/ConfigOptions.d.ts | 2 +- {src/types => types/AnnotOptions}/AnnotOptions.d.ts | 2 +- {src/types => types/Config}/Config.d.ts | 0 {src/types => types/DocumentView}/DocumentView.d.ts | 4 ++-- {src/types => types/PDFViewCtrl}/PDFViewCtrl.d.ts | 0 6 files changed, 8 insertions(+), 8 deletions(-) rename {src/types => types/AnnotOptions}/AnnotOptions.d.ts (95%) rename {src/types => types/Config}/Config.d.ts (100%) rename {src/types => types/DocumentView}/DocumentView.d.ts (98%) rename {src/types => types/PDFViewCtrl}/PDFViewCtrl.d.ts (100%) diff --git a/index.d.ts b/index.d.ts index 894199e44..c1f561981 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,12 +11,12 @@ export interface Pdftron { export const RNPdftron : Pdftron; -export {Config} from "./src/types/Config"; +export {Config} from "react-native-pdftron/types/Config/Config"; export * as ConfigOptions from "./src/types/ConfigOptions"; -export {DocumentView} from "./src/types/DocumentView"; +export {DocumentView} from "react-native-pdftron/types/DocumentView/DocumentView"; -export * as AnnotOptions from "./src/types/AnnotOptions"; +export * as AnnotOptions from "react-native-pdftron/types/AnnotOptions/AnnotOptions"; -export {PDFViewCtrl} from "./src/types/PDFViewCtrl"; \ No newline at end of file +export {PDFViewCtrl} from "react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl"; \ No newline at end of file diff --git a/src/types/ConfigOptions.d.ts b/src/types/ConfigOptions.d.ts index 96d02e487..41a81f8d8 100644 --- a/src/types/ConfigOptions.d.ts +++ b/src/types/ConfigOptions.d.ts @@ -1,4 +1,4 @@ -import Config from "./Config"; +import Config from "react-native-pdftron/types/Config/Config"; type ValueOf = T[keyof T]; diff --git a/src/types/AnnotOptions.d.ts b/types/AnnotOptions/AnnotOptions.d.ts similarity index 95% rename from src/types/AnnotOptions.d.ts rename to types/AnnotOptions/AnnotOptions.d.ts index ec66ebe95..d1f7f7c00 100644 --- a/src/types/AnnotOptions.d.ts +++ b/types/AnnotOptions/AnnotOptions.d.ts @@ -1,4 +1,4 @@ -import * as ConfigOptions from './ConfigOptions'; +import * as ConfigOptions from 'react-native-pdftron/src/types/ConfigOptions'; export interface Annotation { id: string; diff --git a/src/types/Config.d.ts b/types/Config/Config.d.ts similarity index 100% rename from src/types/Config.d.ts rename to types/Config/Config.d.ts diff --git a/src/types/DocumentView.d.ts b/types/DocumentView/DocumentView.d.ts similarity index 98% rename from src/types/DocumentView.d.ts rename to types/DocumentView/DocumentView.d.ts index 9a5cf4a38..6c7324897 100644 --- a/src/types/DocumentView.d.ts +++ b/types/DocumentView/DocumentView.d.ts @@ -1,8 +1,8 @@ import { PureComponent } from "react"; import { ViewProps } from "react-native"; -import * as ConfigOptions from "./ConfigOptions"; -import * as AnnotOptions from "./AnnotOptions"; +import * as ConfigOptions from "react-native-pdftron/src/types/ConfigOptions"; +import * as AnnotOptions from "react-native-pdftron/types/AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { document: string; diff --git a/src/types/PDFViewCtrl.d.ts b/types/PDFViewCtrl/PDFViewCtrl.d.ts similarity index 100% rename from src/types/PDFViewCtrl.d.ts rename to types/PDFViewCtrl/PDFViewCtrl.d.ts From f4688d5f4dd8b50e1565f73b9f22d47fce0d2ac1 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 3 Aug 2021 17:22:09 -0700 Subject: [PATCH 042/226] Revert "move d.ts files" This reverts commit 1390bb33c271aedad8177601c4cfbc0b1543e84d. --- index.d.ts | 8 ++++---- {types/AnnotOptions => src/types}/AnnotOptions.d.ts | 2 +- {types/Config => src/types}/Config.d.ts | 0 src/types/ConfigOptions.d.ts | 2 +- {types/DocumentView => src/types}/DocumentView.d.ts | 4 ++-- {types/PDFViewCtrl => src/types}/PDFViewCtrl.d.ts | 0 6 files changed, 8 insertions(+), 8 deletions(-) rename {types/AnnotOptions => src/types}/AnnotOptions.d.ts (95%) rename {types/Config => src/types}/Config.d.ts (100%) rename {types/DocumentView => src/types}/DocumentView.d.ts (98%) rename {types/PDFViewCtrl => src/types}/PDFViewCtrl.d.ts (100%) diff --git a/index.d.ts b/index.d.ts index c1f561981..894199e44 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,12 +11,12 @@ export interface Pdftron { export const RNPdftron : Pdftron; -export {Config} from "react-native-pdftron/types/Config/Config"; +export {Config} from "./src/types/Config"; export * as ConfigOptions from "./src/types/ConfigOptions"; -export {DocumentView} from "react-native-pdftron/types/DocumentView/DocumentView"; +export {DocumentView} from "./src/types/DocumentView"; -export * as AnnotOptions from "react-native-pdftron/types/AnnotOptions/AnnotOptions"; +export * as AnnotOptions from "./src/types/AnnotOptions"; -export {PDFViewCtrl} from "react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl"; \ No newline at end of file +export {PDFViewCtrl} from "./src/types/PDFViewCtrl"; \ No newline at end of file diff --git a/types/AnnotOptions/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts similarity index 95% rename from types/AnnotOptions/AnnotOptions.d.ts rename to src/types/AnnotOptions.d.ts index d1f7f7c00..ec66ebe95 100644 --- a/types/AnnotOptions/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -1,4 +1,4 @@ -import * as ConfigOptions from 'react-native-pdftron/src/types/ConfigOptions'; +import * as ConfigOptions from './ConfigOptions'; export interface Annotation { id: string; diff --git a/types/Config/Config.d.ts b/src/types/Config.d.ts similarity index 100% rename from types/Config/Config.d.ts rename to src/types/Config.d.ts diff --git a/src/types/ConfigOptions.d.ts b/src/types/ConfigOptions.d.ts index 41a81f8d8..96d02e487 100644 --- a/src/types/ConfigOptions.d.ts +++ b/src/types/ConfigOptions.d.ts @@ -1,4 +1,4 @@ -import Config from "react-native-pdftron/types/Config/Config"; +import Config from "./Config"; type ValueOf = T[keyof T]; diff --git a/types/DocumentView/DocumentView.d.ts b/src/types/DocumentView.d.ts similarity index 98% rename from types/DocumentView/DocumentView.d.ts rename to src/types/DocumentView.d.ts index 6c7324897..9a5cf4a38 100644 --- a/types/DocumentView/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -1,8 +1,8 @@ import { PureComponent } from "react"; import { ViewProps } from "react-native"; -import * as ConfigOptions from "react-native-pdftron/src/types/ConfigOptions"; -import * as AnnotOptions from "react-native-pdftron/types/AnnotOptions/AnnotOptions"; +import * as ConfigOptions from "./ConfigOptions"; +import * as AnnotOptions from "./AnnotOptions"; export interface DocumentViewProps extends ViewProps { document: string; diff --git a/types/PDFViewCtrl/PDFViewCtrl.d.ts b/src/types/PDFViewCtrl.d.ts similarity index 100% rename from types/PDFViewCtrl/PDFViewCtrl.d.ts rename to src/types/PDFViewCtrl.d.ts From 553b7f4a7003952918d264db81517b7ad36037bf Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 3 Aug 2021 17:27:29 -0700 Subject: [PATCH 043/226] generate new d.ts, .js files --- index.d.ts | 21 +- index.js | 20 +- src/AnnotOptions/AnnotOptions.js | 1 + src/Config/Config.js | 517 ++++---- src/DocumentView/DocumentView.js | 1753 +++++++++++++-------------- src/PDFViewCtrl/PDFViewCtrl.js | 46 +- src/types/AnnotOptions.d.ts | 32 +- src/types/Config.d.ts | 524 ++++---- src/types/ConfigOptions.d.ts | 30 - src/types/DocumentView.d.ts | 316 ++++- src/types/PDFViewCtrl.d.ts | 7 +- tsconfig.json | 1 + types/DocumentView/DocumentView.tsx | 266 ++-- 13 files changed, 1827 insertions(+), 1707 deletions(-) create mode 100644 src/AnnotOptions/AnnotOptions.js delete mode 100644 src/types/ConfigOptions.d.ts diff --git a/index.d.ts b/index.d.ts index 894199e44..40bbe9389 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,12 +1,15 @@ +import { PDFViewCtrl } from 'react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from 'react-native-pdftron/types/DocumentView/DocumentView'; +import { Config } from 'react-native-pdftron/types/Config/Config'; export interface Pdftron { - initialize(licenseKey: string) : void; - enableJavaScript(enabled: boolean) : void; - getVersion() : Promise; - getPlatformVersion() : Promise; - getSystemFontList() : Promise; - clearRubberStampCache() : Promise; - encryptDocument(filePath: string, password: string, currentPassword: string) : Promise; - pdfFromOfficeTemplate(docxPath: string, json: object) : Promise; + initialize?(licenseKey: string): void; + enableJavaScript?(enabled: boolean): void; + getVersion?(): Promise; + getPlatformVersion?(): Promise; + getSystemFontList?(): Promise; + clearRubberStampCache?(): Promise; + encryptDocument?(filePath: string, password: string, currentPassword: string): Promise; + pdfFromOfficeTemplate?(docxPath: string, json: object): Promise; } export const RNPdftron : Pdftron; @@ -19,4 +22,4 @@ export {DocumentView} from "./src/types/DocumentView"; export * as AnnotOptions from "./src/types/AnnotOptions"; -export {PDFViewCtrl} from "./src/types/PDFViewCtrl"; \ No newline at end of file +export {PDFViewCtrl} from "./src/types/PDFViewCtrl"; diff --git a/index.js b/index.js index e5d3aa9aa..74ff14f9e 100644 --- a/index.js +++ b/index.js @@ -1,16 +1,6 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import { NativeModules } from 'react-native'; - -import PDFViewCtrl from './src/PDFViewCtrl'; -import DocumentView from './src/DocumentView'; -import Config from './src/Config'; - -const { RNPdftron } = NativeModules; - -export { - RNPdftron, - PDFViewCtrl, - DocumentView, - Config -}; +import { PDFViewCtrl } from 'react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from 'react-native-pdftron/types/DocumentView/DocumentView'; +import { Config } from 'react-native-pdftron/types/Config/Config'; +const RNPdftron = NativeModules; +export { RNPdftron, PDFViewCtrl, DocumentView, Config }; diff --git a/src/AnnotOptions/AnnotOptions.js b/src/AnnotOptions/AnnotOptions.js new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/src/AnnotOptions/AnnotOptions.js @@ -0,0 +1 @@ +export {}; diff --git a/src/Config/Config.js b/src/Config/Config.js index babd63fe0..277f5ac70 100644 --- a/src/Config/Config.js +++ b/src/Config/Config.js @@ -1,271 +1,248 @@ -export default { - - // 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', - - // Android only - saveReducedCopyButton: 'saveReducedCopyButton', - saveCroppedCopyButton: 'saveCroppedCopyButton', - savePasswordCopyButton: 'savePasswordCopyButton', - }, - - // Tools define the various kinds of tools for the viewer - Tools: { - annotationEdit: 'AnnotationEdit', - textSelect: 'TextSelect', - pan: 'Pan', - annotationEraserTool: 'AnnotationEraserTool', - 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', - annotationCreateLinkText: 'AnnotationCreateLinkText', - annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter', - formCreateTextField: 'FormCreateTextField', - formCreateCheckboxField: 'FormCreateCheckboxField', - formCreateSignatureField: 'FormCreateSignatureField', - formCreateRadioField: 'FormCreateRadioField', - formCreateComboBoxField: 'FormCreateComboBoxField', - formCreateListBoxField: 'FormCreateListBoxField', - - // iOS only. - pencilKitDrawing: 'PencilKitDrawing', - }, - - // 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', - delete: 'delete', - flatten: 'flatten', - editText: 'editText', - editInk: 'editInk', - search: 'search', - share: 'share', - markupType: 'markupType', - read: 'read', - screenCapture: 'screenCapture', - playSound: 'playSound', - openAttachment: 'openAttachment', - calibrate: 'calibrate', - }, - - // EraserType defines the type of earse 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" - }, - - // ThumbnailFilterMode defines filter modes in the thumbnails browser - ThumbnailFilterMode: { - Annotated: "annotated", - Bookmarked: "bookmarked", - }, - - // 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", - }, - - // 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", - }, +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', + // Android only + saveReducedCopyButton: 'saveReducedCopyButton', + saveCroppedCopyButton: 'saveCroppedCopyButton', + savePasswordCopyButton: 'savePasswordCopyButton', + }, + // Tools define the various kinds of tools for the viewer + Tools: { + annotationEdit: 'AnnotationEdit', + textSelect: 'TextSelect', + pan: 'Pan', + annotationEraserTool: 'AnnotationEraserTool', + 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', + annotationCreateLinkText: 'AnnotationCreateLinkText', + annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter', + formCreateTextField: 'FormCreateTextField', + formCreateCheckboxField: 'FormCreateCheckboxField', + formCreateSignatureField: 'FormCreateSignatureField', + formCreateRadioField: 'FormCreateRadioField', + formCreateComboBoxField: 'FormCreateComboBoxField', + formCreateListBoxField: 'FormCreateListBoxField', + // iOS only. + pencilKitDrawing: 'PencilKitDrawing', + }, + // 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', + delete: 'delete', + flatten: 'flatten', + editText: 'editText', + editInk: 'editInk', + search: 'search', + share: 'share', + markupType: 'markupType', + read: 'read', + screenCapture: 'screenCapture', + playSound: 'playSound', + openAttachment: 'openAttachment', + calibrate: 'calibrate', + }, + // EraserType defines the type of earse 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" + }, + // ThumbnailFilterMode defines filter modes in the thumbnails browser + ThumbnailFilterMode: { + Annotated: "annotated", + Bookmarked: "bookmarked", + }, + // 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", + }, + // 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", + }, }; diff --git a/src/DocumentView/DocumentView.js b/src/DocumentView/DocumentView.js index 2e7e819ca..c3057f7a9 100644 --- a/src/DocumentView/DocumentView.js +++ b/src/DocumentView/DocumentView.js @@ -1,931 +1,838 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; -import { - requireNativeComponent, - ViewPropTypes, - Platform, - Alert, - NativeModules, - findNodeHandle -} from 'react-native'; +import { requireNativeComponent, ViewPropTypes, Platform, Alert, NativeModules, findNodeHandle, } from 'react-native'; const { DocumentViewManager } = NativeModules; - -export default class DocumentView extends PureComponent { - - static propTypes = { - document: PropTypes.string, - password: PropTypes.string, - initialPageNumber: PropTypes.number, - pageNumber: PropTypes.number, - customHeaders: PropTypes.object, - leadingNavButtonIcon: PropTypes.string, - showLeadingNavButton: PropTypes.bool, - onLeadingNavButtonPressed: PropTypes.func, - onDocumentLoaded: PropTypes.func, - onDocumentError: PropTypes.func, - onPageChanged: PropTypes.func, - onScrollChanged: PropTypes.func, - onZoomChanged: PropTypes.func, - onZoomFinished: PropTypes.func, - zoom: PropTypes.number, - disabledElements: PropTypes.array, - disabledTools: PropTypes.array, - longPressMenuItems: PropTypes.array, - overrideLongPressMenuBehavior: PropTypes.array, - onLongPressMenuPress: PropTypes.func, - longPressMenuEnabled: PropTypes.bool, - annotationMenuItems: PropTypes.array, - overrideAnnotationMenuBehavior: PropTypes.array, - onAnnotationMenuPress: PropTypes.func, - hideAnnotationMenu: PropTypes.array, - overrideBehavior: PropTypes.array, - onBehaviorActivated: PropTypes.func, - topToolbarEnabled: PropTypes.bool, - bottomToolbarEnabled: PropTypes.bool, - hideToolbarsOnTap: PropTypes.bool, - documentSliderEnabled: PropTypes.bool, - pageIndicatorEnabled: PropTypes.bool, - keyboardShortcutsEnabled: PropTypes.bool, - onAnnotationsSelected: PropTypes.func, - onAnnotationChanged: PropTypes.func, - onFormFieldValueChanged: PropTypes.func, - readOnly: PropTypes.bool, - thumbnailViewEditingEnabled: PropTypes.bool, - fitMode: PropTypes.string, - layoutMode: PropTypes.string, - onLayoutChanged: PropTypes.func, - padStatusBar: PropTypes.bool, - continuousAnnotationEditing: PropTypes.bool, - selectAnnotationAfterCreation: PropTypes.bool, - annotationAuthor: PropTypes.string, - showSavedSignatures: PropTypes.bool, - isBase64String: PropTypes.bool, - collabEnabled: PropTypes.bool, - currentUser: PropTypes.string, - currentUserName: PropTypes.string, - onExportAnnotationCommand: PropTypes.func, - autoSaveEnabled: PropTypes.bool, - pageChangeOnTap: PropTypes.bool, - followSystemDarkMode: PropTypes.bool, - useStylusAsPen: PropTypes.bool, - multiTabEnabled: PropTypes.bool, - tabTitle: PropTypes.string, - maxTabCount: PropTypes.number, - signSignatureFieldsWithStamps: PropTypes.bool, - annotationPermissionCheckEnabled: PropTypes.bool, - annotationToolbars: PropTypes.array, - hideDefaultAnnotationToolbars: PropTypes.array, - topAppNavBarRightBar: PropTypes.array, - bottomToolbar: PropTypes.array, - hideAnnotationToolbarSwitcher: PropTypes.bool, - hideTopToolbars: PropTypes.bool, - hideTopAppNavBar: PropTypes.bool, - onBookmarkChanged: PropTypes.func, - hideThumbnailFilterModes: PropTypes.array, - onToolChanged: PropTypes.func, - horizontalScrollPos: PropTypes.number, - verticalScrollPos: PropTypes.number, - onTextSearchStart: PropTypes.func, - onTextSearchResult: PropTypes.func, - hideViewModeItems: PropTypes.array, - pageStackEnabled: PropTypes.bool, - showQuickNavigationButton: PropTypes.bool, - photoPickerEnabled: PropTypes.bool, - autoResizeFreeTextEnabled: PropTypes.bool, - annotationsListEditingEnabled: PropTypes.bool, - showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, - restrictDownloadUsage: PropTypes.bool, - userBookmarksListEditingEnabled: PropTypes.bool, - imageInReflowEnabled: PropTypes.bool, - reflowOrientation: PropTypes.string, - onUndoRedoStateChanged: PropTypes.func, - tabletLayoutEnabled: PropTypes.bool, - initialToolbar: PropTypes.string, - inkMultiStrokeEnabled: PropTypes.bool, - defaultEraserType: PropTypes.string, - exportPath: PropTypes.string, - openUrlPath: PropTypes.string, - hideScrollbars: PropTypes.bool, - saveStateEnabled: PropTypes.bool, - openSavedCopyInNewTab: PropTypes.bool, - ...ViewPropTypes, - }; - - onChange = (event) => { - if (event.nativeEvent.onLeadingNavButtonPressed) { - if (this.props.onLeadingNavButtonPressed) { - this.props.onLeadingNavButtonPressed(); - } - } else if (event.nativeEvent.onDocumentLoaded) { - if (this.props.onDocumentLoaded) { - this.props.onDocumentLoaded(event.nativeEvent.onDocumentLoaded); - } - } else if (event.nativeEvent.onPageChanged) { - if (this.props.onPageChanged) { - this.props.onPageChanged({ - 'previousPageNumber': event.nativeEvent.previousPageNumber, - 'pageNumber': event.nativeEvent.pageNumber, - }); - } - } else if (event.nativeEvent.onScrollChanged) { - if (this.props.onScrollChanged) { - this.props.onScrollChanged({ - 'horizontal': event.nativeEvent.horizontal, - 'vertical': event.nativeEvent.vertical, - }); - } - } else if (event.nativeEvent.onZoomChanged) { - if (this.props.onZoomChanged) { - this.props.onZoomChanged({ - 'zoom': event.nativeEvent.zoom, - }); - } - } else if (event.nativeEvent.onZoomFinished) { - if (this.props.onZoomFinished) { - this.props.onZoomFinished({ - 'zoom': event.nativeEvent.zoom, - }); - } - } else if (event.nativeEvent.onLayoutChanged) { - if (this.props.onLayoutChanged) { - this.props.onLayoutChanged(); - } - } else if (event.nativeEvent.onAnnotationChanged) { - if (this.props.onAnnotationChanged) { - this.props.onAnnotationChanged({ - 'action': event.nativeEvent.action, - 'annotations': event.nativeEvent.annotations, - }); - } - } else if (event.nativeEvent.onAnnotationsSelected) { - if (this.props.onAnnotationsSelected) { - this.props.onAnnotationsSelected({ - 'annotations': event.nativeEvent.annotations, - }); - } - } else if (event.nativeEvent.onFormFieldValueChanged) { - if (this.props.onFormFieldValueChanged) { - this.props.onFormFieldValueChanged({ - 'fields': event.nativeEvent.fields, - }); - } - } else if (event.nativeEvent.onDocumentError) { - if (this.props.onDocumentError) { - this.props.onDocumentError(event.nativeEvent.onDocumentError); - } else { - const msg = event.nativeEvent.onDocumentError ? event.nativeEvent.onDocumentError : 'Unknown error'; - Alert.alert( - 'Alert', - msg, - [ - { text: 'OK' } - ], - { cancelable: true } - ); - } - } else if (event.nativeEvent.onExportAnnotationCommand) { - if (this.props.onExportAnnotationCommand) { - this.props.onExportAnnotationCommand({ - 'action': event.nativeEvent.action, - 'xfdfCommand': event.nativeEvent.xfdfCommand, - 'annotations': event.nativeEvent.annotations, - }); - } - } else if (event.nativeEvent.onAnnotationMenuPress) { - if (this.props.onAnnotationMenuPress) { - this.props.onAnnotationMenuPress({ - 'annotationMenu': event.nativeEvent.annotationMenu, - 'annotations': event.nativeEvent.annotations, - }); - } - } else if (event.nativeEvent.onLongPressMenuPress) { - if (this.props.onLongPressMenuPress) { - this.props.onLongPressMenuPress({ - 'longPressMenu': event.nativeEvent.longPressMenu, - 'longPressText': event.nativeEvent.longPressText, - }); - } - } else if (event.nativeEvent.onBehaviorActivated) { - if (this.props.onBehaviorActivated) { - this.props.onBehaviorActivated({ - 'action': event.nativeEvent.action, - 'data': event.nativeEvent.data, - }); - } - } else if (event.nativeEvent.onBookmarkChanged) { - if (this.props.onBookmarkChanged) { - this.props.onBookmarkChanged({ - 'bookmarkJson': event.nativeEvent.bookmarkJson, - }); - } - } else if (event.nativeEvent.onToolChanged) { - if (this.props.onToolChanged) { - this.props.onToolChanged({ - 'previousTool': event.nativeEvent.previousTool, - 'tool': event.nativeEvent.tool, - }); - } - } else if (event.nativeEvent.onTextSearchStart) { - if (this.props.onTextSearchStart) { - this.props.onTextSearchStart(event.nativeEvent.onTextSearchStart); - } - } else if (event.nativeEvent.onTextSearchResult) { - if (this.props.onTextSearchResult) { - this.props.onTextSearchResult({ - 'found': event.nativeEvent.found, - 'textSelection': event.nativeEvent.textSelection, - }); - } - } else if (event.nativeEvent.onUndoRedoStateChanged) { - if (this.props.onUndoRedoStateChanged) { - this.props.onUndoRedoStateChanged(); - } +export class DocumentView extends PureComponent { + _viewerRef; + static propTypes = { + document: PropTypes.string, + password: PropTypes.string, + initialPageNumber: PropTypes.number, + pageNumber: PropTypes.number, + customHeaders: PropTypes.object, + leadingNavButtonIcon: PropTypes.string, + showLeadingNavButton: PropTypes.bool, + onLeadingNavButtonPressed: PropTypes.func, + onDocumentLoaded: PropTypes.func, + onDocumentError: PropTypes.func, + onPageChanged: PropTypes.func, + onScrollChanged: PropTypes.func, + onZoomChanged: PropTypes.func, + onZoomFinished: PropTypes.func, + zoom: PropTypes.number, + disabledElements: PropTypes.array, + disabledTools: PropTypes.array, + longPressMenuItems: PropTypes.array, + overrideLongPressMenuBehavior: PropTypes.array, + onLongPressMenuPress: PropTypes.func, + longPressMenuEnabled: PropTypes.bool, + annotationMenuItems: PropTypes.array, + overrideAnnotationMenuBehavior: PropTypes.array, + onAnnotationMenuPress: PropTypes.func, + hideAnnotationMenu: PropTypes.array, + overrideBehavior: PropTypes.array, + onBehaviorActivated: PropTypes.func, + topToolbarEnabled: PropTypes.bool, + bottomToolbarEnabled: PropTypes.bool, + hideToolbarsOnTap: PropTypes.bool, + documentSliderEnabled: PropTypes.bool, + pageIndicatorEnabled: PropTypes.bool, + keyboardShortcutsEnabled: PropTypes.bool, + onAnnotationsSelected: PropTypes.func, + onAnnotationChanged: PropTypes.func, + onFormFieldValueChanged: PropTypes.func, + readOnly: PropTypes.bool, + thumbnailViewEditingEnabled: PropTypes.bool, + fitMode: PropTypes.string, + layoutMode: PropTypes.string, + onLayoutChanged: PropTypes.func, + padStatusBar: PropTypes.bool, + continuousAnnotationEditing: PropTypes.bool, + selectAnnotationAfterCreation: PropTypes.bool, + annotationAuthor: PropTypes.string, + showSavedSignatures: PropTypes.bool, + isBase64String: PropTypes.bool, + collabEnabled: PropTypes.bool, + currentUser: PropTypes.string, + currentUserName: PropTypes.string, + onExportAnnotationCommand: PropTypes.func, + autoSaveEnabled: PropTypes.bool, + pageChangeOnTap: PropTypes.bool, + followSystemDarkMode: PropTypes.bool, + useStylusAsPen: PropTypes.bool, + multiTabEnabled: PropTypes.bool, + tabTitle: PropTypes.string, + maxTabCount: PropTypes.number, + signSignatureFieldsWithStamps: PropTypes.bool, + annotationPermissionCheckEnabled: PropTypes.bool, + annotationToolbars: PropTypes.array, + hideDefaultAnnotationToolbars: PropTypes.array, + topAppNavBarRightBar: PropTypes.array, + bottomToolbar: PropTypes.array, + hideAnnotationToolbarSwitcher: PropTypes.bool, + hideTopToolbars: PropTypes.bool, + hideTopAppNavBar: PropTypes.bool, + onBookmarkChanged: PropTypes.func, + hideThumbnailFilterModes: PropTypes.array, + onToolChanged: PropTypes.func, + horizontalScrollPos: PropTypes.number, + verticalScrollPos: PropTypes.number, + onTextSearchStart: PropTypes.func, + onTextSearchResult: PropTypes.func, + hideViewModeItems: PropTypes.array, + pageStackEnabled: PropTypes.bool, + showQuickNavigationButton: PropTypes.bool, + photoPickerEnabled: PropTypes.bool, + autoResizeFreeTextEnabled: PropTypes.bool, + annotationsListEditingEnabled: PropTypes.bool, + showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, + restrictDownloadUsage: PropTypes.bool, + userBookmarksListEditingEnabled: PropTypes.bool, + imageInReflowEnabled: PropTypes.bool, + reflowOrientation: PropTypes.string, + onUndoRedoStateChanged: PropTypes.func, + tabletLayoutEnabled: PropTypes.bool, + initialToolbar: PropTypes.string, + inkMultiStrokeEnabled: PropTypes.bool, + defaultEraserType: PropTypes.string, + exportPath: PropTypes.string, + openUrlPath: PropTypes.string, + hideScrollbars: PropTypes.bool, + saveStateEnabled: PropTypes.bool, + openSavedCopyInNewTab: PropTypes.bool, + ...ViewPropTypes, + }; + onChange = (event) => { + if (event.nativeEvent.onLeadingNavButtonPressed) { + if (this.props.onLeadingNavButtonPressed) { + this.props.onLeadingNavButtonPressed(); + } + } + else if (event.nativeEvent.onDocumentLoaded) { + if (this.props.onDocumentLoaded) { + this.props.onDocumentLoaded(event.nativeEvent.onDocumentLoaded); + } + } + else if (event.nativeEvent.onPageChanged) { + if (this.props.onPageChanged) { + this.props.onPageChanged({ + 'previousPageNumber': event.nativeEvent.previousPageNumber, + 'pageNumber': event.nativeEvent.pageNumber, + }); + } + } + else if (event.nativeEvent.onScrollChanged) { + if (this.props.onScrollChanged) { + this.props.onScrollChanged({ + 'horizontal': event.nativeEvent.horizontal, + 'vertical': event.nativeEvent.vertical, + }); + } + } + else if (event.nativeEvent.onZoomChanged) { + if (this.props.onZoomChanged) { + this.props.onZoomChanged({ + 'zoom': event.nativeEvent.zoom, + }); + } + } + else if (event.nativeEvent.onZoomFinished) { + if (this.props.onZoomFinished) { + this.props.onZoomFinished({ + 'zoom': event.nativeEvent.zoom, + }); + } + } + else if (event.nativeEvent.onLayoutChanged) { + if (this.props.onLayoutChanged) { + this.props.onLayoutChanged(); + } + } + else if (event.nativeEvent.onAnnotationChanged) { + if (this.props.onAnnotationChanged) { + this.props.onAnnotationChanged({ + 'action': event.nativeEvent.action, + 'annotations': event.nativeEvent.annotations, + }); + } + } + else if (event.nativeEvent.onAnnotationsSelected) { + if (this.props.onAnnotationsSelected) { + this.props.onAnnotationsSelected({ + 'annotations': event.nativeEvent.annotations, + }); + } + } + else if (event.nativeEvent.onFormFieldValueChanged) { + if (this.props.onFormFieldValueChanged) { + this.props.onFormFieldValueChanged({ + 'fields': event.nativeEvent.fields, + }); + } + } + else if (event.nativeEvent.onDocumentError) { + if (this.props.onDocumentError) { + this.props.onDocumentError(event.nativeEvent.onDocumentError); + } + else { + const msg = event.nativeEvent.onDocumentError ? event.nativeEvent.onDocumentError : 'Unknown error'; + Alert.alert('Alert', msg, [ + { text: 'OK' } + ], { cancelable: true }); + } + } + else if (event.nativeEvent.onExportAnnotationCommand) { + if (this.props.onExportAnnotationCommand) { + this.props.onExportAnnotationCommand({ + 'action': event.nativeEvent.action, + 'xfdfCommand': event.nativeEvent.xfdfCommand, + 'annotations': event.nativeEvent.annotations, + }); + } + } + else if (event.nativeEvent.onAnnotationMenuPress) { + if (this.props.onAnnotationMenuPress) { + this.props.onAnnotationMenuPress({ + 'annotationMenu': event.nativeEvent.annotationMenu, + 'annotations': event.nativeEvent.annotations, + }); + } + } + else if (event.nativeEvent.onLongPressMenuPress) { + if (this.props.onLongPressMenuPress) { + this.props.onLongPressMenuPress({ + 'longPressMenu': event.nativeEvent.longPressMenu, + 'longPressText': event.nativeEvent.longPressText, + }); + } + } + else if (event.nativeEvent.onBehaviorActivated) { + if (this.props.onBehaviorActivated) { + this.props.onBehaviorActivated({ + 'action': event.nativeEvent.action, + 'data': event.nativeEvent.data, + }); + } + } + else if (event.nativeEvent.onBookmarkChanged) { + if (this.props.onBookmarkChanged) { + this.props.onBookmarkChanged({ + 'bookmarkJson': event.nativeEvent.bookmarkJson, + }); + } + } + else if (event.nativeEvent.onToolChanged) { + if (this.props.onToolChanged) { + this.props.onToolChanged({ + 'previousTool': event.nativeEvent.previousTool, + 'tool': event.nativeEvent.tool, + }); + } + } + else if (event.nativeEvent.onTextSearchStart) { + if (this.props.onTextSearchStart) { + this.props.onTextSearchStart(); + } + } + else if (event.nativeEvent.onTextSearchResult) { + if (this.props.onTextSearchResult) { + this.props.onTextSearchResult({ + 'found': event.nativeEvent.found, + 'textSelection': event.nativeEvent.textSelection, + }); + } + } + else if (event.nativeEvent.onUndoRedoStateChanged) { + if (this.props.onUndoRedoStateChanged) { + this.props.onUndoRedoStateChanged(); + } + } + }; + // Methods + getDocumentPath = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getDocumentPath(tag); + } + return Promise.resolve(); + }; + setToolMode = (toolMode) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setToolMode(tag, toolMode); + } + return Promise.resolve(); + }; + commitTool = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.commitTool(tag); + } + return Promise.resolve(); + }; + getPageCount = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageCount(tag); + } + return Promise.resolve(); + }; + importBookmarkJson = (bookmarkJson) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.importBookmarkJson(tag, bookmarkJson); + } + return Promise.resolve(); + }; + importAnnotationCommand = (xfdfCommand, initialLoad) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + if (initialLoad === undefined) { + initialLoad = false; + } + return DocumentViewManager.importAnnotationCommand(tag, xfdfCommand, initialLoad); + } + return Promise.resolve(); + }; + importAnnotations = (xfdf) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.importAnnotations(tag, xfdf); + } + return Promise.resolve(); + }; + exportAnnotations = (options) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.exportAnnotations(tag, options); + } + return Promise.resolve(); + }; + flattenAnnotations = (formsOnly) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.flattenAnnotations(tag, formsOnly); + } + return Promise.resolve(); + }; + deleteAnnotations = (annotations) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.deleteAnnotations(tag, annotations); + } + return Promise.resolve(); + }; + saveDocument = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.saveDocument(tag); + } + return Promise.resolve(); + }; + setFlagForFields = (fields, flag, value) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setFlagForFields(tag, fields, flag, value); + } + return Promise.resolve(); + }; + getField = (fieldName) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getField(tag, fieldName); + } + return Promise.resolve(); + }; + /** + * note: this function exists for supporting the old version. It simply calls setValuesForFields. + * + */ + setValueForFields = (fieldsMap) => { + return this.setValuesForFields(fieldsMap); + }; + setValuesForFields = (fieldsMap) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setValuesForFields(tag, fieldsMap); + } + return Promise.resolve(); + }; + handleBackButton = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.handleBackButton(tag); + } + return Promise.resolve(); + }; + /** + * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. + * + */ + setFlagForAnnotations = (annotationFlagList) => { + return this.setFlagsForAnnotations(annotationFlagList); + }; + setFlagsForAnnotations = (annotationFlagList) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setFlagsForAnnotations(tag, annotationFlagList); + } + return Promise.resolve(); + }; + selectAnnotation = (id, pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.selectAnnotation(tag, id, pageNumber); + } + return Promise.resolve(); + }; + /** + * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. + * + */ + setPropertyForAnnotation = (id, pageNumber, propertyMap) => { + return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); // check this._viewerRef + }; + setPropertiesForAnnotation = (id, pageNumber, propertyMap) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setPropertiesForAnnotation(tag, id, pageNumber, propertyMap); + } + return Promise.resolve(); + }; + getPropertiesForAnnotation = (id, pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); + } + return Promise.resolve(); + }; + setDrawAnnotations = (drawAnnotations) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setDrawAnnotations(tag, drawAnnotations); + } + return Promise.resolve(); + }; + setVisibilityForAnnotation = (id, pageNumber, visibility) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + DocumentViewManager.setVisibilityForAnnotation(tag, id, pageNumber, visibility); + } + return Promise.resolve(); + }; + setHighlightFields = (highlightFields) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + DocumentViewManager.setHighlightFields(tag, highlightFields); + } + return Promise.resolve(); + }; + getAnnotationAtPoint = (x, y, distanceThreshold, minimumLineWeight) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); + } + return Promise.resolve(); + }; + getAnnotationListAt = (x1, y1, x2, y2) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); + } + return Promise.resolve(); + }; + getAnnotationsOnPage = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); + } + return Promise.resolve(); + }; + getCustomDataForAnnotation = (annotationID, pageNumber, key) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); + } + return Promise.resolve(); + }; + getPageCropBox = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageCropBox(tag, pageNumber); + } + return Promise.resolve(); + }; + setCurrentPage = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setCurrentPage(tag, pageNumber); + } + return Promise.resolve(); + }; + getVisiblePages = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getVisiblePages(tag); + } + return Promise.resolve(); + }; + gotoPreviousPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoPreviousPage(tag); + } + return Promise.resolve(); + }; + gotoNextPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoNextPage(tag); + } + return Promise.resolve(); + }; + gotoFirstPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoFirstPage(tag); + } + return Promise.resolve(); + }; + gotoLastPage = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.gotoLastPage(tag); + } + return Promise.resolve(); + }; + showGoToPageView = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.showGoToPageView(tag); + } + return Promise.resolve(); + }; + closeAllTabs = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.closeAllTabs(tag); + } + return Promise.resolve(); + }; + getZoom = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getZoom(tag); + } + return Promise.resolve(); + }; + setZoomLimits = (zoomLimitMode, minimum, maximum) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); + } + return Promise.resolve(); + }; + zoomWithCenter = (zoom, x, y) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.zoomWithCenter(tag, zoom, x, y); + } + return Promise.resolve(); + }; + zoomToRect = (pageNumber, rect) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.zoomToRect(tag, pageNumber, rect); + } + return Promise.resolve(); + }; + smartZoom = (x, y, animated) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.smartZoom(tag, x, y, animated); + } + return Promise.resolve(); + }; + getScrollPos = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getScrollPos(tag); + } + return Promise.resolve(); + }; + getCanvasSize = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getCanvasSize(tag); + } + return Promise.resolve(); + }; + getPageRotation = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageRotation(tag); + } + return Promise.resolve(); + }; + rotateClockwise = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.rotateClockwise(tag); + } + return Promise.resolve(); + }; + rotateCounterClockwise = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.rotateCounterClockwise(tag); + } + return Promise.resolve(); + }; + convertScreenPointsToPagePoints = (points) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); + } + return Promise.resolve(); + }; + convertPagePointsToScreenPoints = (points) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); + } + return Promise.resolve(); + }; + getPageNumberFromScreenPoint = (x, y) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); + } + return Promise.resolve(); + }; + setProgressiveRendering = (progressiveRendering, initialDelay, interval) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setProgressiveRendering(tag, progressiveRendering, initialDelay, interval); + } + return Promise.resolve(); + }; + setImageSmoothing = (imageSmoothing) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setImageSmoothing(tag, imageSmoothing); + } + return Promise.resolve(); + }; + setOverprint = (overprint) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setOverprint(tag, overprint); + } + return Promise.resolve(); + }; + setColorPostProcessMode = (colorPostProcessMode) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); + } + return Promise.resolve(); + }; + setColorPostProcessColors = (whiteColor, blackColor) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setColorPostProcessColors(tag, whiteColor, blackColor); + } + return Promise.resolve(); + }; + startSearchMode = (searchString, matchCase, matchWholeWord) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.startSearchMode(tag, searchString, matchCase, matchWholeWord); + } + return Promise.resolve(); + }; + exitSearchMode = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.exitSearchMode(tag); + } + return Promise.resolve(); + }; + findText = (searchString, matchCase, matchWholeWord, searchUp, regExp) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.findText(tag, searchString, matchCase, matchWholeWord, searchUp, regExp); + } + return Promise.resolve(); + }; + cancelFindText = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.cancelFindText(tag); + } + return Promise.resolve(); + }; + getSelection = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getSelection(tag, pageNumber); + } + return Promise.resolve(); + }; + hasSelection = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.hasSelection(tag); + } + return Promise.resolve(); + }; + clearSelection = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.clearSelection(tag); + } + return Promise.resolve(); + }; + getSelectionPageRange = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.getSelectionPageRange(tag); + } + return Promise.resolve(); + }; + hasSelectionOnPage = (pageNumber) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); + } + return Promise.resolve(); + }; + selectInRect = (rect) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.selectInRect(tag, rect); + } + return Promise.resolve(); + }; + isThereTextInRect = (rect) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.isThereTextInRect(tag, rect); + } + return Promise.resolve(); + }; + selectAll = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.selectAll(tag); + } + return Promise.resolve(); + }; + setUrlExtraction = (urlExtraction) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setUrlExtraction(tag, urlExtraction); + } + return Promise.resolve(); + }; + setPageBorderVisibility = (pageBorderVisibility) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setPageBorderVisibility(tag, pageBorderVisibility); + } + return Promise.resolve(); + }; + setPageTransparencyGrid = (pageTransparencyGrid) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setPageTransparencyGrid(tag, pageTransparencyGrid); + } + return Promise.resolve(); + }; + setDefaultPageColor = (defaultPageColor) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setDefaultPageColor(tag, defaultPageColor); + } + return Promise.resolve(); + }; + setBackgroundColor = (backgroundColor) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setBackgroundColor(tag, backgroundColor); + } + return Promise.resolve(); + }; + exportAsImage = (pageNumber, dpi, exportFormat) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); + } + return Promise.resolve(); + }; + undo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.undo(tag); + } + return Promise.resolve(); + }; + redo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.redo(tag); + } + return Promise.resolve(); + }; + canUndo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.canUndo(tag); + } + return Promise.resolve(); + }; + canRedo = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.canRedo(tag); + } + return Promise.resolve(); + }; + showCrop = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.showCrop(tag); + } + return Promise.resolve(); + }; + setCurrentToolbar = (toolbar) => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.setCurrentToolbar(tag, toolbar); + } + return Promise.resolve(); + }; + openThumbnailsView = () => { + const tag = findNodeHandle(this._viewerRef); + if (tag != null) { + return DocumentViewManager.openThumbnailsView(tag); + } + return Promise.resolve(); + }; + _setNativeRef = (ref) => { + this._viewerRef = ref; + }; + render() { + return (); } - } - - getDocumentPath = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getDocumentPath(tag); - } - return Promise.resolve(); - } - - setToolMode = (toolMode) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setToolMode(tag, toolMode); - } - return Promise.resolve(); - } - - commitTool = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.commitTool(tag); - } - return Promise.resolve(); - } - - getPageCount = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageCount(tag); - } - return Promise.resolve(); - } - - importBookmarkJson = (bookmarkJson) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.importBookmarkJson(tag, bookmarkJson); - } - return Promise.resolve(); - } - - importAnnotationCommand = (xfdfCommand, initialLoad) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - if (initialLoad === undefined) { - initialLoad = false; - } - return DocumentViewManager.importAnnotationCommand( - tag, - xfdfCommand, - initialLoad, - ); - } - return Promise.resolve(); - } - - importAnnotations = (xfdf) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.importAnnotations(tag, xfdf); - } - return Promise.resolve(); - } - - exportAnnotations = (options) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.exportAnnotations(tag, options); - } - return Promise.resolve(); - } - - flattenAnnotations = (formsOnly) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.flattenAnnotations(tag, formsOnly); - } - return Promise.resolve(); - } - - deleteAnnotations = (annotations) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.deleteAnnotations(tag, annotations); - } - return Promise.resolve(); - } - - saveDocument = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.saveDocument(tag); - } - return Promise.resolve(); - } - - setFlagForFields = (fields, flag, value) => { - const tag = findNodeHandle(this._viewerRef); - if(tag != null) { - return DocumentViewManager.setFlagForFields(tag, fields, flag, value); - } - return Promise.resolve(); - } - - getField = (fieldName) => { - const tag = findNodeHandle(this._viewerRef); - if(tag != null) { - return DocumentViewManager.getField(tag, fieldName); - } - return Promise.resolve(); - } - - /** - * note: this function exists for supporting the old version. It simply calls setValuesForFields. - * - */ - setValueForFields = (fieldsMap) => { - return this.setValuesForFields(fieldsMap); - } - - setValuesForFields = (fieldsMap) => { - const tag = findNodeHandle(this._viewerRef); - if(tag != null) { - return DocumentViewManager.setValuesForFields(tag, fieldsMap); - } - return Promise.resolve(); - } - - handleBackButton = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.handleBackButton(tag); - } - return Promise.resolve(); - } - - - /** - * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. - * - */ - setFlagForAnnotations = (annotationFlagList) => { - return this.setFlagsForAnnotations(annotationFlagList); - } - - setFlagsForAnnotations = (annotationFlagList) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setFlagsForAnnotations(tag, annotationFlagList); - } - return Promise.resolve(); - } - - selectAnnotation = (id, pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.selectAnnotation(tag, id, pageNumber); - } - return Promise.resolve(); - } - - /** - * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. - * - */ - setPropertyForAnnotation = (id, pageNumber, propertyMap) => { - return setPropertiesForAnnotation(id, pageNumber, propertyMap); - } - - setPropertiesForAnnotation = (id, pageNumber, propertyMap) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setPropertiesForAnnotation(tag, id, pageNumber, propertyMap); - } - return Promise.resolve(); - } - - getPropertiesForAnnotation = (id, pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); - } - return Promise.resolve(); - } - - setDrawAnnotations = (drawAnnotations) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setDrawAnnotations(tag, drawAnnotations); - } - return Promise.resolve(); - } - - setVisibilityForAnnotation = (id, pageNumber, visibility) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - DocumentViewManager.setVisibilityForAnnotation(tag, id, pageNumber, visibility); - } - return Promise.resolve(); - } - - setHighlightFields = (highlightFields) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - DocumentViewManager.setHighlightFields(tag, highlightFields); - } - return Promise.resolve(); - } - - getAnnotationAtPoint = (x, y, distanceThreshold, minimumLineWeight) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); - } - return Promise.resolve(); - } - - getAnnotationListAt = (x1, y1, x2, y2) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); - } - return Promise.resolve(); - } - - getAnnotationsOnPage = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); - } - return Promise.resolve(); - } - - getCustomDataForAnnotation = (annotationID, pageNumber, key) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); - } - return Promise.resolve(); - } - - getPageCropBox = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageCropBox(tag, pageNumber); - } - return Promise.resolve(); - } - - setCurrentPage = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setCurrentPage(tag, pageNumber); - } - return Promise.resolve(); - } - - getVisiblePages = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getVisiblePages(tag); - } - return Promise.resolve(); - } - - gotoPreviousPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoPreviousPage(tag); - } - return Promise.resolve(); - } - - gotoNextPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoNextPage(tag); - } - return Promise.resolve(); - } - - gotoFirstPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoFirstPage(tag); - } - return Promise.resolve(); - } - - gotoLastPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoLastPage(tag); - } - return Promise.resolve(); - } - - showGoToPageView = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.showGoToPageView(tag); - } - return Promise.resolve(); - } - - closeAllTabs = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.closeAllTabs(tag); - } - return Promise.resolve(); - } - - getZoom = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getZoom(tag); - } - return Promise.resolve(); - } - - setZoomLimits = (zoomLimitMode, minimum, maximum) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); - } - return Promise.resolve(); - } - - zoomWithCenter = (zoom, x, y) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.zoomWithCenter(tag, zoom, x, y); - } - return Promise.resolve(); - } - - zoomToRect = (pageNumber, rect) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.zoomToRect(tag, pageNumber, rect); - } - return Promise.resolve(); - } - - smartZoom = (x, y, animated) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.smartZoom(tag, x, y, animated); - } - return Promise.resolve(); - } - - getScrollPos = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getScrollPos(tag); - } - return Promise.resolve(); - } - - getCanvasSize = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getCanvasSize(tag); - } - return Promise.resolve(); - } - - getPageRotation = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageRotation(tag); - } - return Promise.resolve(); - } - - rotateClockwise = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.rotateClockwise(tag); - } - return Promise.resolve(); - } - - rotateCounterClockwise = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.rotateCounterClockwise(tag); - } - return Promise.resolve(); - } - - - convertScreenPointsToPagePoints = (points) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); - } - return Promise.resolve(); - } - - convertPagePointsToScreenPoints = (points) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); - } - return Promise.resolve(); - } - - getPageNumberFromScreenPoint = (x, y) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); - } - return Promise.resolve(); - } - - setProgressiveRendering = (progressiveRendering, initialDelay, interval) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setProgressiveRendering(tag, progressiveRendering, initialDelay, interval); - } - return Promise.resolve(); - } - - setImageSmoothing = (imageSmoothing) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setImageSmoothing(tag, imageSmoothing); - } - return Promise.resolve(); - } - - setOverprint = (overprint) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setOverprint(tag, overprint); - } - return Promise.resolve(); - } - - setColorPostProcessMode = (colorPostProcessMode) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); - } - return Promise.resolve(); - } - - setColorPostProcessColors = (whiteColor, blackColor) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setColorPostProcessColors(tag, whiteColor, blackColor); - } - return Promise.resolve(); - } - - startSearchMode = (searchString, matchCase, matchWholeWord) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.startSearchMode(tag, searchString, matchCase, matchWholeWord); - } - return Promise.resolve(); - } - - exitSearchMode = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.exitSearchMode(tag); - } - return Promise.resolve(); - } - - findText = (searchString, matchCase, matchWholeWord, searchUp, regExp) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.findText(tag, searchString, matchCase, matchWholeWord, searchUp, regExp); - } - return Promise.resolve(); - } - - cancelFindText = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.cancelFindText(tag); - } - return Promise.resolve(); - } - - getSelection = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getSelection(tag, pageNumber); - } - return Promise.resolve(); - } - - hasSelection = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.hasSelection(tag); - } - return Promise.resolve(); - } - - clearSelection = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.clearSelection(tag); - } - return Promise.resolve(); - } - - getSelectionPageRange = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getSelectionPageRange(tag); - } - return Promise.resolve(); - } - - hasSelectionOnPage = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); - } - return Promise.resolve(); - } - - - selectInRect = (rect) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.selectInRect(tag, rect); - } - return Promise.resolve(); - } - - isThereTextInRect = (rect) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.isThereTextInRect(tag, rect); - } - return Promise.resolve(); - } - - selectAll = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.selectAll(tag); - } - return Promise.resolve(); - } - - - setUrlExtraction = (urlExtraction) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setUrlExtraction(tag, urlExtraction); - } - return Promise.resolve(); - } - - setPageBorderVisibility = (pageBorderVisibility) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setPageBorderVisibility(tag, pageBorderVisibility); - } - return Promise.resolve(); - } - - setPageTransparencyGrid = (pageTransparencyGrid) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setPageTransparencyGrid(tag, pageTransparencyGrid); - } - return Promise.resolve(); - } - - setDefaultPageColor = (defaultPageColor) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setDefaultPageColor(tag, defaultPageColor); - } - return Promise.resolve(); - } - - setBackgroundColor = (backgroundColor) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setBackgroundColor(tag, backgroundColor); - } - return Promise.resolve(); - } - - exportAsImage = (pageNumber, dpi, exportFormat) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); - } - return Promise.resolve(); - } - - undo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.undo(tag); - } - return Promise.resolve(); - } - - redo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.redo(tag); - } - return Promise.resolve(); - } - - canUndo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.canUndo(tag); - } - return Promise.resolve(); - } - - canRedo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.canRedo(tag); - } - return Promise.resolve(); - } - - showCrop = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.showCrop(tag); - } - return Promise.resolve(); - } - - setCurrentToolbar = (toolbar) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setCurrentToolbar(tag, toolbar); - } - return Promise.resolve(); - } - - openThumbnailsView = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.openThumbnailsView(tag); - } - return Promise.resolve(); - } - - _setNativeRef = (ref) => { - this._viewerRef = ref; - }; - - render() { - return ( - - ) - } } - const name = Platform.OS === 'ios' ? 'RNTPTDocumentView' : 'RCTDocumentView'; - -const RCTDocumentView = requireNativeComponent( - name, - DocumentView, - { +const RCTDocumentView = requireNativeComponent(// https://github.com/facebook/react-native/issues/28351 +name, +// @ts-ignore +DocumentView, { nativeOnly: { - onChange: true + onChange: true } - } -); +}); diff --git a/src/PDFViewCtrl/PDFViewCtrl.js b/src/PDFViewCtrl/PDFViewCtrl.js index 1c899cf1f..dbba09284 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.js +++ b/src/PDFViewCtrl/PDFViewCtrl.js @@ -1,41 +1,19 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; -import { - requireNativeComponent, - ViewPropTypes, - Text, - View, - Dimensions, - Platform -} from 'react-native'; - +import { requireNativeComponent, ViewPropTypes, Dimensions, Platform } from 'react-native'; const { height, width } = Dimensions.get('window'); - -export default class PDFViewCtrl extends PureComponent { - - static propTypes = { - document: PropTypes.string, - ...ViewPropTypes, - }; - - render() { - return ( - - ) - } +export class PDFViewCtrl extends PureComponent { + render() { + return (); + } } - var iface = { - name: 'PDFViewCtrl', - propTypes: { - document: PropTypes.string, - ...ViewPropTypes, // include the default view properties - }, + name: 'PDFViewCtrl', + propTypes: { + document: PropTypes.string, + ...ViewPropTypes, // include the default view properties + }, }; - const name = Platform.OS === 'ios' ? 'RNTPTPDFViewCtrl' : 'RCTPDFViewCtrl'; - -const RCTPDFViewCtrl = requireNativeComponent(name, PDFViewCtrl, iface); \ No newline at end of file +// @ts-ignore +const RCTPDFViewCtrl = requireNativeComponent(name, PDFViewCtrl, iface); // https://github.com/facebook/react-native/issues/28351 diff --git a/src/types/AnnotOptions.d.ts b/src/types/AnnotOptions.d.ts index ec66ebe95..fb73bf0e8 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/types/AnnotOptions.d.ts @@ -8,7 +8,6 @@ export interface Annotation { pageRect?: Rect; screenRect?: Rect; } - export interface Rect { height?: number; width?: number; @@ -17,52 +16,41 @@ export interface Rect { x2: number; y2: number; } - -export type CropBox = Required; - +export declare type CropBox = Required; export interface Color { red: number; green: number; blue: number; } - -export type RotationDegree = 0 | 90 | 180 | 270; - +export declare type RotationDegree = 0 | 90 | 180 | 270; export interface Field { fieldName: string; fieldValue: string | boolean | number; } - export interface FieldWithStringValue { fieldName: string; fieldValue: string; } - export interface Point { x: number; y: number; } - export interface PointWithPage extends Point { pageNumber?: number; } - -export type Quad = [Point, Point, Point, Point]; - +export declare type Quad = [Point, Point, Point, Point]; export interface TextSelectionResult { - html: string; - unicode: string; - pageNumber: number; + html: string; + unicode: string; + pageNumber: number; quads: Array; } - export interface AnnotationFlag { id: string; pageNumber: number; - flag: ConfigOptions.AnnotationFlags; + flag: Config.AnnotationFlags; flagValue: boolean; } - export interface AnnotationProperties { rect?: Rect; contents?: string; @@ -72,16 +60,14 @@ export interface AnnotationProperties { customData?: object; strokeColor?: Color; } - export interface LinkPressData { url: string; } - -export interface StickyNoteData { +export interface StickyNoteData { id: string; pageNumber: number; type: string; rect?: Rect; pageRect?: Rect; screenRect?: Rect; -} \ No newline at end of file +} diff --git a/src/types/Config.d.ts b/src/types/Config.d.ts index 59771f1e1..32115dab6 100644 --- a/src/types/Config.d.ts +++ b/src/types/Config.d.ts @@ -1,271 +1,253 @@ -export interface 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'; - - // Android only - saveReducedCopyButton: 'saveReducedCopyButton'; - saveCroppedCopyButton: 'saveCroppedCopyButton'; - savePasswordCopyButton: 'savePasswordCopyButton'; -} - -export interface Tools { - annotationEdit: 'AnnotationEdit'; - textSelect: 'TextSelect'; - pan: 'Pan'; - annotationEraserTool: 'AnnotationEraserTool'; - 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'; - annotationCreateLinkText: 'AnnotationCreateLinkText'; - annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter'; - formCreateTextField: 'FormCreateTextField'; - formCreateCheckboxField: 'FormCreateCheckboxField'; - formCreateSignatureField: 'FormCreateSignatureField'; - formCreateRadioField: 'FormCreateRadioField'; - formCreateComboBoxField: 'FormCreateComboBoxField'; - formCreateListBoxField: 'FormCreateListBoxField'; - pencilKitDrawing: 'PencilKitDrawing'; -} - -export interface FitMode { - FitPage: 'FitPage'; - FitWidth: 'FitWidth'; - FitHeight: 'FitHeight'; - Zoom: 'Zoom'; -} - -export interface LayoutMode { - Single: 'Single'; - Continuous: 'Continuous'; - Facing: 'Facing'; - FacingContinuous: 'FacingContinuous'; - FacingCover: 'FacingCover'; - FacingCoverContinuous: 'FacingCoverContinuous'; -} - -export interface FieldFlags { - ReadOnly: 0; - Required: 1; -} - -export interface AnnotationMenu { - style: 'style'; - note: 'note'; - copy: 'copy'; - delete: 'delete'; - flatten: 'flatten'; - editText: 'editText'; - editInk: 'editInk'; - search: 'search'; - share: 'share'; - markupType: 'markupType'; - read: 'read'; - screenCapture: 'screenCapture'; - playSound: 'playSound'; - openAttachment: 'openAttachment'; - calibrate: 'calibrate'; -} - -export interface EraserType { - annotationEraser: 'annotationEraser'; - hybrideEraser: 'hybrideEraser'; - inkEraser: 'inkEraser'; -} - -export interface LongPressMenu { - copy: 'copy'; - paste: 'paste'; - search: 'search'; - share: 'share'; - read: 'read'; -} - -export interface Actions { - linkPress: 'linkPress'; - stickyNoteShowPopUp: 'stickyNoteShowPopUp'; -} - -export interface AnnotationFlags { - hidden: "hidden"; - invisible: "invisible"; - locked: "locked"; - lockedContents: "lockedContents"; - noRotate: "noRotate"; - noView: "noView"; - noZoom: "noZoom"; - print: "print"; - readOnly: "readOnly"; - toggleNoView: "toggleNoView"; -} - -export interface 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"; - } - -export interface 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"; -} - -export interface CustomToolbarKey { - Id: "id"; - Name: "name"; - Icon: "icon"; - Items: "items"; -} - -export interface ThumbnailFilterMode { - Annotated: "annotated"; - Bookmarked: "bookmarked"; -} - -export interface Conversion { - Screen: "screen"; - Canvas: "canvas"; - Page: "page"; -} - -export interface ViewModePickerItem { - Crop: "viewModeCrop"; - Rotation: "viewModeRotation"; - ColorMode: "viewModeColorMode"; -} - -export interface ZoomLimitMode { - None: "none"; - Absolute: "absolute"; - Relative: "relative"; -} - -export interface OverprintMode { - On: "on"; - Off: "off"; - OnlyPDFX: "pdfx"; -} - -export interface ColorPostProcessMode { - None: "none"; - Invert: "invert"; - GradientMap: "gradientMap"; - NightMode: "nightMode"; -} - -export interface ReflowOrientation { - Horizontal: 'horizontal'; - Vertical: 'vertical'; - } - -export interface ExportFormat { - BMP: "BMP"; - JPEG: "JPEG"; - PNG: "PNG"; -} - -export interface ConfigIF { - Buttons: Buttons; - Tools: Tools; - FitMode: FitMode; - LayoutMode: LayoutMode; - FieldFlags: FieldFlags; - AnnotationMenu: AnnotationMenu; - EraserType: EraserType; - LongPressMenu: LongPressMenu; - Actions: Actions; - AnnotationFlags: AnnotationFlags; - DefaultToolbars: DefaultToolbars; - ToolbarIcons: ToolbarIcons; - CustomToolbarKey: CustomToolbarKey; - ThumbnailFilterMode: ThumbnailFilterMode; - Conversion: Conversion; - ViewModePickerItem: ViewModePickerItem; - ZoomLimitMode: ZoomLimitMode; - OverprintMode: OverprintMode; - ColorPostProcessMode: ColorPostProcessMode; - ReflowOrientation: ReflowOrientation; - ExportFormat: ExportFormat; -} - -export const Config: ConfigIF; \ No newline at end of file +export declare const Config: { + readonly Buttons: { + readonly editToolButton: "editToolButton"; + readonly viewControlsButton: "viewControlsButton"; + readonly freeHandToolButton: "freeHandToolButton"; + readonly highlightToolButton: "highlightToolButton"; + readonly underlineToolButton: "underlineToolButton"; + readonly squigglyToolButton: "squigglyToolButton"; + readonly strikeoutToolButton: "strikeoutToolButton"; + readonly rectangleToolButton: "rectangleToolButton"; + readonly ellipseToolButton: "ellipseToolButton"; + readonly lineToolButton: "lineToolButton"; + readonly arrowToolButton: "arrowToolButton"; + readonly polylineToolButton: "polylineToolButton"; + readonly polygonToolButton: "polygonToolButton"; + readonly cloudToolButton: "cloudToolButton"; + readonly signatureToolButton: "signatureToolButton"; + readonly freeTextToolButton: "freeTextToolButton"; + readonly stickyToolButton: "stickyToolButton"; + readonly calloutToolButton: "calloutToolButton"; + readonly stampToolButton: "stampToolButton"; + readonly toolsButton: "toolsButton"; + readonly searchButton: "searchButton"; + readonly shareButton: "shareButton"; + readonly editPagesButton: "editPagesButton"; + readonly viewLayersButton: "viewLayersButton"; + readonly printButton: "printButton"; + readonly closeButton: "closeButton"; + readonly saveCopyButton: "saveCopyButton"; + readonly saveIdenticalCopyButton: "saveIdenticalCopyButton"; + readonly saveFlattenedCopyButton: "saveFlattenedCopyButton"; + readonly formToolsButton: "formToolsButton"; + readonly fillSignToolsButton: "fillSignToolsButton"; + readonly moreItemsButton: "moreItemsButton"; + readonly digitalSignatureButton: "digitalSignatureButton"; + readonly thumbnailsButton: "thumbnailsButton"; + readonly listsButton: "listsButton"; + readonly thumbnailSlider: "thumbnailSlider"; + readonly outlineListButton: "outlineListButton"; + readonly annotationListButton: "annotationListButton"; + readonly userBookmarkListButton: "userBookmarkListButton"; + readonly reflowButton: "reflowButton"; + readonly editMenuButton: "editMenuButton"; + readonly cropPageButton: "cropPageButton"; + readonly undo: "undo"; + readonly redo: "redo"; + readonly addPageButton: "addPageButton"; + readonly saveReducedCopyButton: "saveReducedCopyButton"; + readonly saveCroppedCopyButton: "saveCroppedCopyButton"; + readonly savePasswordCopyButton: "savePasswordCopyButton"; + }; + readonly Tools: { + readonly annotationEdit: "AnnotationEdit"; + readonly textSelect: "TextSelect"; + readonly pan: "Pan"; + readonly annotationEraserTool: "AnnotationEraserTool"; + readonly annotationCreateSticky: "AnnotationCreateSticky"; + readonly annotationCreateFreeHand: "AnnotationCreateFreeHand"; + readonly annotationCreateTextHighlight: "AnnotationCreateTextHighlight"; + readonly annotationCreateTextUnderline: "AnnotationCreateTextUnderline"; + readonly annotationCreateTextSquiggly: "AnnotationCreateTextSquiggly"; + readonly annotationCreateTextStrikeout: "AnnotationCreateTextStrikeout"; + readonly annotationCreateFreeText: "AnnotationCreateFreeText"; + readonly annotationCreateCallout: "AnnotationCreateCallout"; + readonly annotationCreateSignature: "AnnotationCreateSignature"; + readonly annotationCreateLine: "AnnotationCreateLine"; + readonly annotationCreateArrow: "AnnotationCreateArrow"; + readonly annotationCreatePolyline: "AnnotationCreatePolyline"; + readonly annotationCreateStamp: "AnnotationCreateStamp"; + readonly annotationCreateRubberStamp: "AnnotationCreateRubberStamp"; + readonly annotationCreateRectangle: "AnnotationCreateRectangle"; + readonly annotationCreateEllipse: "AnnotationCreateEllipse"; + readonly annotationCreatePolygon: "AnnotationCreatePolygon"; + readonly annotationCreatePolygonCloud: "AnnotationCreatePolygonCloud"; + readonly annotationCreateDistanceMeasurement: "AnnotationCreateDistanceMeasurement"; + readonly annotationCreatePerimeterMeasurement: "AnnotationCreatePerimeterMeasurement"; + readonly annotationCreateAreaMeasurement: "AnnotationCreateAreaMeasurement"; + readonly annotationCreateFileAttachment: "AnnotationCreateFileAttachment"; + readonly annotationCreateSound: "AnnotationCreateSound"; + readonly annotationCreateRedaction: "AnnotationCreateRedaction"; + readonly annotationCreateLink: "AnnotationCreateLink"; + readonly annotationCreateRedactionText: "AnnotationCreateRedactionText"; + readonly annotationCreateLinkText: "AnnotationCreateLinkText"; + readonly annotationCreateFreeHighlighter: "AnnotationCreateFreeHighlighter"; + readonly formCreateTextField: "FormCreateTextField"; + readonly formCreateCheckboxField: "FormCreateCheckboxField"; + readonly formCreateSignatureField: "FormCreateSignatureField"; + readonly formCreateRadioField: "FormCreateRadioField"; + readonly formCreateComboBoxField: "FormCreateComboBoxField"; + readonly formCreateListBoxField: "FormCreateListBoxField"; + readonly pencilKitDrawing: "PencilKitDrawing"; + }; + readonly FitMode: { + readonly FitPage: "FitPage"; + readonly FitWidth: "FitWidth"; + readonly FitHeight: "FitHeight"; + readonly Zoom: "Zoom"; + }; + readonly LayoutMode: { + readonly Single: "Single"; + readonly Continuous: "Continuous"; + readonly Facing: "Facing"; + readonly FacingContinuous: "FacingContinuous"; + readonly FacingCover: "FacingCover"; + readonly FacingCoverContinuous: "FacingCoverContinuous"; + }; + readonly FieldFlags: { + readonly ReadOnly: 0; + readonly Required: 1; + }; + readonly AnnotationMenu: { + readonly style: "style"; + readonly note: "note"; + readonly copy: "copy"; + readonly delete: "delete"; + readonly flatten: "flatten"; + readonly editText: "editText"; + readonly editInk: "editInk"; + readonly search: "search"; + readonly share: "share"; + readonly markupType: "markupType"; + readonly read: "read"; + readonly screenCapture: "screenCapture"; + readonly playSound: "playSound"; + readonly openAttachment: "openAttachment"; + readonly calibrate: "calibrate"; + }; + readonly EraserType: { + readonly annotationEraser: "annotationEraser"; + readonly hybrideEraser: "hybrideEraser"; + readonly inkEraser: "inkEraser"; + }; + readonly LongPressMenu: { + readonly copy: "copy"; + readonly paste: "paste"; + readonly search: "search"; + readonly share: "share"; + readonly read: "read"; + }; + readonly Actions: { + readonly linkPress: "linkPress"; + readonly stickyNoteShowPopUp: "stickyNoteShowPopUp"; + }; + readonly AnnotationFlags: { + readonly hidden: "hidden"; + readonly invisible: "invisible"; + readonly locked: "locked"; + readonly lockedContents: "lockedContents"; + readonly noRotate: "noRotate"; + readonly noView: "noView"; + readonly noZoom: "noZoom"; + readonly print: "print"; + readonly readOnly: "readOnly"; + readonly toggleNoView: "toggleNoView"; + }; + readonly DefaultToolbars: { + readonly View: "PDFTron_View"; + readonly Annotate: "PDFTron_Annotate"; + readonly Draw: "PDFTron_Draw"; + readonly Insert: "PDFTron_Insert"; + readonly FillAndSign: "PDFTron_Fill_and_Sign"; + readonly PrepareForm: "PDFTron_Prepare_Form"; + readonly Measure: "PDFTron_Measure"; + readonly Pens: "PDFTron_Pens"; + readonly Redaction: "PDFTron_Redact"; + readonly Favorite: "PDFTron_Favorite"; + }; + readonly ToolbarIcons: { + readonly View: "PDFTron_View"; + readonly Annotate: "PDFTron_Annotate"; + readonly Draw: "PDFTron_Draw"; + readonly Insert: "PDFTron_Insert"; + readonly FillAndSign: "PDFTron_Fill_and_Sign"; + readonly PrepareForm: "PDFTron_Prepare_Form"; + readonly Measure: "PDFTron_Measure"; + readonly Pens: "PDFTron_Pens"; + readonly Redaction: "PDFTron_Redact"; + readonly Favorite: "PDFTron_Favorite"; + }; + readonly CustomToolbarKey: { + readonly Id: "id"; + readonly Name: "name"; + readonly Icon: "icon"; + readonly Items: "items"; + }; + readonly ThumbnailFilterMode: { + readonly Annotated: "annotated"; + readonly Bookmarked: "bookmarked"; + }; + readonly Conversion: { + readonly Screen: "screen"; + readonly Canvas: "canvas"; + readonly Page: "page"; + }; + readonly ViewModePickerItem: { + readonly Crop: "viewModeCrop"; + readonly Rotation: "viewModeRotation"; + readonly ColorMode: "viewModeColorMode"; + }; + readonly ZoomLimitMode: { + readonly None: "none"; + readonly Absolute: "absolute"; + readonly Relative: "relative"; + }; + readonly OverprintMode: { + readonly On: "on"; + readonly Off: "off"; + readonly OnlyPDFX: "pdfx"; + }; + readonly ColorPostProcessMode: { + readonly None: "none"; + readonly Invert: "invert"; + readonly GradientMap: "gradientMap"; + readonly NightMode: "nightMode"; + }; + readonly ReflowOrientation: { + readonly Horizontal: "horizontal"; + readonly Vertical: "vertical"; + }; + readonly ExportFormat: { + readonly BMP: "BMP"; + readonly JPEG: "JPEG"; + readonly PNG: "PNG"; + }; +}; +declare type ValueOf = T[keyof T]; +export declare type Buttons = ValueOf; +export declare type Tools = ValueOf; +export declare type FitMode = ValueOf; +export declare type LayoutMode = ValueOf; +export declare type FieldFlags = ValueOf; +export declare type AnnotationMenu = ValueOf; +export declare type EraserType = ValueOf; +export declare type LongPressMenu = ValueOf; +export declare type Actions = ValueOf; +export declare type AnnotationFlags = ValueOf; +export declare type DefaultToolbars = ValueOf; +export declare type ToolbarIcons = ValueOf; +export declare type ThumbnailFilterMode = ValueOf; +export declare type Conversion = ValueOf; +export declare type ViewModePickerItem = ValueOf; +export declare type ZoomLimitMode = ValueOf; +export declare type OverprintMode = ValueOf; +export declare type ColorPostProcessMode = ValueOf; +export declare type ReflowOrientation = ValueOf; +export declare type ExportFormat = ValueOf; +export declare type CustomToolbarKey = { + id: string; + name: string; + icon: ToolbarIcons; + items: (Tools | Buttons)[]; +}; +export {}; diff --git a/src/types/ConfigOptions.d.ts b/src/types/ConfigOptions.d.ts deleted file mode 100644 index 96d02e487..000000000 --- a/src/types/ConfigOptions.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import Config from "./Config"; - -type ValueOf = T[keyof T]; - -export type Buttons = ValueOf; -export type Tools = ValueOf; -export type FitMode = ValueOf; -export type LayoutMode = ValueOf; -export type FieldFlags = ValueOf; -export type AnnotationMenu = ValueOf; -export type EraserType = ValueOf; -export type LongPressMenu = ValueOf; -export type Actions = ValueOf; -export type AnnotationFlags = ValueOf; -export type DefaultToolbars = ValueOf; -export type ToolbarIcons = ValueOf; -export type ThumbnailFilterMode = ValueOf; -export type Conversion = ValueOf; -export type ViewModePickerItem = ValueOf; -export type ZoomLimitMode = ValueOf; -export type OverprintMode = ValueOf; -export type ColorPostProcessMode = ValueOf; -export type ReflowOrientation = ValueOf; -export type ExportFormat = ValueOf; - -export type CustomToolbarKey = { - [Property in keyof Config.CustomToolbarKey as `${Lowercase}`] : Config.CustomToolbarKey[Property] extends "items" ? - Array : Config.CustomToolbarKey[Property] extends "icon" ? - ToolbarIcons : string; -} \ No newline at end of file diff --git a/src/types/DocumentView.d.ts b/src/types/DocumentView.d.ts index 9a5cf4a38..1a58a32c0 100644 --- a/src/types/DocumentView.d.ts +++ b/src/types/DocumentView.d.ts @@ -13,38 +13,64 @@ export interface DocumentViewProps extends ViewProps { leadingNavButtonIcon?: string; showLeadingNavButton?: boolean; onLeadingNavButtonPressed?: () => void; - onDocumentLoaded?: (path : string) => void; + onDocumentLoaded?: (path: string) => void; onDocumentError?: (error: string) => void; - onPageChanged?: ({previousPageNumber, pageNumber}: {previousPageNumber: number, pageNumber: number}) => void; - onScrollChanged?: ({horizontal, vertical}: {horizontal: number, vertical: number}) => void; - onZoomChanged?: ({zoom}: {zoom: number}) => void; - onZoomFinished?: ({zoom}: {zoom: number}) => void; + onPageChanged?: ({ previousPageNumber, pageNumber }: { + previousPageNumber: number; + pageNumber: number; + }) => void; + onScrollChanged?: ({ horizontal, vertical }: { + horizontal: number; + vertical: number; + }) => void; + onZoomChanged?: ({ zoom }: { + zoom: number; + }) => void; + onZoomFinished?: ({ zoom }: { + zoom: number; + }) => void; zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; - onLongPressMenuPress?: ({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; + onLongPressMenuPress?: ({ longPressMenu, longPressText }: { + longPressMenu: string; + longPressText: string; + }) => void; longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; - onAnnotationMenuPress?: ({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; - onBehaviorActivated?: ({action, data}: {action: ConfigOptions.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; + onAnnotationMenuPress?: ({ annotationMenu, annotations }: { + annotationMenu: string; + annotations: Array; + }) => void; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; + onBehaviorActivated?: ({ action, data }: { + action: Config.Actions; + data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData; + }) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; documentSliderEnabled?: boolean; pageIndicatorEnabled?: boolean; keyboardShortcutsEnabled?: boolean; - onAnnotationsSelected?: ({annotations}: {annotations: Array}) => void ; - onAnnotationChanged?: ({action, annotations}: {action: string, annotations: Array}) => void; - onFormFieldValueChanged?: ({fields}: {fields: Array}) => void; + onAnnotationsSelected?: ({ annotations }: { + annotations: Array; + }) => void; + onAnnotationChanged?: ({ action, annotations }: { + action: string; + annotations: Array; + }) => void; + onFormFieldValueChanged?: ({ fields }: { + fields: Array; + }) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; - fitMode?: ConfigOptions.FitMode; - layoutMode?: ConfigOptions.LayoutMode; + fitMode?: Config.FitMode; + layoutMode?: Config.LayoutMode; onLayoutChanged?: () => void; padStatusBar?: boolean; continuousAnnotationEditing?: boolean; @@ -55,7 +81,11 @@ export interface DocumentViewProps extends ViewProps { collabEnabled?: boolean; currentUser?: string; currentUserName?: string; - onExportAnnotationCommand?: ({action, xfdfCommand, annotations}: {action: string, xfdfCommand: string, annotations: Array}) => void; + onExportAnnotationCommand?: ({ action, xfdfCommand, annotations }: { + action: string; + xfdfCommand: string; + annotations: Array; + }) => void; autoSaveEnabled?: boolean; pageChangeOnTap?: boolean; followSystemDarkMode?: boolean; @@ -65,21 +95,29 @@ export interface DocumentViewProps extends ViewProps { maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; hideAnnotationToolbarSwitcher?: boolean; hideTopToolbars?: boolean; hideTopAppNavBar?: boolean; - onBookmarkChanged?: ({bookmarkJson}: {bookmarkJson: string}) => void; - hideThumbnailFilterModes?: Array; - onToolChanged?: ({previousTool, tool}: {previousTool: ConfigOptions.Tools | "unknown tool", tool: ConfigOptions.Tools | "unknown tool"}) => void; + onBookmarkChanged?: ({ bookmarkJson }: { + bookmarkJson: string; + }) => void; + hideThumbnailFilterModes?: Array; + onToolChanged?: ({ previousTool, tool }: { + previousTool: Config.Tools | "unknown tool"; + tool: Config.Tools | "unknown tool"; + }) => void; horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; - onTextSearchResult?: ({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; - hideViewModeItems?: Array; + onTextSearchResult?: ({ found, textSelection }: { + found: boolean; + textSelection: AnnotOptions.TextSelectionResult | null; + }) => void; + hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; photoPickerEnabled?: boolean; @@ -89,40 +127,211 @@ export interface DocumentViewProps extends ViewProps { restrictDownloadUsage?: boolean; userBookmarksListEditingEnabled?: boolean; imageInReflowEnabled?: boolean; - reflowOrientation?: ConfigOptions.ReflowOrientation; + reflowOrientation?: Config.ReflowOrientation; onUndoRedoStateChanged?: () => void; tabletLayoutEnabled?: boolean; initialToolbar?: string; inkMultiStrokeEnabled?: boolean; - defaultEraserType?: ConfigOptions.EraserType; + defaultEraserType?: Config.EraserType; exportPath?: string; openUrlPath?: string; hideScrollbars?: boolean; saveStateEnabled?: boolean; openSavedCopyInNewTab?: boolean; + onChange?(event: any): void; } - - -export class DocumentView extends PureComponent { +export declare class DocumentView extends PureComponent { + _viewerRef: any; + static propTypes: { + hitSlop?: PropTypes.Validator; + onLayout?: PropTypes.Validator<(event: import("react-native").LayoutChangeEvent) => void>; + pointerEvents?: PropTypes.Validator<"none" | "box-none" | "box-only" | "auto">; + removeClippedSubviews?: PropTypes.Validator; + style?: PropTypes.Validator>; + testID?: PropTypes.Validator; + nativeID?: PropTypes.Validator; + collapsable?: PropTypes.Validator; + needsOffscreenAlphaCompositing?: PropTypes.Validator; + renderToHardwareTextureAndroid?: PropTypes.Validator; + focusable?: PropTypes.Validator; + shouldRasterizeIOS?: PropTypes.Validator; + isTVSelectable?: PropTypes.Validator; + hasTVPreferredFocus?: PropTypes.Validator; + tvParallaxProperties?: PropTypes.Validator; + tvParallaxShiftDistanceX?: PropTypes.Validator; + tvParallaxShiftDistanceY?: PropTypes.Validator; + tvParallaxTiltAngle?: PropTypes.Validator; + tvParallaxMagnification?: PropTypes.Validator; + onStartShouldSetResponder?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; + onMoveShouldSetResponder?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; + onResponderEnd?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onResponderGrant?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onResponderReject?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onResponderMove?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onResponderRelease?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onResponderStart?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onResponderTerminationRequest?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; + onResponderTerminate?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onStartShouldSetResponderCapture?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; + onMoveShouldSetResponderCapture?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; + onTouchStart?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onTouchMove?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onTouchEnd?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onTouchCancel?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + onTouchEndCapture?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; + accessible?: PropTypes.Validator; + accessibilityActions?: PropTypes.Validator[]>; + accessibilityLabel?: PropTypes.Validator; + accessibilityRole?: PropTypes.Validator; + accessibilityState?: PropTypes.Validator; + accessibilityHint?: PropTypes.Validator; + accessibilityValue?: PropTypes.Validator; + onAccessibilityAction?: PropTypes.Validator<(event: import("react-native").AccessibilityActionEvent) => void>; + accessibilityLiveRegion?: PropTypes.Validator<"none" | "polite" | "assertive">; + importantForAccessibility?: PropTypes.Validator<"auto" | "yes" | "no" | "no-hide-descendants">; + accessibilityElementsHidden?: PropTypes.Validator; + accessibilityViewIsModal?: PropTypes.Validator; + onAccessibilityEscape?: PropTypes.Validator<() => void>; + onAccessibilityTap?: PropTypes.Validator<() => void>; + onMagicTap?: PropTypes.Validator<() => void>; + accessibilityIgnoresInvertColors?: PropTypes.Validator; + document: PropTypes.Requireable; + password: PropTypes.Requireable; + initialPageNumber: PropTypes.Requireable; + pageNumber: PropTypes.Requireable; + customHeaders: PropTypes.Requireable; + leadingNavButtonIcon: PropTypes.Requireable; + showLeadingNavButton: PropTypes.Requireable; + onLeadingNavButtonPressed: PropTypes.Requireable<(...args: any[]) => any>; + onDocumentLoaded: PropTypes.Requireable<(...args: any[]) => any>; + onDocumentError: PropTypes.Requireable<(...args: any[]) => any>; + onPageChanged: PropTypes.Requireable<(...args: any[]) => any>; + onScrollChanged: PropTypes.Requireable<(...args: any[]) => any>; + onZoomChanged: PropTypes.Requireable<(...args: any[]) => any>; + onZoomFinished: PropTypes.Requireable<(...args: any[]) => any>; + zoom: PropTypes.Requireable; + disabledElements: PropTypes.Requireable; + disabledTools: PropTypes.Requireable; + longPressMenuItems: PropTypes.Requireable; + overrideLongPressMenuBehavior: PropTypes.Requireable; + onLongPressMenuPress: PropTypes.Requireable<(...args: any[]) => any>; + longPressMenuEnabled: PropTypes.Requireable; + annotationMenuItems: PropTypes.Requireable; + overrideAnnotationMenuBehavior: PropTypes.Requireable; + onAnnotationMenuPress: PropTypes.Requireable<(...args: any[]) => any>; + hideAnnotationMenu: PropTypes.Requireable; + overrideBehavior: PropTypes.Requireable; + onBehaviorActivated: PropTypes.Requireable<(...args: any[]) => any>; + topToolbarEnabled: PropTypes.Requireable; + bottomToolbarEnabled: PropTypes.Requireable; + hideToolbarsOnTap: PropTypes.Requireable; + documentSliderEnabled: PropTypes.Requireable; + pageIndicatorEnabled: PropTypes.Requireable; + keyboardShortcutsEnabled: PropTypes.Requireable; + onAnnotationsSelected: PropTypes.Requireable<(...args: any[]) => any>; + onAnnotationChanged: PropTypes.Requireable<(...args: any[]) => any>; + onFormFieldValueChanged: PropTypes.Requireable<(...args: any[]) => any>; + readOnly: PropTypes.Requireable; + thumbnailViewEditingEnabled: PropTypes.Requireable; + fitMode: PropTypes.Requireable; + layoutMode: PropTypes.Requireable; + onLayoutChanged: PropTypes.Requireable<(...args: any[]) => any>; + padStatusBar: PropTypes.Requireable; + continuousAnnotationEditing: PropTypes.Requireable; + selectAnnotationAfterCreation: PropTypes.Requireable; + annotationAuthor: PropTypes.Requireable; + showSavedSignatures: PropTypes.Requireable; + isBase64String: PropTypes.Requireable; + collabEnabled: PropTypes.Requireable; + currentUser: PropTypes.Requireable; + currentUserName: PropTypes.Requireable; + onExportAnnotationCommand: PropTypes.Requireable<(...args: any[]) => any>; + autoSaveEnabled: PropTypes.Requireable; + pageChangeOnTap: PropTypes.Requireable; + followSystemDarkMode: PropTypes.Requireable; + useStylusAsPen: PropTypes.Requireable; + multiTabEnabled: PropTypes.Requireable; + tabTitle: PropTypes.Requireable; + maxTabCount: PropTypes.Requireable; + signSignatureFieldsWithStamps: PropTypes.Requireable; + annotationPermissionCheckEnabled: PropTypes.Requireable; + annotationToolbars: PropTypes.Requireable; + hideDefaultAnnotationToolbars: PropTypes.Requireable; + topAppNavBarRightBar: PropTypes.Requireable; + bottomToolbar: PropTypes.Requireable; + hideAnnotationToolbarSwitcher: PropTypes.Requireable; + hideTopToolbars: PropTypes.Requireable; + hideTopAppNavBar: PropTypes.Requireable; + onBookmarkChanged: PropTypes.Requireable<(...args: any[]) => any>; + hideThumbnailFilterModes: PropTypes.Requireable; + onToolChanged: PropTypes.Requireable<(...args: any[]) => any>; + horizontalScrollPos: PropTypes.Requireable; + verticalScrollPos: PropTypes.Requireable; + onTextSearchStart: PropTypes.Requireable<(...args: any[]) => any>; + onTextSearchResult: PropTypes.Requireable<(...args: any[]) => any>; + hideViewModeItems: PropTypes.Requireable; + pageStackEnabled: PropTypes.Requireable; + showQuickNavigationButton: PropTypes.Requireable; + photoPickerEnabled: PropTypes.Requireable; + autoResizeFreeTextEnabled: PropTypes.Requireable; + annotationsListEditingEnabled: PropTypes.Requireable; + showNavigationListAsSidePanelOnLargeDevices: PropTypes.Requireable; + restrictDownloadUsage: PropTypes.Requireable; + userBookmarksListEditingEnabled: PropTypes.Requireable; + imageInReflowEnabled: PropTypes.Requireable; + reflowOrientation: PropTypes.Requireable; + onUndoRedoStateChanged: PropTypes.Requireable<(...args: any[]) => any>; + tabletLayoutEnabled: PropTypes.Requireable; + initialToolbar: PropTypes.Requireable; + inkMultiStrokeEnabled: PropTypes.Requireable; + defaultEraserType: PropTypes.Requireable; + exportPath: PropTypes.Requireable; + openUrlPath: PropTypes.Requireable; + hideScrollbars: PropTypes.Requireable; + saveStateEnabled: PropTypes.Requireable; + openSavedCopyInNewTab: PropTypes.Requireable; + }; + onChange: (event: any) => void; getDocumentPath: () => Promise | Promise; - setToolMode: (toolMode: ConfigOptions.Tools) => Promise; + setToolMode: (toolMode: Config.Tools) => Promise; commitTool: () => Promise | Promise; getPageCount: () => Promise | Promise; importBookmarkJson: (bookmarkJson: string) => Promise; importAnnotationCommand: (xfdfCommand: string, initialLoad?: boolean) => Promise; importAnnotations: (xfdf: string) => Promise; - exportAnnotations: (options?: {annotList: Array}) => Promise | Promise; + exportAnnotations: (options?: { + annotList: Array; + }) => Promise | Promise; flattenAnnotations: (formsOnly: boolean) => Promise; deleteAnnotations: (annotations: Array) => Promise; saveDocument: () => Promise | Promise; - setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; - getField: (fieldName: string) => Promise | Promise<{fieldName: string, fieldValue?: any, fieldType?: string}>; + setFlagForFields: (fields: Array, flag: Config.FieldFlags, value: boolean) => Promise; + getField: (fieldName: string) => Promise | Promise<{ + fieldName: string; + fieldValue?: any; + fieldType?: string; + }>; + /** + * note: this function exists for supporting the old version. It simply calls setValuesForFields. + * + */ setValueForFields: (fieldsMap: Record) => Promise; setValuesForFields: (fieldsMap: Record) => Promise; handleBackButton: () => Promise | Promise; + /** + * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. + * + */ setFlagForAnnotations: (annotationFlagList: Array) => Promise; setFlagsForAnnotations: (annotationFlagList: Array) => Promise; selectAnnotation: (id: string, pageNumber: number) => Promise; + /** + * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. + * + */ setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | Promise; @@ -143,12 +352,18 @@ export class DocumentView extends PureComponent { showGoToPageView: () => Promise; closeAllTabs: () => Promise; getZoom: () => Promise | Promise; - setZoomLimits: (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number) => Promise; + setZoomLimits: (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number) => Promise; zoomWithCenter: (zoom: number, x: number, y: number) => Promise; zoomToRect: (pageNumber: number, rect: AnnotOptions.Rect) => Promise; smartZoom: (x: number, y: number, animated: boolean) => Promise; - getScrollPos: () => Promise | Promise<{horizontal: number, vertical: number}>; - getCanvasSize: () => Promise | Promise<{width: number, height: number}>; + getScrollPos: () => Promise | Promise<{ + horizontal: number; + vertical: number; + }>; + getCanvasSize: () => Promise | Promise<{ + width: number; + height: number; + }>; getPageRotation: () => Promise | Promise; rotateClockwise: () => Promise; rotateCounterClockwise: () => Promise; @@ -157,8 +372,8 @@ export class DocumentView extends PureComponent { getPageNumberFromScreenPoint: (x: number, y: number) => Promise | Promise; setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; setImageSmoothing: (imageSmoothing: boolean) => Promise; - setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; - setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; + setOverprint: (overprint: Config.OverprintMode) => Promise; + setColorPostProcessMode: (colorPostProcessMode: Config.ColorPostProcessMode) => Promise; setColorPostProcessColors: (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color) => Promise; startSearchMode: (searchString: string, matchCase: boolean, matchWholeWord: boolean) => Promise; exitSearchMode: () => Promise; @@ -167,7 +382,10 @@ export class DocumentView extends PureComponent { getSelection: (pageNumber: number) => Promise | Promise; hasSelection: () => Promise | Promise; clearSelection: () => Promise; - getSelectionPageRange: () => Promise | Promise<{begin: number, end: number}>; + getSelectionPageRange: () => Promise | Promise<{ + begin: number; + end: number; + }>; hasSelectionOnPage: (pageNumber: number) => Promise | Promise; selectInRect: (rect: AnnotOptions.Rect) => Promise | Promise; isThereTextInRect: (rect: AnnotOptions.Rect) => Promise | Promise; @@ -177,7 +395,7 @@ export class DocumentView extends PureComponent { setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; setDefaultPageColor: (defaultPageColor: AnnotOptions.Color) => Promise; setBackgroundColor: (backgroundColor: AnnotOptions.Color) => Promise; - exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | Promise; + exportAsImage: (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat) => Promise | Promise; undo: () => Promise; redo: () => Promise; canUndo: () => Promise | Promise; @@ -185,4 +403,6 @@ export class DocumentView extends PureComponent { showCrop: () => Promise; setCurrentToolbar: (toolbar: string) => Promise; openThumbnailsView: () => Promise; -} \ No newline at end of file + _setNativeRef: (ref: any) => void; + render(): JSX.Element; +} diff --git a/src/types/PDFViewCtrl.d.ts b/src/types/PDFViewCtrl.d.ts index a99e3167d..faa649938 100644 --- a/src/types/PDFViewCtrl.d.ts +++ b/src/types/PDFViewCtrl.d.ts @@ -1,8 +1,9 @@ import { PureComponent } from 'react'; import { ViewProps } from 'react-native'; - export interface PDFViewCtrlProps extends ViewProps { document: string; + style?: object; +} +export declare class PDFViewCtrl extends PureComponent { + render(): JSX.Element; } - -export class PDFViewCtrl extends PureComponent {} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index c639e1d8c..755240590 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "outDir": "./src", "skipLibCheck": true, "declaration": true, + "declarationDir": "./types", "rootDirs": ["types/", "./"] }, "include": ["types/**/*", "../index.ts"], diff --git a/types/DocumentView/DocumentView.tsx b/types/DocumentView/DocumentView.tsx index 5f1489b2f..4d8305a71 100644 --- a/types/DocumentView/DocumentView.tsx +++ b/types/DocumentView/DocumentView.tsx @@ -1,6 +1,8 @@ import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; import { requireNativeComponent, + ViewPropTypes, ViewProps, Platform, Alert, @@ -116,6 +118,105 @@ export class DocumentView extends PureComponent { _viewerRef; + static propTypes = { + document: PropTypes.string, + password: PropTypes.string, + initialPageNumber: PropTypes.number, + pageNumber: PropTypes.number, + customHeaders: PropTypes.object, + leadingNavButtonIcon: PropTypes.string, + showLeadingNavButton: PropTypes.bool, + onLeadingNavButtonPressed: PropTypes.func, + onDocumentLoaded: PropTypes.func, + onDocumentError: PropTypes.func, + onPageChanged: PropTypes.func, + onScrollChanged: PropTypes.func, + onZoomChanged: PropTypes.func, + onZoomFinished: PropTypes.func, + zoom: PropTypes.number, + disabledElements: PropTypes.array, + disabledTools: PropTypes.array, + longPressMenuItems: PropTypes.array, + overrideLongPressMenuBehavior: PropTypes.array, + onLongPressMenuPress: PropTypes.func, + longPressMenuEnabled: PropTypes.bool, + annotationMenuItems: PropTypes.array, + overrideAnnotationMenuBehavior: PropTypes.array, + onAnnotationMenuPress: PropTypes.func, + hideAnnotationMenu: PropTypes.array, + overrideBehavior: PropTypes.array, + onBehaviorActivated: PropTypes.func, + topToolbarEnabled: PropTypes.bool, + bottomToolbarEnabled: PropTypes.bool, + hideToolbarsOnTap: PropTypes.bool, + documentSliderEnabled: PropTypes.bool, + pageIndicatorEnabled: PropTypes.bool, + keyboardShortcutsEnabled: PropTypes.bool, + onAnnotationsSelected: PropTypes.func, + onAnnotationChanged: PropTypes.func, + onFormFieldValueChanged: PropTypes.func, + readOnly: PropTypes.bool, + thumbnailViewEditingEnabled: PropTypes.bool, + fitMode: PropTypes.string, + layoutMode: PropTypes.string, + onLayoutChanged: PropTypes.func, + padStatusBar: PropTypes.bool, + continuousAnnotationEditing: PropTypes.bool, + selectAnnotationAfterCreation: PropTypes.bool, + annotationAuthor: PropTypes.string, + showSavedSignatures: PropTypes.bool, + isBase64String: PropTypes.bool, + collabEnabled: PropTypes.bool, + currentUser: PropTypes.string, + currentUserName: PropTypes.string, + onExportAnnotationCommand: PropTypes.func, + autoSaveEnabled: PropTypes.bool, + pageChangeOnTap: PropTypes.bool, + followSystemDarkMode: PropTypes.bool, + useStylusAsPen: PropTypes.bool, + multiTabEnabled: PropTypes.bool, + tabTitle: PropTypes.string, + maxTabCount: PropTypes.number, + signSignatureFieldsWithStamps: PropTypes.bool, + annotationPermissionCheckEnabled: PropTypes.bool, + annotationToolbars: PropTypes.array, + hideDefaultAnnotationToolbars: PropTypes.array, + topAppNavBarRightBar: PropTypes.array, + bottomToolbar: PropTypes.array, + hideAnnotationToolbarSwitcher: PropTypes.bool, + hideTopToolbars: PropTypes.bool, + hideTopAppNavBar: PropTypes.bool, + onBookmarkChanged: PropTypes.func, + hideThumbnailFilterModes: PropTypes.array, + onToolChanged: PropTypes.func, + horizontalScrollPos: PropTypes.number, + verticalScrollPos: PropTypes.number, + onTextSearchStart: PropTypes.func, + onTextSearchResult: PropTypes.func, + hideViewModeItems: PropTypes.array, + pageStackEnabled: PropTypes.bool, + showQuickNavigationButton: PropTypes.bool, + photoPickerEnabled: PropTypes.bool, + autoResizeFreeTextEnabled: PropTypes.bool, + annotationsListEditingEnabled: PropTypes.bool, + showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, + restrictDownloadUsage: PropTypes.bool, + userBookmarksListEditingEnabled: PropTypes.bool, + imageInReflowEnabled: PropTypes.bool, + reflowOrientation: PropTypes.string, + onUndoRedoStateChanged: PropTypes.func, + tabletLayoutEnabled: PropTypes.bool, + initialToolbar: PropTypes.string, + inkMultiStrokeEnabled: PropTypes.bool, + defaultEraserType: PropTypes.string, + exportPath: PropTypes.string, + openUrlPath: PropTypes.string, + hideScrollbars: PropTypes.bool, + saveStateEnabled: PropTypes.bool, + openSavedCopyInNewTab: PropTypes.bool, + ...ViewPropTypes, + }; + onChange = (event) => { if (event.nativeEvent.onLeadingNavButtonPressed) { if (this.props.onLeadingNavButtonPressed) { @@ -248,7 +349,9 @@ export class DocumentView extends PureComponent { } } - getDocumentPath = () => { + // Methods + + getDocumentPath = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getDocumentPath(tag); @@ -256,7 +359,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setToolMode = (toolMode) => { + + setToolMode = (toolMode: Config.Tools): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setToolMode(tag, toolMode); @@ -264,7 +368,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - commitTool = () => { + commitTool = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.commitTool(tag); @@ -272,7 +376,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageCount = () => { + getPageCount = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageCount(tag); @@ -280,7 +384,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - importBookmarkJson = (bookmarkJson) => { + importBookmarkJson = (bookmarkJson: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.importBookmarkJson(tag, bookmarkJson); @@ -288,7 +392,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - importAnnotationCommand = (xfdfCommand, initialLoad) => { + importAnnotationCommand = (xfdfCommand: string, initialLoad?: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { if (initialLoad === undefined) { @@ -303,7 +407,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - importAnnotations = (xfdf) => { + importAnnotations = (xfdf: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.importAnnotations(tag, xfdf); @@ -311,7 +415,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAnnotations = (options) => { + exportAnnotations = (options?: {annotList: Array}): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAnnotations(tag, options); @@ -319,7 +423,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - flattenAnnotations = (formsOnly) => { + flattenAnnotations = (formsOnly: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.flattenAnnotations(tag, formsOnly); @@ -327,7 +431,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - deleteAnnotations = (annotations) => { + deleteAnnotations = (annotations: Array): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.deleteAnnotations(tag, annotations); @@ -335,7 +439,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - saveDocument = () => { + saveDocument = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.saveDocument(tag); @@ -343,7 +447,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setFlagForFields = (fields, flag, value) => { + setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.setFlagForFields(tag, fields, flag, value); @@ -351,7 +455,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getField = (fieldName) => { + getField = (fieldName: string): Promise | Promise<{fieldName: string, fieldValue?: any, fieldType?: string}> => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.getField(tag, fieldName); @@ -363,11 +467,11 @@ export class DocumentView extends PureComponent { * note: this function exists for supporting the old version. It simply calls setValuesForFields. * */ - setValueForFields = (fieldsMap) => { + setValueForFields = (fieldsMap: Record): Promise => { return this.setValuesForFields(fieldsMap); } - setValuesForFields = (fieldsMap) => { + setValuesForFields = (fieldsMap: Record): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.setValuesForFields(tag, fieldsMap); @@ -375,7 +479,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - handleBackButton = () => { + handleBackButton = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.handleBackButton(tag); @@ -388,11 +492,11 @@ export class DocumentView extends PureComponent { * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. * */ - setFlagForAnnotations = (annotationFlagList) => { + setFlagForAnnotations = (annotationFlagList: Array): Promise => { return this.setFlagsForAnnotations(annotationFlagList); } - setFlagsForAnnotations = (annotationFlagList) => { + setFlagsForAnnotations = (annotationFlagList: Array): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setFlagsForAnnotations(tag, annotationFlagList); @@ -400,7 +504,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - selectAnnotation = (id, pageNumber) => { + selectAnnotation = (id: string, pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.selectAnnotation(tag, id, pageNumber); @@ -412,11 +516,11 @@ export class DocumentView extends PureComponent { * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. * */ - setPropertyForAnnotation = (id, pageNumber, propertyMap) => { + setPropertyForAnnotation = (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties): Promise => { return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); // check this._viewerRef } - setPropertiesForAnnotation = (id, pageNumber, propertyMap) => { + setPropertiesForAnnotation = (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setPropertiesForAnnotation(tag, id, pageNumber, propertyMap); @@ -424,7 +528,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPropertiesForAnnotation = (id, pageNumber) => { + getPropertiesForAnnotation = (id: string, pageNumber: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); @@ -432,7 +536,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setDrawAnnotations = (drawAnnotations) => { + setDrawAnnotations = (drawAnnotations: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setDrawAnnotations(tag, drawAnnotations); @@ -440,7 +544,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setVisibilityForAnnotation = (id, pageNumber, visibility) => { + setVisibilityForAnnotation = (id: string, pageNumber: number, visibility: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setVisibilityForAnnotation(tag, id, pageNumber, visibility); @@ -448,7 +552,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setHighlightFields = (highlightFields) => { + setHighlightFields = (highlightFields: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setHighlightFields(tag, highlightFields); @@ -456,7 +560,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationAtPoint = (x, y, distanceThreshold, minimumLineWeight) => { + getAnnotationAtPoint = (x: number, y: number, distanceThreshold: number, minimumLineWeight: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); @@ -464,7 +568,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationListAt = (x1, y1, x2, y2) => { + getAnnotationListAt = (x1: number, y1: number, x2: number, y2: number): Promise | Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); @@ -472,7 +576,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationsOnPage = (pageNumber) => { + getAnnotationsOnPage = (pageNumber: number): Promise | Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); @@ -480,7 +584,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getCustomDataForAnnotation = (annotationID, pageNumber, key) => { + getCustomDataForAnnotation = (annotationID: string, pageNumber: number, key: string): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); @@ -488,7 +592,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageCropBox = (pageNumber) => { + getPageCropBox = (pageNumber: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageCropBox(tag, pageNumber); @@ -496,7 +600,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setCurrentPage = (pageNumber) => { + setCurrentPage = (pageNumber: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setCurrentPage(tag, pageNumber); @@ -504,7 +608,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getVisiblePages = () => { + getVisiblePages = (): Promise | Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getVisiblePages(tag); @@ -512,7 +616,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoPreviousPage = () => { + gotoPreviousPage = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoPreviousPage(tag); @@ -520,7 +624,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoNextPage = () => { + gotoNextPage = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoNextPage(tag); @@ -528,7 +632,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoFirstPage = () => { + gotoFirstPage = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoFirstPage(tag); @@ -536,7 +640,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoLastPage = () => { + gotoLastPage = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoLastPage(tag); @@ -544,7 +648,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - showGoToPageView = () => { + showGoToPageView = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.showGoToPageView(tag); @@ -552,7 +656,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - closeAllTabs = () => { + closeAllTabs = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.closeAllTabs(tag); @@ -560,7 +664,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getZoom = () => { + getZoom = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getZoom(tag); @@ -568,7 +672,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setZoomLimits = (zoomLimitMode, minimum, maximum) => { + setZoomLimits = (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); @@ -576,7 +680,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - zoomWithCenter = (zoom, x, y) => { + zoomWithCenter = (zoom: number, x: number, y: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.zoomWithCenter(tag, zoom, x, y); @@ -584,7 +688,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - zoomToRect = (pageNumber, rect) => { + zoomToRect = (pageNumber: number, rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.zoomToRect(tag, pageNumber, rect); @@ -592,7 +696,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - smartZoom = (x, y, animated) => { + smartZoom = (x: number, y: number, animated: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.smartZoom(tag, x, y, animated); @@ -600,7 +704,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getScrollPos = () => { + getScrollPos = (): Promise | Promise<{horizontal: number, vertical: number}> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getScrollPos(tag); @@ -608,7 +712,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getCanvasSize = () => { + getCanvasSize = (): Promise | Promise<{width: number, height: number}> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getCanvasSize(tag); @@ -616,7 +720,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageRotation = () => { + getPageRotation = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageRotation(tag); @@ -624,7 +728,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - rotateClockwise = () => { + rotateClockwise = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.rotateClockwise(tag); @@ -632,7 +736,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - rotateCounterClockwise = () => { + rotateCounterClockwise = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.rotateCounterClockwise(tag); @@ -641,7 +745,7 @@ export class DocumentView extends PureComponent { } - convertScreenPointsToPagePoints = (points) => { + convertScreenPointsToPagePoints = (points: Array): Promise | Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); @@ -649,7 +753,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - convertPagePointsToScreenPoints = (points) => { + convertPagePointsToScreenPoints = (points: Array): Promise | Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); @@ -657,7 +761,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageNumberFromScreenPoint = (x, y) => { + getPageNumberFromScreenPoint = (x: number, y: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); @@ -665,7 +769,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setProgressiveRendering = (progressiveRendering, initialDelay, interval) => { + setProgressiveRendering = (progressiveRendering: boolean, initialDelay: number, interval: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setProgressiveRendering(tag, progressiveRendering, initialDelay, interval); @@ -673,7 +777,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setImageSmoothing = (imageSmoothing) => { + setImageSmoothing = (imageSmoothing: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setImageSmoothing(tag, imageSmoothing); @@ -681,7 +785,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setOverprint = (overprint) => { + setOverprint = (overprint: Config.OverprintMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setOverprint(tag, overprint); @@ -689,7 +793,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setColorPostProcessMode = (colorPostProcessMode) => { + setColorPostProcessMode = (colorPostProcessMode: Config.ColorPostProcessMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); @@ -697,7 +801,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setColorPostProcessColors = (whiteColor, blackColor) => { + setColorPostProcessColors = (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setColorPostProcessColors(tag, whiteColor, blackColor); @@ -705,7 +809,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - startSearchMode = (searchString, matchCase, matchWholeWord) => { + startSearchMode = (searchString: string, matchCase: boolean, matchWholeWord: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.startSearchMode(tag, searchString, matchCase, matchWholeWord); @@ -713,7 +817,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exitSearchMode = () => { + exitSearchMode = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exitSearchMode(tag); @@ -721,7 +825,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - findText = (searchString, matchCase, matchWholeWord, searchUp, regExp) => { + findText = (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.findText(tag, searchString, matchCase, matchWholeWord, searchUp, regExp); @@ -729,7 +833,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - cancelFindText = () => { + cancelFindText = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.cancelFindText(tag); @@ -737,7 +841,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getSelection = (pageNumber) => { + getSelection = (pageNumber: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getSelection(tag, pageNumber); @@ -745,7 +849,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - hasSelection = () => { + hasSelection = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.hasSelection(tag); @@ -753,7 +857,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - clearSelection = () => { + clearSelection = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.clearSelection(tag); @@ -761,7 +865,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getSelectionPageRange = () => { + getSelectionPageRange = (): Promise | Promise<{begin: number, end: number}> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getSelectionPageRange(tag); @@ -769,7 +873,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - hasSelectionOnPage = (pageNumber) => { + hasSelectionOnPage = (pageNumber: number): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); @@ -778,7 +882,7 @@ export class DocumentView extends PureComponent { } - selectInRect = (rect) => { + selectInRect = (rect: AnnotOptions.Rect): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.selectInRect(tag, rect); @@ -786,7 +890,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - isThereTextInRect = (rect) => { + isThereTextInRect = (rect: AnnotOptions.Rect): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.isThereTextInRect(tag, rect); @@ -794,7 +898,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - selectAll = () => { + selectAll = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.selectAll(tag); @@ -803,7 +907,7 @@ export class DocumentView extends PureComponent { } - setUrlExtraction = (urlExtraction) => { + setUrlExtraction = (urlExtraction: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setUrlExtraction(tag, urlExtraction); @@ -811,7 +915,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setPageBorderVisibility = (pageBorderVisibility) => { + setPageBorderVisibility = (pageBorderVisibility: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setPageBorderVisibility(tag, pageBorderVisibility); @@ -819,7 +923,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setPageTransparencyGrid = (pageTransparencyGrid) => { + setPageTransparencyGrid = (pageTransparencyGrid: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setPageTransparencyGrid(tag, pageTransparencyGrid); @@ -827,7 +931,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setDefaultPageColor = (defaultPageColor) => { + setDefaultPageColor = (defaultPageColor: AnnotOptions.Color): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setDefaultPageColor(tag, defaultPageColor); @@ -835,7 +939,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setBackgroundColor = (backgroundColor) => { + setBackgroundColor = (backgroundColor: AnnotOptions.Color): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setBackgroundColor(tag, backgroundColor); @@ -843,7 +947,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAsImage = (pageNumber, dpi, exportFormat) => { + exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); @@ -851,7 +955,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - undo = () => { + undo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.undo(tag); @@ -859,7 +963,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - redo = () => { + redo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.redo(tag); @@ -867,7 +971,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - canUndo = () => { + canUndo = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.canUndo(tag); @@ -875,7 +979,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - canRedo = () => { + canRedo = (): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.canRedo(tag); @@ -883,7 +987,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - showCrop = () => { + showCrop = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.showCrop(tag); @@ -891,7 +995,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setCurrentToolbar = (toolbar) => { + setCurrentToolbar = (toolbar: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setCurrentToolbar(tag, toolbar); @@ -899,7 +1003,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - openThumbnailsView = () => { + openThumbnailsView = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.openThumbnailsView(tag); From 0b9509c32390d265380d8f7da67b3435a91b03f2 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 4 Aug 2021 10:04:10 -0700 Subject: [PATCH 044/226] add tsconfig to get correct output structure --- index.d.ts | 20 +++++-------------- index.js | 6 +++--- index.ts | 6 +++--- src/{types => AnnotOptions}/AnnotOptions.d.ts | 3 +-- src/{types => Config}/Config.d.ts | 0 src/Config/package.json | 7 ------- src/{types => DocumentView}/DocumentView.d.ts | 11 +++++----- src/DocumentView/package.json | 7 ------- src/{types => PDFViewCtrl}/PDFViewCtrl.d.ts | 0 src/PDFViewCtrl/package.json | 7 ------- tsconfig.json | 6 ++---- tsconfig.src.json | 14 +++++++++++++ types/AnnotOptions/AnnotOptions.ts | 2 +- types/DocumentView/DocumentView.tsx | 4 ++-- 14 files changed, 36 insertions(+), 57 deletions(-) rename src/{types => AnnotOptions}/AnnotOptions.d.ts (96%) rename src/{types => Config}/Config.d.ts (100%) delete mode 100644 src/Config/package.json rename src/{types => DocumentView}/DocumentView.d.ts (99%) delete mode 100644 src/DocumentView/package.json rename src/{types => PDFViewCtrl}/PDFViewCtrl.d.ts (100%) delete mode 100644 src/PDFViewCtrl/package.json create mode 100644 tsconfig.src.json diff --git a/index.d.ts b/index.d.ts index 40bbe9389..4392ddbe4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ -import { PDFViewCtrl } from 'react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from 'react-native-pdftron/types/DocumentView/DocumentView'; -import { Config } from 'react-native-pdftron/types/Config/Config'; +import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from './types/DocumentView/DocumentView'; +import { Config } from './types/Config/Config'; export interface Pdftron { initialize?(licenseKey: string): void; enableJavaScript?(enabled: boolean): void; @@ -11,15 +11,5 @@ export interface Pdftron { encryptDocument?(filePath: string, password: string, currentPassword: string): Promise; pdfFromOfficeTemplate?(docxPath: string, json: object): Promise; } - -export const RNPdftron : Pdftron; - -export {Config} from "./src/types/Config"; - -export * as ConfigOptions from "./src/types/ConfigOptions"; - -export {DocumentView} from "./src/types/DocumentView"; - -export * as AnnotOptions from "./src/types/AnnotOptions"; - -export {PDFViewCtrl} from "./src/types/PDFViewCtrl"; +declare const RNPdftron: Pdftron; +export { RNPdftron, PDFViewCtrl, DocumentView, Config }; diff --git a/index.js b/index.js index 74ff14f9e..db681127a 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ import { NativeModules } from 'react-native'; -import { PDFViewCtrl } from 'react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from 'react-native-pdftron/types/DocumentView/DocumentView'; -import { Config } from 'react-native-pdftron/types/Config/Config'; +import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from './types/DocumentView/DocumentView'; +import { Config } from './types/Config/Config'; const RNPdftron = NativeModules; export { RNPdftron, PDFViewCtrl, DocumentView, Config }; diff --git a/index.ts b/index.ts index df28b2fbb..74fc3ac48 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,7 @@ import { NativeModules } from 'react-native'; -import { PDFViewCtrl } from 'react-native-pdftron/types/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from 'react-native-pdftron/types/DocumentView/DocumentView'; -import { Config } from 'react-native-pdftron/types/Config/Config'; +import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from './types/DocumentView/DocumentView'; +import { Config } from './types/Config/Config'; export interface Pdftron { initialize?(licenseKey: string) : void; diff --git a/src/types/AnnotOptions.d.ts b/src/AnnotOptions/AnnotOptions.d.ts similarity index 96% rename from src/types/AnnotOptions.d.ts rename to src/AnnotOptions/AnnotOptions.d.ts index fb73bf0e8..d825160b2 100644 --- a/src/types/AnnotOptions.d.ts +++ b/src/AnnotOptions/AnnotOptions.d.ts @@ -1,5 +1,4 @@ -import * as ConfigOptions from './ConfigOptions'; - +import * as Config from '../Config/Config'; export interface Annotation { id: string; pageNumber?: number; diff --git a/src/types/Config.d.ts b/src/Config/Config.d.ts similarity index 100% rename from src/types/Config.d.ts rename to src/Config/Config.d.ts diff --git a/src/Config/package.json b/src/Config/package.json deleted file mode 100644 index f7c0a9707..000000000 --- a/src/Config/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "Config", - "version": "0.0.0", - "private": true, - "main": "./Config", - "typings": "../types/config.d.ts" -} \ No newline at end of file diff --git a/src/types/DocumentView.d.ts b/src/DocumentView/DocumentView.d.ts similarity index 99% rename from src/types/DocumentView.d.ts rename to src/DocumentView/DocumentView.d.ts index 1a58a32c0..414e53187 100644 --- a/src/types/DocumentView.d.ts +++ b/src/DocumentView/DocumentView.d.ts @@ -1,9 +1,8 @@ - -import { PureComponent } from "react"; -import { ViewProps } from "react-native"; -import * as ConfigOptions from "./ConfigOptions"; -import * as AnnotOptions from "./AnnotOptions"; - +import { PureComponent } from 'react'; +import PropTypes from 'prop-types'; +import { ViewProps } from 'react-native'; +import * as Config from "../Config/Config"; +import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { document: string; password?: string; diff --git a/src/DocumentView/package.json b/src/DocumentView/package.json deleted file mode 100644 index 1d1a49f10..000000000 --- a/src/DocumentView/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "DocumentView", - "version": "0.0.0", - "private": true, - "main": "./DocumentView", - "typings": "../types/document_view.d.ts" -} \ No newline at end of file diff --git a/src/types/PDFViewCtrl.d.ts b/src/PDFViewCtrl/PDFViewCtrl.d.ts similarity index 100% rename from src/types/PDFViewCtrl.d.ts rename to src/PDFViewCtrl/PDFViewCtrl.d.ts diff --git a/src/PDFViewCtrl/package.json b/src/PDFViewCtrl/package.json deleted file mode 100644 index a55444ea6..000000000 --- a/src/PDFViewCtrl/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "PDFViewCtrl", - "version": "0.0.0", - "private": true, - "main": "./PDFViewCtrl", - "typings": "../types/pdf_view_ctrl.d.ts" -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 755240590..6e2b56b65 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,12 +4,10 @@ "target": "ESNext", "jsx": "react-native", "esModuleInterop": true, - "outDir": "./src", "skipLibCheck": true, "declaration": true, - "declarationDir": "./types", - "rootDirs": ["types/", "./"] + "outDir": "./", }, - "include": ["types/**/*", "../index.ts"], + "files": ["index.ts"], "exclude": ["node_modules", "**/*.spec.ts"] } \ No newline at end of file diff --git a/tsconfig.src.json b/tsconfig.src.json new file mode 100644 index 000000000..e6bbe93ac --- /dev/null +++ b/tsconfig.src.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "moduleResolution": "Node", + "target": "ESNext", + "jsx": "react-native", + "esModuleInterop": true, + "skipLibCheck": true, + "declaration": true, + "outDir": "./src", + }, + "files": ["types/AnnotOptions/AnnotOptions.ts", "types/Config/Config.ts", "types/DocumentView/DocumentView.tsx", "types/PDFViewCtrl/PDFViewCtrl.tsx"], + "exclude": ["node_modules", "**/*.spec.ts"] +} \ No newline at end of file diff --git a/types/AnnotOptions/AnnotOptions.ts b/types/AnnotOptions/AnnotOptions.ts index 06ec71cd3..a2f33d56e 100644 --- a/types/AnnotOptions/AnnotOptions.ts +++ b/types/AnnotOptions/AnnotOptions.ts @@ -1,4 +1,4 @@ -import * as Config from 'react-native-pdftron/types/Config/Config'; +import * as Config from '../Config/Config'; export interface Annotation { id: string; diff --git a/types/DocumentView/DocumentView.tsx b/types/DocumentView/DocumentView.tsx index 4d8305a71..35f7b579f 100644 --- a/types/DocumentView/DocumentView.tsx +++ b/types/DocumentView/DocumentView.tsx @@ -10,8 +10,8 @@ import { findNodeHandle, } from 'react-native'; const { DocumentViewManager } = NativeModules; -import * as Config from "react-native-pdftron/types/Config/Config"; -import * as AnnotOptions from "react-native-pdftron/types/AnnotOptions/AnnotOptions"; +import * as Config from "../Config/Config"; +import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { document: string; From 2ce9f69604b5b57b7db602a271aa14960199b0e1 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Wed, 4 Aug 2021 16:12:42 -0700 Subject: [PATCH 045/226] Added a build script and updated the exports --- example/package.json | 3 ++ index.d.ts | 21 +++++------ index.js | 5 +-- index.ts | 25 +++++++------ types/AnnotOptions/AnnotOptions.ts | 4 +-- types/Config/Config.ts | 52 ++++++++++++++------------- types/DocumentView/DocumentView.tsx | 54 ++++++++++++++--------------- 7 files changed, 87 insertions(+), 77 deletions(-) diff --git a/example/package.json b/example/package.json index 698f786b2..2bb7888d9 100644 --- a/example/package.json +++ b/example/package.json @@ -3,8 +3,11 @@ "version": "0.0.1", "private": true, "scripts": { + "preandroid" : "npx tsc", "android": "react-native run-android", + "preios": "npx tsc", "ios": "react-native run-ios", + "prestart": "npx tsc", "start": "react-native start", "test": "jest", "lint": "eslint ." diff --git a/index.d.ts b/index.d.ts index 4392ddbe4..3186471a6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,15 +1,16 @@ import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; import { DocumentView } from './types/DocumentView/DocumentView'; -import { Config } from './types/Config/Config'; +import { Config, ConfigOptions } from './types/Config/Config'; +import * as AnnotOptions from './types/AnnotOptions/AnnotOptions'; export interface Pdftron { - initialize?(licenseKey: string): void; - enableJavaScript?(enabled: boolean): void; - getVersion?(): Promise; - getPlatformVersion?(): Promise; - getSystemFontList?(): Promise; - clearRubberStampCache?(): Promise; - encryptDocument?(filePath: string, password: string, currentPassword: string): Promise; - pdfFromOfficeTemplate?(docxPath: string, json: object): Promise; + initialize(licenseKey: string): void; + enableJavaScript(enabled: boolean): void; + getVersion(): Promise; + getPlatformVersion(): Promise; + getSystemFontList(): Promise; + clearRubberStampCache(): Promise; + encryptDocument(filePath: string, password: string, currentPassword: string): Promise; + pdfFromOfficeTemplate(docxPath: string, json: object): Promise; } declare const RNPdftron: Pdftron; -export { RNPdftron, PDFViewCtrl, DocumentView, Config }; +export { RNPdftron, PDFViewCtrl, DocumentView, Config, AnnotOptions, ConfigOptions }; diff --git a/index.js b/index.js index db681127a..d1ab65271 100644 --- a/index.js +++ b/index.js @@ -2,5 +2,6 @@ import { NativeModules } from 'react-native'; import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; import { DocumentView } from './types/DocumentView/DocumentView'; import { Config } from './types/Config/Config'; -const RNPdftron = NativeModules; -export { RNPdftron, PDFViewCtrl, DocumentView, Config }; +import * as AnnotOptions from './types/AnnotOptions/AnnotOptions'; +const RNPdftron = NativeModules.RNPdftron; +export { RNPdftron, PDFViewCtrl, DocumentView, Config, AnnotOptions }; diff --git a/index.ts b/index.ts index 74fc3ac48..dc755807b 100644 --- a/index.ts +++ b/index.ts @@ -1,24 +1,27 @@ import { NativeModules } from 'react-native'; import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; import { DocumentView } from './types/DocumentView/DocumentView'; -import { Config } from './types/Config/Config'; +import { Config, ConfigOptions } from './types/Config/Config'; +import * as AnnotOptions from './types/AnnotOptions/AnnotOptions'; export interface Pdftron { - initialize?(licenseKey: string) : void; - enableJavaScript?(enabled: boolean) : void; - getVersion?() : Promise; - getPlatformVersion?() : Promise; - getSystemFontList?() : Promise; - clearRubberStampCache?() : Promise; - encryptDocument?(filePath: string, password: string, currentPassword: string) : Promise; - pdfFromOfficeTemplate?(docxPath: string, json: object) : Promise; + initialize(licenseKey: string) : void; + enableJavaScript(enabled: boolean) : void; + getVersion() : Promise; + getPlatformVersion() : Promise; + getSystemFontList() : Promise; + clearRubberStampCache() : Promise; + encryptDocument(filePath: string, password: string, currentPassword: string) : Promise; + pdfFromOfficeTemplate(docxPath: string, json: object) : Promise; } -const RNPdftron : Pdftron = NativeModules; +const RNPdftron : Pdftron = NativeModules.RNPdftron; export { RNPdftron, PDFViewCtrl, DocumentView, - Config + Config, + AnnotOptions, + ConfigOptions }; \ No newline at end of file diff --git a/types/AnnotOptions/AnnotOptions.ts b/types/AnnotOptions/AnnotOptions.ts index a2f33d56e..524fa4f30 100644 --- a/types/AnnotOptions/AnnotOptions.ts +++ b/types/AnnotOptions/AnnotOptions.ts @@ -1,4 +1,4 @@ -import * as Config from '../Config/Config'; +import {ConfigOptions} from '../Config/Config'; export interface Annotation { id: string; @@ -59,7 +59,7 @@ export interface TextSelectionResult { export interface AnnotationFlag { id: string; pageNumber: number; - flag: Config.AnnotationFlags; + flag: ConfigOptions.AnnotationFlags; flagValue: boolean; } diff --git a/types/Config/Config.ts b/types/Config/Config.ts index 2c9fdbef5..8bd70ac7e 100644 --- a/types/Config/Config.ts +++ b/types/Config/Config.ts @@ -272,29 +272,31 @@ export const Config = { type ValueOf = T[keyof T]; -export type Buttons = ValueOf; -export type Tools = ValueOf; -export type FitMode = ValueOf; -export type LayoutMode = ValueOf; -export type FieldFlags = ValueOf; -export type AnnotationMenu = ValueOf; -export type EraserType = ValueOf; -export type LongPressMenu = ValueOf; -export type Actions = ValueOf; -export type AnnotationFlags = ValueOf; -export type DefaultToolbars = ValueOf; -export type ToolbarIcons = ValueOf; -export type ThumbnailFilterMode = ValueOf; -export type Conversion = ValueOf; -export type ViewModePickerItem = ValueOf; -export type ZoomLimitMode = ValueOf; -export type OverprintMode = ValueOf; -export type ColorPostProcessMode = ValueOf; -export type ReflowOrientation = ValueOf; -export type ExportFormat = ValueOf; -export type CustomToolbarKey = { - id : string; - name: string; - icon: ToolbarIcons; - items: (Tools | Buttons)[]; +export namespace ConfigOptions { + export type Buttons = ValueOf; + export type Tools = ValueOf; + export type FitMode = ValueOf; + export type LayoutMode = ValueOf; + export type FieldFlags = ValueOf; + export type AnnotationMenu = ValueOf; + export type EraserType = ValueOf; + export type LongPressMenu = ValueOf; + export type Actions = ValueOf; + export type AnnotationFlags = ValueOf; + export type DefaultToolbars = ValueOf; + export type ToolbarIcons = ValueOf; + export type ThumbnailFilterMode = ValueOf; + export type Conversion = ValueOf; + export type ViewModePickerItem = ValueOf; + export type ZoomLimitMode = ValueOf; + export type OverprintMode = ValueOf; + export type ColorPostProcessMode = ValueOf; + export type ReflowOrientation = ValueOf; + export type ExportFormat = ValueOf; + export type CustomToolbarKey = { + id : string; + name: string; + icon: ToolbarIcons; + items: (Tools | Buttons)[]; + } } \ No newline at end of file diff --git a/types/DocumentView/DocumentView.tsx b/types/DocumentView/DocumentView.tsx index 35f7b579f..e0031d188 100644 --- a/types/DocumentView/DocumentView.tsx +++ b/types/DocumentView/DocumentView.tsx @@ -10,7 +10,7 @@ import { findNodeHandle, } from 'react-native'; const { DocumentViewManager } = NativeModules; -import * as Config from "../Config/Config"; +import {ConfigOptions} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { @@ -29,18 +29,18 @@ export interface DocumentViewProps extends ViewProps { onZoomChanged?: ({zoom}: {zoom: number}) => void; onZoomFinished?: ({zoom}: {zoom: number}) => void; zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; onLongPressMenuPress?: ({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void; longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; onAnnotationMenuPress?: ({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; - onBehaviorActivated?: ({action, data}: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; + onBehaviorActivated?: ({action, data}: {action: ConfigOptions.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; @@ -52,8 +52,8 @@ export interface DocumentViewProps extends ViewProps { onFormFieldValueChanged?: ({fields}: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; - fitMode?: Config.FitMode; - layoutMode?: Config.LayoutMode; + fitMode?: ConfigOptions.FitMode; + layoutMode?: ConfigOptions.LayoutMode; onLayoutChanged?: () => void; padStatusBar?: boolean; continuousAnnotationEditing?: boolean; @@ -74,21 +74,21 @@ export interface DocumentViewProps extends ViewProps { maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; hideAnnotationToolbarSwitcher?: boolean; hideTopToolbars?: boolean; hideTopAppNavBar?: boolean; onBookmarkChanged?: ({bookmarkJson}: {bookmarkJson: string}) => void; - hideThumbnailFilterModes?: Array; - onToolChanged?: ({previousTool, tool}: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void; + hideThumbnailFilterModes?: Array; + onToolChanged?: ({previousTool, tool}: {previousTool: ConfigOptions.Tools | "unknown tool", tool: ConfigOptions.Tools | "unknown tool"}) => void; horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; onTextSearchResult?: ({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; - hideViewModeItems?: Array; + hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; photoPickerEnabled?: boolean; @@ -98,12 +98,12 @@ export interface DocumentViewProps extends ViewProps { restrictDownloadUsage?: boolean; userBookmarksListEditingEnabled?: boolean; imageInReflowEnabled?: boolean; - reflowOrientation?: Config.ReflowOrientation; + reflowOrientation?: ConfigOptions.ReflowOrientation; onUndoRedoStateChanged?: () => void; tabletLayoutEnabled?: boolean; initialToolbar?: string; inkMultiStrokeEnabled?: boolean; - defaultEraserType?: Config.EraserType; + defaultEraserType?: ConfigOptions.EraserType; exportPath?: string; openUrlPath?: string; hideScrollbars?: boolean; @@ -360,7 +360,7 @@ export class DocumentView extends PureComponent { } - setToolMode = (toolMode: Config.Tools): Promise => { + setToolMode = (toolMode: ConfigOptions.Tools): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setToolMode(tag, toolMode); @@ -447,7 +447,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { + setFlagForFields = (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.setFlagForFields(tag, fields, flag, value); @@ -672,7 +672,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setZoomLimits = (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number): Promise => { + setZoomLimits = (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); @@ -785,7 +785,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setOverprint = (overprint: Config.OverprintMode): Promise => { + setOverprint = (overprint: ConfigOptions.OverprintMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setOverprint(tag, overprint); @@ -793,7 +793,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setColorPostProcessMode = (colorPostProcessMode: Config.ColorPostProcessMode): Promise => { + setColorPostProcessMode = (colorPostProcessMode: ConfigOptions.ColorPostProcessMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); @@ -947,7 +947,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise | Promise => { + exportAsImage = (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); From 0275519b40228d7b280f475bf97d4b9971731ec1 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 5 Aug 2021 09:20:32 -0700 Subject: [PATCH 046/226] Fixed build script --- example/package.json | 3 -- package.json | 3 +- src/AnnotOptions/AnnotOptions.d.ts | 4 +-- src/Config/Config.d.ts | 54 ++++++++++++++-------------- src/DocumentView/DocumentView.d.ts | 56 +++++++++++++++--------------- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/example/package.json b/example/package.json index 2bb7888d9..698f786b2 100644 --- a/example/package.json +++ b/example/package.json @@ -3,11 +3,8 @@ "version": "0.0.1", "private": true, "scripts": { - "preandroid" : "npx tsc", "android": "react-native run-android", - "preios": "npx tsc", "ios": "react-native run-ios", - "prestart": "npx tsc", "start": "react-native start", "test": "jest", "lint": "eslint ." diff --git a/package.json b/package.json index f4688ac32..e56d6955a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "typings": "./index.d.ts", "scripts": { "copy-to-repo": "cd scripts && python3 fileCopy.py toRepo && cd ..", - "copy-to-node-modules": "cd scripts && python3 fileCopy.py toModule && cd .." + "copy-to-node-modules": "cd scripts && python3 fileCopy.py toModule && cd ..", + "start": "npx tsc && npx tsc --p ./tsconfig.src.json" }, "repository": { "type": "git", diff --git a/src/AnnotOptions/AnnotOptions.d.ts b/src/AnnotOptions/AnnotOptions.d.ts index d825160b2..a354763bd 100644 --- a/src/AnnotOptions/AnnotOptions.d.ts +++ b/src/AnnotOptions/AnnotOptions.d.ts @@ -1,4 +1,4 @@ -import * as Config from '../Config/Config'; +import { ConfigOptions } from '../Config/Config'; export interface Annotation { id: string; pageNumber?: number; @@ -47,7 +47,7 @@ export interface TextSelectionResult { export interface AnnotationFlag { id: string; pageNumber: number; - flag: Config.AnnotationFlags; + flag: ConfigOptions.AnnotationFlags; flagValue: boolean; } export interface AnnotationProperties { diff --git a/src/Config/Config.d.ts b/src/Config/Config.d.ts index 32115dab6..f74f4a8d3 100644 --- a/src/Config/Config.d.ts +++ b/src/Config/Config.d.ts @@ -224,30 +224,32 @@ export declare const Config: { }; }; declare type ValueOf = T[keyof T]; -export declare type Buttons = ValueOf; -export declare type Tools = ValueOf; -export declare type FitMode = ValueOf; -export declare type LayoutMode = ValueOf; -export declare type FieldFlags = ValueOf; -export declare type AnnotationMenu = ValueOf; -export declare type EraserType = ValueOf; -export declare type LongPressMenu = ValueOf; -export declare type Actions = ValueOf; -export declare type AnnotationFlags = ValueOf; -export declare type DefaultToolbars = ValueOf; -export declare type ToolbarIcons = ValueOf; -export declare type ThumbnailFilterMode = ValueOf; -export declare type Conversion = ValueOf; -export declare type ViewModePickerItem = ValueOf; -export declare type ZoomLimitMode = ValueOf; -export declare type OverprintMode = ValueOf; -export declare type ColorPostProcessMode = ValueOf; -export declare type ReflowOrientation = ValueOf; -export declare type ExportFormat = ValueOf; -export declare type CustomToolbarKey = { - id: string; - name: string; - icon: ToolbarIcons; - items: (Tools | Buttons)[]; -}; +export declare namespace ConfigOptions { + type Buttons = ValueOf; + type Tools = ValueOf; + type FitMode = ValueOf; + type LayoutMode = ValueOf; + type FieldFlags = ValueOf; + type AnnotationMenu = ValueOf; + type EraserType = ValueOf; + type LongPressMenu = ValueOf; + type Actions = ValueOf; + type AnnotationFlags = ValueOf; + type DefaultToolbars = ValueOf; + type ToolbarIcons = ValueOf; + type ThumbnailFilterMode = ValueOf; + type Conversion = ValueOf; + type ViewModePickerItem = ValueOf; + type ZoomLimitMode = ValueOf; + type OverprintMode = ValueOf; + type ColorPostProcessMode = ValueOf; + type ReflowOrientation = ValueOf; + type ExportFormat = ValueOf; + type CustomToolbarKey = { + id: string; + name: string; + icon: ToolbarIcons; + items: (Tools | Buttons)[]; + }; +} export {}; diff --git a/src/DocumentView/DocumentView.d.ts b/src/DocumentView/DocumentView.d.ts index 414e53187..827949d24 100644 --- a/src/DocumentView/DocumentView.d.ts +++ b/src/DocumentView/DocumentView.d.ts @@ -1,7 +1,7 @@ import { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { ViewProps } from 'react-native'; -import * as Config from "../Config/Config"; +import { ConfigOptions } from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { document: string; @@ -29,25 +29,25 @@ export interface DocumentViewProps extends ViewProps { zoom: number; }) => void; zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; onLongPressMenuPress?: ({ longPressMenu, longPressText }: { longPressMenu: string; longPressText: string; }) => void; longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; onAnnotationMenuPress?: ({ annotationMenu, annotations }: { annotationMenu: string; annotations: Array; }) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; onBehaviorActivated?: ({ action, data }: { - action: Config.Actions; + action: ConfigOptions.Actions; data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData; }) => void; topToolbarEnabled?: boolean; @@ -68,8 +68,8 @@ export interface DocumentViewProps extends ViewProps { }) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; - fitMode?: Config.FitMode; - layoutMode?: Config.LayoutMode; + fitMode?: ConfigOptions.FitMode; + layoutMode?: ConfigOptions.LayoutMode; onLayoutChanged?: () => void; padStatusBar?: boolean; continuousAnnotationEditing?: boolean; @@ -94,20 +94,20 @@ export interface DocumentViewProps extends ViewProps { maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; hideAnnotationToolbarSwitcher?: boolean; hideTopToolbars?: boolean; hideTopAppNavBar?: boolean; onBookmarkChanged?: ({ bookmarkJson }: { bookmarkJson: string; }) => void; - hideThumbnailFilterModes?: Array; + hideThumbnailFilterModes?: Array; onToolChanged?: ({ previousTool, tool }: { - previousTool: Config.Tools | "unknown tool"; - tool: Config.Tools | "unknown tool"; + previousTool: ConfigOptions.Tools | "unknown tool"; + tool: ConfigOptions.Tools | "unknown tool"; }) => void; horizontalScrollPos?: number; verticalScrollPos?: number; @@ -116,7 +116,7 @@ export interface DocumentViewProps extends ViewProps { found: boolean; textSelection: AnnotOptions.TextSelectionResult | null; }) => void; - hideViewModeItems?: Array; + hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; photoPickerEnabled?: boolean; @@ -126,12 +126,12 @@ export interface DocumentViewProps extends ViewProps { restrictDownloadUsage?: boolean; userBookmarksListEditingEnabled?: boolean; imageInReflowEnabled?: boolean; - reflowOrientation?: Config.ReflowOrientation; + reflowOrientation?: ConfigOptions.ReflowOrientation; onUndoRedoStateChanged?: () => void; tabletLayoutEnabled?: boolean; initialToolbar?: string; inkMultiStrokeEnabled?: boolean; - defaultEraserType?: Config.EraserType; + defaultEraserType?: ConfigOptions.EraserType; exportPath?: string; openUrlPath?: string; hideScrollbars?: boolean; @@ -295,7 +295,7 @@ export declare class DocumentView extends PureComponent }; onChange: (event: any) => void; getDocumentPath: () => Promise | Promise; - setToolMode: (toolMode: Config.Tools) => Promise; + setToolMode: (toolMode: ConfigOptions.Tools) => Promise; commitTool: () => Promise | Promise; getPageCount: () => Promise | Promise; importBookmarkJson: (bookmarkJson: string) => Promise; @@ -307,7 +307,7 @@ export declare class DocumentView extends PureComponent flattenAnnotations: (formsOnly: boolean) => Promise; deleteAnnotations: (annotations: Array) => Promise; saveDocument: () => Promise | Promise; - setFlagForFields: (fields: Array, flag: Config.FieldFlags, value: boolean) => Promise; + setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; getField: (fieldName: string) => Promise | Promise<{ fieldName: string; fieldValue?: any; @@ -351,7 +351,7 @@ export declare class DocumentView extends PureComponent showGoToPageView: () => Promise; closeAllTabs: () => Promise; getZoom: () => Promise | Promise; - setZoomLimits: (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number) => Promise; + setZoomLimits: (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number) => Promise; zoomWithCenter: (zoom: number, x: number, y: number) => Promise; zoomToRect: (pageNumber: number, rect: AnnotOptions.Rect) => Promise; smartZoom: (x: number, y: number, animated: boolean) => Promise; @@ -371,8 +371,8 @@ export declare class DocumentView extends PureComponent getPageNumberFromScreenPoint: (x: number, y: number) => Promise | Promise; setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; setImageSmoothing: (imageSmoothing: boolean) => Promise; - setOverprint: (overprint: Config.OverprintMode) => Promise; - setColorPostProcessMode: (colorPostProcessMode: Config.ColorPostProcessMode) => Promise; + setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; + setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; setColorPostProcessColors: (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color) => Promise; startSearchMode: (searchString: string, matchCase: boolean, matchWholeWord: boolean) => Promise; exitSearchMode: () => Promise; @@ -394,7 +394,7 @@ export declare class DocumentView extends PureComponent setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; setDefaultPageColor: (defaultPageColor: AnnotOptions.Color) => Promise; setBackgroundColor: (backgroundColor: AnnotOptions.Color) => Promise; - exportAsImage: (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat) => Promise | Promise; + exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | Promise; undo: () => Promise; redo: () => Promise; canUndo: () => Promise | Promise; From f28f9a71358a9f0e6eca9aa807ad0bf6cdb8d377 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Mon, 9 Aug 2021 10:18:15 -0700 Subject: [PATCH 047/226] Restructed repo --- .gitignore | 3 + index.d.ts | 16 - index.js | 7 - index.ts | 8 +- package.json | 6 +- src/AnnotOptions/AnnotOptions.d.ts | 72 -- src/AnnotOptions/AnnotOptions.js | 1 - {types => src}/AnnotOptions/AnnotOptions.ts | 0 src/Config/Config.d.ts | 255 ------ src/Config/Config.js | 248 ------ {types => src}/Config/Config.ts | 2 +- src/DocumentView/DocumentView.d.ts | 407 --------- src/DocumentView/DocumentView.js | 838 ------------------- {types => src}/DocumentView/DocumentView.tsx | 0 src/PDFViewCtrl/PDFViewCtrl.d.ts | 9 - src/PDFViewCtrl/PDFViewCtrl.js | 19 - {types => src}/PDFViewCtrl/PDFViewCtrl.tsx | 0 tsconfig.json | 6 +- tsconfig.src.json | 14 - 19 files changed, 14 insertions(+), 1897 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.js delete mode 100644 src/AnnotOptions/AnnotOptions.d.ts delete mode 100644 src/AnnotOptions/AnnotOptions.js rename {types => src}/AnnotOptions/AnnotOptions.ts (100%) delete mode 100644 src/Config/Config.d.ts delete mode 100644 src/Config/Config.js rename {types => src}/Config/Config.ts (99%) delete mode 100644 src/DocumentView/DocumentView.d.ts delete mode 100644 src/DocumentView/DocumentView.js rename {types => src}/DocumentView/DocumentView.tsx (100%) delete mode 100644 src/PDFViewCtrl/PDFViewCtrl.d.ts delete mode 100644 src/PDFViewCtrl/PDFViewCtrl.js rename {types => src}/PDFViewCtrl/PDFViewCtrl.tsx (100%) delete mode 100644 tsconfig.src.json diff --git a/.gitignore b/.gitignore index e53e706c4..a2a179893 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ buck-out/ example/android/app/src/main/assets/index.android.bundle example/android/app/src/main/assets/index.android.bundle.meta + +# Build +/lib \ No newline at end of file diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 3186471a6..000000000 --- a/index.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from './types/DocumentView/DocumentView'; -import { Config, ConfigOptions } from './types/Config/Config'; -import * as AnnotOptions from './types/AnnotOptions/AnnotOptions'; -export interface Pdftron { - initialize(licenseKey: string): void; - enableJavaScript(enabled: boolean): void; - getVersion(): Promise; - getPlatformVersion(): Promise; - getSystemFontList(): Promise; - clearRubberStampCache(): Promise; - encryptDocument(filePath: string, password: string, currentPassword: string): Promise; - pdfFromOfficeTemplate(docxPath: string, json: object): Promise; -} -declare const RNPdftron: Pdftron; -export { RNPdftron, PDFViewCtrl, DocumentView, Config, AnnotOptions, ConfigOptions }; diff --git a/index.js b/index.js deleted file mode 100644 index d1ab65271..000000000 --- a/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { NativeModules } from 'react-native'; -import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from './types/DocumentView/DocumentView'; -import { Config } from './types/Config/Config'; -import * as AnnotOptions from './types/AnnotOptions/AnnotOptions'; -const RNPdftron = NativeModules.RNPdftron; -export { RNPdftron, PDFViewCtrl, DocumentView, Config, AnnotOptions }; diff --git a/index.ts b/index.ts index dc755807b..06cd9510b 100644 --- a/index.ts +++ b/index.ts @@ -1,8 +1,8 @@ import { NativeModules } from 'react-native'; -import { PDFViewCtrl } from './types/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from './types/DocumentView/DocumentView'; -import { Config, ConfigOptions } from './types/Config/Config'; -import * as AnnotOptions from './types/AnnotOptions/AnnotOptions'; +import { PDFViewCtrl } from './src/PDFViewCtrl/PDFViewCtrl'; +import { DocumentView } from './src/DocumentView/DocumentView copy'; +import { Config, ConfigOptions } from './src/Config/Config'; +import * as AnnotOptions from './src/AnnotOptions/AnnotOptions'; export interface Pdftron { initialize(licenseKey: string) : void; diff --git a/package.json b/package.json index e56d6955a..49522d7a6 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "title": "React Native Pdftron", "version": "2.0.3-beta.149", "description": "React Native Pdftron", - "main": "index.js", - "typings": "./index.d.ts", + "main": "./lib/index.js", + "typings": "index.ts", "scripts": { "copy-to-repo": "cd scripts && python3 fileCopy.py toRepo && cd ..", "copy-to-node-modules": "cd scripts && python3 fileCopy.py toModule && cd ..", - "start": "npx tsc && npx tsc --p ./tsconfig.src.json" + "start": "npx tsc" }, "repository": { "type": "git", diff --git a/src/AnnotOptions/AnnotOptions.d.ts b/src/AnnotOptions/AnnotOptions.d.ts deleted file mode 100644 index a354763bd..000000000 --- a/src/AnnotOptions/AnnotOptions.d.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { ConfigOptions } from '../Config/Config'; -export interface Annotation { - id: string; - pageNumber?: number; - type?: string; - rect?: Rect; - pageRect?: Rect; - screenRect?: Rect; -} -export interface Rect { - height?: number; - width?: number; - x1: number; - y1: number; - x2: number; - y2: number; -} -export declare type CropBox = Required; -export interface Color { - red: number; - green: number; - blue: number; -} -export declare type RotationDegree = 0 | 90 | 180 | 270; -export interface Field { - fieldName: string; - fieldValue: string | boolean | number; -} -export interface FieldWithStringValue { - fieldName: string; - fieldValue: string; -} -export interface Point { - x: number; - y: number; -} -export interface PointWithPage extends Point { - pageNumber?: number; -} -export declare type Quad = [Point, Point, Point, Point]; -export interface TextSelectionResult { - html: string; - unicode: string; - pageNumber: number; - quads: Array; -} -export interface AnnotationFlag { - id: string; - pageNumber: number; - flag: ConfigOptions.AnnotationFlags; - flagValue: boolean; -} -export interface AnnotationProperties { - rect?: Rect; - contents?: string; - subject?: string; - title?: string; - contentRect?: Rect; - customData?: object; - strokeColor?: Color; -} -export interface LinkPressData { - url: string; -} -export interface StickyNoteData { - id: string; - pageNumber: number; - type: string; - rect?: Rect; - pageRect?: Rect; - screenRect?: Rect; -} diff --git a/src/AnnotOptions/AnnotOptions.js b/src/AnnotOptions/AnnotOptions.js deleted file mode 100644 index cb0ff5c3b..000000000 --- a/src/AnnotOptions/AnnotOptions.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/types/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts similarity index 100% rename from types/AnnotOptions/AnnotOptions.ts rename to src/AnnotOptions/AnnotOptions.ts diff --git a/src/Config/Config.d.ts b/src/Config/Config.d.ts deleted file mode 100644 index f74f4a8d3..000000000 --- a/src/Config/Config.d.ts +++ /dev/null @@ -1,255 +0,0 @@ -export declare const Config: { - readonly Buttons: { - readonly editToolButton: "editToolButton"; - readonly viewControlsButton: "viewControlsButton"; - readonly freeHandToolButton: "freeHandToolButton"; - readonly highlightToolButton: "highlightToolButton"; - readonly underlineToolButton: "underlineToolButton"; - readonly squigglyToolButton: "squigglyToolButton"; - readonly strikeoutToolButton: "strikeoutToolButton"; - readonly rectangleToolButton: "rectangleToolButton"; - readonly ellipseToolButton: "ellipseToolButton"; - readonly lineToolButton: "lineToolButton"; - readonly arrowToolButton: "arrowToolButton"; - readonly polylineToolButton: "polylineToolButton"; - readonly polygonToolButton: "polygonToolButton"; - readonly cloudToolButton: "cloudToolButton"; - readonly signatureToolButton: "signatureToolButton"; - readonly freeTextToolButton: "freeTextToolButton"; - readonly stickyToolButton: "stickyToolButton"; - readonly calloutToolButton: "calloutToolButton"; - readonly stampToolButton: "stampToolButton"; - readonly toolsButton: "toolsButton"; - readonly searchButton: "searchButton"; - readonly shareButton: "shareButton"; - readonly editPagesButton: "editPagesButton"; - readonly viewLayersButton: "viewLayersButton"; - readonly printButton: "printButton"; - readonly closeButton: "closeButton"; - readonly saveCopyButton: "saveCopyButton"; - readonly saveIdenticalCopyButton: "saveIdenticalCopyButton"; - readonly saveFlattenedCopyButton: "saveFlattenedCopyButton"; - readonly formToolsButton: "formToolsButton"; - readonly fillSignToolsButton: "fillSignToolsButton"; - readonly moreItemsButton: "moreItemsButton"; - readonly digitalSignatureButton: "digitalSignatureButton"; - readonly thumbnailsButton: "thumbnailsButton"; - readonly listsButton: "listsButton"; - readonly thumbnailSlider: "thumbnailSlider"; - readonly outlineListButton: "outlineListButton"; - readonly annotationListButton: "annotationListButton"; - readonly userBookmarkListButton: "userBookmarkListButton"; - readonly reflowButton: "reflowButton"; - readonly editMenuButton: "editMenuButton"; - readonly cropPageButton: "cropPageButton"; - readonly undo: "undo"; - readonly redo: "redo"; - readonly addPageButton: "addPageButton"; - readonly saveReducedCopyButton: "saveReducedCopyButton"; - readonly saveCroppedCopyButton: "saveCroppedCopyButton"; - readonly savePasswordCopyButton: "savePasswordCopyButton"; - }; - readonly Tools: { - readonly annotationEdit: "AnnotationEdit"; - readonly textSelect: "TextSelect"; - readonly pan: "Pan"; - readonly annotationEraserTool: "AnnotationEraserTool"; - readonly annotationCreateSticky: "AnnotationCreateSticky"; - readonly annotationCreateFreeHand: "AnnotationCreateFreeHand"; - readonly annotationCreateTextHighlight: "AnnotationCreateTextHighlight"; - readonly annotationCreateTextUnderline: "AnnotationCreateTextUnderline"; - readonly annotationCreateTextSquiggly: "AnnotationCreateTextSquiggly"; - readonly annotationCreateTextStrikeout: "AnnotationCreateTextStrikeout"; - readonly annotationCreateFreeText: "AnnotationCreateFreeText"; - readonly annotationCreateCallout: "AnnotationCreateCallout"; - readonly annotationCreateSignature: "AnnotationCreateSignature"; - readonly annotationCreateLine: "AnnotationCreateLine"; - readonly annotationCreateArrow: "AnnotationCreateArrow"; - readonly annotationCreatePolyline: "AnnotationCreatePolyline"; - readonly annotationCreateStamp: "AnnotationCreateStamp"; - readonly annotationCreateRubberStamp: "AnnotationCreateRubberStamp"; - readonly annotationCreateRectangle: "AnnotationCreateRectangle"; - readonly annotationCreateEllipse: "AnnotationCreateEllipse"; - readonly annotationCreatePolygon: "AnnotationCreatePolygon"; - readonly annotationCreatePolygonCloud: "AnnotationCreatePolygonCloud"; - readonly annotationCreateDistanceMeasurement: "AnnotationCreateDistanceMeasurement"; - readonly annotationCreatePerimeterMeasurement: "AnnotationCreatePerimeterMeasurement"; - readonly annotationCreateAreaMeasurement: "AnnotationCreateAreaMeasurement"; - readonly annotationCreateFileAttachment: "AnnotationCreateFileAttachment"; - readonly annotationCreateSound: "AnnotationCreateSound"; - readonly annotationCreateRedaction: "AnnotationCreateRedaction"; - readonly annotationCreateLink: "AnnotationCreateLink"; - readonly annotationCreateRedactionText: "AnnotationCreateRedactionText"; - readonly annotationCreateLinkText: "AnnotationCreateLinkText"; - readonly annotationCreateFreeHighlighter: "AnnotationCreateFreeHighlighter"; - readonly formCreateTextField: "FormCreateTextField"; - readonly formCreateCheckboxField: "FormCreateCheckboxField"; - readonly formCreateSignatureField: "FormCreateSignatureField"; - readonly formCreateRadioField: "FormCreateRadioField"; - readonly formCreateComboBoxField: "FormCreateComboBoxField"; - readonly formCreateListBoxField: "FormCreateListBoxField"; - readonly pencilKitDrawing: "PencilKitDrawing"; - }; - readonly FitMode: { - readonly FitPage: "FitPage"; - readonly FitWidth: "FitWidth"; - readonly FitHeight: "FitHeight"; - readonly Zoom: "Zoom"; - }; - readonly LayoutMode: { - readonly Single: "Single"; - readonly Continuous: "Continuous"; - readonly Facing: "Facing"; - readonly FacingContinuous: "FacingContinuous"; - readonly FacingCover: "FacingCover"; - readonly FacingCoverContinuous: "FacingCoverContinuous"; - }; - readonly FieldFlags: { - readonly ReadOnly: 0; - readonly Required: 1; - }; - readonly AnnotationMenu: { - readonly style: "style"; - readonly note: "note"; - readonly copy: "copy"; - readonly delete: "delete"; - readonly flatten: "flatten"; - readonly editText: "editText"; - readonly editInk: "editInk"; - readonly search: "search"; - readonly share: "share"; - readonly markupType: "markupType"; - readonly read: "read"; - readonly screenCapture: "screenCapture"; - readonly playSound: "playSound"; - readonly openAttachment: "openAttachment"; - readonly calibrate: "calibrate"; - }; - readonly EraserType: { - readonly annotationEraser: "annotationEraser"; - readonly hybrideEraser: "hybrideEraser"; - readonly inkEraser: "inkEraser"; - }; - readonly LongPressMenu: { - readonly copy: "copy"; - readonly paste: "paste"; - readonly search: "search"; - readonly share: "share"; - readonly read: "read"; - }; - readonly Actions: { - readonly linkPress: "linkPress"; - readonly stickyNoteShowPopUp: "stickyNoteShowPopUp"; - }; - readonly AnnotationFlags: { - readonly hidden: "hidden"; - readonly invisible: "invisible"; - readonly locked: "locked"; - readonly lockedContents: "lockedContents"; - readonly noRotate: "noRotate"; - readonly noView: "noView"; - readonly noZoom: "noZoom"; - readonly print: "print"; - readonly readOnly: "readOnly"; - readonly toggleNoView: "toggleNoView"; - }; - readonly DefaultToolbars: { - readonly View: "PDFTron_View"; - readonly Annotate: "PDFTron_Annotate"; - readonly Draw: "PDFTron_Draw"; - readonly Insert: "PDFTron_Insert"; - readonly FillAndSign: "PDFTron_Fill_and_Sign"; - readonly PrepareForm: "PDFTron_Prepare_Form"; - readonly Measure: "PDFTron_Measure"; - readonly Pens: "PDFTron_Pens"; - readonly Redaction: "PDFTron_Redact"; - readonly Favorite: "PDFTron_Favorite"; - }; - readonly ToolbarIcons: { - readonly View: "PDFTron_View"; - readonly Annotate: "PDFTron_Annotate"; - readonly Draw: "PDFTron_Draw"; - readonly Insert: "PDFTron_Insert"; - readonly FillAndSign: "PDFTron_Fill_and_Sign"; - readonly PrepareForm: "PDFTron_Prepare_Form"; - readonly Measure: "PDFTron_Measure"; - readonly Pens: "PDFTron_Pens"; - readonly Redaction: "PDFTron_Redact"; - readonly Favorite: "PDFTron_Favorite"; - }; - readonly CustomToolbarKey: { - readonly Id: "id"; - readonly Name: "name"; - readonly Icon: "icon"; - readonly Items: "items"; - }; - readonly ThumbnailFilterMode: { - readonly Annotated: "annotated"; - readonly Bookmarked: "bookmarked"; - }; - readonly Conversion: { - readonly Screen: "screen"; - readonly Canvas: "canvas"; - readonly Page: "page"; - }; - readonly ViewModePickerItem: { - readonly Crop: "viewModeCrop"; - readonly Rotation: "viewModeRotation"; - readonly ColorMode: "viewModeColorMode"; - }; - readonly ZoomLimitMode: { - readonly None: "none"; - readonly Absolute: "absolute"; - readonly Relative: "relative"; - }; - readonly OverprintMode: { - readonly On: "on"; - readonly Off: "off"; - readonly OnlyPDFX: "pdfx"; - }; - readonly ColorPostProcessMode: { - readonly None: "none"; - readonly Invert: "invert"; - readonly GradientMap: "gradientMap"; - readonly NightMode: "nightMode"; - }; - readonly ReflowOrientation: { - readonly Horizontal: "horizontal"; - readonly Vertical: "vertical"; - }; - readonly ExportFormat: { - readonly BMP: "BMP"; - readonly JPEG: "JPEG"; - readonly PNG: "PNG"; - }; -}; -declare type ValueOf = T[keyof T]; -export declare namespace ConfigOptions { - type Buttons = ValueOf; - type Tools = ValueOf; - type FitMode = ValueOf; - type LayoutMode = ValueOf; - type FieldFlags = ValueOf; - type AnnotationMenu = ValueOf; - type EraserType = ValueOf; - type LongPressMenu = ValueOf; - type Actions = ValueOf; - type AnnotationFlags = ValueOf; - type DefaultToolbars = ValueOf; - type ToolbarIcons = ValueOf; - type ThumbnailFilterMode = ValueOf; - type Conversion = ValueOf; - type ViewModePickerItem = ValueOf; - type ZoomLimitMode = ValueOf; - type OverprintMode = ValueOf; - type ColorPostProcessMode = ValueOf; - type ReflowOrientation = ValueOf; - type ExportFormat = ValueOf; - type CustomToolbarKey = { - id: string; - name: string; - icon: ToolbarIcons; - items: (Tools | Buttons)[]; - }; -} -export {}; diff --git a/src/Config/Config.js b/src/Config/Config.js deleted file mode 100644 index 277f5ac70..000000000 --- a/src/Config/Config.js +++ /dev/null @@ -1,248 +0,0 @@ -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', - // Android only - saveReducedCopyButton: 'saveReducedCopyButton', - saveCroppedCopyButton: 'saveCroppedCopyButton', - savePasswordCopyButton: 'savePasswordCopyButton', - }, - // Tools define the various kinds of tools for the viewer - Tools: { - annotationEdit: 'AnnotationEdit', - textSelect: 'TextSelect', - pan: 'Pan', - annotationEraserTool: 'AnnotationEraserTool', - 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', - annotationCreateLinkText: 'AnnotationCreateLinkText', - annotationCreateFreeHighlighter: 'AnnotationCreateFreeHighlighter', - formCreateTextField: 'FormCreateTextField', - formCreateCheckboxField: 'FormCreateCheckboxField', - formCreateSignatureField: 'FormCreateSignatureField', - formCreateRadioField: 'FormCreateRadioField', - formCreateComboBoxField: 'FormCreateComboBoxField', - formCreateListBoxField: 'FormCreateListBoxField', - // iOS only. - pencilKitDrawing: 'PencilKitDrawing', - }, - // 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', - delete: 'delete', - flatten: 'flatten', - editText: 'editText', - editInk: 'editInk', - search: 'search', - share: 'share', - markupType: 'markupType', - read: 'read', - screenCapture: 'screenCapture', - playSound: 'playSound', - openAttachment: 'openAttachment', - calibrate: 'calibrate', - }, - // EraserType defines the type of earse 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" - }, - // ThumbnailFilterMode defines filter modes in the thumbnails browser - ThumbnailFilterMode: { - Annotated: "annotated", - Bookmarked: "bookmarked", - }, - // 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", - }, - // 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", - }, -}; diff --git a/types/Config/Config.ts b/src/Config/Config.ts similarity index 99% rename from types/Config/Config.ts rename to src/Config/Config.ts index 8bd70ac7e..c1283b82d 100644 --- a/types/Config/Config.ts +++ b/src/Config/Config.ts @@ -272,7 +272,7 @@ export const Config = { type ValueOf = T[keyof T]; -export namespace ConfigOptions { +export module ConfigOptions { export type Buttons = ValueOf; export type Tools = ValueOf; export type FitMode = ValueOf; diff --git a/src/DocumentView/DocumentView.d.ts b/src/DocumentView/DocumentView.d.ts deleted file mode 100644 index 827949d24..000000000 --- a/src/DocumentView/DocumentView.d.ts +++ /dev/null @@ -1,407 +0,0 @@ -import { PureComponent } from 'react'; -import PropTypes from 'prop-types'; -import { ViewProps } from 'react-native'; -import { ConfigOptions } from "../Config/Config"; -import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; -export interface DocumentViewProps extends ViewProps { - document: string; - password?: string; - initialPageNumber?: number; - pageNumber?: number; - customHeaders?: object; - leadingNavButtonIcon?: string; - showLeadingNavButton?: boolean; - onLeadingNavButtonPressed?: () => void; - onDocumentLoaded?: (path: string) => void; - onDocumentError?: (error: string) => void; - onPageChanged?: ({ previousPageNumber, pageNumber }: { - previousPageNumber: number; - pageNumber: number; - }) => void; - onScrollChanged?: ({ horizontal, vertical }: { - horizontal: number; - vertical: number; - }) => void; - onZoomChanged?: ({ zoom }: { - zoom: number; - }) => void; - onZoomFinished?: ({ zoom }: { - zoom: number; - }) => void; - zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; - onLongPressMenuPress?: ({ longPressMenu, longPressText }: { - longPressMenu: string; - longPressText: string; - }) => void; - longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; - onAnnotationMenuPress?: ({ annotationMenu, annotations }: { - annotationMenu: string; - annotations: Array; - }) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; - onBehaviorActivated?: ({ action, data }: { - action: ConfigOptions.Actions; - data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData; - }) => void; - topToolbarEnabled?: boolean; - bottomToolbarEnabled?: boolean; - hideToolbarsOnTap?: boolean; - documentSliderEnabled?: boolean; - pageIndicatorEnabled?: boolean; - keyboardShortcutsEnabled?: boolean; - onAnnotationsSelected?: ({ annotations }: { - annotations: Array; - }) => void; - onAnnotationChanged?: ({ action, annotations }: { - action: string; - annotations: Array; - }) => void; - onFormFieldValueChanged?: ({ fields }: { - fields: Array; - }) => void; - readOnly?: boolean; - thumbnailViewEditingEnabled?: boolean; - fitMode?: ConfigOptions.FitMode; - layoutMode?: ConfigOptions.LayoutMode; - onLayoutChanged?: () => void; - padStatusBar?: boolean; - continuousAnnotationEditing?: boolean; - selectAnnotationAfterCreation?: boolean; - annotationAuthor?: string; - showSavedSignatures?: boolean; - isBase64String?: boolean; - collabEnabled?: boolean; - currentUser?: string; - currentUserName?: string; - onExportAnnotationCommand?: ({ action, xfdfCommand, annotations }: { - action: string; - xfdfCommand: string; - annotations: Array; - }) => void; - autoSaveEnabled?: boolean; - pageChangeOnTap?: boolean; - followSystemDarkMode?: boolean; - useStylusAsPen?: boolean; - multiTabEnabled?: boolean; - tabTitle?: string; - maxTabCount?: number; - signSignatureFieldsWithStamps?: boolean; - annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; - hideAnnotationToolbarSwitcher?: boolean; - hideTopToolbars?: boolean; - hideTopAppNavBar?: boolean; - onBookmarkChanged?: ({ bookmarkJson }: { - bookmarkJson: string; - }) => void; - hideThumbnailFilterModes?: Array; - onToolChanged?: ({ previousTool, tool }: { - previousTool: ConfigOptions.Tools | "unknown tool"; - tool: ConfigOptions.Tools | "unknown tool"; - }) => void; - horizontalScrollPos?: number; - verticalScrollPos?: number; - onTextSearchStart?: () => void; - onTextSearchResult?: ({ found, textSelection }: { - found: boolean; - textSelection: AnnotOptions.TextSelectionResult | null; - }) => void; - hideViewModeItems?: Array; - pageStackEnabled?: boolean; - showQuickNavigationButton?: boolean; - photoPickerEnabled?: boolean; - autoResizeFreeTextEnabled?: boolean; - annotationsListEditingEnabled?: boolean; - showNavigationListAsSidePanelOnLargeDevices?: boolean; - restrictDownloadUsage?: boolean; - userBookmarksListEditingEnabled?: boolean; - imageInReflowEnabled?: boolean; - reflowOrientation?: ConfigOptions.ReflowOrientation; - onUndoRedoStateChanged?: () => void; - tabletLayoutEnabled?: boolean; - initialToolbar?: string; - inkMultiStrokeEnabled?: boolean; - defaultEraserType?: ConfigOptions.EraserType; - exportPath?: string; - openUrlPath?: string; - hideScrollbars?: boolean; - saveStateEnabled?: boolean; - openSavedCopyInNewTab?: boolean; - onChange?(event: any): void; -} -export declare class DocumentView extends PureComponent { - _viewerRef: any; - static propTypes: { - hitSlop?: PropTypes.Validator; - onLayout?: PropTypes.Validator<(event: import("react-native").LayoutChangeEvent) => void>; - pointerEvents?: PropTypes.Validator<"none" | "box-none" | "box-only" | "auto">; - removeClippedSubviews?: PropTypes.Validator; - style?: PropTypes.Validator>; - testID?: PropTypes.Validator; - nativeID?: PropTypes.Validator; - collapsable?: PropTypes.Validator; - needsOffscreenAlphaCompositing?: PropTypes.Validator; - renderToHardwareTextureAndroid?: PropTypes.Validator; - focusable?: PropTypes.Validator; - shouldRasterizeIOS?: PropTypes.Validator; - isTVSelectable?: PropTypes.Validator; - hasTVPreferredFocus?: PropTypes.Validator; - tvParallaxProperties?: PropTypes.Validator; - tvParallaxShiftDistanceX?: PropTypes.Validator; - tvParallaxShiftDistanceY?: PropTypes.Validator; - tvParallaxTiltAngle?: PropTypes.Validator; - tvParallaxMagnification?: PropTypes.Validator; - onStartShouldSetResponder?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; - onMoveShouldSetResponder?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; - onResponderEnd?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onResponderGrant?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onResponderReject?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onResponderMove?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onResponderRelease?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onResponderStart?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onResponderTerminationRequest?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; - onResponderTerminate?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onStartShouldSetResponderCapture?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; - onMoveShouldSetResponderCapture?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => boolean>; - onTouchStart?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onTouchMove?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onTouchEnd?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onTouchCancel?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - onTouchEndCapture?: PropTypes.Validator<(event: import("react-native").GestureResponderEvent) => void>; - accessible?: PropTypes.Validator; - accessibilityActions?: PropTypes.Validator[]>; - accessibilityLabel?: PropTypes.Validator; - accessibilityRole?: PropTypes.Validator; - accessibilityState?: PropTypes.Validator; - accessibilityHint?: PropTypes.Validator; - accessibilityValue?: PropTypes.Validator; - onAccessibilityAction?: PropTypes.Validator<(event: import("react-native").AccessibilityActionEvent) => void>; - accessibilityLiveRegion?: PropTypes.Validator<"none" | "polite" | "assertive">; - importantForAccessibility?: PropTypes.Validator<"auto" | "yes" | "no" | "no-hide-descendants">; - accessibilityElementsHidden?: PropTypes.Validator; - accessibilityViewIsModal?: PropTypes.Validator; - onAccessibilityEscape?: PropTypes.Validator<() => void>; - onAccessibilityTap?: PropTypes.Validator<() => void>; - onMagicTap?: PropTypes.Validator<() => void>; - accessibilityIgnoresInvertColors?: PropTypes.Validator; - document: PropTypes.Requireable; - password: PropTypes.Requireable; - initialPageNumber: PropTypes.Requireable; - pageNumber: PropTypes.Requireable; - customHeaders: PropTypes.Requireable; - leadingNavButtonIcon: PropTypes.Requireable; - showLeadingNavButton: PropTypes.Requireable; - onLeadingNavButtonPressed: PropTypes.Requireable<(...args: any[]) => any>; - onDocumentLoaded: PropTypes.Requireable<(...args: any[]) => any>; - onDocumentError: PropTypes.Requireable<(...args: any[]) => any>; - onPageChanged: PropTypes.Requireable<(...args: any[]) => any>; - onScrollChanged: PropTypes.Requireable<(...args: any[]) => any>; - onZoomChanged: PropTypes.Requireable<(...args: any[]) => any>; - onZoomFinished: PropTypes.Requireable<(...args: any[]) => any>; - zoom: PropTypes.Requireable; - disabledElements: PropTypes.Requireable; - disabledTools: PropTypes.Requireable; - longPressMenuItems: PropTypes.Requireable; - overrideLongPressMenuBehavior: PropTypes.Requireable; - onLongPressMenuPress: PropTypes.Requireable<(...args: any[]) => any>; - longPressMenuEnabled: PropTypes.Requireable; - annotationMenuItems: PropTypes.Requireable; - overrideAnnotationMenuBehavior: PropTypes.Requireable; - onAnnotationMenuPress: PropTypes.Requireable<(...args: any[]) => any>; - hideAnnotationMenu: PropTypes.Requireable; - overrideBehavior: PropTypes.Requireable; - onBehaviorActivated: PropTypes.Requireable<(...args: any[]) => any>; - topToolbarEnabled: PropTypes.Requireable; - bottomToolbarEnabled: PropTypes.Requireable; - hideToolbarsOnTap: PropTypes.Requireable; - documentSliderEnabled: PropTypes.Requireable; - pageIndicatorEnabled: PropTypes.Requireable; - keyboardShortcutsEnabled: PropTypes.Requireable; - onAnnotationsSelected: PropTypes.Requireable<(...args: any[]) => any>; - onAnnotationChanged: PropTypes.Requireable<(...args: any[]) => any>; - onFormFieldValueChanged: PropTypes.Requireable<(...args: any[]) => any>; - readOnly: PropTypes.Requireable; - thumbnailViewEditingEnabled: PropTypes.Requireable; - fitMode: PropTypes.Requireable; - layoutMode: PropTypes.Requireable; - onLayoutChanged: PropTypes.Requireable<(...args: any[]) => any>; - padStatusBar: PropTypes.Requireable; - continuousAnnotationEditing: PropTypes.Requireable; - selectAnnotationAfterCreation: PropTypes.Requireable; - annotationAuthor: PropTypes.Requireable; - showSavedSignatures: PropTypes.Requireable; - isBase64String: PropTypes.Requireable; - collabEnabled: PropTypes.Requireable; - currentUser: PropTypes.Requireable; - currentUserName: PropTypes.Requireable; - onExportAnnotationCommand: PropTypes.Requireable<(...args: any[]) => any>; - autoSaveEnabled: PropTypes.Requireable; - pageChangeOnTap: PropTypes.Requireable; - followSystemDarkMode: PropTypes.Requireable; - useStylusAsPen: PropTypes.Requireable; - multiTabEnabled: PropTypes.Requireable; - tabTitle: PropTypes.Requireable; - maxTabCount: PropTypes.Requireable; - signSignatureFieldsWithStamps: PropTypes.Requireable; - annotationPermissionCheckEnabled: PropTypes.Requireable; - annotationToolbars: PropTypes.Requireable; - hideDefaultAnnotationToolbars: PropTypes.Requireable; - topAppNavBarRightBar: PropTypes.Requireable; - bottomToolbar: PropTypes.Requireable; - hideAnnotationToolbarSwitcher: PropTypes.Requireable; - hideTopToolbars: PropTypes.Requireable; - hideTopAppNavBar: PropTypes.Requireable; - onBookmarkChanged: PropTypes.Requireable<(...args: any[]) => any>; - hideThumbnailFilterModes: PropTypes.Requireable; - onToolChanged: PropTypes.Requireable<(...args: any[]) => any>; - horizontalScrollPos: PropTypes.Requireable; - verticalScrollPos: PropTypes.Requireable; - onTextSearchStart: PropTypes.Requireable<(...args: any[]) => any>; - onTextSearchResult: PropTypes.Requireable<(...args: any[]) => any>; - hideViewModeItems: PropTypes.Requireable; - pageStackEnabled: PropTypes.Requireable; - showQuickNavigationButton: PropTypes.Requireable; - photoPickerEnabled: PropTypes.Requireable; - autoResizeFreeTextEnabled: PropTypes.Requireable; - annotationsListEditingEnabled: PropTypes.Requireable; - showNavigationListAsSidePanelOnLargeDevices: PropTypes.Requireable; - restrictDownloadUsage: PropTypes.Requireable; - userBookmarksListEditingEnabled: PropTypes.Requireable; - imageInReflowEnabled: PropTypes.Requireable; - reflowOrientation: PropTypes.Requireable; - onUndoRedoStateChanged: PropTypes.Requireable<(...args: any[]) => any>; - tabletLayoutEnabled: PropTypes.Requireable; - initialToolbar: PropTypes.Requireable; - inkMultiStrokeEnabled: PropTypes.Requireable; - defaultEraserType: PropTypes.Requireable; - exportPath: PropTypes.Requireable; - openUrlPath: PropTypes.Requireable; - hideScrollbars: PropTypes.Requireable; - saveStateEnabled: PropTypes.Requireable; - openSavedCopyInNewTab: PropTypes.Requireable; - }; - onChange: (event: any) => void; - getDocumentPath: () => Promise | Promise; - setToolMode: (toolMode: ConfigOptions.Tools) => Promise; - commitTool: () => Promise | Promise; - getPageCount: () => Promise | Promise; - importBookmarkJson: (bookmarkJson: string) => Promise; - importAnnotationCommand: (xfdfCommand: string, initialLoad?: boolean) => Promise; - importAnnotations: (xfdf: string) => Promise; - exportAnnotations: (options?: { - annotList: Array; - }) => Promise | Promise; - flattenAnnotations: (formsOnly: boolean) => Promise; - deleteAnnotations: (annotations: Array) => Promise; - saveDocument: () => Promise | Promise; - setFlagForFields: (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean) => Promise; - getField: (fieldName: string) => Promise | Promise<{ - fieldName: string; - fieldValue?: any; - fieldType?: string; - }>; - /** - * note: this function exists for supporting the old version. It simply calls setValuesForFields. - * - */ - setValueForFields: (fieldsMap: Record) => Promise; - setValuesForFields: (fieldsMap: Record) => Promise; - handleBackButton: () => Promise | Promise; - /** - * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. - * - */ - setFlagForAnnotations: (annotationFlagList: Array) => Promise; - setFlagsForAnnotations: (annotationFlagList: Array) => Promise; - selectAnnotation: (id: string, pageNumber: number) => Promise; - /** - * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. - * - */ - setPropertyForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; - setPropertiesForAnnotation: (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties) => Promise; - getPropertiesForAnnotation: (id: string, pageNumber: number) => Promise | Promise; - setDrawAnnotations: (drawAnnotations: boolean) => Promise; - setVisibilityForAnnotation: (id: string, pageNumber: number, visibility: boolean) => Promise; - setHighlightFields: (highlightFields: boolean) => Promise; - getAnnotationAtPoint: (x: number, y: number, distanceThreshold: number, minimumLineWeight: number) => Promise | Promise; - getAnnotationListAt: (x1: number, y1: number, x2: number, y2: number) => Promise | Promise>; - getAnnotationsOnPage: (pageNumber: number) => Promise | Promise>; - getCustomDataForAnnotation: (annotationID: string, pageNumber: number, key: string) => Promise | Promise; - getPageCropBox: (pageNumber: number) => Promise | Promise; - setCurrentPage: (pageNumber: number) => Promise | Promise; - getVisiblePages: () => Promise | Promise>; - gotoPreviousPage: () => Promise | Promise; - gotoNextPage: () => Promise | Promise; - gotoFirstPage: () => Promise | Promise; - gotoLastPage: () => Promise | Promise; - showGoToPageView: () => Promise; - closeAllTabs: () => Promise; - getZoom: () => Promise | Promise; - setZoomLimits: (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number) => Promise; - zoomWithCenter: (zoom: number, x: number, y: number) => Promise; - zoomToRect: (pageNumber: number, rect: AnnotOptions.Rect) => Promise; - smartZoom: (x: number, y: number, animated: boolean) => Promise; - getScrollPos: () => Promise | Promise<{ - horizontal: number; - vertical: number; - }>; - getCanvasSize: () => Promise | Promise<{ - width: number; - height: number; - }>; - getPageRotation: () => Promise | Promise; - rotateClockwise: () => Promise; - rotateCounterClockwise: () => Promise; - convertScreenPointsToPagePoints: (points: Array) => Promise | Promise>; - convertPagePointsToScreenPoints: (points: Array) => Promise | Promise>; - getPageNumberFromScreenPoint: (x: number, y: number) => Promise | Promise; - setProgressiveRendering: (progressiveRendering: boolean, initialDelay: number, interval: number) => Promise; - setImageSmoothing: (imageSmoothing: boolean) => Promise; - setOverprint: (overprint: ConfigOptions.OverprintMode) => Promise; - setColorPostProcessMode: (colorPostProcessMode: ConfigOptions.ColorPostProcessMode) => Promise; - setColorPostProcessColors: (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color) => Promise; - startSearchMode: (searchString: string, matchCase: boolean, matchWholeWord: boolean) => Promise; - exitSearchMode: () => Promise; - findText: (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean) => Promise; - cancelFindText: () => Promise; - getSelection: (pageNumber: number) => Promise | Promise; - hasSelection: () => Promise | Promise; - clearSelection: () => Promise; - getSelectionPageRange: () => Promise | Promise<{ - begin: number; - end: number; - }>; - hasSelectionOnPage: (pageNumber: number) => Promise | Promise; - selectInRect: (rect: AnnotOptions.Rect) => Promise | Promise; - isThereTextInRect: (rect: AnnotOptions.Rect) => Promise | Promise; - selectAll: () => Promise; - setUrlExtraction: (urlExtraction: boolean) => Promise; - setPageBorderVisibility: (pageBorderVisibility: boolean) => Promise; - setPageTransparencyGrid: (pageTransparencyGrid: boolean) => Promise; - setDefaultPageColor: (defaultPageColor: AnnotOptions.Color) => Promise; - setBackgroundColor: (backgroundColor: AnnotOptions.Color) => Promise; - exportAsImage: (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat) => Promise | Promise; - undo: () => Promise; - redo: () => Promise; - canUndo: () => Promise | Promise; - canRedo: () => Promise | Promise; - showCrop: () => Promise; - setCurrentToolbar: (toolbar: string) => Promise; - openThumbnailsView: () => Promise; - _setNativeRef: (ref: any) => void; - render(): JSX.Element; -} diff --git a/src/DocumentView/DocumentView.js b/src/DocumentView/DocumentView.js deleted file mode 100644 index c3057f7a9..000000000 --- a/src/DocumentView/DocumentView.js +++ /dev/null @@ -1,838 +0,0 @@ -import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; -import { requireNativeComponent, ViewPropTypes, Platform, Alert, NativeModules, findNodeHandle, } from 'react-native'; -const { DocumentViewManager } = NativeModules; -export class DocumentView extends PureComponent { - _viewerRef; - static propTypes = { - document: PropTypes.string, - password: PropTypes.string, - initialPageNumber: PropTypes.number, - pageNumber: PropTypes.number, - customHeaders: PropTypes.object, - leadingNavButtonIcon: PropTypes.string, - showLeadingNavButton: PropTypes.bool, - onLeadingNavButtonPressed: PropTypes.func, - onDocumentLoaded: PropTypes.func, - onDocumentError: PropTypes.func, - onPageChanged: PropTypes.func, - onScrollChanged: PropTypes.func, - onZoomChanged: PropTypes.func, - onZoomFinished: PropTypes.func, - zoom: PropTypes.number, - disabledElements: PropTypes.array, - disabledTools: PropTypes.array, - longPressMenuItems: PropTypes.array, - overrideLongPressMenuBehavior: PropTypes.array, - onLongPressMenuPress: PropTypes.func, - longPressMenuEnabled: PropTypes.bool, - annotationMenuItems: PropTypes.array, - overrideAnnotationMenuBehavior: PropTypes.array, - onAnnotationMenuPress: PropTypes.func, - hideAnnotationMenu: PropTypes.array, - overrideBehavior: PropTypes.array, - onBehaviorActivated: PropTypes.func, - topToolbarEnabled: PropTypes.bool, - bottomToolbarEnabled: PropTypes.bool, - hideToolbarsOnTap: PropTypes.bool, - documentSliderEnabled: PropTypes.bool, - pageIndicatorEnabled: PropTypes.bool, - keyboardShortcutsEnabled: PropTypes.bool, - onAnnotationsSelected: PropTypes.func, - onAnnotationChanged: PropTypes.func, - onFormFieldValueChanged: PropTypes.func, - readOnly: PropTypes.bool, - thumbnailViewEditingEnabled: PropTypes.bool, - fitMode: PropTypes.string, - layoutMode: PropTypes.string, - onLayoutChanged: PropTypes.func, - padStatusBar: PropTypes.bool, - continuousAnnotationEditing: PropTypes.bool, - selectAnnotationAfterCreation: PropTypes.bool, - annotationAuthor: PropTypes.string, - showSavedSignatures: PropTypes.bool, - isBase64String: PropTypes.bool, - collabEnabled: PropTypes.bool, - currentUser: PropTypes.string, - currentUserName: PropTypes.string, - onExportAnnotationCommand: PropTypes.func, - autoSaveEnabled: PropTypes.bool, - pageChangeOnTap: PropTypes.bool, - followSystemDarkMode: PropTypes.bool, - useStylusAsPen: PropTypes.bool, - multiTabEnabled: PropTypes.bool, - tabTitle: PropTypes.string, - maxTabCount: PropTypes.number, - signSignatureFieldsWithStamps: PropTypes.bool, - annotationPermissionCheckEnabled: PropTypes.bool, - annotationToolbars: PropTypes.array, - hideDefaultAnnotationToolbars: PropTypes.array, - topAppNavBarRightBar: PropTypes.array, - bottomToolbar: PropTypes.array, - hideAnnotationToolbarSwitcher: PropTypes.bool, - hideTopToolbars: PropTypes.bool, - hideTopAppNavBar: PropTypes.bool, - onBookmarkChanged: PropTypes.func, - hideThumbnailFilterModes: PropTypes.array, - onToolChanged: PropTypes.func, - horizontalScrollPos: PropTypes.number, - verticalScrollPos: PropTypes.number, - onTextSearchStart: PropTypes.func, - onTextSearchResult: PropTypes.func, - hideViewModeItems: PropTypes.array, - pageStackEnabled: PropTypes.bool, - showQuickNavigationButton: PropTypes.bool, - photoPickerEnabled: PropTypes.bool, - autoResizeFreeTextEnabled: PropTypes.bool, - annotationsListEditingEnabled: PropTypes.bool, - showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, - restrictDownloadUsage: PropTypes.bool, - userBookmarksListEditingEnabled: PropTypes.bool, - imageInReflowEnabled: PropTypes.bool, - reflowOrientation: PropTypes.string, - onUndoRedoStateChanged: PropTypes.func, - tabletLayoutEnabled: PropTypes.bool, - initialToolbar: PropTypes.string, - inkMultiStrokeEnabled: PropTypes.bool, - defaultEraserType: PropTypes.string, - exportPath: PropTypes.string, - openUrlPath: PropTypes.string, - hideScrollbars: PropTypes.bool, - saveStateEnabled: PropTypes.bool, - openSavedCopyInNewTab: PropTypes.bool, - ...ViewPropTypes, - }; - onChange = (event) => { - if (event.nativeEvent.onLeadingNavButtonPressed) { - if (this.props.onLeadingNavButtonPressed) { - this.props.onLeadingNavButtonPressed(); - } - } - else if (event.nativeEvent.onDocumentLoaded) { - if (this.props.onDocumentLoaded) { - this.props.onDocumentLoaded(event.nativeEvent.onDocumentLoaded); - } - } - else if (event.nativeEvent.onPageChanged) { - if (this.props.onPageChanged) { - this.props.onPageChanged({ - 'previousPageNumber': event.nativeEvent.previousPageNumber, - 'pageNumber': event.nativeEvent.pageNumber, - }); - } - } - else if (event.nativeEvent.onScrollChanged) { - if (this.props.onScrollChanged) { - this.props.onScrollChanged({ - 'horizontal': event.nativeEvent.horizontal, - 'vertical': event.nativeEvent.vertical, - }); - } - } - else if (event.nativeEvent.onZoomChanged) { - if (this.props.onZoomChanged) { - this.props.onZoomChanged({ - 'zoom': event.nativeEvent.zoom, - }); - } - } - else if (event.nativeEvent.onZoomFinished) { - if (this.props.onZoomFinished) { - this.props.onZoomFinished({ - 'zoom': event.nativeEvent.zoom, - }); - } - } - else if (event.nativeEvent.onLayoutChanged) { - if (this.props.onLayoutChanged) { - this.props.onLayoutChanged(); - } - } - else if (event.nativeEvent.onAnnotationChanged) { - if (this.props.onAnnotationChanged) { - this.props.onAnnotationChanged({ - 'action': event.nativeEvent.action, - 'annotations': event.nativeEvent.annotations, - }); - } - } - else if (event.nativeEvent.onAnnotationsSelected) { - if (this.props.onAnnotationsSelected) { - this.props.onAnnotationsSelected({ - 'annotations': event.nativeEvent.annotations, - }); - } - } - else if (event.nativeEvent.onFormFieldValueChanged) { - if (this.props.onFormFieldValueChanged) { - this.props.onFormFieldValueChanged({ - 'fields': event.nativeEvent.fields, - }); - } - } - else if (event.nativeEvent.onDocumentError) { - if (this.props.onDocumentError) { - this.props.onDocumentError(event.nativeEvent.onDocumentError); - } - else { - const msg = event.nativeEvent.onDocumentError ? event.nativeEvent.onDocumentError : 'Unknown error'; - Alert.alert('Alert', msg, [ - { text: 'OK' } - ], { cancelable: true }); - } - } - else if (event.nativeEvent.onExportAnnotationCommand) { - if (this.props.onExportAnnotationCommand) { - this.props.onExportAnnotationCommand({ - 'action': event.nativeEvent.action, - 'xfdfCommand': event.nativeEvent.xfdfCommand, - 'annotations': event.nativeEvent.annotations, - }); - } - } - else if (event.nativeEvent.onAnnotationMenuPress) { - if (this.props.onAnnotationMenuPress) { - this.props.onAnnotationMenuPress({ - 'annotationMenu': event.nativeEvent.annotationMenu, - 'annotations': event.nativeEvent.annotations, - }); - } - } - else if (event.nativeEvent.onLongPressMenuPress) { - if (this.props.onLongPressMenuPress) { - this.props.onLongPressMenuPress({ - 'longPressMenu': event.nativeEvent.longPressMenu, - 'longPressText': event.nativeEvent.longPressText, - }); - } - } - else if (event.nativeEvent.onBehaviorActivated) { - if (this.props.onBehaviorActivated) { - this.props.onBehaviorActivated({ - 'action': event.nativeEvent.action, - 'data': event.nativeEvent.data, - }); - } - } - else if (event.nativeEvent.onBookmarkChanged) { - if (this.props.onBookmarkChanged) { - this.props.onBookmarkChanged({ - 'bookmarkJson': event.nativeEvent.bookmarkJson, - }); - } - } - else if (event.nativeEvent.onToolChanged) { - if (this.props.onToolChanged) { - this.props.onToolChanged({ - 'previousTool': event.nativeEvent.previousTool, - 'tool': event.nativeEvent.tool, - }); - } - } - else if (event.nativeEvent.onTextSearchStart) { - if (this.props.onTextSearchStart) { - this.props.onTextSearchStart(); - } - } - else if (event.nativeEvent.onTextSearchResult) { - if (this.props.onTextSearchResult) { - this.props.onTextSearchResult({ - 'found': event.nativeEvent.found, - 'textSelection': event.nativeEvent.textSelection, - }); - } - } - else if (event.nativeEvent.onUndoRedoStateChanged) { - if (this.props.onUndoRedoStateChanged) { - this.props.onUndoRedoStateChanged(); - } - } - }; - // Methods - getDocumentPath = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getDocumentPath(tag); - } - return Promise.resolve(); - }; - setToolMode = (toolMode) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setToolMode(tag, toolMode); - } - return Promise.resolve(); - }; - commitTool = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.commitTool(tag); - } - return Promise.resolve(); - }; - getPageCount = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageCount(tag); - } - return Promise.resolve(); - }; - importBookmarkJson = (bookmarkJson) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.importBookmarkJson(tag, bookmarkJson); - } - return Promise.resolve(); - }; - importAnnotationCommand = (xfdfCommand, initialLoad) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - if (initialLoad === undefined) { - initialLoad = false; - } - return DocumentViewManager.importAnnotationCommand(tag, xfdfCommand, initialLoad); - } - return Promise.resolve(); - }; - importAnnotations = (xfdf) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.importAnnotations(tag, xfdf); - } - return Promise.resolve(); - }; - exportAnnotations = (options) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.exportAnnotations(tag, options); - } - return Promise.resolve(); - }; - flattenAnnotations = (formsOnly) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.flattenAnnotations(tag, formsOnly); - } - return Promise.resolve(); - }; - deleteAnnotations = (annotations) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.deleteAnnotations(tag, annotations); - } - return Promise.resolve(); - }; - saveDocument = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.saveDocument(tag); - } - return Promise.resolve(); - }; - setFlagForFields = (fields, flag, value) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setFlagForFields(tag, fields, flag, value); - } - return Promise.resolve(); - }; - getField = (fieldName) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getField(tag, fieldName); - } - return Promise.resolve(); - }; - /** - * note: this function exists for supporting the old version. It simply calls setValuesForFields. - * - */ - setValueForFields = (fieldsMap) => { - return this.setValuesForFields(fieldsMap); - }; - setValuesForFields = (fieldsMap) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setValuesForFields(tag, fieldsMap); - } - return Promise.resolve(); - }; - handleBackButton = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.handleBackButton(tag); - } - return Promise.resolve(); - }; - /** - * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. - * - */ - setFlagForAnnotations = (annotationFlagList) => { - return this.setFlagsForAnnotations(annotationFlagList); - }; - setFlagsForAnnotations = (annotationFlagList) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setFlagsForAnnotations(tag, annotationFlagList); - } - return Promise.resolve(); - }; - selectAnnotation = (id, pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.selectAnnotation(tag, id, pageNumber); - } - return Promise.resolve(); - }; - /** - * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. - * - */ - setPropertyForAnnotation = (id, pageNumber, propertyMap) => { - return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); // check this._viewerRef - }; - setPropertiesForAnnotation = (id, pageNumber, propertyMap) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setPropertiesForAnnotation(tag, id, pageNumber, propertyMap); - } - return Promise.resolve(); - }; - getPropertiesForAnnotation = (id, pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); - } - return Promise.resolve(); - }; - setDrawAnnotations = (drawAnnotations) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setDrawAnnotations(tag, drawAnnotations); - } - return Promise.resolve(); - }; - setVisibilityForAnnotation = (id, pageNumber, visibility) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - DocumentViewManager.setVisibilityForAnnotation(tag, id, pageNumber, visibility); - } - return Promise.resolve(); - }; - setHighlightFields = (highlightFields) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - DocumentViewManager.setHighlightFields(tag, highlightFields); - } - return Promise.resolve(); - }; - getAnnotationAtPoint = (x, y, distanceThreshold, minimumLineWeight) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); - } - return Promise.resolve(); - }; - getAnnotationListAt = (x1, y1, x2, y2) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); - } - return Promise.resolve(); - }; - getAnnotationsOnPage = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); - } - return Promise.resolve(); - }; - getCustomDataForAnnotation = (annotationID, pageNumber, key) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); - } - return Promise.resolve(); - }; - getPageCropBox = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageCropBox(tag, pageNumber); - } - return Promise.resolve(); - }; - setCurrentPage = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setCurrentPage(tag, pageNumber); - } - return Promise.resolve(); - }; - getVisiblePages = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getVisiblePages(tag); - } - return Promise.resolve(); - }; - gotoPreviousPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoPreviousPage(tag); - } - return Promise.resolve(); - }; - gotoNextPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoNextPage(tag); - } - return Promise.resolve(); - }; - gotoFirstPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoFirstPage(tag); - } - return Promise.resolve(); - }; - gotoLastPage = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.gotoLastPage(tag); - } - return Promise.resolve(); - }; - showGoToPageView = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.showGoToPageView(tag); - } - return Promise.resolve(); - }; - closeAllTabs = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.closeAllTabs(tag); - } - return Promise.resolve(); - }; - getZoom = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getZoom(tag); - } - return Promise.resolve(); - }; - setZoomLimits = (zoomLimitMode, minimum, maximum) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); - } - return Promise.resolve(); - }; - zoomWithCenter = (zoom, x, y) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.zoomWithCenter(tag, zoom, x, y); - } - return Promise.resolve(); - }; - zoomToRect = (pageNumber, rect) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.zoomToRect(tag, pageNumber, rect); - } - return Promise.resolve(); - }; - smartZoom = (x, y, animated) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.smartZoom(tag, x, y, animated); - } - return Promise.resolve(); - }; - getScrollPos = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getScrollPos(tag); - } - return Promise.resolve(); - }; - getCanvasSize = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getCanvasSize(tag); - } - return Promise.resolve(); - }; - getPageRotation = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageRotation(tag); - } - return Promise.resolve(); - }; - rotateClockwise = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.rotateClockwise(tag); - } - return Promise.resolve(); - }; - rotateCounterClockwise = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.rotateCounterClockwise(tag); - } - return Promise.resolve(); - }; - convertScreenPointsToPagePoints = (points) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); - } - return Promise.resolve(); - }; - convertPagePointsToScreenPoints = (points) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); - } - return Promise.resolve(); - }; - getPageNumberFromScreenPoint = (x, y) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); - } - return Promise.resolve(); - }; - setProgressiveRendering = (progressiveRendering, initialDelay, interval) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setProgressiveRendering(tag, progressiveRendering, initialDelay, interval); - } - return Promise.resolve(); - }; - setImageSmoothing = (imageSmoothing) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setImageSmoothing(tag, imageSmoothing); - } - return Promise.resolve(); - }; - setOverprint = (overprint) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setOverprint(tag, overprint); - } - return Promise.resolve(); - }; - setColorPostProcessMode = (colorPostProcessMode) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); - } - return Promise.resolve(); - }; - setColorPostProcessColors = (whiteColor, blackColor) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setColorPostProcessColors(tag, whiteColor, blackColor); - } - return Promise.resolve(); - }; - startSearchMode = (searchString, matchCase, matchWholeWord) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.startSearchMode(tag, searchString, matchCase, matchWholeWord); - } - return Promise.resolve(); - }; - exitSearchMode = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.exitSearchMode(tag); - } - return Promise.resolve(); - }; - findText = (searchString, matchCase, matchWholeWord, searchUp, regExp) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.findText(tag, searchString, matchCase, matchWholeWord, searchUp, regExp); - } - return Promise.resolve(); - }; - cancelFindText = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.cancelFindText(tag); - } - return Promise.resolve(); - }; - getSelection = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getSelection(tag, pageNumber); - } - return Promise.resolve(); - }; - hasSelection = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.hasSelection(tag); - } - return Promise.resolve(); - }; - clearSelection = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.clearSelection(tag); - } - return Promise.resolve(); - }; - getSelectionPageRange = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.getSelectionPageRange(tag); - } - return Promise.resolve(); - }; - hasSelectionOnPage = (pageNumber) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); - } - return Promise.resolve(); - }; - selectInRect = (rect) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.selectInRect(tag, rect); - } - return Promise.resolve(); - }; - isThereTextInRect = (rect) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.isThereTextInRect(tag, rect); - } - return Promise.resolve(); - }; - selectAll = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.selectAll(tag); - } - return Promise.resolve(); - }; - setUrlExtraction = (urlExtraction) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setUrlExtraction(tag, urlExtraction); - } - return Promise.resolve(); - }; - setPageBorderVisibility = (pageBorderVisibility) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setPageBorderVisibility(tag, pageBorderVisibility); - } - return Promise.resolve(); - }; - setPageTransparencyGrid = (pageTransparencyGrid) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setPageTransparencyGrid(tag, pageTransparencyGrid); - } - return Promise.resolve(); - }; - setDefaultPageColor = (defaultPageColor) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setDefaultPageColor(tag, defaultPageColor); - } - return Promise.resolve(); - }; - setBackgroundColor = (backgroundColor) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setBackgroundColor(tag, backgroundColor); - } - return Promise.resolve(); - }; - exportAsImage = (pageNumber, dpi, exportFormat) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); - } - return Promise.resolve(); - }; - undo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.undo(tag); - } - return Promise.resolve(); - }; - redo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.redo(tag); - } - return Promise.resolve(); - }; - canUndo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.canUndo(tag); - } - return Promise.resolve(); - }; - canRedo = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.canRedo(tag); - } - return Promise.resolve(); - }; - showCrop = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.showCrop(tag); - } - return Promise.resolve(); - }; - setCurrentToolbar = (toolbar) => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.setCurrentToolbar(tag, toolbar); - } - return Promise.resolve(); - }; - openThumbnailsView = () => { - const tag = findNodeHandle(this._viewerRef); - if (tag != null) { - return DocumentViewManager.openThumbnailsView(tag); - } - return Promise.resolve(); - }; - _setNativeRef = (ref) => { - this._viewerRef = ref; - }; - render() { - return (); - } -} -const name = Platform.OS === 'ios' ? 'RNTPTDocumentView' : 'RCTDocumentView'; -const RCTDocumentView = requireNativeComponent(// https://github.com/facebook/react-native/issues/28351 -name, -// @ts-ignore -DocumentView, { - nativeOnly: { - onChange: true - } -}); diff --git a/types/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx similarity index 100% rename from types/DocumentView/DocumentView.tsx rename to src/DocumentView/DocumentView.tsx diff --git a/src/PDFViewCtrl/PDFViewCtrl.d.ts b/src/PDFViewCtrl/PDFViewCtrl.d.ts deleted file mode 100644 index faa649938..000000000 --- a/src/PDFViewCtrl/PDFViewCtrl.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { PureComponent } from 'react'; -import { ViewProps } from 'react-native'; -export interface PDFViewCtrlProps extends ViewProps { - document: string; - style?: object; -} -export declare class PDFViewCtrl extends PureComponent { - render(): JSX.Element; -} diff --git a/src/PDFViewCtrl/PDFViewCtrl.js b/src/PDFViewCtrl/PDFViewCtrl.js deleted file mode 100644 index dbba09284..000000000 --- a/src/PDFViewCtrl/PDFViewCtrl.js +++ /dev/null @@ -1,19 +0,0 @@ -import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; -import { requireNativeComponent, ViewPropTypes, Dimensions, Platform } from 'react-native'; -const { height, width } = Dimensions.get('window'); -export class PDFViewCtrl extends PureComponent { - render() { - return (); - } -} -var iface = { - name: 'PDFViewCtrl', - propTypes: { - document: PropTypes.string, - ...ViewPropTypes, // include the default view properties - }, -}; -const name = Platform.OS === 'ios' ? 'RNTPTPDFViewCtrl' : 'RCTPDFViewCtrl'; -// @ts-ignore -const RCTPDFViewCtrl = requireNativeComponent(name, PDFViewCtrl, iface); // https://github.com/facebook/react-native/issues/28351 diff --git a/types/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx similarity index 100% rename from types/PDFViewCtrl/PDFViewCtrl.tsx rename to src/PDFViewCtrl/PDFViewCtrl.tsx diff --git a/tsconfig.json b/tsconfig.json index 6e2b56b65..4b2b803a9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,9 +5,9 @@ "jsx": "react-native", "esModuleInterop": true, "skipLibCheck": true, - "declaration": true, - "outDir": "./", + "declaration": false, + "outDir": "./lib", }, - "files": ["index.ts"], + "include": ["index.ts", "src/**/*"], "exclude": ["node_modules", "**/*.spec.ts"] } \ No newline at end of file diff --git a/tsconfig.src.json b/tsconfig.src.json deleted file mode 100644 index e6bbe93ac..000000000 --- a/tsconfig.src.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig", - "compilerOptions": { - "moduleResolution": "Node", - "target": "ESNext", - "jsx": "react-native", - "esModuleInterop": true, - "skipLibCheck": true, - "declaration": true, - "outDir": "./src", - }, - "files": ["types/AnnotOptions/AnnotOptions.ts", "types/Config/Config.ts", "types/DocumentView/DocumentView.tsx", "types/PDFViewCtrl/PDFViewCtrl.tsx"], - "exclude": ["node_modules", "**/*.spec.ts"] -} \ No newline at end of file From 4447a14651578fcf04c7d3b0142763b45907b324 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Mon, 9 Aug 2021 14:54:27 -0700 Subject: [PATCH 048/226] fix typo --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 06cd9510b..56b8dcc1e 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,6 @@ import { NativeModules } from 'react-native'; import { PDFViewCtrl } from './src/PDFViewCtrl/PDFViewCtrl'; -import { DocumentView } from './src/DocumentView/DocumentView copy'; +import { DocumentView } from './src/DocumentView/DocumentView'; import { Config, ConfigOptions } from './src/Config/Config'; import * as AnnotOptions from './src/AnnotOptions/AnnotOptions'; From fa55453c27aae77fcbddef0bc0dc86f36454b8e9 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 10 Aug 2021 08:54:45 -0700 Subject: [PATCH 049/226] Updated PropTypes in DocumentView.tsx --- src/DocumentView/DocumentView.tsx | 52 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index e0031d188..4b28a7942 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -10,7 +10,7 @@ import { findNodeHandle, } from 'react-native'; const { DocumentViewManager } = NativeModules; -import {ConfigOptions} from "../Config/Config"; +import {Config, ConfigOptions} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { @@ -119,7 +119,8 @@ export class DocumentView extends PureComponent { _viewerRef; static propTypes = { - document: PropTypes.string, + document: PropTypes.string.isRequired, + onChange: PropTypes.func, password: PropTypes.string, initialPageNumber: PropTypes.number, pageNumber: PropTypes.number, @@ -134,17 +135,17 @@ export class DocumentView extends PureComponent { onZoomChanged: PropTypes.func, onZoomFinished: PropTypes.func, zoom: PropTypes.number, - disabledElements: PropTypes.array, - disabledTools: PropTypes.array, - longPressMenuItems: PropTypes.array, - overrideLongPressMenuBehavior: PropTypes.array, + disabledElements: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), + disabledTools: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), + longPressMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), + overrideLongPressMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), onLongPressMenuPress: PropTypes.func, longPressMenuEnabled: PropTypes.bool, - annotationMenuItems: PropTypes.array, - overrideAnnotationMenuBehavior: PropTypes.array, + annotationMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), + overrideAnnotationMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), onAnnotationMenuPress: PropTypes.func, - hideAnnotationMenu: PropTypes.array, - overrideBehavior: PropTypes.array, + hideAnnotationMenu: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), + overrideBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Actions))), onBehaviorActivated: PropTypes.func, topToolbarEnabled: PropTypes.bool, bottomToolbarEnabled: PropTypes.bool, @@ -157,8 +158,8 @@ export class DocumentView extends PureComponent { onFormFieldValueChanged: PropTypes.func, readOnly: PropTypes.bool, thumbnailViewEditingEnabled: PropTypes.bool, - fitMode: PropTypes.string, - layoutMode: PropTypes.string, + fitMode: PropTypes.oneOf(Object.values(Config.FitMode)), + layoutMode: PropTypes.oneOf(Object.values(Config.LayoutMode)), onLayoutChanged: PropTypes.func, padStatusBar: PropTypes.bool, continuousAnnotationEditing: PropTypes.bool, @@ -179,21 +180,32 @@ export class DocumentView extends PureComponent { maxTabCount: PropTypes.number, signSignatureFieldsWithStamps: PropTypes.bool, annotationPermissionCheckEnabled: PropTypes.bool, - annotationToolbars: PropTypes.array, - hideDefaultAnnotationToolbars: PropTypes.array, - topAppNavBarRightBar: PropTypes.array, - bottomToolbar: PropTypes.array, + annotationToolbars: PropTypes.arrayOf(PropTypes.oneOfType([ + PropTypes.oneOf(Object.values(Config.DefaultToolbars)), + PropTypes.exact({ + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + icon: PropTypes.oneOf(Object.values(Config.ToolbarIcons)).isRequired, + items: PropTypes.arrayOf(PropTypes.oneOfType([ + PropTypes.oneOf(Object.values(Config.Tools)), + PropTypes.oneOf(Object.values(Config.Buttons)) + ])).isRequired + }) + ])), + hideDefaultAnnotationToolbars: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.DefaultToolbars))), + topAppNavBarRightBar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), + bottomToolbar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), hideAnnotationToolbarSwitcher: PropTypes.bool, hideTopToolbars: PropTypes.bool, hideTopAppNavBar: PropTypes.bool, onBookmarkChanged: PropTypes.func, - hideThumbnailFilterModes: PropTypes.array, + hideThumbnailFilterModes: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ThumbnailFilterMode))), onToolChanged: PropTypes.func, horizontalScrollPos: PropTypes.number, verticalScrollPos: PropTypes.number, onTextSearchStart: PropTypes.func, onTextSearchResult: PropTypes.func, - hideViewModeItems: PropTypes.array, + hideViewModeItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ViewModePickerItem))), pageStackEnabled: PropTypes.bool, showQuickNavigationButton: PropTypes.bool, photoPickerEnabled: PropTypes.bool, @@ -203,12 +215,12 @@ export class DocumentView extends PureComponent { restrictDownloadUsage: PropTypes.bool, userBookmarksListEditingEnabled: PropTypes.bool, imageInReflowEnabled: PropTypes.bool, - reflowOrientation: PropTypes.string, + reflowOrientation: PropTypes.oneOf(Object.values(Config.ReflowOrientation)), onUndoRedoStateChanged: PropTypes.func, tabletLayoutEnabled: PropTypes.bool, initialToolbar: PropTypes.string, inkMultiStrokeEnabled: PropTypes.bool, - defaultEraserType: PropTypes.string, + defaultEraserType: PropTypes.oneOf(Object.values(Config.EraserType)), exportPath: PropTypes.string, openUrlPath: PropTypes.string, hideScrollbars: PropTypes.bool, From 47bcb474a6340f2dbdfe0e5c3e928900c0b66bb0 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 10 Aug 2021 10:19:32 -0700 Subject: [PATCH 050/226] Rename ConfigOptions to Config --- index.ts | 3 +- src/AnnotOptions/AnnotOptions.ts | 4 +-- src/Config/Config.ts | 2 +- src/DocumentView/DocumentView.tsx | 54 +++++++++++++++---------------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/index.ts b/index.ts index 56b8dcc1e..d7a52229f 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,7 @@ import { NativeModules } from 'react-native'; import { PDFViewCtrl } from './src/PDFViewCtrl/PDFViewCtrl'; import { DocumentView } from './src/DocumentView/DocumentView'; -import { Config, ConfigOptions } from './src/Config/Config'; +import { Config } from './src/Config/Config'; import * as AnnotOptions from './src/AnnotOptions/AnnotOptions'; export interface Pdftron { @@ -23,5 +23,4 @@ export { DocumentView, Config, AnnotOptions, - ConfigOptions }; \ No newline at end of file diff --git a/src/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts index 524fa4f30..450b046ad 100644 --- a/src/AnnotOptions/AnnotOptions.ts +++ b/src/AnnotOptions/AnnotOptions.ts @@ -1,4 +1,4 @@ -import {ConfigOptions} from '../Config/Config'; +import {Config} from '../Config/Config'; export interface Annotation { id: string; @@ -59,7 +59,7 @@ export interface TextSelectionResult { export interface AnnotationFlag { id: string; pageNumber: number; - flag: ConfigOptions.AnnotationFlags; + flag: Config.AnnotationFlags; flagValue: boolean; } diff --git a/src/Config/Config.ts b/src/Config/Config.ts index c1283b82d..ce932b676 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -272,7 +272,7 @@ export const Config = { type ValueOf = T[keyof T]; -export module ConfigOptions { +export module Config { export type Buttons = ValueOf; export type Tools = ValueOf; export type FitMode = ValueOf; diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 4b28a7942..04de3fd26 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -10,7 +10,7 @@ import { findNodeHandle, } from 'react-native'; const { DocumentViewManager } = NativeModules; -import {Config, ConfigOptions} from "../Config/Config"; +import {Config} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; export interface DocumentViewProps extends ViewProps { @@ -29,18 +29,18 @@ export interface DocumentViewProps extends ViewProps { onZoomChanged?: ({zoom}: {zoom: number}) => void; onZoomFinished?: ({zoom}: {zoom: number}) => void; zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; + disabledElements?: Array; + disabledTools?: Array; + longPressMenuItems?: Array; + overrideLongPressMenuBehavior?: Array; onLongPressMenuPress?: ({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void; longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; + annotationMenuItems?: Array; + overrideAnnotationMenuBehavior?: Array; onAnnotationMenuPress?: ({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; - onBehaviorActivated?: ({action, data}: {action: ConfigOptions.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; + hideAnnotationMenu?: Array; + overrideBehavior?: Array; + onBehaviorActivated?: ({action, data}: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; topToolbarEnabled?: boolean; bottomToolbarEnabled?: boolean; hideToolbarsOnTap?: boolean; @@ -52,8 +52,8 @@ export interface DocumentViewProps extends ViewProps { onFormFieldValueChanged?: ({fields}: {fields: Array}) => void; readOnly?: boolean; thumbnailViewEditingEnabled?: boolean; - fitMode?: ConfigOptions.FitMode; - layoutMode?: ConfigOptions.LayoutMode; + fitMode?: Config.FitMode; + layoutMode?: Config.LayoutMode; onLayoutChanged?: () => void; padStatusBar?: boolean; continuousAnnotationEditing?: boolean; @@ -74,21 +74,21 @@ export interface DocumentViewProps extends ViewProps { maxTabCount?: number; signSignatureFieldsWithStamps?: boolean; annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; + annotationToolbars?: Array; + hideDefaultAnnotationToolbars?: Array; + topAppNavBarRightBar?: Array; + bottomToolbar?: Array; hideAnnotationToolbarSwitcher?: boolean; hideTopToolbars?: boolean; hideTopAppNavBar?: boolean; onBookmarkChanged?: ({bookmarkJson}: {bookmarkJson: string}) => void; - hideThumbnailFilterModes?: Array; - onToolChanged?: ({previousTool, tool}: {previousTool: ConfigOptions.Tools | "unknown tool", tool: ConfigOptions.Tools | "unknown tool"}) => void; + hideThumbnailFilterModes?: Array; + onToolChanged?: ({previousTool, tool}: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void; horizontalScrollPos?: number; verticalScrollPos?: number; onTextSearchStart?: () => void; onTextSearchResult?: ({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; - hideViewModeItems?: Array; + hideViewModeItems?: Array; pageStackEnabled?: boolean; showQuickNavigationButton?: boolean; photoPickerEnabled?: boolean; @@ -98,12 +98,12 @@ export interface DocumentViewProps extends ViewProps { restrictDownloadUsage?: boolean; userBookmarksListEditingEnabled?: boolean; imageInReflowEnabled?: boolean; - reflowOrientation?: ConfigOptions.ReflowOrientation; + reflowOrientation?: Config.ReflowOrientation; onUndoRedoStateChanged?: () => void; tabletLayoutEnabled?: boolean; initialToolbar?: string; inkMultiStrokeEnabled?: boolean; - defaultEraserType?: ConfigOptions.EraserType; + defaultEraserType?: Config.EraserType; exportPath?: string; openUrlPath?: string; hideScrollbars?: boolean; @@ -372,7 +372,7 @@ export class DocumentView extends PureComponent { } - setToolMode = (toolMode: ConfigOptions.Tools): Promise => { + setToolMode = (toolMode: Config.Tools): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setToolMode(tag, toolMode); @@ -459,7 +459,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setFlagForFields = (fields: Array, flag: ConfigOptions.FieldFlags, value: boolean): Promise => { + setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.setFlagForFields(tag, fields, flag, value); @@ -684,7 +684,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setZoomLimits = (zoomLimitMode: ConfigOptions.ZoomLimitMode, minimum: number, maximum: number): Promise => { + setZoomLimits = (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); @@ -797,7 +797,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setOverprint = (overprint: ConfigOptions.OverprintMode): Promise => { + setOverprint = (overprint: Config.OverprintMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setOverprint(tag, overprint); @@ -805,7 +805,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setColorPostProcessMode = (colorPostProcessMode: ConfigOptions.ColorPostProcessMode): Promise => { + setColorPostProcessMode = (colorPostProcessMode: Config.ColorPostProcessMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); @@ -959,7 +959,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAsImage = (pageNumber: number, dpi: number, exportFormat: ConfigOptions.ExportFormat): Promise | Promise => { + exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise | Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); From a3adf363fff9cf51801e4823caa1d01d6edb2088 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 10 Aug 2021 16:00:53 -0700 Subject: [PATCH 051/226] Created custom PropTypes --- package.json | 2 +- src/DocumentView/DocumentView.tsx | 336 +++++++++++------------------- 2 files changed, 126 insertions(+), 212 deletions(-) diff --git a/package.json b/package.json index 49522d7a6..b1af9f3cd 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "scripts": { "copy-to-repo": "cd scripts && python3 fileCopy.py toRepo && cd ..", "copy-to-node-modules": "cd scripts && python3 fileCopy.py toModule && cd ..", - "start": "npx tsc" + "start": "tsc" }, "repository": { "type": "git", diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 04de3fd26..5aa4b7f59 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; +import PropTypes, {Requireable} from 'prop-types'; import { requireNativeComponent, ViewPropTypes, @@ -13,221 +13,135 @@ const { DocumentViewManager } = NativeModules; import {Config} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; -export interface DocumentViewProps extends ViewProps { - document: string; - password?: string; - initialPageNumber?: number; - pageNumber?: number; - customHeaders?: object; - leadingNavButtonIcon?: string; - showLeadingNavButton?: boolean; - onLeadingNavButtonPressed?: () => void; - onDocumentLoaded?: (path : string) => void; - onDocumentError?: (error: string) => void; - onPageChanged?: ({previousPageNumber, pageNumber}: {previousPageNumber: number, pageNumber: number}) => void; - onScrollChanged?: ({horizontal, vertical}: {horizontal: number, vertical: number}) => void; - onZoomChanged?: ({zoom}: {zoom: number}) => void; - onZoomFinished?: ({zoom}: {zoom: number}) => void; - zoom?: number; - disabledElements?: Array; - disabledTools?: Array; - longPressMenuItems?: Array; - overrideLongPressMenuBehavior?: Array; - onLongPressMenuPress?: ({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void; - longPressMenuEnabled?: boolean; - annotationMenuItems?: Array; - overrideAnnotationMenuBehavior?: Array; - onAnnotationMenuPress?: ({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void; - hideAnnotationMenu?: Array; - overrideBehavior?: Array; - onBehaviorActivated?: ({action, data}: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void; - topToolbarEnabled?: boolean; - bottomToolbarEnabled?: boolean; - hideToolbarsOnTap?: boolean; - documentSliderEnabled?: boolean; - pageIndicatorEnabled?: boolean; - keyboardShortcutsEnabled?: boolean; - onAnnotationsSelected?: ({annotations}: {annotations: Array}) => void ; - onAnnotationChanged?: ({action, annotations}: {action: string, annotations: Array}) => void; - onFormFieldValueChanged?: ({fields}: {fields: Array}) => void; - readOnly?: boolean; - thumbnailViewEditingEnabled?: boolean; - fitMode?: Config.FitMode; - layoutMode?: Config.LayoutMode; - onLayoutChanged?: () => void; - padStatusBar?: boolean; - continuousAnnotationEditing?: boolean; - selectAnnotationAfterCreation?: boolean; - annotationAuthor?: string; - showSavedSignatures?: boolean; - isBase64String?: boolean; - collabEnabled?: boolean; - currentUser?: string; - currentUserName?: string; - onExportAnnotationCommand?: ({action, xfdfCommand, annotations}: {action: string, xfdfCommand: string, annotations: Array}) => void; - autoSaveEnabled?: boolean; - pageChangeOnTap?: boolean; - followSystemDarkMode?: boolean; - useStylusAsPen?: boolean; - multiTabEnabled?: boolean; - tabTitle?: string; - maxTabCount?: number; - signSignatureFieldsWithStamps?: boolean; - annotationPermissionCheckEnabled?: boolean; - annotationToolbars?: Array; - hideDefaultAnnotationToolbars?: Array; - topAppNavBarRightBar?: Array; - bottomToolbar?: Array; - hideAnnotationToolbarSwitcher?: boolean; - hideTopToolbars?: boolean; - hideTopAppNavBar?: boolean; - onBookmarkChanged?: ({bookmarkJson}: {bookmarkJson: string}) => void; - hideThumbnailFilterModes?: Array; - onToolChanged?: ({previousTool, tool}: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void; - horizontalScrollPos?: number; - verticalScrollPos?: number; - onTextSearchStart?: () => void; - onTextSearchResult?: ({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void; - hideViewModeItems?: Array; - pageStackEnabled?: boolean; - showQuickNavigationButton?: boolean; - photoPickerEnabled?: boolean; - autoResizeFreeTextEnabled?: boolean; - annotationsListEditingEnabled?: boolean; - showNavigationListAsSidePanelOnLargeDevices?: boolean; - restrictDownloadUsage?: boolean; - userBookmarksListEditingEnabled?: boolean; - imageInReflowEnabled?: boolean; - reflowOrientation?: Config.ReflowOrientation; - onUndoRedoStateChanged?: () => void; - tabletLayoutEnabled?: boolean; - initialToolbar?: string; - inkMultiStrokeEnabled?: boolean; - defaultEraserType?: Config.EraserType; - exportPath?: string; - openUrlPath?: string; - hideScrollbars?: boolean; - saveStateEnabled?: boolean; - openSavedCopyInNewTab?: boolean; - - onChange?(event): void; +const propTypes = { + document: PropTypes.string.isRequired, + onChange: PropTypes.func, + password: PropTypes.string, + initialPageNumber: PropTypes.number, + pageNumber: PropTypes.number, + customHeaders: PropTypes.object, + leadingNavButtonIcon: PropTypes.string, + showLeadingNavButton: PropTypes.bool, + onLeadingNavButtonPressed: PropTypes.func, + onDocumentLoaded: funcProp<(path: string) => void>(), + onDocumentError: funcProp<(error: string) => void>(), + onPageChanged: funcProp<({previousPageNumber, pageNumber}: {previousPageNumber: number, pageNumber: number}) => void>(), + onScrollChanged: funcProp<({horizontal, vertical}: {horizontal: number, vertical: number}) => void>(), + onZoomChanged: funcProp<({zoom}: {zoom: number}) => void>(), + onZoomFinished: funcProp<({zoom}: {zoom: number}) => void>(), + zoom: PropTypes.number, + disabledElements: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), + disabledTools: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), + longPressMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), + overrideLongPressMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), + onLongPressMenuPress: funcProp<({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void>(), + longPressMenuEnabled: PropTypes.bool, + annotationMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), + overrideAnnotationMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), + onAnnotationMenuPress: funcProp<({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void>(), + hideAnnotationMenu: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), + overrideBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Actions))), + onBehaviorActivated: funcProp<({action, data}: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), + topToolbarEnabled: PropTypes.bool, + bottomToolbarEnabled: PropTypes.bool, + hideToolbarsOnTap: PropTypes.bool, + documentSliderEnabled: PropTypes.bool, + pageIndicatorEnabled: PropTypes.bool, + keyboardShortcutsEnabled: PropTypes.bool, + onAnnotationsSelected: funcProp<({annotations}: {annotations: Array}) => void>(), + onAnnotationChanged: funcProp<({action, annotations}: {action: string, annotations: Array}) => void>(), + onFormFieldValueChanged: funcProp<({fields}: {fields: Array}) => void>(), + readOnly: PropTypes.bool, + thumbnailViewEditingEnabled: PropTypes.bool, + fitMode: PropTypes.oneOf(Object.values(Config.FitMode)), + layoutMode: PropTypes.oneOf(Object.values(Config.LayoutMode)), + onLayoutChanged: funcProp<() => void>(), + padStatusBar: PropTypes.bool, + continuousAnnotationEditing: PropTypes.bool, + selectAnnotationAfterCreation: PropTypes.bool, + annotationAuthor: PropTypes.string, + showSavedSignatures: PropTypes.bool, + isBase64String: PropTypes.bool, + collabEnabled: PropTypes.bool, + currentUser: PropTypes.string, + currentUserName: PropTypes.string, + onExportAnnotationCommand: funcProp<({action, xfdfCommand, annotations}: {action: string, xfdfCommand: string, annotations: Array}) => void>(), + autoSaveEnabled: PropTypes.bool, + pageChangeOnTap: PropTypes.bool, + followSystemDarkMode: PropTypes.bool, + useStylusAsPen: PropTypes.bool, + multiTabEnabled: PropTypes.bool, + tabTitle: PropTypes.string, + maxTabCount: PropTypes.number, + signSignatureFieldsWithStamps: PropTypes.bool, + annotationPermissionCheckEnabled: PropTypes.bool, + annotationToolbars: PropTypes.arrayOf(PropTypes.oneOfType([ + PropTypes.oneOf(Object.values(Config.DefaultToolbars)), + PropTypes.exact({ + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + icon: PropTypes.oneOf(Object.values(Config.ToolbarIcons)).isRequired, + items: PropTypes.arrayOf(PropTypes.oneOfType([ + PropTypes.oneOf(Object.values(Config.Tools)), + PropTypes.oneOf(Object.values(Config.Buttons)) + ])).isRequired + }) + ])), + hideDefaultAnnotationToolbars: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.DefaultToolbars))), + topAppNavBarRightBar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), + bottomToolbar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), + hideAnnotationToolbarSwitcher: PropTypes.bool, + hideTopToolbars: PropTypes.bool, + hideTopAppNavBar: PropTypes.bool, + onBookmarkChanged: funcProp<({bookmarkJson}: {bookmarkJson: string}) => void>(), + hideThumbnailFilterModes: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ThumbnailFilterMode))), + onToolChanged: funcProp<({previousTool, tool}: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), + horizontalScrollPos: PropTypes.number, + verticalScrollPos: PropTypes.number, + onTextSearchStart: funcProp<() => void>(), + onTextSearchResult: funcProp<({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), + hideViewModeItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ViewModePickerItem))), + pageStackEnabled: PropTypes.bool, + showQuickNavigationButton: PropTypes.bool, + photoPickerEnabled: PropTypes.bool, + autoResizeFreeTextEnabled: PropTypes.bool, + annotationsListEditingEnabled: PropTypes.bool, + showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, + restrictDownloadUsage: PropTypes.bool, + userBookmarksListEditingEnabled: PropTypes.bool, + imageInReflowEnabled: PropTypes.bool, + reflowOrientation: PropTypes.oneOf(Object.values(Config.ReflowOrientation)), + onUndoRedoStateChanged: funcProp<() => void>(), + tabletLayoutEnabled: PropTypes.bool, + initialToolbar: PropTypes.string, + inkMultiStrokeEnabled: PropTypes.bool, + defaultEraserType: PropTypes.oneOf(Object.values(Config.EraserType)), + exportPath: PropTypes.string, + openUrlPath: PropTypes.string, + hideScrollbars: PropTypes.bool, + saveStateEnabled: PropTypes.bool, + openSavedCopyInNewTab: PropTypes.bool, + ...ViewPropTypes, +}; + +type DocumentViewProps = PropTypes.InferProps; + +function funcProp () : Requireable { + let validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error { + if (typeof props[propName] !== "function" && typeof props[propName] !== "undefined") { + return new Error ("Invalid prop `" + propName + "` of type `" + typeof props[propName] + "` supplied to `" + componentName + "`, expected a function"); + } + } + + const t : Requireable = validator as Requireable; + t.isRequired = validator; + return t; } - - export class DocumentView extends PureComponent { _viewerRef; - static propTypes = { - document: PropTypes.string.isRequired, - onChange: PropTypes.func, - password: PropTypes.string, - initialPageNumber: PropTypes.number, - pageNumber: PropTypes.number, - customHeaders: PropTypes.object, - leadingNavButtonIcon: PropTypes.string, - showLeadingNavButton: PropTypes.bool, - onLeadingNavButtonPressed: PropTypes.func, - onDocumentLoaded: PropTypes.func, - onDocumentError: PropTypes.func, - onPageChanged: PropTypes.func, - onScrollChanged: PropTypes.func, - onZoomChanged: PropTypes.func, - onZoomFinished: PropTypes.func, - zoom: PropTypes.number, - disabledElements: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), - disabledTools: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), - longPressMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), - overrideLongPressMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), - onLongPressMenuPress: PropTypes.func, - longPressMenuEnabled: PropTypes.bool, - annotationMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), - overrideAnnotationMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), - onAnnotationMenuPress: PropTypes.func, - hideAnnotationMenu: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), - overrideBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Actions))), - onBehaviorActivated: PropTypes.func, - topToolbarEnabled: PropTypes.bool, - bottomToolbarEnabled: PropTypes.bool, - hideToolbarsOnTap: PropTypes.bool, - documentSliderEnabled: PropTypes.bool, - pageIndicatorEnabled: PropTypes.bool, - keyboardShortcutsEnabled: PropTypes.bool, - onAnnotationsSelected: PropTypes.func, - onAnnotationChanged: PropTypes.func, - onFormFieldValueChanged: PropTypes.func, - readOnly: PropTypes.bool, - thumbnailViewEditingEnabled: PropTypes.bool, - fitMode: PropTypes.oneOf(Object.values(Config.FitMode)), - layoutMode: PropTypes.oneOf(Object.values(Config.LayoutMode)), - onLayoutChanged: PropTypes.func, - padStatusBar: PropTypes.bool, - continuousAnnotationEditing: PropTypes.bool, - selectAnnotationAfterCreation: PropTypes.bool, - annotationAuthor: PropTypes.string, - showSavedSignatures: PropTypes.bool, - isBase64String: PropTypes.bool, - collabEnabled: PropTypes.bool, - currentUser: PropTypes.string, - currentUserName: PropTypes.string, - onExportAnnotationCommand: PropTypes.func, - autoSaveEnabled: PropTypes.bool, - pageChangeOnTap: PropTypes.bool, - followSystemDarkMode: PropTypes.bool, - useStylusAsPen: PropTypes.bool, - multiTabEnabled: PropTypes.bool, - tabTitle: PropTypes.string, - maxTabCount: PropTypes.number, - signSignatureFieldsWithStamps: PropTypes.bool, - annotationPermissionCheckEnabled: PropTypes.bool, - annotationToolbars: PropTypes.arrayOf(PropTypes.oneOfType([ - PropTypes.oneOf(Object.values(Config.DefaultToolbars)), - PropTypes.exact({ - id: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - icon: PropTypes.oneOf(Object.values(Config.ToolbarIcons)).isRequired, - items: PropTypes.arrayOf(PropTypes.oneOfType([ - PropTypes.oneOf(Object.values(Config.Tools)), - PropTypes.oneOf(Object.values(Config.Buttons)) - ])).isRequired - }) - ])), - hideDefaultAnnotationToolbars: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.DefaultToolbars))), - topAppNavBarRightBar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), - bottomToolbar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), - hideAnnotationToolbarSwitcher: PropTypes.bool, - hideTopToolbars: PropTypes.bool, - hideTopAppNavBar: PropTypes.bool, - onBookmarkChanged: PropTypes.func, - hideThumbnailFilterModes: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ThumbnailFilterMode))), - onToolChanged: PropTypes.func, - horizontalScrollPos: PropTypes.number, - verticalScrollPos: PropTypes.number, - onTextSearchStart: PropTypes.func, - onTextSearchResult: PropTypes.func, - hideViewModeItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ViewModePickerItem))), - pageStackEnabled: PropTypes.bool, - showQuickNavigationButton: PropTypes.bool, - photoPickerEnabled: PropTypes.bool, - autoResizeFreeTextEnabled: PropTypes.bool, - annotationsListEditingEnabled: PropTypes.bool, - showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, - restrictDownloadUsage: PropTypes.bool, - userBookmarksListEditingEnabled: PropTypes.bool, - imageInReflowEnabled: PropTypes.bool, - reflowOrientation: PropTypes.oneOf(Object.values(Config.ReflowOrientation)), - onUndoRedoStateChanged: PropTypes.func, - tabletLayoutEnabled: PropTypes.bool, - initialToolbar: PropTypes.string, - inkMultiStrokeEnabled: PropTypes.bool, - defaultEraserType: PropTypes.oneOf(Object.values(Config.EraserType)), - exportPath: PropTypes.string, - openUrlPath: PropTypes.string, - hideScrollbars: PropTypes.bool, - saveStateEnabled: PropTypes.bool, - openSavedCopyInNewTab: PropTypes.bool, - ...ViewPropTypes, - }; + static propTypes = propTypes; onChange = (event) => { if (event.nativeEvent.onLeadingNavButtonPressed) { From 92d39dc53fa382d20c0969d391943ea2856e0d1e Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 10 Aug 2021 17:00:21 -0700 Subject: [PATCH 052/226] Refactor event function params --- src/DocumentView/DocumentView.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 5aa4b7f59..89863fedf 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -25,32 +25,32 @@ const propTypes = { onLeadingNavButtonPressed: PropTypes.func, onDocumentLoaded: funcProp<(path: string) => void>(), onDocumentError: funcProp<(error: string) => void>(), - onPageChanged: funcProp<({previousPageNumber, pageNumber}: {previousPageNumber: number, pageNumber: number}) => void>(), - onScrollChanged: funcProp<({horizontal, vertical}: {horizontal: number, vertical: number}) => void>(), - onZoomChanged: funcProp<({zoom}: {zoom: number}) => void>(), - onZoomFinished: funcProp<({zoom}: {zoom: number}) => void>(), + onPageChanged: funcProp<(event: {previousPageNumber: number, pageNumber: number}) => void>(), + onScrollChanged: funcProp<(event: {horizontal: number, vertical: number}) => void>(), + onZoomChanged: funcProp<(event: {zoom: number}) => void>(), + onZoomFinished: funcProp<(event: {zoom: number}) => void>(), zoom: PropTypes.number, disabledElements: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), disabledTools: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), longPressMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), overrideLongPressMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), - onLongPressMenuPress: funcProp<({longPressMenu, longPressText}: {longPressMenu: string, longPressText: string}) => void>(), + onLongPressMenuPress: funcProp<(event: {longPressMenu: string, longPressText: string}) => void>(), longPressMenuEnabled: PropTypes.bool, annotationMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), overrideAnnotationMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), - onAnnotationMenuPress: funcProp<({annotationMenu, annotations}: {annotationMenu: string, annotations: Array}) => void>(), + onAnnotationMenuPress: funcProp<(event: {annotationMenu: string, annotations: Array}) => void>(), hideAnnotationMenu: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), overrideBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Actions))), - onBehaviorActivated: funcProp<({action, data}: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), + onBehaviorActivated: funcProp<(event: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), topToolbarEnabled: PropTypes.bool, bottomToolbarEnabled: PropTypes.bool, hideToolbarsOnTap: PropTypes.bool, documentSliderEnabled: PropTypes.bool, pageIndicatorEnabled: PropTypes.bool, keyboardShortcutsEnabled: PropTypes.bool, - onAnnotationsSelected: funcProp<({annotations}: {annotations: Array}) => void>(), - onAnnotationChanged: funcProp<({action, annotations}: {action: string, annotations: Array}) => void>(), - onFormFieldValueChanged: funcProp<({fields}: {fields: Array}) => void>(), + onAnnotationsSelected: funcProp<(event: {annotations: Array}) => void>(), + onAnnotationChanged: funcProp<(event: {action: string, annotations: Array}) => void>(), + onFormFieldValueChanged: funcProp<(event: {fields: Array}) => void>(), readOnly: PropTypes.bool, thumbnailViewEditingEnabled: PropTypes.bool, fitMode: PropTypes.oneOf(Object.values(Config.FitMode)), @@ -65,7 +65,7 @@ const propTypes = { collabEnabled: PropTypes.bool, currentUser: PropTypes.string, currentUserName: PropTypes.string, - onExportAnnotationCommand: funcProp<({action, xfdfCommand, annotations}: {action: string, xfdfCommand: string, annotations: Array}) => void>(), + onExportAnnotationCommand: funcProp<(event: {action: string, xfdfCommand: string, annotations: Array}) => void>(), autoSaveEnabled: PropTypes.bool, pageChangeOnTap: PropTypes.bool, followSystemDarkMode: PropTypes.bool, @@ -93,13 +93,13 @@ const propTypes = { hideAnnotationToolbarSwitcher: PropTypes.bool, hideTopToolbars: PropTypes.bool, hideTopAppNavBar: PropTypes.bool, - onBookmarkChanged: funcProp<({bookmarkJson}: {bookmarkJson: string}) => void>(), + onBookmarkChanged: funcProp<(event: {bookmarkJson: string}) => void>(), hideThumbnailFilterModes: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ThumbnailFilterMode))), - onToolChanged: funcProp<({previousTool, tool}: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), + onToolChanged: funcProp<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), horizontalScrollPos: PropTypes.number, verticalScrollPos: PropTypes.number, onTextSearchStart: funcProp<() => void>(), - onTextSearchResult: funcProp<({found, textSelection}: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), + onTextSearchResult: funcProp<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), hideViewModeItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ViewModePickerItem))), pageStackEnabled: PropTypes.bool, showQuickNavigationButton: PropTypes.bool, From ceffad4887fbcf37aac722221d0a092f07fd1e1a Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 10 Aug 2021 17:46:07 -0700 Subject: [PATCH 053/226] Script for Build Process --- .github/workflows/jsBuilder.yml | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/jsBuilder.yml diff --git a/.github/workflows/jsBuilder.yml b/.github/workflows/jsBuilder.yml new file mode 100644 index 000000000..ca831a957 --- /dev/null +++ b/.github/workflows/jsBuilder.yml @@ -0,0 +1,42 @@ +name: Transpile TS + +on: + push: + branches: [ts-support-js-to-ts] # <-- Change this to whatever the primary branch is (ex: master) + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + + - name: Node setup + uses: actions/setup-node@v2 + with: + node-version: '16' + cache: 'npm' + + - name: Build JavaScript files + run: | # Change last line to your build script command # + npm i + npm run start + + - name: Force add JS files to override .gitignore + run: git add --force /lib # <-- Change this to your build path + + - name: Commit files + run: | # Change last line to your preferred commit message (I like `chore: build js files`) + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "Updating JS files" -a + + - name: Push changes + uses: ad-m/github-push-action@v0.6.0 + with: + force: true + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ts-support # <-- Change this to the new branch where you want builds to be \ No newline at end of file From e301d2daae134596197caf9c0c16f8d141335518 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 10 Aug 2021 18:00:18 -0700 Subject: [PATCH 054/226] Updating Build Process Script --- .github/workflows/jsBuilder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jsBuilder.yml b/.github/workflows/jsBuilder.yml index ca831a957..8dfad4f40 100644 --- a/.github/workflows/jsBuilder.yml +++ b/.github/workflows/jsBuilder.yml @@ -26,7 +26,7 @@ jobs: npm run start - name: Force add JS files to override .gitignore - run: git add --force /lib # <-- Change this to your build path + run: git add --force ./lib # <-- Change this to your build path - name: Commit files run: | # Change last line to your preferred commit message (I like `chore: build js files`) From d7aed3f05fae22821310c8b46003ca6ae17aede0 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 10:51:50 -0700 Subject: [PATCH 055/226] document funcProp --- src/DocumentView/DocumentView.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 89863fedf..259f51dc6 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import PropTypes, {Requireable} from 'prop-types'; +import PropTypes, { Requireable } from 'prop-types'; import { requireNativeComponent, ViewPropTypes, @@ -124,9 +124,16 @@ const propTypes = { ...ViewPropTypes, }; +// Generates the prop types for TypeScript users, from PropTypes. type DocumentViewProps = PropTypes.InferProps; +// Creates a custom PropType for functions. +// When the prop types are generated for TS users, type checking for +// function parameters and return values is provided. +// Usage: funcProp<(arg: argType) => returnType>() function funcProp () : Requireable { + + // Creates a validator, similar to Validator from prop-types. let validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error { if (typeof props[propName] !== "function" && typeof props[propName] !== "undefined") { return new Error ("Invalid prop `" + propName + "` of type `" + typeof props[propName] + "` supplied to `" + componentName + "`, expected a function"); @@ -137,6 +144,7 @@ function funcProp () : Requireable { t.isRequired = validator; return t; } + export class DocumentView extends PureComponent { _viewerRef; From 2f448a11510eb39b257e6ab7abc15a0b2f8f6c3c Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Wed, 11 Aug 2021 11:01:10 -0700 Subject: [PATCH 056/226] Created functions to make propTypes easier to read --- README.md | 1 - src/DocumentView/DocumentView.tsx | 55 +++++++++++++++++-------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 16365cba9..672922f22 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ - [Preview](#preview) - [Installation](#installation) - [Usage](#usage) -- [Components](#components) - [License](#license) ## API diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 259f51dc6..3b8466b6f 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -15,14 +15,14 @@ import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; const propTypes = { document: PropTypes.string.isRequired, - onChange: PropTypes.func, + onChange: funcProp<(event : any) => void>(), password: PropTypes.string, initialPageNumber: PropTypes.number, pageNumber: PropTypes.number, customHeaders: PropTypes.object, leadingNavButtonIcon: PropTypes.string, showLeadingNavButton: PropTypes.bool, - onLeadingNavButtonPressed: PropTypes.func, + onLeadingNavButtonPressed: funcProp<() => void>(), onDocumentLoaded: funcProp<(path: string) => void>(), onDocumentError: funcProp<(error: string) => void>(), onPageChanged: funcProp<(event: {previousPageNumber: number, pageNumber: number}) => void>(), @@ -30,17 +30,17 @@ const propTypes = { onZoomChanged: funcProp<(event: {zoom: number}) => void>(), onZoomFinished: funcProp<(event: {zoom: number}) => void>(), zoom: PropTypes.number, - disabledElements: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), - disabledTools: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), - longPressMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), - overrideLongPressMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.LongPressMenu))), + disabledElements: arrayOfProp(Config.Buttons), + disabledTools: arrayOfProp(Config.Tools), + longPressMenuItems: arrayOfProp(Config.LongPressMenu), + overrideLongPressMenuBehavior: arrayOfProp(Config.LongPressMenu), onLongPressMenuPress: funcProp<(event: {longPressMenu: string, longPressText: string}) => void>(), longPressMenuEnabled: PropTypes.bool, - annotationMenuItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), - overrideAnnotationMenuBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.AnnotationMenu))), + annotationMenuItems: arrayOfProp(Config.AnnotationMenu), + overrideAnnotationMenuBehavior: arrayOfProp(Config.AnnotationMenu), onAnnotationMenuPress: funcProp<(event: {annotationMenu: string, annotations: Array}) => void>(), - hideAnnotationMenu: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Tools))), - overrideBehavior: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Actions))), + hideAnnotationMenu: arrayOfProp(Config.Tools), + overrideBehavior: arrayOfProp(Config.Actions), onBehaviorActivated: funcProp<(event: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), topToolbarEnabled: PropTypes.bool, bottomToolbarEnabled: PropTypes.bool, @@ -53,8 +53,8 @@ const propTypes = { onFormFieldValueChanged: funcProp<(event: {fields: Array}) => void>(), readOnly: PropTypes.bool, thumbnailViewEditingEnabled: PropTypes.bool, - fitMode: PropTypes.oneOf(Object.values(Config.FitMode)), - layoutMode: PropTypes.oneOf(Object.values(Config.LayoutMode)), + fitMode: oneOfProp(Config.FitMode), + layoutMode: oneOfProp(Config.LayoutMode), onLayoutChanged: funcProp<() => void>(), padStatusBar: PropTypes.bool, continuousAnnotationEditing: PropTypes.bool, @@ -76,31 +76,31 @@ const propTypes = { signSignatureFieldsWithStamps: PropTypes.bool, annotationPermissionCheckEnabled: PropTypes.bool, annotationToolbars: PropTypes.arrayOf(PropTypes.oneOfType([ - PropTypes.oneOf(Object.values(Config.DefaultToolbars)), + oneOfProp(Config.DefaultToolbars), PropTypes.exact({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, - icon: PropTypes.oneOf(Object.values(Config.ToolbarIcons)).isRequired, + icon: oneOfProp(Config.ToolbarIcons).isRequired, items: PropTypes.arrayOf(PropTypes.oneOfType([ - PropTypes.oneOf(Object.values(Config.Tools)), - PropTypes.oneOf(Object.values(Config.Buttons)) + oneOfProp(Config.Tools), + oneOfProp(Config.Buttons) ])).isRequired }) ])), - hideDefaultAnnotationToolbars: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.DefaultToolbars))), - topAppNavBarRightBar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), - bottomToolbar: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.Buttons))), + hideDefaultAnnotationToolbars: arrayOfProp(Config.DefaultToolbars), + topAppNavBarRightBar: arrayOfProp(Config.Buttons), + bottomToolbar: arrayOfProp(Config.Buttons), hideAnnotationToolbarSwitcher: PropTypes.bool, hideTopToolbars: PropTypes.bool, hideTopAppNavBar: PropTypes.bool, onBookmarkChanged: funcProp<(event: {bookmarkJson: string}) => void>(), - hideThumbnailFilterModes: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ThumbnailFilterMode))), + hideThumbnailFilterModes: arrayOfProp(Config.ThumbnailFilterMode), onToolChanged: funcProp<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), horizontalScrollPos: PropTypes.number, verticalScrollPos: PropTypes.number, onTextSearchStart: funcProp<() => void>(), onTextSearchResult: funcProp<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), - hideViewModeItems: PropTypes.arrayOf(PropTypes.oneOf(Object.values(Config.ViewModePickerItem))), + hideViewModeItems: arrayOfProp(Config.ViewModePickerItem), pageStackEnabled: PropTypes.bool, showQuickNavigationButton: PropTypes.bool, photoPickerEnabled: PropTypes.bool, @@ -110,12 +110,12 @@ const propTypes = { restrictDownloadUsage: PropTypes.bool, userBookmarksListEditingEnabled: PropTypes.bool, imageInReflowEnabled: PropTypes.bool, - reflowOrientation: PropTypes.oneOf(Object.values(Config.ReflowOrientation)), + reflowOrientation: oneOfProp(Config.ReflowOrientation), onUndoRedoStateChanged: funcProp<() => void>(), tabletLayoutEnabled: PropTypes.bool, initialToolbar: PropTypes.string, inkMultiStrokeEnabled: PropTypes.bool, - defaultEraserType: PropTypes.oneOf(Object.values(Config.EraserType)), + defaultEraserType: oneOfProp(Config.EraserType), exportPath: PropTypes.string, openUrlPath: PropTypes.string, hideScrollbars: PropTypes.bool, @@ -134,7 +134,7 @@ type DocumentViewProps = PropTypes.InferProps; function funcProp () : Requireable { // Creates a validator, similar to Validator from prop-types. - let validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error { + let validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error | null{ if (typeof props[propName] !== "function" && typeof props[propName] !== "undefined") { return new Error ("Invalid prop `" + propName + "` of type `" + typeof props[propName] + "` supplied to `" + componentName + "`, expected a function"); } @@ -145,6 +145,13 @@ function funcProp () : Requireable { return t; } +function oneOfProp(val : object) : Requireable { + return PropTypes.oneOf(Object.values(val)); +} + +function arrayOfProp(val : object) : Requireable { + return PropTypes.arrayOf(oneOfProp(val)); +} export class DocumentView extends PureComponent { _viewerRef; From 8049192cc31c93b06f68a239e243a9a07d8093e7 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 11:12:22 -0700 Subject: [PATCH 057/226] funcProp to func --- src/DocumentView/DocumentView.tsx | 46 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 3b8466b6f..ad65a625e 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -15,47 +15,47 @@ import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; const propTypes = { document: PropTypes.string.isRequired, - onChange: funcProp<(event : any) => void>(), + onChange: func<(event : any) => void>(), password: PropTypes.string, initialPageNumber: PropTypes.number, pageNumber: PropTypes.number, customHeaders: PropTypes.object, leadingNavButtonIcon: PropTypes.string, showLeadingNavButton: PropTypes.bool, - onLeadingNavButtonPressed: funcProp<() => void>(), - onDocumentLoaded: funcProp<(path: string) => void>(), - onDocumentError: funcProp<(error: string) => void>(), - onPageChanged: funcProp<(event: {previousPageNumber: number, pageNumber: number}) => void>(), - onScrollChanged: funcProp<(event: {horizontal: number, vertical: number}) => void>(), - onZoomChanged: funcProp<(event: {zoom: number}) => void>(), - onZoomFinished: funcProp<(event: {zoom: number}) => void>(), + onLeadingNavButtonPressed: func<() => void>(), + onDocumentLoaded: func<(path: string) => void>(), + onDocumentError: func<(error: string) => void>(), + onPageChanged: func<(event: {previousPageNumber: number, pageNumber: number}) => void>(), + onScrollChanged: func<(event: {horizontal: number, vertical: number}) => void>(), + onZoomChanged: func<(event: {zoom: number}) => void>(), + onZoomFinished: func<(event: {zoom: number}) => void>(), zoom: PropTypes.number, disabledElements: arrayOfProp(Config.Buttons), disabledTools: arrayOfProp(Config.Tools), longPressMenuItems: arrayOfProp(Config.LongPressMenu), overrideLongPressMenuBehavior: arrayOfProp(Config.LongPressMenu), - onLongPressMenuPress: funcProp<(event: {longPressMenu: string, longPressText: string}) => void>(), + onLongPressMenuPress: func<(event: {longPressMenu: string, longPressText: string}) => void>(), longPressMenuEnabled: PropTypes.bool, annotationMenuItems: arrayOfProp(Config.AnnotationMenu), overrideAnnotationMenuBehavior: arrayOfProp(Config.AnnotationMenu), - onAnnotationMenuPress: funcProp<(event: {annotationMenu: string, annotations: Array}) => void>(), + onAnnotationMenuPress: func<(event: {annotationMenu: string, annotations: Array}) => void>(), hideAnnotationMenu: arrayOfProp(Config.Tools), overrideBehavior: arrayOfProp(Config.Actions), - onBehaviorActivated: funcProp<(event: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), + onBehaviorActivated: func<(event: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), topToolbarEnabled: PropTypes.bool, bottomToolbarEnabled: PropTypes.bool, hideToolbarsOnTap: PropTypes.bool, documentSliderEnabled: PropTypes.bool, pageIndicatorEnabled: PropTypes.bool, keyboardShortcutsEnabled: PropTypes.bool, - onAnnotationsSelected: funcProp<(event: {annotations: Array}) => void>(), - onAnnotationChanged: funcProp<(event: {action: string, annotations: Array}) => void>(), - onFormFieldValueChanged: funcProp<(event: {fields: Array}) => void>(), + onAnnotationsSelected: func<(event: {annotations: Array}) => void>(), + onAnnotationChanged: func<(event: {action: string, annotations: Array}) => void>(), + onFormFieldValueChanged: func<(event: {fields: Array}) => void>(), readOnly: PropTypes.bool, thumbnailViewEditingEnabled: PropTypes.bool, fitMode: oneOfProp(Config.FitMode), layoutMode: oneOfProp(Config.LayoutMode), - onLayoutChanged: funcProp<() => void>(), + onLayoutChanged: func<() => void>(), padStatusBar: PropTypes.bool, continuousAnnotationEditing: PropTypes.bool, selectAnnotationAfterCreation: PropTypes.bool, @@ -65,7 +65,7 @@ const propTypes = { collabEnabled: PropTypes.bool, currentUser: PropTypes.string, currentUserName: PropTypes.string, - onExportAnnotationCommand: funcProp<(event: {action: string, xfdfCommand: string, annotations: Array}) => void>(), + onExportAnnotationCommand: func<(event: {action: string, xfdfCommand: string, annotations: Array}) => void>(), autoSaveEnabled: PropTypes.bool, pageChangeOnTap: PropTypes.bool, followSystemDarkMode: PropTypes.bool, @@ -93,13 +93,13 @@ const propTypes = { hideAnnotationToolbarSwitcher: PropTypes.bool, hideTopToolbars: PropTypes.bool, hideTopAppNavBar: PropTypes.bool, - onBookmarkChanged: funcProp<(event: {bookmarkJson: string}) => void>(), + onBookmarkChanged: func<(event: {bookmarkJson: string}) => void>(), hideThumbnailFilterModes: arrayOfProp(Config.ThumbnailFilterMode), - onToolChanged: funcProp<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), + onToolChanged: func<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), horizontalScrollPos: PropTypes.number, verticalScrollPos: PropTypes.number, - onTextSearchStart: funcProp<() => void>(), - onTextSearchResult: funcProp<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), + onTextSearchStart: func<() => void>(), + onTextSearchResult: func<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), hideViewModeItems: arrayOfProp(Config.ViewModePickerItem), pageStackEnabled: PropTypes.bool, showQuickNavigationButton: PropTypes.bool, @@ -111,7 +111,7 @@ const propTypes = { userBookmarksListEditingEnabled: PropTypes.bool, imageInReflowEnabled: PropTypes.bool, reflowOrientation: oneOfProp(Config.ReflowOrientation), - onUndoRedoStateChanged: funcProp<() => void>(), + onUndoRedoStateChanged: func<() => void>(), tabletLayoutEnabled: PropTypes.bool, initialToolbar: PropTypes.string, inkMultiStrokeEnabled: PropTypes.bool, @@ -130,8 +130,8 @@ type DocumentViewProps = PropTypes.InferProps; // Creates a custom PropType for functions. // When the prop types are generated for TS users, type checking for // function parameters and return values is provided. -// Usage: funcProp<(arg: argType) => returnType>() -function funcProp () : Requireable { +// Usage: func<(arg: argType) => returnType>() +function func () : Requireable { // Creates a validator, similar to Validator from prop-types. let validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error | null{ From 96daddb3a8d4bb3cf3b54b37fc5743a0f7751bab Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 11:13:24 -0700 Subject: [PATCH 058/226] arrayOfProp to arrayOf --- src/DocumentView/DocumentView.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index ad65a625e..3b7d82ac3 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -30,17 +30,17 @@ const propTypes = { onZoomChanged: func<(event: {zoom: number}) => void>(), onZoomFinished: func<(event: {zoom: number}) => void>(), zoom: PropTypes.number, - disabledElements: arrayOfProp(Config.Buttons), - disabledTools: arrayOfProp(Config.Tools), - longPressMenuItems: arrayOfProp(Config.LongPressMenu), - overrideLongPressMenuBehavior: arrayOfProp(Config.LongPressMenu), + disabledElements: arrayOf(Config.Buttons), + disabledTools: arrayOf(Config.Tools), + longPressMenuItems: arrayOf(Config.LongPressMenu), + overrideLongPressMenuBehavior: arrayOf(Config.LongPressMenu), onLongPressMenuPress: func<(event: {longPressMenu: string, longPressText: string}) => void>(), longPressMenuEnabled: PropTypes.bool, - annotationMenuItems: arrayOfProp(Config.AnnotationMenu), - overrideAnnotationMenuBehavior: arrayOfProp(Config.AnnotationMenu), + annotationMenuItems: arrayOf(Config.AnnotationMenu), + overrideAnnotationMenuBehavior: arrayOf(Config.AnnotationMenu), onAnnotationMenuPress: func<(event: {annotationMenu: string, annotations: Array}) => void>(), - hideAnnotationMenu: arrayOfProp(Config.Tools), - overrideBehavior: arrayOfProp(Config.Actions), + hideAnnotationMenu: arrayOf(Config.Tools), + overrideBehavior: arrayOf(Config.Actions), onBehaviorActivated: func<(event: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), topToolbarEnabled: PropTypes.bool, bottomToolbarEnabled: PropTypes.bool, @@ -87,20 +87,20 @@ const propTypes = { ])).isRequired }) ])), - hideDefaultAnnotationToolbars: arrayOfProp(Config.DefaultToolbars), - topAppNavBarRightBar: arrayOfProp(Config.Buttons), - bottomToolbar: arrayOfProp(Config.Buttons), + hideDefaultAnnotationToolbars: arrayOf(Config.DefaultToolbars), + topAppNavBarRightBar: arrayOf(Config.Buttons), + bottomToolbar: arrayOf(Config.Buttons), hideAnnotationToolbarSwitcher: PropTypes.bool, hideTopToolbars: PropTypes.bool, hideTopAppNavBar: PropTypes.bool, onBookmarkChanged: func<(event: {bookmarkJson: string}) => void>(), - hideThumbnailFilterModes: arrayOfProp(Config.ThumbnailFilterMode), + hideThumbnailFilterModes: arrayOf(Config.ThumbnailFilterMode), onToolChanged: func<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), horizontalScrollPos: PropTypes.number, verticalScrollPos: PropTypes.number, onTextSearchStart: func<() => void>(), onTextSearchResult: func<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), - hideViewModeItems: arrayOfProp(Config.ViewModePickerItem), + hideViewModeItems: arrayOf(Config.ViewModePickerItem), pageStackEnabled: PropTypes.bool, showQuickNavigationButton: PropTypes.bool, photoPickerEnabled: PropTypes.bool, @@ -149,7 +149,7 @@ function oneOfProp(val : object) : Requireable { return PropTypes.oneOf(Object.values(val)); } -function arrayOfProp(val : object) : Requireable { +function arrayOf(val : object) : Requireable { return PropTypes.arrayOf(oneOfProp(val)); } export class DocumentView extends PureComponent { From 3e88fe82fd557378a635a9d2e0b57b07275e15c3 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 11:14:51 -0700 Subject: [PATCH 059/226] oneOfProp to oneOf --- src/DocumentView/DocumentView.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 3b7d82ac3..31d1fd095 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -53,8 +53,8 @@ const propTypes = { onFormFieldValueChanged: func<(event: {fields: Array}) => void>(), readOnly: PropTypes.bool, thumbnailViewEditingEnabled: PropTypes.bool, - fitMode: oneOfProp(Config.FitMode), - layoutMode: oneOfProp(Config.LayoutMode), + fitMode: oneOf(Config.FitMode), + layoutMode: oneOf(Config.LayoutMode), onLayoutChanged: func<() => void>(), padStatusBar: PropTypes.bool, continuousAnnotationEditing: PropTypes.bool, @@ -76,14 +76,14 @@ const propTypes = { signSignatureFieldsWithStamps: PropTypes.bool, annotationPermissionCheckEnabled: PropTypes.bool, annotationToolbars: PropTypes.arrayOf(PropTypes.oneOfType([ - oneOfProp(Config.DefaultToolbars), + oneOf(Config.DefaultToolbars), PropTypes.exact({ id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, - icon: oneOfProp(Config.ToolbarIcons).isRequired, + icon: oneOf(Config.ToolbarIcons).isRequired, items: PropTypes.arrayOf(PropTypes.oneOfType([ - oneOfProp(Config.Tools), - oneOfProp(Config.Buttons) + oneOf(Config.Tools), + oneOf(Config.Buttons) ])).isRequired }) ])), @@ -110,12 +110,12 @@ const propTypes = { restrictDownloadUsage: PropTypes.bool, userBookmarksListEditingEnabled: PropTypes.bool, imageInReflowEnabled: PropTypes.bool, - reflowOrientation: oneOfProp(Config.ReflowOrientation), + reflowOrientation: oneOf(Config.ReflowOrientation), onUndoRedoStateChanged: func<() => void>(), tabletLayoutEnabled: PropTypes.bool, initialToolbar: PropTypes.string, inkMultiStrokeEnabled: PropTypes.bool, - defaultEraserType: oneOfProp(Config.EraserType), + defaultEraserType: oneOf(Config.EraserType), exportPath: PropTypes.string, openUrlPath: PropTypes.string, hideScrollbars: PropTypes.bool, @@ -145,12 +145,12 @@ function func () : Requireable { return t; } -function oneOfProp(val : object) : Requireable { +function oneOf(val : object) : Requireable { return PropTypes.oneOf(Object.values(val)); } function arrayOf(val : object) : Requireable { - return PropTypes.arrayOf(oneOfProp(val)); + return PropTypes.arrayOf(oneOf(val)); } export class DocumentView extends PureComponent { From 3b3bd83004a3226db448d20337d54ef774537835 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 11:29:57 -0700 Subject: [PATCH 060/226] use Validator, add JSDocs for functions --- src/DocumentView/DocumentView.tsx | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 31d1fd095..4766e9df9 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import PropTypes, { Requireable } from 'prop-types'; +import PropTypes, { Requireable, Validator } from 'prop-types'; import { requireNativeComponent, ViewPropTypes, @@ -124,34 +124,47 @@ const propTypes = { ...ViewPropTypes, }; -// Generates the prop types for TypeScript users, from PropTypes. +/** Generates the prop types for TypeScript users, from PropTypes. */ type DocumentViewProps = PropTypes.InferProps; -// Creates a custom PropType for functions. -// When the prop types are generated for TS users, type checking for -// function parameters and return values is provided. -// Usage: func<(arg: argType) => returnType>() +/** +* Creates a custom PropType for functions. +* +* If the resulting PropType is used to generate prop types for TS users, +* type checking for function parameters and return values will be provided. +* Usage: func<(arg: argType) => returnType>() +*/ function func () : Requireable { - - // Creates a validator, similar to Validator from prop-types. - let validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error | null{ + + let validator : Validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error | null { if (typeof props[propName] !== "function" && typeof props[propName] !== "undefined") { return new Error ("Invalid prop `" + propName + "` of type `" + typeof props[propName] + "` supplied to `" + componentName + "`, expected a function"); } } const t : Requireable = validator as Requireable; - t.isRequired = validator; + t.isRequired = validator as Validator>; return t; } +/** + * Returns a PropType representing any value from a given object. + * @param {object} val + * @returns {Requireable} +*/ function oneOf(val : object) : Requireable { return PropTypes.oneOf(Object.values(val)); } +/** + * Returns a PropType representing any array containing values from a given object. + * @param {object} val + * @returns {Requireable(val : object) : Requireable { return PropTypes.arrayOf(oneOf(val)); } + export class DocumentView extends PureComponent { _viewerRef; From f1d24ce8f4cb93d0e11d2dcd39dfa5af5e73f990 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 11:43:08 -0700 Subject: [PATCH 061/226] Edit comments, rename param val to obj --- src/DocumentView/DocumentView.tsx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 4766e9df9..f3fef6852 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -124,7 +124,7 @@ const propTypes = { ...ViewPropTypes, }; -/** Generates the prop types for TypeScript users, from PropTypes. */ +// Generates the prop types for TypeScript users, from PropTypes. type DocumentViewProps = PropTypes.InferProps; /** @@ -132,6 +132,7 @@ type DocumentViewProps = PropTypes.InferProps; * * If the resulting PropType is used to generate prop types for TS users, * type checking for function parameters and return values will be provided. +* * Usage: func<(arg: argType) => returnType>() */ function func () : Requireable { @@ -148,21 +149,21 @@ function func () : Requireable { } /** - * Returns a PropType representing any value from a given object. - * @param {object} val - * @returns {Requireable} + * Returns a custom PropType representing any value from a given object. + * @param {object} obj An object containing values. + * @returns {Requireable} A custom PropType constant. */ -function oneOf(val : object) : Requireable { - return PropTypes.oneOf(Object.values(val)); +function oneOf(obj : object) : Requireable { + return PropTypes.oneOf(Object.values(obj)); } /** - * Returns a PropType representing any array containing values from a given object. - * @param {object} val - * @returns {Requireable(val : object) : Requireable { - return PropTypes.arrayOf(oneOf(val)); +function arrayOf(obj : object) : Requireable { + return PropTypes.arrayOf(oneOf(obj)); } export class DocumentView extends PureComponent { From 9427de9e6220439c77477b41c39b7dc9118c1366 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 11:44:34 -0700 Subject: [PATCH 062/226] edit comments --- src/DocumentView/DocumentView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index f3fef6852..391245141 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -134,6 +134,7 @@ type DocumentViewProps = PropTypes.InferProps; * type checking for function parameters and return values will be provided. * * Usage: func<(arg: argType) => returnType>() +* @returns {Requireable} A custom PropType constant. */ function func () : Requireable { From 16b6f5cf9c2c7adaf82dade8a62aa2c81ad24cd0 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 13:33:10 -0700 Subject: [PATCH 063/226] Refactor and add JSDoc * Add JSDoc for propTypes for dev use * Use arrayOf for custom annotationToolbars items * Use template literal for validator Error string --- src/DocumentView/DocumentView.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 391245141..e69b303c2 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -3,7 +3,6 @@ import PropTypes, { Requireable, Validator } from 'prop-types'; import { requireNativeComponent, ViewPropTypes, - ViewProps, Platform, Alert, NativeModules, @@ -13,6 +12,14 @@ const { DocumentViewManager } = NativeModules; import {Config} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; +/** + * Object containing PropTypes types for {@link DocumentView} class. + * Also used to generate prop types for TS users. + * + * To represent functions, please use {@link func}. + * To represent "one of Config.Buttons values" or "an array of + * Config.Buttons values", please use {@link oneOf} or {@link arrayOf}. + */ const propTypes = { document: PropTypes.string.isRequired, onChange: func<(event : any) => void>(), @@ -81,10 +88,7 @@ const propTypes = { id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, icon: oneOf(Config.ToolbarIcons).isRequired, - items: PropTypes.arrayOf(PropTypes.oneOfType([ - oneOf(Config.Tools), - oneOf(Config.Buttons) - ])).isRequired + items: arrayOf(Object.assign({}, Config.Tools, Config.Buttons)).isRequired }) ])), hideDefaultAnnotationToolbars: arrayOf(Config.DefaultToolbars), @@ -140,7 +144,7 @@ function func () : Requireable { let validator : Validator = function (props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) : Error | null { if (typeof props[propName] !== "function" && typeof props[propName] !== "undefined") { - return new Error ("Invalid prop `" + propName + "` of type `" + typeof props[propName] + "` supplied to `" + componentName + "`, expected a function"); + return new Error (`Invalid prop \`${propName}\` of type \`${typeof props[propName]}\` supplied to \`${componentName}\`, expected a function.`); } } From 64f13d04220115331c0eca0b4acfa11d0a39614c Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 14:39:11 -0700 Subject: [PATCH 064/226] make oneOf, arrayOf accept multiple objects --- src/DocumentView/DocumentView.tsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index e69b303c2..13cc0a6fe 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -88,7 +88,7 @@ const propTypes = { id: PropTypes.string.isRequired, name: PropTypes.string.isRequired, icon: oneOf(Config.ToolbarIcons).isRequired, - items: arrayOf(Object.assign({}, Config.Tools, Config.Buttons)).isRequired + items: arrayOf(Config.Tools, Config.Buttons).isRequired }) ])), hideDefaultAnnotationToolbars: arrayOf(Config.DefaultToolbars), @@ -154,21 +154,31 @@ function func () : Requireable { } /** - * Returns a custom PropType representing any value from a given object. + * Returns a custom PropType representing any value from given object(s). * @param {object} obj An object containing values. + * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. */ -function oneOf(obj : object) : Requireable { - return PropTypes.oneOf(Object.values(obj)); +function oneOf(obj: object, ...rest: object[]) : Requireable { + if (rest.length > 0) { + return PropTypes.oneOf(Object.values(Object.assign({}, obj, rest.values))); + } else { + return PropTypes.oneOf(Object.values(obj)); + } } /** - * Returns a custom PropType representing any array containing values from a given object. + * Returns a custom PropType representing any array containing values from given object(s). * @param {object} obj An object containing values. - * @returns {Requireable} A custom PropType constant. */ -function arrayOf(obj : object) : Requireable { - return PropTypes.arrayOf(oneOf(obj)); +function arrayOf(obj: object, ...rest: object[]) : Requireable { + if (rest.length > 0) { + return PropTypes.arrayOf(oneOf(Object.assign({}, obj, rest.values))); + } else { + return PropTypes.arrayOf(oneOf(obj)); + } } export class DocumentView extends PureComponent { From e04eeb7ecaf19eb0b9319c6d7a4357bd20a948e1 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 14:58:29 -0700 Subject: [PATCH 065/226] make oneOf, arrayOf accept multiple values --- src/DocumentView/DocumentView.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 13cc0a6fe..90abb1b30 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -161,7 +161,9 @@ function func () : Requireable { */ function oneOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { - return PropTypes.oneOf(Object.values(Object.assign({}, obj, rest.values))); + let temp: object = Object.assign({}, obj); + rest.forEach((val: object) => { Object.assign(temp, val)}); + return PropTypes.oneOf(Object.values(temp)); } else { return PropTypes.oneOf(Object.values(obj)); } @@ -175,7 +177,9 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { */ function arrayOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { - return PropTypes.arrayOf(oneOf(Object.assign({}, obj, rest.values))); + let temp: object = Object.assign({}, obj); + rest.forEach((val: object) => { Object.assign(temp, val)}); + return PropTypes.arrayOf(oneOf(temp)); } else { return PropTypes.arrayOf(oneOf(obj)); } From 732e8b6fc0504aeb5625628257ec20e8ebc2972c Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 15:04:07 -0700 Subject: [PATCH 066/226] simplify oneOf, arrayOf --- src/DocumentView/DocumentView.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 90abb1b30..9f2d789aa 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -161,9 +161,7 @@ function func () : Requireable { */ function oneOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { - let temp: object = Object.assign({}, obj); - rest.forEach((val: object) => { Object.assign(temp, val)}); - return PropTypes.oneOf(Object.values(temp)); + return PropTypes.oneOf(Object.values(Object.assign({}, obj, ...rest))); } else { return PropTypes.oneOf(Object.values(obj)); } @@ -177,14 +175,11 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { */ function arrayOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { - let temp: object = Object.assign({}, obj); - rest.forEach((val: object) => { Object.assign(temp, val)}); - return PropTypes.arrayOf(oneOf(temp)); + return PropTypes.arrayOf(oneOf(Object.assign({}, obj, ...rest))); } else { return PropTypes.arrayOf(oneOf(obj)); } } - export class DocumentView extends PureComponent { _viewerRef; From a97332609f9ee59b6f1bb71acd51fafc4bb1bf02 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 15:13:13 -0700 Subject: [PATCH 067/226] refactor, edit comments --- src/DocumentView/DocumentView.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 9f2d789aa..f0fc53362 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -154,7 +154,7 @@ function func () : Requireable { } /** - * Returns a custom PropType representing any value from given object(s). + * Creates a custom PropType representing any value from given object(s). * @param {object} obj An object containing values. * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. @@ -162,13 +162,12 @@ function func () : Requireable { function oneOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { return PropTypes.oneOf(Object.values(Object.assign({}, obj, ...rest))); - } else { - return PropTypes.oneOf(Object.values(obj)); } + return PropTypes.oneOf(Object.values(obj)); } /** - * Returns a custom PropType representing any array containing values from given object(s). + * Creates a custom PropType representing any array containing values from given object(s). * @param {object} obj An object containing values. * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. @@ -176,9 +175,8 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { function arrayOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { return PropTypes.arrayOf(oneOf(Object.assign({}, obj, ...rest))); - } else { - return PropTypes.arrayOf(oneOf(obj)); } + return PropTypes.arrayOf(oneOf(obj)); } export class DocumentView extends PureComponent { From f868a2c79a4ffb4548ba312e68b0813e19e497c4 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 16:07:50 -0700 Subject: [PATCH 068/226] Simplify arrayOf --- src/DocumentView/DocumentView.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index f0fc53362..247770bd1 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -173,10 +173,7 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { * @returns {Requireable} A custom PropType constant. */ function arrayOf(obj: object, ...rest: object[]) : Requireable { - if (rest.length > 0) { - return PropTypes.arrayOf(oneOf(Object.assign({}, obj, ...rest))); - } - return PropTypes.arrayOf(oneOf(obj)); + return PropTypes.arrayOf(oneOf(obj, ...rest)); } export class DocumentView extends PureComponent { From 210bc33332b16b46ad6a03f08409bcb6bfe0deb4 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 16:10:51 -0700 Subject: [PATCH 069/226] Add pull_request to build event triggers --- .github/workflows/jsBuilder.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jsBuilder.yml b/.github/workflows/jsBuilder.yml index 8dfad4f40..313d8ea40 100644 --- a/.github/workflows/jsBuilder.yml +++ b/.github/workflows/jsBuilder.yml @@ -1,8 +1,7 @@ name: Transpile TS -on: - push: - branches: [ts-support-js-to-ts] # <-- Change this to whatever the primary branch is (ex: master) +on: [push, pull_request] + branches: [ts-support-js-to-ts] # <-- Change this to whatever the primary branch is (ex: master) jobs: build: From 022277ac293376fb52cd8a307993bcab56ec1170 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 16:17:40 -0700 Subject: [PATCH 070/226] Revert "Add pull_request to build event triggers" This reverts commit 210bc33332b16b46ad6a03f08409bcb6bfe0deb4. --- .github/workflows/jsBuilder.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jsBuilder.yml b/.github/workflows/jsBuilder.yml index 313d8ea40..8dfad4f40 100644 --- a/.github/workflows/jsBuilder.yml +++ b/.github/workflows/jsBuilder.yml @@ -1,7 +1,8 @@ name: Transpile TS -on: [push, pull_request] - branches: [ts-support-js-to-ts] # <-- Change this to whatever the primary branch is (ex: master) +on: + push: + branches: [ts-support-js-to-ts] # <-- Change this to whatever the primary branch is (ex: master) jobs: build: From 91b94d1da1b546091196fb600f4ced9f8bfd021d Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 16:28:57 -0700 Subject: [PATCH 071/226] Add JSDoc examples --- src/DocumentView/DocumentView.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 247770bd1..42bfcb6de 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -136,8 +136,8 @@ type DocumentViewProps = PropTypes.InferProps; * * If the resulting PropType is used to generate prop types for TS users, * type checking for function parameters and return values will be provided. -* -* Usage: func<(arg: argType) => returnType>() +* @example +* func<(path: string) => void>() * @returns {Requireable} A custom PropType constant. */ function func () : Requireable { @@ -158,6 +158,10 @@ function func () : Requireable { * @param {object} obj An object containing values. * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. + * + * @example + * oneOf(Config.Tools) + * oneOf(Config.Tools, Config.Buttons) */ function oneOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { @@ -171,6 +175,10 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { * @param {object} obj An object containing values. * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. + * + * @example + * arrayOf(Config.Tools) + * arrayOf(Config.Tools, Config.Buttons) */ function arrayOf(obj: object, ...rest: object[]) : Requireable { return PropTypes.arrayOf(oneOf(obj, ...rest)); From 815d25d93ee5669379957ba20438514b36940a23 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 11 Aug 2021 17:45:59 -0700 Subject: [PATCH 072/226] Edit JSDocs --- src/DocumentView/DocumentView.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 4d05c4605..786a83f25 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -139,9 +139,9 @@ type DocumentViewProps = PropTypes.InferProps; * * If the resulting PropType is used to generate prop types for TS users, * type checking for function parameters and return values will be provided. +* @returns {Requireable} A custom PropType constant. * @example * func<(path: string) => void>() -* @returns {Requireable} A custom PropType constant. */ function func () : Requireable { @@ -161,7 +161,6 @@ function func () : Requireable { * @param {object} obj An object containing values. * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. - * * @example * oneOf(Config.Tools) * oneOf(Config.Tools, Config.Buttons) @@ -178,7 +177,6 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { * @param {object} obj An object containing values. * @param {...object} rest Indefinite number of other objects containing values. * @returns {Requireable} A custom PropType constant. - * * @example * arrayOf(Config.Tools) * arrayOf(Config.Tools, Config.Buttons) From e2b3b495a0e4b0676ba0c284c5662be4fef51ce7 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 12 Aug 2021 13:31:38 -0700 Subject: [PATCH 073/226] Return null at end of validator function * also specify onChange event type --- package-lock.json | 2 +- src/DocumentView/DocumentView.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a276e8e02..624a57609 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-native-pdftron", - "version": "2.0.3-beta.149", + "version": "2.0.3-beta.166", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 786a83f25..57664fed4 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -149,6 +149,7 @@ function func () : Requireable { if (typeof props[propName] !== "function" && typeof props[propName] !== "undefined") { return new Error (`Invalid prop \`${propName}\` of type \`${typeof props[propName]}\` supplied to \`${componentName}\`, expected a function.`); } + return null; } const t : Requireable = validator as Requireable; @@ -190,7 +191,7 @@ export class DocumentView extends PureComponent { static propTypes = propTypes; - onChange = (event) => { + onChange = (event: any) => { if (event.nativeEvent.onLeadingNavButtonPressed) { if (this.props.onLeadingNavButtonPressed) { this.props.onLeadingNavButtonPressed(); From 520585869124828d9b40e3153ea4bbbaf9b60754 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 12 Aug 2021 20:10:54 -0700 Subject: [PATCH 074/226] remove onChange from propTypes & clean comments --- src/DocumentView/DocumentView.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 57664fed4..7c2e91260 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -22,7 +22,6 @@ import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; */ const propTypes = { document: PropTypes.string.isRequired, - onChange: func<(event : any) => void>(), password: PropTypes.string, initialPageNumber: PropTypes.number, pageNumber: PropTypes.number, @@ -507,7 +506,7 @@ export class DocumentView extends PureComponent { * */ setPropertyForAnnotation = (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties): Promise => { - return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); // check this._viewerRef + return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); } setPropertiesForAnnotation = (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties): Promise => { @@ -1073,7 +1072,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - _setNativeRef = (ref) => { // check ref type. + _setNativeRef = (ref) => { this._viewerRef = ref; }; @@ -1082,7 +1081,8 @@ export class DocumentView extends PureComponent { ) From fb3a280296eeaf8d4de7fce27458e6af5aeafbee Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 13 Aug 2021 09:57:08 -0700 Subject: [PATCH 075/226] Refactor methods to use one Promise --- src/DocumentView/DocumentView.tsx | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 7c2e91260..0092936ce 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -324,7 +324,7 @@ export class DocumentView extends PureComponent { // Methods - getDocumentPath = (): Promise | Promise => { + getDocumentPath = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getDocumentPath(tag); @@ -341,7 +341,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - commitTool = (): Promise | Promise => { + commitTool = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.commitTool(tag); @@ -349,7 +349,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageCount = (): Promise | Promise => { + getPageCount = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageCount(tag); @@ -396,7 +396,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAnnotations = (options?: {annotList: Array}): Promise | Promise => { + exportAnnotations = (options?: {annotList: Array}): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAnnotations(tag, options); @@ -420,7 +420,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - saveDocument = (): Promise | Promise => { + saveDocument = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.saveDocument(tag); @@ -436,7 +436,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getField = (fieldName: string): Promise | Promise<{fieldName: string, fieldValue?: any, fieldType?: string}> => { + getField = (fieldName: string): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.getField(tag, fieldName); @@ -468,7 +468,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - handleBackButton = (): Promise | Promise => { + handleBackButton = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.handleBackButton(tag); @@ -517,7 +517,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPropertiesForAnnotation = (id: string, pageNumber: number): Promise | Promise => { + getPropertiesForAnnotation = (id: string, pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); @@ -549,7 +549,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationAtPoint = (x: number, y: number, distanceThreshold: number, minimumLineWeight: number): Promise | Promise => { + getAnnotationAtPoint = (x: number, y: number, distanceThreshold: number, minimumLineWeight: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); @@ -557,7 +557,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationListAt = (x1: number, y1: number, x2: number, y2: number): Promise | Promise> => { + getAnnotationListAt = (x1: number, y1: number, x2: number, y2: number): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); @@ -565,7 +565,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationsOnPage = (pageNumber: number): Promise | Promise> => { + getAnnotationsOnPage = (pageNumber: number): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); @@ -573,7 +573,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getCustomDataForAnnotation = (annotationID: string, pageNumber: number, key: string): Promise | Promise => { + getCustomDataForAnnotation = (annotationID: string, pageNumber: number, key: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); @@ -581,7 +581,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageCropBox = (pageNumber: number): Promise | Promise => { + getPageCropBox = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageCropBox(tag, pageNumber); @@ -589,7 +589,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setCurrentPage = (pageNumber: number): Promise | Promise => { + setCurrentPage = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setCurrentPage(tag, pageNumber); @@ -597,7 +597,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getVisiblePages = (): Promise | Promise> => { + getVisiblePages = (): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getVisiblePages(tag); @@ -605,7 +605,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoPreviousPage = (): Promise | Promise => { + gotoPreviousPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoPreviousPage(tag); @@ -613,7 +613,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoNextPage = (): Promise | Promise => { + gotoNextPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoNextPage(tag); @@ -621,7 +621,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoFirstPage = (): Promise | Promise => { + gotoFirstPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoFirstPage(tag); @@ -629,7 +629,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoLastPage = (): Promise | Promise => { + gotoLastPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoLastPage(tag); @@ -661,7 +661,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getZoom = (): Promise | Promise => { + getZoom = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getZoom(tag); @@ -701,7 +701,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getScrollPos = (): Promise | Promise<{horizontal: number, vertical: number}> => { + getScrollPos = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getScrollPos(tag); @@ -709,7 +709,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getCanvasSize = (): Promise | Promise<{width: number, height: number}> => { + getCanvasSize = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getCanvasSize(tag); @@ -717,7 +717,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageRotation = (): Promise | Promise => { + getPageRotation = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageRotation(tag); @@ -742,7 +742,7 @@ export class DocumentView extends PureComponent { } - convertScreenPointsToPagePoints = (points: Array): Promise | Promise> => { + convertScreenPointsToPagePoints = (points: Array): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); @@ -750,7 +750,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - convertPagePointsToScreenPoints = (points: Array): Promise | Promise> => { + convertPagePointsToScreenPoints = (points: Array): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); @@ -758,7 +758,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageNumberFromScreenPoint = (x: number, y: number): Promise | Promise => { + getPageNumberFromScreenPoint = (x: number, y: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); @@ -838,7 +838,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getSelection = (pageNumber: number): Promise | Promise => { + getSelection = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getSelection(tag, pageNumber); @@ -846,7 +846,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - hasSelection = (): Promise | Promise => { + hasSelection = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.hasSelection(tag); @@ -862,7 +862,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getSelectionPageRange = (): Promise | Promise<{begin: number, end: number}> => { + getSelectionPageRange = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getSelectionPageRange(tag); @@ -870,7 +870,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - hasSelectionOnPage = (pageNumber: number): Promise | Promise => { + hasSelectionOnPage = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); @@ -879,7 +879,7 @@ export class DocumentView extends PureComponent { } - selectInRect = (rect: AnnotOptions.Rect): Promise | Promise => { + selectInRect = (rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.selectInRect(tag, rect); @@ -887,7 +887,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - isThereTextInRect = (rect: AnnotOptions.Rect): Promise | Promise => { + isThereTextInRect = (rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.isThereTextInRect(tag, rect); @@ -944,7 +944,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise | Promise => { + exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); @@ -968,7 +968,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - canUndo = (): Promise | Promise => { + canUndo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.canUndo(tag); @@ -976,7 +976,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - canRedo = (): Promise | Promise => { + canRedo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.canRedo(tag); @@ -1016,7 +1016,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - isReflowMode = (): Promise | Promise => { + isReflowMode = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.isReflowMode(tag); From af49bce2980047a01046a23081e331741363aa45 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 13 Aug 2021 15:48:26 -0700 Subject: [PATCH 076/226] enable allowSyntheticDefaultImports * minor edit to ts-ignore description --- package-lock.json | 2 +- src/DocumentView/DocumentView.tsx | 2 +- tsconfig.json | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 624a57609..4116865bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-native-pdftron", - "version": "2.0.3-beta.166", + "version": "2.0.3-beta.167", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 0092936ce..d1be62e68 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -1081,7 +1081,7 @@ export class DocumentView extends PureComponent { diff --git a/tsconfig.json b/tsconfig.json index 4b2b803a9..1d93ac4c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "moduleResolution": "Node", "target": "ESNext", "jsx": "react-native", + "allowSyntheticDefaultImports": true, "esModuleInterop": true, "skipLibCheck": true, "declaration": false, From a955b75a33a9b3048d012a247c5c796e5f075091 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 13 Aug 2021 17:34:22 -0700 Subject: [PATCH 077/226] use strict mode --- src/DocumentView/DocumentView.tsx | 6 +++--- tsconfig.json | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index d1be62e68..3217662e2 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -182,11 +182,11 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { * arrayOf(Config.Tools, Config.Buttons) */ function arrayOf(obj: object, ...rest: object[]) : Requireable { - return PropTypes.arrayOf(oneOf(obj, ...rest)); + return PropTypes.arrayOf(oneOf(obj, ...rest)) as Requireable; } export class DocumentView extends PureComponent { - _viewerRef; + _viewerRef: any; static propTypes = propTypes; @@ -1072,7 +1072,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - _setNativeRef = (ref) => { + _setNativeRef = (ref: any) => { this._viewerRef = ref; }; diff --git a/tsconfig.json b/tsconfig.json index 1d93ac4c8..67fd9d3c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "skipLibCheck": true, "declaration": false, "outDir": "./lib", + "strict": true, }, "include": ["index.ts", "src/**/*"], "exclude": ["node_modules", "**/*.spec.ts"] From bca96b47e727c6065cf4faaf62688c9513cad4dd Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 17 Aug 2021 09:53:09 -0700 Subject: [PATCH 078/226] Make type-related dependencies any-ver devDependencies --- package.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index af19e4f59..95a13defb 100644 --- a/package.json +++ b/package.json @@ -28,11 +28,9 @@ "prop-types": "*" }, "devDependencies": { - "react": "*" - }, - "dependencies": { - "@types/react": "^17.0.15", - "@types/react-native": "^0.64.12", - "typescript": "^4.3.5" + "react": "*", + "@types/react": "*", + "@types/react-native": "*", + "typescript": "*" } } From a7cc4a97f148c8e8f04f2fef4ed2d34fcec30d70 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 17 Aug 2021 11:08:14 -0700 Subject: [PATCH 079/226] Updated Field interfaces due to changes to master --- CONTRIBUTING.md | 4 ++-- src/AnnotOptions/AnnotOptions.ts | 8 ++------ src/DocumentView/DocumentView.tsx | 14 ++------------ 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20bebbe17..58ed7fc2d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,9 +8,9 @@ ## Pull requests 1. Fork the repository. -2. Create a branch from `master`. +2. Create a branch from `dev`. 3. Update the source code. 4. Commit and push the changes with descriptive messages. -5. Create a pull request to `master`. +5. Create a pull request to `dev`. \* Please note that all pull requests should be tied to an issue, and all but the most trivial pull requests should be discussed beforehand. \ No newline at end of file diff --git a/src/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts index 450b046ad..e97b1cbf5 100644 --- a/src/AnnotOptions/AnnotOptions.ts +++ b/src/AnnotOptions/AnnotOptions.ts @@ -30,12 +30,8 @@ export type RotationDegree = 0 | 90 | 180 | 270; export interface Field { fieldName: string; - fieldValue: string | boolean | number; -} - -export interface FieldWithStringValue { - fieldName: string; - fieldValue: string; + fieldType: string; + fieldValue?: string | boolean | number | undefined; } export interface Point { diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 3217662e2..3ee4d13ca 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -56,7 +56,7 @@ const propTypes = { keyboardShortcutsEnabled: PropTypes.bool, onAnnotationsSelected: func<(event: {annotations: Array}) => void>(), onAnnotationChanged: func<(event: {action: string, annotations: Array}) => void>(), - onFormFieldValueChanged: func<(event: {fields: Array}) => void>(), + onFormFieldValueChanged: func<(event: {fields: Array}) => void>(), readOnly: PropTypes.bool, thumbnailViewEditingEnabled: PropTypes.bool, fitMode: oneOf(Config.FitMode), @@ -1091,14 +1091,4 @@ export class DocumentView extends PureComponent { const name = Platform.OS === 'ios' ? 'RNTPTDocumentView' : 'RCTDocumentView'; - -const RCTDocumentView = requireNativeComponent( // https://github.com/facebook/react-native/issues/28351 - name, - // @ts-ignore - DocumentView, - { - nativeOnly: { - onChange: true - } - } -); +const RCTDocumentView = requireNativeComponent(name); From 6a543161b65a64437b2dd82971e44193b787dd90 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Tue, 17 Aug 2021 11:14:19 -0700 Subject: [PATCH 080/226] Replaced an object type with its primitive version --- src/DocumentView/DocumentView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 3ee4d13ca..14951a120 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -428,7 +428,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { + setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.setFlagForFields(tag, fields, flag, value); From fc725fc75a9de2c65951be7bc5bde7f1486660c3 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 19 Aug 2021 14:42:19 -0700 Subject: [PATCH 081/226] Create npmignore file excl. lib folder --- .npmignore | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 000000000..ba0fcd823 --- /dev/null +++ b/.npmignore @@ -0,0 +1,49 @@ + +# OSX +# +.DS_Store + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + + +# Xcode +# +build/ +Pods/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +example/android/app/src/main/assets/index.android.bundle +example/android/app/src/main/assets/index.android.bundle.meta \ No newline at end of file From ffc88de85e53fb99b67e152b5a1fe1155018c45d Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 19 Aug 2021 19:17:07 -0700 Subject: [PATCH 082/226] Add extra ts-ignore to onChange --- src/DocumentView/DocumentView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index ca1f36e45..16625b746 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -1093,6 +1093,7 @@ export class DocumentView extends PureComponent { render() { return ( + // @ts-ignore Date: Fri, 20 Aug 2021 13:03:34 -0700 Subject: [PATCH 083/226] Updated README and API docs in prep for TS release --- API.md | 4 ++++ README.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/API.md b/API.md index 76665b579..cfdc913fa 100644 --- a/API.md +++ b/API.md @@ -1,5 +1,9 @@ # PDFTron React Native API +## TypeScript + +PDFTron React Native now has support for TypeScript. Since not all customers use the language, the typings used in this document will be described using normal JavaScript types. For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](src). + ## RNPdftron RNPdftron contains static methods for global library initialization, configuration, and utility methods. diff --git a/README.md b/README.md index 672922f22..740e47f88 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ - [API](API.md) - [Prerequisites](#prerequisites) - [Preview](#preview) +- [TypeScript Support](#typescript) - [Installation](#installation) - [Usage](#usage) - [License](#license) @@ -15,6 +16,7 @@ APIs are available on the [API page](API.md). - npm or yarn - PDFTron SDK >= 9.0.0 - react-native >= 0.60.0 +- TypeScript >= 3.4.1 (optional) ## Preview @@ -28,6 +30,33 @@ Version `2.0.2` is the last stable release for the legacy UI. The release can be found here: https://github.com/PDFTron/pdftron-react-native/releases/tag/legacy-ui. +## TypeScript + +PDFTron React Native now has support for TypeScript. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript. + +To get access to this update, simply update your dependencies. + +### All Users + +Regardless of whether you use TypeScript, the following benefits are available: +- Proper typings for our APIs which can be used in tools such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). This offers insight into the data being passed without referring to the [API documentation](API.md). +- Greater type safety and reliability because we have migrated our source files from JavaScript to TypeScript. +- Updated Add an API guides for [Android](https://www.pdftron.com/documentation/android/get-started/react-native/add-an-api/) and [iOS](https://www.pdftron.com/documentation/ios/get-started/react-native/add-an-api) to offer step-by-step, TypeScript-supported examples on accessing properties, methods, and events. Contributors should be aware that PRs will now be made to the `dev` branch (see ). + +If you have questions, head to our FAQ's Integration section for [Android](https://www.pdftron.com/documentation/android/faq) and [iOS](https://www.pdftron.com/documentation/ios/faq/). + +### TypeScript Users + +If you are an existing TypeScript user, then our custom typings will be available to you simply by updating your dependencies. + +Note: +- We recommend that our library is used with at least TypeScript v3.4.1. Although it can be compiled using lower versions, our typings will begin degrading to `any`. +- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings about your usage of these APIs. In most cases these warnings will not break your app but it is advised that you address them to take full advantage of TypeScript. + +### Migrating to TypeScript + +If you would like to migrate, [here](https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project) is a guide on how to add TypeScript to an existing React Native project and [here](https://www.typescriptlang.org/docs/) is documentation for you to learn about the language. + ## Installation 0. If using yarn, do: `yarn global add react-native-cli` From f7dcd81b550166d51073723be43585c45f4c382c Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 20 Aug 2021 13:19:24 -0700 Subject: [PATCH 084/226] Edit TypeScript docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 740e47f88..03ad2dd16 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ The release can be found here: https://github.com/PDFTron/pdftron-react-native/r PDFTron React Native now has support for TypeScript. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript. -To get access to this update, simply update your dependencies. +To get access to this update, simply update your PDFTron React Native dependency to version ___ or higher. ### All Users @@ -51,7 +51,7 @@ If you are an existing TypeScript user, then our custom typings will be availabl Note: - We recommend that our library is used with at least TypeScript v3.4.1. Although it can be compiled using lower versions, our typings will begin degrading to `any`. -- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings about your usage of these APIs. In most cases these warnings will not break your app but it is advised that you address them to take full advantage of TypeScript. +- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings or errors about your usage of these APIs. In most cases these will not break your app but it is advised that you address them to take full advantage of TypeScript. It is particularly important to address them if you use TypeScript to emit files and have enabled `noEmitOnError` in your `tsconfig.json`. ### Migrating to TypeScript From de3a95284ddd6f1ee845dd109785fc45e67d1db2 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 20 Aug 2021 13:31:36 -0700 Subject: [PATCH 085/226] update Installation and Usage with TypeScript --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 03ad2dd16..3603b753b 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ If you would like to migrate, [here](https://reactnative.dev/docs/typescript#add 0. If using yarn, do: `yarn global add react-native-cli` -1. First, follow the official getting started guide on [setting up the React Native environment](https://reactnative.dev/docs/environment-setup), [setting up the iOS and Android environment](https://reactnative.dev/docs/environment-setup), and [creating a React Native project](https://reactnative.dev/docs/environment-setup), the following steps will assume your app is created through `react-native init MyApp`. +1. First, follow the official getting started guide on [setting up the React Native environment](https://reactnative.dev/docs/environment-setup), [setting up the iOS and Android environment](https://reactnative.dev/docs/environment-setup), and [creating a React Native project](https://reactnative.dev/docs/environment-setup). The following steps will assume your app is created through `react-native init MyApp`. This guide also applies if you are using the [TypeScript template](https://reactnative.dev/docs/environment-setup#optional-using-a-specific-version-or-template). 2. In `MyApp` folder, install `react-native-pdftron` by calling: ```shell @@ -177,7 +177,7 @@ If you would like to migrate, [here](https://reactnative.dev/docs/typescript#add + public class MainApplication extends MultiDexApplication implements ReactApplication { ``` -6. Replace `App.js` with what is shown [here](#usage) +6. Replace `App.js` (or `App.tsx`) with what is shown [here](#usage). 7. Finally in the root project directory, run `react-native run-android`. ### iOS @@ -193,13 +193,13 @@ If you would like to migrate, [here](https://reactnative.dev/docs/typescript#add ``` 2. In the `ios` folder, run `pod install`. -3. Replace `App.js` with what is shown [here](#usage). +3. Replace `App.js` (or `App.tsx`) with what is shown [here](#usage). 4. Finally in the root project directory, run `react-native run-ios`. 5. (Optional) If you need a close button icon, you will need to add the PNG resources to `MyApp` as well, i.e. `ic_close_black_24px`. ## Usage -Replace `App.js` with the code below. +Replace `App.js` (or `App.tsx` if you are [using TypeScript](#typescript)) with the code below. If you set your path variable to point to a local storage file, then the `PermissionsAndroid` component is required to ensure that storage permission is properly granted. @@ -229,7 +229,7 @@ import { DocumentView, RNPdftron } from 'react-native-pdftron'; type Props = {}; export default class App extends Component { - constructor(props) { + constructor(props) { // may need to use `props: Props` in TypeScript super(props); // Uses the platform to determine if storage permisions have been automatically granted. From 69ac47b32d1be45395f644b6dc524474b819acf6 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 20 Aug 2021 14:13:45 -0700 Subject: [PATCH 086/226] move TS section of readme --- README.md | 59 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 3603b753b..b0d083533 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,10 @@ - [API](API.md) - [Prerequisites](#prerequisites) - [Preview](#preview) -- [TypeScript Support](#typescript) - [Installation](#installation) - [Usage](#usage) +- [TypeScript](#typescript) +- [Contributing](#contributing) - [License](#license) ## API @@ -16,7 +17,7 @@ APIs are available on the [API page](API.md). - npm or yarn - PDFTron SDK >= 9.0.0 - react-native >= 0.60.0 -- TypeScript >= 3.4.1 (optional) +- TypeScript >= 3.4.1 (optional; see [TypeScript](#typescript)) ## Preview @@ -30,33 +31,6 @@ Version `2.0.2` is the last stable release for the legacy UI. The release can be found here: https://github.com/PDFTron/pdftron-react-native/releases/tag/legacy-ui. -## TypeScript - -PDFTron React Native now has support for TypeScript. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript. - -To get access to this update, simply update your PDFTron React Native dependency to version ___ or higher. - -### All Users - -Regardless of whether you use TypeScript, the following benefits are available: -- Proper typings for our APIs which can be used in tools such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). This offers insight into the data being passed without referring to the [API documentation](API.md). -- Greater type safety and reliability because we have migrated our source files from JavaScript to TypeScript. -- Updated Add an API guides for [Android](https://www.pdftron.com/documentation/android/get-started/react-native/add-an-api/) and [iOS](https://www.pdftron.com/documentation/ios/get-started/react-native/add-an-api) to offer step-by-step, TypeScript-supported examples on accessing properties, methods, and events. Contributors should be aware that PRs will now be made to the `dev` branch (see ). - -If you have questions, head to our FAQ's Integration section for [Android](https://www.pdftron.com/documentation/android/faq) and [iOS](https://www.pdftron.com/documentation/ios/faq/). - -### TypeScript Users - -If you are an existing TypeScript user, then our custom typings will be available to you simply by updating your dependencies. - -Note: -- We recommend that our library is used with at least TypeScript v3.4.1. Although it can be compiled using lower versions, our typings will begin degrading to `any`. -- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings or errors about your usage of these APIs. In most cases these will not break your app but it is advised that you address them to take full advantage of TypeScript. It is particularly important to address them if you use TypeScript to emit files and have enabled `noEmitOnError` in your `tsconfig.json`. - -### Migrating to TypeScript - -If you would like to migrate, [here](https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project) is a guide on how to add TypeScript to an existing React Native project and [here](https://www.typescriptlang.org/docs/) is documentation for you to learn about the language. - ## Installation 0. If using yarn, do: `yarn global add react-native-cli` @@ -348,6 +322,33 @@ const styles = StyleSheet.create({ document="content://..." ``` +## TypeScript + +PDFTron React Native now has support for TypeScript. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript. + +To get access to this update, simply update your PDFTron React Native dependency to version ___ or higher. + +### All Users + +Regardless of whether you use TypeScript, the following benefits are available: +- Proper typings for our APIs which can be used in tools such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). This offers insight into the data being passed without referring to the [API documentation](API.md). +- Greater type safety and reliability because we have migrated our source files from JavaScript to TypeScript. +- Updated Add an API guides for [Android](https://www.pdftron.com/documentation/android/get-started/react-native/add-an-api/) and [iOS](https://www.pdftron.com/documentation/ios/get-started/react-native/add-an-api) to offer step-by-step, TypeScript-supported examples on accessing properties, methods, and events. Contributors should be aware that PRs will now be made to the `dev` branch (see ). + +If you have questions, head to our FAQ's Integration section for [Android](https://www.pdftron.com/documentation/android/faq) and [iOS](https://www.pdftron.com/documentation/ios/faq/). + +### TypeScript Users + +If you are an existing TypeScript user, then our custom typings will be available to you simply by updating your dependencies. + +Note: +- We recommend that our library is used with at least TypeScript v3.4.1. Although it can be compiled using lower versions, our typings will begin degrading to `any`. +- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings or errors about your usage of these APIs. In most cases these will not break your app but it is advised that you address them to take full advantage of TypeScript. It is particularly important to address them if you use TypeScript to emit files and have enabled `noEmitOnError` in your `tsconfig.json`. + +### Migrating to TypeScript + +If you would like to migrate, [here](https://reactnative.dev/docs/typescript#adding-typescript-to-an-existing-project) is a guide on how to add TypeScript to an existing React Native project and [here](https://www.typescriptlang.org/docs/) is documentation for you to learn about the language. + ## Contributing See [Contributing](./CONTRIBUTING.md) From 8855802ed4e8354307bfbf7be401187845d05dda Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 20 Aug 2021 15:39:09 -0700 Subject: [PATCH 087/226] Update TS support version in README, edit CONTRIBUTING --- CONTRIBUTING.md | 5 +++-- README.md | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 58ed7fc2d..66792043f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,8 +9,9 @@ ## Pull requests 1. Fork the repository. 2. Create a branch from `dev`. -3. Update the source code. +3. Update the source code (requires TypeScript). 4. Commit and push the changes with descriptive messages. 5. Create a pull request to `dev`. -\* Please note that all pull requests should be tied to an issue, and all but the most trivial pull requests should be discussed beforehand. \ No newline at end of file +\* Please note that all pull requests should be tied to an issue, and all but the most trivial pull requests should be discussed beforehand. +\*\* Changes made to `dev` will automatically be applied to `master`. \ No newline at end of file diff --git a/README.md b/README.md index b0d083533..f22ddb5fd 100644 --- a/README.md +++ b/README.md @@ -324,16 +324,16 @@ const styles = StyleSheet.create({ ## TypeScript -PDFTron React Native now has support for TypeScript. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript. +PDFTron React Native introduced support for TypeScript in version 3.0.0. This update mainly benefits those who already use TypeScript in their applications. It also provides certain benefits to all customers, including those who use JavaScript without TypeScript. -To get access to this update, simply update your PDFTron React Native dependency to version ___ or higher. +To get access to this update, simply update your PDFTron React Native dependency to version 3.0.0 or higher. ### All Users Regardless of whether you use TypeScript, the following benefits are available: - Proper typings for our APIs which can be used in tools such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). This offers insight into the data being passed without referring to the [API documentation](API.md). - Greater type safety and reliability because we have migrated our source files from JavaScript to TypeScript. -- Updated Add an API guides for [Android](https://www.pdftron.com/documentation/android/get-started/react-native/add-an-api/) and [iOS](https://www.pdftron.com/documentation/ios/get-started/react-native/add-an-api) to offer step-by-step, TypeScript-supported examples on accessing properties, methods, and events. Contributors should be aware that PRs will now be made to the `dev` branch (see ). +- Updated Add an API guides for [Android](https://www.pdftron.com/documentation/android/get-started/react-native/add-an-api/) and [iOS](https://www.pdftron.com/documentation/ios/get-started/react-native/add-an-api) to offer step-by-step, TypeScript-supported examples on accessing properties, methods, and events. Contributors should be aware that PRs will now be made to the `dev` branch (see [Contributing](./CONTRIBUTING.md)). If you have questions, head to our FAQ's Integration section for [Android](https://www.pdftron.com/documentation/android/faq) and [iOS](https://www.pdftron.com/documentation/ios/faq/). From 2a3c5b90ebfb3271ab78491acecc60ee365acbc7 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 20 Aug 2021 16:25:32 -0700 Subject: [PATCH 088/226] Remove extraneous args from PDFViewCtrl requireNativeComponent --- src/PDFViewCtrl/PDFViewCtrl.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx index 48ef4e737..17558a0c4 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.tsx +++ b/src/PDFViewCtrl/PDFViewCtrl.tsx @@ -37,5 +37,4 @@ var iface = { const name = Platform.OS === 'ios' ? 'RNTPTPDFViewCtrl' : 'RCTPDFViewCtrl'; -// @ts-ignore -const RCTPDFViewCtrl = requireNativeComponent(name, PDFViewCtrl, iface); // https://github.com/facebook/react-native/issues/28351 \ No newline at end of file +const RCTPDFViewCtrl = requireNativeComponent(name); \ No newline at end of file From 0ea796c48efef6d3f57470cb380f066a26e49320 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 20 Aug 2021 16:28:13 -0700 Subject: [PATCH 089/226] Remove unused object --- src/PDFViewCtrl/PDFViewCtrl.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx index 17558a0c4..b7da00618 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.tsx +++ b/src/PDFViewCtrl/PDFViewCtrl.tsx @@ -27,14 +27,6 @@ export class PDFViewCtrl extends PureComponent { } } -var iface = { - name: 'PDFViewCtrl', - propTypes: { - document: PropTypes.string, - ...ViewPropTypes, // include the default view properties - }, -}; - const name = Platform.OS === 'ios' ? 'RNTPTPDFViewCtrl' : 'RCTPDFViewCtrl'; const RCTPDFViewCtrl = requireNativeComponent(name); \ No newline at end of file From bd9f954b60b3abbdeeea74468019c4aea00258e9 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 20 Aug 2021 16:43:21 -0700 Subject: [PATCH 090/226] Updated PDFViewCtrl to match DocumentView --- src/PDFViewCtrl/PDFViewCtrl.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx index b7da00618..76654b417 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.tsx +++ b/src/PDFViewCtrl/PDFViewCtrl.tsx @@ -1,22 +1,22 @@ import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; +import PropTypes, { InferProps } from 'prop-types'; import { requireNativeComponent, - ViewProps, ViewPropTypes, - Dimensions, Platform } from 'react-native'; -const { height, width } = Dimensions.get('window'); - -export interface PDFViewCtrlProps extends ViewProps { // needed to add style to props - document: string; - style?: object; +const propTypes = { + document: PropTypes.string, + ...ViewPropTypes, } +type PDFViewCtrlProps = InferProps; + export class PDFViewCtrl extends PureComponent { + static propTypes = propTypes; + render() { return ( Date: Tue, 24 Aug 2021 11:15:20 -0700 Subject: [PATCH 091/226] Made document a required prop in PDFViewCtrl --- src/PDFViewCtrl/PDFViewCtrl.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx index 76654b417..8ac973fe4 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.tsx +++ b/src/PDFViewCtrl/PDFViewCtrl.tsx @@ -7,7 +7,7 @@ import { } from 'react-native'; const propTypes = { - document: PropTypes.string, + document: PropTypes.string.isRequired, ...ViewPropTypes, } From c31341c7f86c7af84d118f29de6c83ce28e6fd4f Mon Sep 17 00:00:00 2001 From: akwanpdf <83605632+akwanpdf@users.noreply.github.com> Date: Tue, 24 Aug 2021 14:49:31 -0700 Subject: [PATCH 092/226] (test) Add a prestart script (#372) * Add prestart script to generate JS files * Change branch where we want builds to be --- .github/workflows/jsBuilder.yml | 2 +- example/package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jsBuilder.yml b/.github/workflows/jsBuilder.yml index 8dfad4f40..573a107c7 100644 --- a/.github/workflows/jsBuilder.yml +++ b/.github/workflows/jsBuilder.yml @@ -39,4 +39,4 @@ jobs: with: force: true github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ts-support # <-- Change this to the new branch where you want builds to be \ No newline at end of file + branch: ts-master # <-- Change this to the new branch where you want builds to be \ No newline at end of file diff --git a/example/package.json b/example/package.json index 698f786b2..3a16236d1 100644 --- a/example/package.json +++ b/example/package.json @@ -5,6 +5,7 @@ "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", + "prestart": "cd node_modules/react-native-pdftron && npm start && cd ../../", "start": "react-native start", "test": "jest", "lint": "eslint ." From 91a2e2672bc2f9dd38c1867cbdfaa6d5aecac24f Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 24 Aug 2021 16:46:49 -0700 Subject: [PATCH 093/226] Added/edited minor details/wording --- CONTRIBUTING.md | 4 ++-- README.md | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 66792043f..f5eae8012 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,9 +9,9 @@ ## Pull requests 1. Fork the repository. 2. Create a branch from `dev`. -3. Update the source code (requires TypeScript). +3. Update the source code (in `*.ts` files). 4. Commit and push the changes with descriptive messages. 5. Create a pull request to `dev`. \* Please note that all pull requests should be tied to an issue, and all but the most trivial pull requests should be discussed beforehand. -\*\* Changes made to `dev` will automatically be applied to `master`. \ No newline at end of file +\*\* Changes made to `dev` will automatically be applied to `master`. For more detailed information on developing post-TypeScript migration, see the wiki. \ No newline at end of file diff --git a/README.md b/README.md index f22ddb5fd..25d081f5f 100644 --- a/README.md +++ b/README.md @@ -330,6 +330,8 @@ To get access to this update, simply update your PDFTron React Native dependency ### All Users +For non-TypeScript users, this update will not automatically install TypeScript, and they can continue to use the library as before. + Regardless of whether you use TypeScript, the following benefits are available: - Proper typings for our APIs which can be used in tools such as [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). This offers insight into the data being passed without referring to the [API documentation](API.md). - Greater type safety and reliability because we have migrated our source files from JavaScript to TypeScript. @@ -343,7 +345,7 @@ If you are an existing TypeScript user, then our custom typings will be availabl Note: - We recommend that our library is used with at least TypeScript v3.4.1. Although it can be compiled using lower versions, our typings will begin degrading to `any`. -- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings or errors about your usage of these APIs. In most cases these will not break your app but it is advised that you address them to take full advantage of TypeScript. It is particularly important to address them if you use TypeScript to emit files and have enabled `noEmitOnError` in your `tsconfig.json`. +- Due to the introduction of proper typings to PDFTron's APIs, your compiler may now give warnings or errors about your usage of these APIs. In most cases these will not prevent your app from running but it is advised that you address them to take full advantage of TypeScript. It is particularly important to address them if you use TypeScript to emit files and have enabled `noEmitOnError` in your `tsconfig.json`. ### Migrating to TypeScript From 9075dccbfbeab5c0a00bfbbc8eefbbac722a0f82 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 25 Aug 2021 17:56:01 -0700 Subject: [PATCH 094/226] Add preandroid and preios scripts to generate lib --- example/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/package.json b/example/package.json index 3a16236d1..c547258db 100644 --- a/example/package.json +++ b/example/package.json @@ -3,7 +3,9 @@ "version": "0.0.1", "private": true, "scripts": { + "preandroid": "cd node_modules/react-native-pdftron && npm start && cd ../../", "android": "react-native run-android", + "preios": "cd node_modules/react-native-pdftron && npm start && cd ../../", "ios": "react-native run-ios", "prestart": "cd node_modules/react-native-pdftron && npm start && cd ../../", "start": "react-native start", From 706d86d01ec7e5c94d5b1fce228b0dc02d7c23e8 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Wed, 25 Aug 2021 18:06:18 -0700 Subject: [PATCH 095/226] Removed rect from the Annotation interface --- src/AnnotOptions/AnnotOptions.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts index e97b1cbf5..4d5017629 100644 --- a/src/AnnotOptions/AnnotOptions.ts +++ b/src/AnnotOptions/AnnotOptions.ts @@ -4,7 +4,6 @@ export interface Annotation { id: string; pageNumber?: number; type?: string; - rect?: Rect; pageRect?: Rect; screenRect?: Rect; } From 1c446f1be24b4e6319f54ddcf0ebb6d8cc77416b Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 26 Aug 2021 11:18:32 -0700 Subject: [PATCH 096/226] Removed PointWithPage interface --- src/AnnotOptions/AnnotOptions.ts | 3 --- src/DocumentView/DocumentView.tsx | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts index 4d5017629..6b9b4d9df 100644 --- a/src/AnnotOptions/AnnotOptions.ts +++ b/src/AnnotOptions/AnnotOptions.ts @@ -36,9 +36,6 @@ export interface Field { export interface Point { x: number; y: number; -} - -export interface PointWithPage extends Point { pageNumber?: number; } diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 16625b746..d8fdcc3d0 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -750,7 +750,7 @@ export class DocumentView extends PureComponent { } - convertScreenPointsToPagePoints = (points: Array): Promise> => { + convertScreenPointsToPagePoints = (points: Array): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertScreenPointsToPagePoints(tag, points); @@ -758,7 +758,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - convertPagePointsToScreenPoints = (points: Array): Promise> => { + convertPagePointsToScreenPoints = (points: Array): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); From ab64dba925b19dc27da656bc650103c5a701f1e1 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Mon, 30 Aug 2021 18:33:07 -0700 Subject: [PATCH 097/226] Edit build process comments * add periods to end of comments * clarify example branches * remove extra rect from StickyNoteData interface --- .github/workflows/jsBuilder.yml | 14 +++++++------- src/AnnotOptions/AnnotOptions.ts | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/jsBuilder.yml b/.github/workflows/jsBuilder.yml index 573a107c7..08d0fd0ed 100644 --- a/.github/workflows/jsBuilder.yml +++ b/.github/workflows/jsBuilder.yml @@ -2,7 +2,7 @@ name: Transpile TS on: push: - branches: [ts-support-js-to-ts] # <-- Change this to whatever the primary branch is (ex: master) + branches: [ts-support-js-to-ts] # <-- Change this to the primary branch (for example, "dev" if you want all changes to `dev` to be watched). jobs: build: @@ -11,8 +11,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 with: - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token - fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token. + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo. - name: Node setup uses: actions/setup-node@v2 @@ -21,15 +21,15 @@ jobs: cache: 'npm' - name: Build JavaScript files - run: | # Change last line to your build script command # + run: | # Change last line to your build script command #. npm i npm run start - name: Force add JS files to override .gitignore - run: git add --force ./lib # <-- Change this to your build path + run: git add --force ./lib # <-- Change this to your build path. - name: Commit files - run: | # Change last line to your preferred commit message (I like `chore: build js files`) + run: | # Change last line to your preferred commit message (I like `chore: build js files`). git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git commit -m "Updating JS files" -a @@ -39,4 +39,4 @@ jobs: with: force: true github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ts-master # <-- Change this to the new branch where you want builds to be \ No newline at end of file + branch: ts-master # <-- Change this to the branch where you want builds to be (for example, "master" if you want changes to the primary branch to be applied to `master`). \ No newline at end of file diff --git a/src/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts index 6b9b4d9df..12edca35f 100644 --- a/src/AnnotOptions/AnnotOptions.ts +++ b/src/AnnotOptions/AnnotOptions.ts @@ -73,7 +73,6 @@ export interface StickyNoteData { id: string; pageNumber: number; type: string; - rect?: Rect; pageRect?: Rect; screenRect?: Rect; } \ No newline at end of file From b33841d8f9ec4266ab00c100c34a62e9e08ee583 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 1 Sep 2021 11:00:11 -0700 Subject: [PATCH 098/226] avoid emitting JS files if there is type error --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 67fd9d3c0..ee731576f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "declaration": false, "outDir": "./lib", "strict": true, + "noEmitOnError": true, }, "include": ["index.ts", "src/**/*"], "exclude": ["node_modules", "**/*.spec.ts"] From 2cf685903e1836c3442c419caa878838b29ebe26 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Wed, 1 Sep 2021 15:46:27 -0700 Subject: [PATCH 099/226] Add JSDoc comments and set up some templates to try out --- DocHome.md | 5 + conf.json | 29 + index.ts | 94 +- package-lock.json | 2208 ++++++++++++++++++++++++++++- package.json | 7 +- src/AnnotOptions/AnnotOptions.ts | 60 +- src/Config/Config.ts | 8 + src/DocumentView/DocumentView.tsx | 944 ++++++++++-- src/PDFViewCtrl/PDFViewCtrl.tsx | 7 + typedoc.json | 6 + 10 files changed, 3252 insertions(+), 116 deletions(-) create mode 100644 DocHome.md create mode 100644 conf.json create mode 100644 typedoc.json diff --git a/DocHome.md b/DocHome.md new file mode 100644 index 000000000..aacd43707 --- /dev/null +++ b/DocHome.md @@ -0,0 +1,5 @@ +# PDFTron React Native API + +## TypeScript + +PDFTron React Native now has support for TypeScript. Since not all customers use the language, the typings used in this document will be described using normal JavaScript types. For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](src). diff --git a/conf.json b/conf.json new file mode 100644 index 000000000..e21a404e2 --- /dev/null +++ b/conf.json @@ -0,0 +1,29 @@ +{ + "tags": { + "allowUnknownTags": ["optional", "category"] + }, + "plugins": ["plugins/markdown", + "node_modules/better-docs/typescript", + "node_modules/better-docs/category" + ], + "source": { + "includePattern": "\\.(jsx|js|ts|tsx)$", + "include": ["lib/", "index.ts"], + "exclude": ["lib/index.js"] + }, + "templates": { + "systemName" : "PDFTron React Native", + "includeDate" : "false", + "navType" : "vertical", + "theme" : "lumen", + "linenums" : "false", + "collapseSymbols" : "true", + "syntaxTheme" : "default", + "sort" : "true", + "search" : "true", + "inverseNav" : "false", + "outputSourceFiles" : "false" , + "outputSourcePath" : "false", + "useLongnameInNav": 1 + } +} \ No newline at end of file diff --git a/index.ts b/index.ts index d7a52229f..7a4e44565 100644 --- a/index.ts +++ b/index.ts @@ -4,17 +4,109 @@ import { DocumentView } from './src/DocumentView/DocumentView'; import { Config } from './src/Config/Config'; import * as AnnotOptions from './src/AnnotOptions/AnnotOptions'; -export interface Pdftron { +/** + * @typedef Pdftron + * @description Contains {@link RNPdftron} methods. The Pdftron interface is implemented internally by PDFTron. + */ +export interface Pdftron +{ + /** + * @method + * @description Initializes PDFTron SDK with your PDFTron commercial license key. You can run PDFTron in demo mode by passing an empty string. + * @param {string} licenseKey your PDFTron license key + * @example RNPdftron.initialize('your_license_key'); + */ initialize(licenseKey: string) : void; + + /** + * @method + * @description Enables JavaScript for PDFTron SDK, by default it is enabled. + * @param {boolean} enabled whether to enable or disable JavaScript + * @example RNPdftron.enableJavaScript(true); + */ enableJavaScript(enabled: boolean) : void; + + /** + * @method + * @description Gets the current PDFNet version. + * @returns version - currentPDFNet version + * @example + * RNPdftron.getVersion().then((version) => { + * console.log("Current PDFNet version:", version); + * }); + */ getVersion() : Promise; + + /** + * @method + * @description Gets the version of current platform (Android/iOS). + * @returns platformVersion - current platform version (Android/iOS) + * @example + * RNPdftron.getPlatformVersion().then((platformVersion) => { + * console.log("App currently running on:", platformVersion); + * }); + */ getPlatformVersion() : Promise; + + /** + * @method + * @description Gets the font list available on the OS (Android only). + * This is typically useful when you are mostly working with non-ascii characters in the viewer. + * @returns fontList - the font list available on Android + * @example + * RNPdftron.getSystemFontList().then((fontList) => { + * console.log("OS font list:", fontList); + * }); + */ getSystemFontList() : Promise; + + /** + * @method + * @description Clear the information and bitmap cache for rubber stamps (Android only). + * This is typically useful when the content of rubber stamps has been changed in the viewer. + * @example + * RNPdftron.clearRubberStampCache().then(() => { + * console.log("Rubber stamp cache cleared"); + * }); + */ clearRubberStampCache() : Promise; + + /** + * @method + * @description Encrypts (password-protect) a document (must be a PDF). **Note**: This function does not lock the document it cannot be used it while the document is opened in the viewer. + * @param {string} filePath the local file path to the file + * @param {string} password the password you would like to set + * @param {string} currentPassword the current password, use empty string if no password + * @example + * RNPdftron.encryptDocument("/sdcard/Download/new.pdf", "1111", "").then(() => { + * console.log("done password"); + * }); + */ encryptDocument(filePath: string, password: string, currentPassword: string) : Promise; + + /** + * @method + * @description Generates a PDF using a template in the form of an Office document and replacement data in the form of a JSON object. + * For more information please see our [template guide](https://www.pdftron.com/documentation/core/guides/generate-via-template/). + * + * The user is responsible for cleaning up the temporary file that is generated. + * @param {string} docxPath the local file path to the template file + * @param {object} json the replacement data in the form of a JSON object + * @returns resultPdfPath - the local file path to the generated PDF + * @example + * RNPdftron.pdfFromOfficeTemplate("/sdcard/Download/red.docx", json).then((resultPdfPath) => { + * console.log(resultPdfPath); + * }); + */ pdfFromOfficeTemplate(docxPath: string, json: object) : Promise; } +/** + * @class + * @classdesc RNPdftron contains static methods for global library initialization, configuration, and utility methods. + * @see {@link Pdftron} interface for RNPdftron method descriptions. + * @hideconstructor + */ const RNPdftron : Pdftron = NativeModules.RNPdftron; export { diff --git a/package-lock.json b/package-lock.json index 4116865bc..ee50d8e78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,361 @@ { "name": "react-native-pdftron", - "version": "2.0.3-beta.167", + "version": "2.0.3-beta.173", "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz", + "integrity": "sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.14.5" + } + }, + "@babel/compat-data": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.15.0.tgz", + "integrity": "sha512-0NqAC1IJE0S0+lL1SWFMxMkz1pKCNCjI4tr2Zx4LJSXxCLAdr6KyArnY+sno5m3yH9g737ygOyPABDsnXkpxiA==", + "dev": true + }, + "@babel/core": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.15.0.tgz", + "integrity": "sha512-tXtmTminrze5HEUPn/a0JtOzzfp0nk+UEXQ/tqIJo3WDGypl/2OFQEMll/zSFU8f/lfmfLXvTaORHF3cfXIQMw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.14.5", + "@babel/generator": "^7.15.0", + "@babel/helper-compilation-targets": "^7.15.0", + "@babel/helper-module-transforms": "^7.15.0", + "@babel/helpers": "^7.14.8", + "@babel/parser": "^7.15.0", + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.15.0", + "@babel/types": "^7.15.0", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.1.2", + "semver": "^6.3.0", + "source-map": "^0.5.0" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.15.0.tgz", + "integrity": "sha512-eKl4XdMrbpYvuB505KTta4AV9g+wWzmVBW69tX0H2NwKVKd2YJbKgyK6M8j/rgLbmHOYJn6rUklV677nOyJrEQ==", + "dev": true, + "requires": { + "@babel/types": "^7.15.0", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "@babel/helper-compilation-targets": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.15.0.tgz", + "integrity": "sha512-h+/9t0ncd4jfZ8wsdAsoIxSa61qhBYlycXiHWqJaQBCXAhDCMbPRSMTGnZIkkmt1u4ag+UQmuqcILwqKzZ4N2A==", + "dev": true, + "requires": { + "@babel/compat-data": "^7.15.0", + "@babel/helper-validator-option": "^7.14.5", + "browserslist": "^4.16.6", + "semver": "^6.3.0" + } + }, + "@babel/helper-function-name": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.14.5.tgz", + "integrity": "sha512-Gjna0AsXWfFvrAuX+VKcN/aNNWonizBj39yGwUzVDVTlMYJMK2Wp6xdpy72mfArFq5uK+NOuexfzZlzI1z9+AQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.14.5", + "@babel/template": "^7.14.5", + "@babel/types": "^7.14.5" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.14.5.tgz", + "integrity": "sha512-I1Db4Shst5lewOM4V+ZKJzQ0JGGaZ6VY1jYvMghRjqs6DWgxLCIyFt30GlnKkfUeFLpJt2vzbMVEXVSXlIFYUg==", + "dev": true, + "requires": { + "@babel/types": "^7.14.5" + } + }, + "@babel/helper-hoist-variables": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.14.5.tgz", + "integrity": "sha512-R1PXiz31Uc0Vxy4OEOm07x0oSjKAdPPCh3tPivn/Eo8cvz6gveAeuyUUPB21Hoiif0uoPQSSdhIPS3352nvdyQ==", + "dev": true, + "requires": { + "@babel/types": "^7.14.5" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.15.0.tgz", + "integrity": "sha512-Jq8H8U2kYiafuj2xMTPQwkTBnEEdGKpT35lJEQsRRjnG0LW3neucsaMWLgKcwu3OHKNeYugfw+Z20BXBSEs2Lg==", + "dev": true, + "requires": { + "@babel/types": "^7.15.0" + } + }, + "@babel/helper-module-imports": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.14.5.tgz", + "integrity": "sha512-SwrNHu5QWS84XlHwGYPDtCxcA0hrSlL2yhWYLgeOc0w7ccOl2qv4s/nARI0aYZW+bSwAL5CukeXA47B/1NKcnQ==", + "dev": true, + "requires": { + "@babel/types": "^7.14.5" + } + }, + "@babel/helper-module-transforms": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.15.0.tgz", + "integrity": "sha512-RkGiW5Rer7fpXv9m1B3iHIFDZdItnO2/BLfWVW/9q7+KqQSDY5kUfQEbzdXM1MVhJGcugKV7kRrNVzNxmk7NBg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.14.5", + "@babel/helper-replace-supers": "^7.15.0", + "@babel/helper-simple-access": "^7.14.8", + "@babel/helper-split-export-declaration": "^7.14.5", + "@babel/helper-validator-identifier": "^7.14.9", + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.15.0", + "@babel/types": "^7.15.0" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.14.5.tgz", + "integrity": "sha512-IqiLIrODUOdnPU9/F8ib1Fx2ohlgDhxnIDU7OEVi+kAbEZcyiF7BLU8W6PfvPi9LzztjS7kcbzbmL7oG8kD6VA==", + "dev": true, + "requires": { + "@babel/types": "^7.14.5" + } + }, + "@babel/helper-replace-supers": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.15.0.tgz", + "integrity": "sha512-6O+eWrhx+HEra/uJnifCwhwMd6Bp5+ZfZeJwbqUTuqkhIT6YcRhiZCOOFChRypOIe0cV46kFrRBlm+t5vHCEaA==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.15.0", + "@babel/helper-optimise-call-expression": "^7.14.5", + "@babel/traverse": "^7.15.0", + "@babel/types": "^7.15.0" + } + }, + "@babel/helper-simple-access": { + "version": "7.14.8", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.14.8.tgz", + "integrity": "sha512-TrFN4RHh9gnWEU+s7JloIho2T76GPwRHhdzOWLqTrMnlas8T9O7ec+oEDNsRXndOmru9ymH9DFrEOxpzPoSbdg==", + "dev": true, + "requires": { + "@babel/types": "^7.14.8" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.14.5.tgz", + "integrity": "sha512-hprxVPu6e5Kdp2puZUmvOGjaLv9TCe58E/Fl6hRq4YiVQxIcNvuq6uTM2r1mT/oPskuS9CgR+I94sqAYv0NGKA==", + "dev": true, + "requires": { + "@babel/types": "^7.14.5" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.14.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.9.tgz", + "integrity": "sha512-pQYxPY0UP6IHISRitNe8bsijHex4TWZXi2HwKVsjPiltzlhse2znVcm9Ace510VT1kxIHjGJCZZQBX2gJDbo0g==", + "dev": true + }, + "@babel/helper-validator-option": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz", + "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==", + "dev": true + }, + "@babel/helpers": { + "version": "7.15.3", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.15.3.tgz", + "integrity": "sha512-HwJiz52XaS96lX+28Tnbu31VeFSQJGOeKHJeaEPQlTl7PnlhFElWPj8tUXtqFIzeN86XxXoBr+WFAyK2PPVz6g==", + "dev": true, + "requires": { + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.15.0", + "@babel/types": "^7.15.0" + } + }, + "@babel/highlight": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", + "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.14.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.15.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.3.tgz", + "integrity": "sha512-O0L6v/HvqbdJawj0iBEfVQMc3/6WP+AeOsovsIgBFyJaG+W2w7eqvZB7puddATmWuARlm1SX7DwxJ/JJUnDpEA==", + "dev": true + }, + "@babel/polyfill": { + "version": "7.12.1", + "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.12.1.tgz", + "integrity": "sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g==", + "dev": true, + "requires": { + "core-js": "^2.6.5", + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/runtime": { + "version": "7.15.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.15.3.tgz", + "integrity": "sha512-OvwMLqNXkCXSz1kSm58sEsNuhqOx/fKpnUnKnFB5v8uDda5bLNEHNgKPvhDN6IU0LDcnHQ90LlJ0Q6jnyBSIBA==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "@babel/template": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", + "integrity": "sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.14.5", + "@babel/parser": "^7.14.5", + "@babel/types": "^7.14.5" + } + }, + "@babel/traverse": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.15.0.tgz", + "integrity": "sha512-392d8BN0C9eVxVWd8H6x9WfipgVH5IaIoLp23334Sc1vbKKWINnvwRpb4us0xtPaCumlwbTtIYNA0Dv/32sVFw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.14.5", + "@babel/generator": "^7.15.0", + "@babel/helper-function-name": "^7.14.5", + "@babel/helper-hoist-variables": "^7.14.5", + "@babel/helper-split-export-declaration": "^7.14.5", + "@babel/parser": "^7.15.0", + "@babel/types": "^7.15.0", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "dependencies": { + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, + "@babel/types": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.15.0.tgz", + "integrity": "sha512-OBvfqnllOIdX4ojTHpwZbpvz4j3EWyjkZEdmjH0/cgsd6QOdSgU8rLSk6ard/pcW7rlmjdVSX/AWOaORR1uNOQ==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.14.9", + "to-fast-properties": "^2.0.0" + } + }, + "@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true + }, + "@types/babel-types": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.11.tgz", + "integrity": "sha512-pkPtJUUY+Vwv6B1inAz55rQvivClHJxc9aVEPPmaq2cbyeMLCiDpbKpcKyX4LAwpNGi+SHBv0tHv6+0gXv0P2A==", + "dev": true + }, + "@types/babylon": { + "version": "6.16.6", + "resolved": "https://registry.npmjs.org/@types/babylon/-/babylon-6.16.6.tgz", + "integrity": "sha512-G4yqdVlhr6YhzLXFKy5F7HtRBU8Y23+iWy7UKthMq/OSQnL1hbsoeXESQ2LY8zEDlknipDG3nRGhUC9tkwvy/w==", + "dev": true, + "requires": { + "@types/babel-types": "*" + } + }, + "@types/istanbul-lib-coverage": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", + "integrity": "sha512-sz7iLqvVUg1gIedBOvlkxPlc8/uVzyS5OwGz1cKjXzkl3FpL3al0crU8YGU1WoHkxn0Wxbw5tyi6hvzJKNzFsw==", + "dev": true + }, "@types/prop-types": { "version": "15.7.4", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz", - "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==" + "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", + "dev": true }, "@types/react": { "version": "17.0.15", "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.15.tgz", "integrity": "sha512-uTKHDK9STXFHLaKv6IMnwp52fm0hwU+N89w/p9grdUqcFA6WuqDyPhaWopbNyE1k/VhgzmHl8pu1L4wITtmlLw==", + "dev": true, "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -23,6 +366,7 @@ "version": "0.64.12", "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.64.12.tgz", "integrity": "sha512-sw6WGSaL219zqrgdb4kQUtFB9iGXC/LmecLZ+UUWEgwYvD0YH81FqWYmONa2HuTkOFAsxu2bK4DspkWRUHIABQ==", + "dev": true, "requires": { "@types/react": "*" } @@ -30,48 +374,1860 @@ "@types/scheduler": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", - "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==" + "integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==", + "dev": true + }, + "acorn-globals": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz", + "integrity": "sha1-/YJw9x+7SZawBPqIDuXUZXOnMb8=", + "dev": true, + "requires": { + "acorn": "^4.0.4" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } + } + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "dev": true + }, + "ast-types": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.2.tgz", + "integrity": "sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==", + "dev": true, + "requires": { + "tslib": "^2.0.1" + } + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + } + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + }, + "dependencies": { + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + } + } + }, + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "better-docs": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/better-docs/-/better-docs-2.3.2.tgz", + "integrity": "sha512-VlbXQgEftaynJSaPa853XB5WqTlPoQQr2TnxIkKi6OsyJJxF42Ke+9SIES/hqTe58aaBnuoDGrIzOso8RdNx6Q==", + "dev": true, + "requires": { + "brace": "^0.11.1", + "react-ace": "^6.5.0", + "react-docgen": "^5.3.0", + "react-frame-component": "^4.1.1", + "typescript": "^3.7.5", + "underscore": "^1.9.1", + "vue-docgen-api": "^3.22.0", + "vue2-ace-editor": "^0.0.13" + }, + "dependencies": { + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true + } + } + }, + "bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", + "dev": true + }, + "brace": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/brace/-/brace-0.11.1.tgz", + "integrity": "sha1-SJb8ydVE7vRfS7dmDbMg07N5/lg=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browserslist": { + "version": "4.16.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.8.tgz", + "integrity": "sha512-sc2m9ohR/49sWEbPj14ZSSZqp+kbi16aLao42Hmn3Z8FpjuMaq2xCA2l4zl9ITfyzvnvyE0hcg62YkIGKxgaNQ==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001251", + "colorette": "^1.3.0", + "electron-to-chromium": "^1.3.811", + "escalade": "^3.1.1", + "node-releases": "^1.1.75" + } + }, + "c8": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-7.8.0.tgz", + "integrity": "sha512-x2Bx+IIEd608B1LmjiNQ/kizRPkCWo5XzuV57J9afPjAHSnYXALwbCSOkQ7cSaNXBNblfqcvdycj+klmL+j6yA==", + "dev": true, + "requires": { + "@bcoe/v8-coverage": "^0.2.3", + "@istanbuljs/schema": "^0.1.2", + "find-up": "^5.0.0", + "foreground-child": "^2.0.0", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-reports": "^3.0.2", + "rimraf": "^3.0.0", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^8.0.0", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.7" + } + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30001252", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001252.tgz", + "integrity": "sha512-I56jhWDGMtdILQORdusxBOH+Nl/KgQSdDmpJezYddnAkVOmnoU8zwjTV9xAjMIYxr0iPreEAVylCGcmHCjfaOw==", + "dev": true + }, + "catharsis": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", + "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", + "dev": true, + "requires": { + "lodash": "^4.17.15" + } + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "character-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz", + "integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A=", + "dev": true, + "requires": { + "is-regex": "^1.0.3" + } + }, + "clean-css": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", + "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", + "dev": true, + "requires": { + "source-map": "~0.6.0" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "colorette": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.3.0.tgz", + "integrity": "sha512-ecORCqbSFP7Wm8Y6lyqMJjexBQqXSF7SSeaTyGGphogUjBlFP9m9o08wy86HL2uB7fMTxtOUzLMk7ogKcxMg1w==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "constantinople": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.1.2.tgz", + "integrity": "sha512-yePcBqEFhLOqSBtwYOGGS1exHo/s1xjekXiinh4itpNQGCu4KA1euPh1fg07N2wMITZXQkBz75Ntdt1ctGZouw==", + "dev": true, + "requires": { + "@types/babel-types": "^7.0.0", + "@types/babylon": "^6.16.2", + "babel-types": "^6.26.0", + "babylon": "^6.18.0" + } + }, + "convert-source-map": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", + "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "dev": true + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } }, "csstype": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.8.tgz", - "integrity": "sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==" + "integrity": "sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==", + "dev": true }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=", "dev": true }, - "loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "diff-match-patch": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.5.tgz", + "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==", + "dev": true + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { - "js-tokens": "^3.0.0 || ^4.0.0" + "esutils": "^2.0.2" } }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "doctypes": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", + "integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=", + "dev": true + }, + "dom-serializer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "dependencies": { + "domhandler": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", + "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "requires": { + "domelementtype": "^2.2.0" + } + } + } + }, + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" + }, + "domhandler": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz", + "integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==", + "requires": { + "domelementtype": "^2.0.1" + } + }, + "domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + }, + "dependencies": { + "domhandler": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", + "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "requires": { + "domelementtype": "^2.2.0" + } + } + } + }, + "electron-to-chromium": { + "version": "1.3.820", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.820.tgz", + "integrity": "sha512-5cFwDmo2yzEA9hn55KZ9+cX/b6DSFvpKz8Hb2fiDmriXWB+DBoXKXmncQwNRFBBTlUdsvPHCoy594OoMLAO0Tg==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "entities": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", + "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==" + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true }, - "react": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", - "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "estree-to-babel": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/estree-to-babel/-/estree-to-babel-3.2.1.tgz", + "integrity": "sha512-YNF+mZ/Wu2FU/gvmzuWtYc8rloubL7wfXCTgouFrnjGVXPA/EeYYA7pupXWrb3Iv1cTBeSSxxJIbK23l4MRNqg==", "dev": true, "requires": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1" + "@babel/traverse": "^7.1.6", + "@babel/types": "^7.2.0", + "c8": "^7.6.0" } }, - "typescript": { - "version": "4.3.5", + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, + "foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, + "glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true + }, + "handlebars": { + "version": "4.7.7", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", + "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", + "requires": { + "minimist": "^1.2.5", + "neo-async": "^2.6.0", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4", + "wordwrap": "^1.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + } + }, + "hash-sum": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz", + "integrity": "sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=", + "dev": true + }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "htmlparser2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.1.0.tgz", + "integrity": "sha512-4zDq1a1zhE4gQso/c5LP1OtrhYTncXNSpvJYtWJBtXAETPlMfi3IFNjGuQbYLuVY4ZR0QMqRVvo4Pdy9KLyP8Q==", + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^3.0.0", + "domutils": "^2.0.0", + "entities": "^2.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ink-docstrap": { + "version": "git+https://github.com/lbittner-pdftron/docstrap.git#ea00d500ce3316ae145fb312cd7b5d769d22fcc7", + "from": "git+https://github.com/lbittner-pdftron/docstrap.git", + "requires": { + "moment": "^2.14.1", + "sanitize-html": "^1.13.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-core-module": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-expression": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-3.0.0.tgz", + "integrity": "sha1-Oayqa+f9HzRx3ELHQW5hwkMXrJ8=", + "dev": true, + "requires": { + "acorn": "~4.0.2", + "object-assign": "^4.0.1" + }, + "dependencies": { + "acorn": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", + "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", + "dev": true + } + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", + "dev": true + }, + "is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "istanbul-reports": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", + "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "js-stringify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", + "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js2xmlparser": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz", + "integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==", + "dev": true, + "requires": { + "xmlcreate": "^2.0.3" + } + }, + "jsdoc": { + "version": "3.6.7", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.7.tgz", + "integrity": "sha512-sxKt7h0vzCd+3Y81Ey2qinupL6DpRSZJclS04ugHDNmRUXGzqicMJ6iwayhSA0S0DwwX30c5ozyUthr1QKF6uw==", + "dev": true, + "requires": { + "@babel/parser": "^7.9.4", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.1", + "klaw": "^3.0.0", + "markdown-it": "^10.0.0", + "markdown-it-anchor": "^5.2.7", + "marked": "^2.0.3", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "taffydb": "2.6.2", + "underscore": "~1.13.1" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json5": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "requires": { + "minimist": "^1.2.5" + } + }, + "jstransformer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz", + "integrity": "sha1-7Yvwkh4vPx7U1cGkT2hwntJHIsM=", + "dev": true, + "requires": { + "is-promise": "^2.0.0", + "promise": "^7.0.1" + } + }, + "klaw": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", + "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.9" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "linkify-it": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", + "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", + "dev": true, + "requires": { + "uc.micro": "^1.0.1" + } + }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", + "dev": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } + }, + "lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==" + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "markdown-it": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", + "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "entities": "~2.0.0", + "linkify-it": "^2.0.0", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + } + }, + "markdown-it-anchor": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz", + "integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==", + "dev": true + }, + "marked": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz", + "integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==" + }, + "mdurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", + "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", + "dev": true + }, + "min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "moment": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + }, + "neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" + }, + "node-dir": { + "version": "0.1.17", + "resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.1.17.tgz", + "integrity": "sha1-X1Zl2TNRM1yqvvjxxVRRbPXx5OU=", + "dev": true, + "requires": { + "minimatch": "^3.0.2" + } + }, + "node-releases": { + "version": "1.1.75", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz", + "integrity": "sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw==", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onigasm": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/onigasm/-/onigasm-2.2.5.tgz", + "integrity": "sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==", + "requires": { + "lru-cache": "^5.1.1" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "parse-srcset": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", + "integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE=" + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "postcss": { + "version": "7.0.36", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.36.tgz", + "integrity": "sha512-BebJSIUMwJHRH0HAQoxN4u1CN86glsrwsW0q7T+/m44eXOUAxSNdHRkNZPYz5vVUbg17hFgOQDE7fZk7li3pZw==", + "requires": { + "chalk": "^2.4.2", + "source-map": "^0.6.1", + "supports-color": "^6.1.0" + } + }, + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "dev": true, + "requires": { + "asap": "~2.0.3" + } + }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "pug": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pug/-/pug-2.0.4.tgz", + "integrity": "sha512-XhoaDlvi6NIzL49nu094R2NA6P37ijtgMDuWE+ofekDChvfKnzFal60bhSdiy8y2PBO6fmz3oMEIcfpBVRUdvw==", + "dev": true, + "requires": { + "pug-code-gen": "^2.0.2", + "pug-filters": "^3.1.1", + "pug-lexer": "^4.1.0", + "pug-linker": "^3.0.6", + "pug-load": "^2.0.12", + "pug-parser": "^5.0.1", + "pug-runtime": "^2.0.5", + "pug-strip-comments": "^1.0.4" + } + }, + "pug-attrs": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-2.0.4.tgz", + "integrity": "sha512-TaZ4Z2TWUPDJcV3wjU3RtUXMrd3kM4Wzjbe3EWnSsZPsJ3LDI0F3yCnf2/W7PPFF+edUFQ0HgDL1IoxSz5K8EQ==", + "dev": true, + "requires": { + "constantinople": "^3.0.1", + "js-stringify": "^1.0.1", + "pug-runtime": "^2.0.5" + } + }, + "pug-code-gen": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-2.0.3.tgz", + "integrity": "sha512-r9sezXdDuZJfW9J91TN/2LFbiqDhmltTFmGpHTsGdrNGp3p4SxAjjXEfnuK2e4ywYsRIVP0NeLbSAMHUcaX1EA==", + "dev": true, + "requires": { + "constantinople": "^3.1.2", + "doctypes": "^1.1.0", + "js-stringify": "^1.0.1", + "pug-attrs": "^2.0.4", + "pug-error": "^1.3.3", + "pug-runtime": "^2.0.5", + "void-elements": "^2.0.1", + "with": "^5.0.0" + } + }, + "pug-error": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-1.3.3.tgz", + "integrity": "sha512-qE3YhESP2mRAWMFJgKdtT5D7ckThRScXRwkfo+Erqga7dyJdY3ZquspprMCj/9sJ2ijm5hXFWQE/A3l4poMWiQ==", + "dev": true + }, + "pug-filters": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-3.1.1.tgz", + "integrity": "sha512-lFfjNyGEyVWC4BwX0WyvkoWLapI5xHSM3xZJFUhx4JM4XyyRdO8Aucc6pCygnqV2uSgJFaJWW3Ft1wCWSoQkQg==", + "dev": true, + "requires": { + "clean-css": "^4.1.11", + "constantinople": "^3.0.1", + "jstransformer": "1.0.0", + "pug-error": "^1.3.3", + "pug-walk": "^1.1.8", + "resolve": "^1.1.6", + "uglify-js": "^2.6.1" + }, + "dependencies": { + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "requires": { + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" + } + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + } + } + } + }, + "pug-lexer": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-4.1.0.tgz", + "integrity": "sha512-i55yzEBtjm0mlplW4LoANq7k3S8gDdfC6+LThGEvsK4FuobcKfDAwt6V4jKPH9RtiE3a2Akfg5UpafZ1OksaPA==", + "dev": true, + "requires": { + "character-parser": "^2.1.1", + "is-expression": "^3.0.0", + "pug-error": "^1.3.3" + } + }, + "pug-linker": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-3.0.6.tgz", + "integrity": "sha512-bagfuHttfQOpANGy1Y6NJ+0mNb7dD2MswFG2ZKj22s8g0wVsojpRlqveEQHmgXXcfROB2RT6oqbPYr9EN2ZWzg==", + "dev": true, + "requires": { + "pug-error": "^1.3.3", + "pug-walk": "^1.1.8" + } + }, + "pug-load": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.12.tgz", + "integrity": "sha512-UqpgGpyyXRYgJs/X60sE6SIf8UBsmcHYKNaOccyVLEuT6OPBIMo6xMPhoJnqtB3Q3BbO4Z3Bjz5qDsUWh4rXsg==", + "dev": true, + "requires": { + "object-assign": "^4.1.0", + "pug-walk": "^1.1.8" + } + }, + "pug-parser": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-5.0.1.tgz", + "integrity": "sha512-nGHqK+w07p5/PsPIyzkTQfzlYfuqoiGjaoqHv1LjOv2ZLXmGX1O+4Vcvps+P4LhxZ3drYSljjq4b+Naid126wA==", + "dev": true, + "requires": { + "pug-error": "^1.3.3", + "token-stream": "0.0.1" + } + }, + "pug-runtime": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-2.0.5.tgz", + "integrity": "sha512-P+rXKn9un4fQY77wtpcuFyvFaBww7/91f3jHa154qU26qFAnOe6SW1CbIDcxiG5lLK9HazYrMCCuDvNgDQNptw==", + "dev": true + }, + "pug-strip-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-1.0.4.tgz", + "integrity": "sha512-i5j/9CS4yFhSxHp5iKPHwigaig/VV9g+FgReLJWWHEHbvKsbqL0oP/K5ubuLco6Wu3Kan5p7u7qk8A4oLLh6vw==", + "dev": true, + "requires": { + "pug-error": "^1.3.3" + } + }, + "pug-walk": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-1.1.8.tgz", + "integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA==", + "dev": true + }, + "react-ace": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/react-ace/-/react-ace-6.6.0.tgz", + "integrity": "sha512-Jehhp8bxa8kqiXk07Jzy+uD5qZMBwo43O+raniGHjdX7Qk93xFkKaAz8LxtUVZPJGlRnV5ODMNj0qHwDSN+PBw==", + "dev": true, + "requires": { + "@babel/polyfill": "^7.4.4", + "brace": "^0.11.1", + "diff-match-patch": "^1.0.4", + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "prop-types": "^15.7.2" + } + }, + "react-docgen": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/react-docgen/-/react-docgen-5.4.0.tgz", + "integrity": "sha512-JBjVQ9cahmNlfjMGxWUxJg919xBBKAoy3hgDgKERbR+BcF4ANpDuzWAScC7j27hZfd8sJNmMPOLWo9+vB/XJEQ==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@babel/generator": "^7.12.11", + "@babel/runtime": "^7.7.6", + "ast-types": "^0.14.2", + "commander": "^2.19.0", + "doctrine": "^3.0.0", + "estree-to-babel": "^3.1.0", + "neo-async": "^2.6.1", + "node-dir": "^0.1.10", + "strip-indent": "^3.0.0" + } + }, + "react-frame-component": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/react-frame-component/-/react-frame-component-4.1.3.tgz", + "integrity": "sha512-4PurhctiqnmC1F5prPZ+LdsalH7pZ3SFA5xoc0HBe8mSHctdLLt4Cr2WXfXOoajHBYq/yiipp9zOgx+vy8GiEA==", + "dev": true + }, + "react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, + "recast": { + "version": "0.17.6", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.17.6.tgz", + "integrity": "sha512-yoQRMRrK1lszNtbkGyM4kN45AwylV5hMiuEveUBlxytUViWevjvX6w+tzJt1LH4cfUhWt4NZvy3ThIhu6+m5wQ==", + "dev": true, + "requires": { + "ast-types": "0.12.4", + "esprima": "~4.0.0", + "private": "^0.1.8", + "source-map": "~0.6.1" + }, + "dependencies": { + "ast-types": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.12.4.tgz", + "integrity": "sha512-ky/YVYCbtVAS8TdMIaTiPFHwEpRB5z1hctepJplTr3UW5q8TDrpIMCILyk8pmLxGtn2KCtC/lSn7zOsaI7nzDw==", + "dev": true + } + } + }, + "regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "requizzle": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", + "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "^0.1.1" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "sanitize-html": { + "version": "1.27.5", + "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.27.5.tgz", + "integrity": "sha512-M4M5iXDAUEcZKLXkmk90zSYWEtk5NH3JmojQxKxV371fnMh+x9t1rqdmXaGoyEHw3z/X/8vnFhKjGL5xFGOJ3A==", + "requires": { + "htmlparser2": "^4.1.0", + "lodash": "^4.17.15", + "parse-srcset": "^1.0.2", + "postcss": "^7.0.27" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "shiki": { + "version": "0.9.7", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.7.tgz", + "integrity": "sha512-rOoAmwRWDiGKjQ1GaSKmbp1J5CamCera+I+DMM3wG/phbwNYQPt1mrjBBZbK66v80Vl1/A9TTLgXVHMbgtOCIQ==", + "requires": { + "json5": "^2.2.0", + "onigasm": "^2.2.5", + "vscode-textmate": "5.2.0" + } + }, + "signal-exit": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "requires": { + "min-indent": "^1.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "supports-color": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", + "dev": true + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + }, + "token-stream": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz", + "integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo=", + "dev": true + }, + "ts-map": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-map/-/ts-map-1.0.3.tgz", + "integrity": "sha512-vDWbsl26LIcPGmDpoVzjEP6+hvHZkBkLW7JpvwbCv/5IYPJlsbzCVXY3wsCeAxAUeTclNOUZxnLdGh3VBD/J6w==", + "dev": true + }, + "tslib": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", + "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "dev": true + }, + "typedoc": { + "version": "0.21.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.21.6.tgz", + "integrity": "sha512-+4u3PEBjQdaL5/yfus5WJbjIdQHv7E/FpZq3cNki9BBdGmZhqnTF6JLIXDQ2EfVggojOJG9/soB5QVFgXRYnIw==", + "requires": { + "glob": "^7.1.7", + "handlebars": "^4.7.7", + "lunr": "^2.3.9", + "marked": "^2.1.1", + "minimatch": "^3.0.0", + "progress": "^2.0.3", + "shiki": "^0.9.3", + "typedoc-default-themes": "^0.12.10" + } + }, + "typedoc-default-themes": { + "version": "0.12.10", + "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz", + "integrity": "sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==" + }, + "typescript": { + "version": "4.3.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==" + "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", + "dev": true + }, + "uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "dev": true + }, + "uglify-js": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz", + "integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==", + "optional": true + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "underscore": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", + "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", + "dev": true + }, + "v8-to-istanbul": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-8.0.0.tgz", + "integrity": "sha512-LkmXi8UUNxnCC+JlH7/fsfsKr5AU110l+SYGJimWNkWhxbN5EyeOtm1MJ0hhvqMMOhGwBj1Fp70Yv9i+hX0QAg==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0", + "source-map": "^0.7.3" + }, + "dependencies": { + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + } + } + }, + "void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "dev": true + }, + "vscode-textmate": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", + "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==" + }, + "vue-docgen-api": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/vue-docgen-api/-/vue-docgen-api-3.26.0.tgz", + "integrity": "sha512-ujdg4i5ZI/wE46RZQMFzKnDGyhEuPCu+fMA86CAd9EIek/6+OqraSVBm5ZkLrbEd5f8xxdnqMU4yiSGHHeao/Q==", + "dev": true, + "requires": { + "@babel/parser": "^7.2.3", + "@babel/types": "^7.0.0", + "ast-types": "^0.12.2", + "hash-sum": "^1.0.2", + "lru-cache": "^4.1.5", + "pug": "^2.0.3", + "recast": "^0.17.3", + "ts-map": "^1.0.3", + "typescript": "^3.2.2", + "vue-template-compiler": "^2.0.0" + }, + "dependencies": { + "ast-types": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.12.4.tgz", + "integrity": "sha512-ky/YVYCbtVAS8TdMIaTiPFHwEpRB5z1hctepJplTr3UW5q8TDrpIMCILyk8pmLxGtn2KCtC/lSn7zOsaI7nzDw==", + "dev": true + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + } + } + }, + "vue-template-compiler": { + "version": "2.6.14", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.14.tgz", + "integrity": "sha512-ODQS1SyMbjKoO1JBJZojSw6FE4qnh9rIpUZn2EUT86FKizx9uH5z6uXiIrm4/Nb/gwxTi/o17ZDEGWAXHvtC7g==", + "dev": true, + "requires": { + "de-indent": "^1.0.2", + "he": "^1.1.0" + } + }, + "vue2-ace-editor": { + "version": "0.0.13", + "resolved": "https://registry.npmjs.org/vue2-ace-editor/-/vue2-ace-editor-0.0.13.tgz", + "integrity": "sha512-uQICyvJzYNix16xeYjNAINuNUQhPbqMR7UQsJeI+ycpEd2otsiNNU73jcZqHkpjuz0uaHDHnrpzQuI/RApsKXA==", + "dev": true, + "requires": { + "brace": "^0.11.0" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true + }, + "with": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/with/-/with-5.1.1.tgz", + "integrity": "sha1-+k2qktrzLE6pTtRTyB8EaGtXXf4=", + "dev": true, + "requires": { + "acorn": "^3.1.0", + "acorn-globals": "^3.0.0" + }, + "dependencies": { + "acorn": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", + "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", + "dev": true + } + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xmlcreate": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz", + "integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==", + "dev": true + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true } } } diff --git a/package.json b/package.json index 88f3a15ce..dfd4f5a7e 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,14 @@ "prop-types": "*" }, "devDependencies": { - "react": "*", "@types/react": "*", "@types/react-native": "*", + "better-docs": "^2.3.2", + "jsdoc": "^3.6.7", "typescript": "*" + }, + "dependencies": { + "ink-docstrap": "https://github.com/lbittner-pdftron/docstrap.git", + "typedoc": "^0.21.6" } } diff --git a/src/AnnotOptions/AnnotOptions.ts b/src/AnnotOptions/AnnotOptions.ts index 4d5017629..988b52857 100644 --- a/src/AnnotOptions/AnnotOptions.ts +++ b/src/AnnotOptions/AnnotOptions.ts @@ -1,5 +1,14 @@ import {Config} from '../Config/Config'; +/** + * @typedef + * @category AnnotOptions + * @property {string} id + * @property {number} [pageNumber] + * @property {string} [type] + * @property {Rect} [pageRect] + * @property {Rect} [screenRect] + */ export interface Annotation { id: string; pageNumber?: number; @@ -8,6 +17,16 @@ export interface Annotation { screenRect?: Rect; } +/** + * @typedef + * @category AnnotOptions + * @property {number} [height] + * @property {number} [width] + * @property {number} x1 + * @property {number} y1 + * @property {number} x2 + * @property {number} y2 + */ export interface Rect { height?: number; width?: number; @@ -17,27 +36,66 @@ export interface Rect { y2: number; } -export type CropBox = Required; +/** + * @typedef + * @category AnnotOptions + * @augments Rect + */ +export interface CropBox extends Rect { + height: number; + width: number; +}; +/** + * @interface + * @category AnnotOptions + * @property {number} red + * @property {number} green + * @property {number} blue + */ export interface Color { red: number; green: number; blue: number; } +/** + * ActionRequest + * @memberof AnnotOptions + * @alias RotationDegree + */ export type RotationDegree = 0 | 90 | 180 | 270; +/** + * @typedef + * @category AnnotOptions + * @property {string} fieldName + * @property {string} fieldType + * @property {string | boolean | number | undefined} [fieldValue] + */ export interface Field { fieldName: string; fieldType: string; fieldValue?: string | boolean | number | undefined; } +/** + * @typedef + * @category AnnotOptions + * @property {number} x + * @property {number} y + */ export interface Point { x: number; y: number; } +/** + * @typedef + * @category AnnotOptions + * @augments Point + * @property {number} [pageNumber] + */ export interface PointWithPage extends Point { pageNumber?: number; } diff --git a/src/Config/Config.ts b/src/Config/Config.ts index 4d81a2787..0f4ded1c0 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -1,3 +1,11 @@ +/** + * @constant + * @module + * @name Config + * @description Defines configuration constants for the viewer. + * See [`Config.ts`](https://github.com/PDFTron/pdftron-react-native/blob/master/src/Config/Config.js) + * for the full list of constants. + */ export const Config = { // Buttons define the various kinds of buttons for the viewer diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 16625b746..b48a73341 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -13,54 +13,607 @@ import {Config} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; /** - * Object containing PropTypes types for {@link DocumentView} class. - * Also used to generate prop types for TS users. + * For Users: {@link DocumentView} class props. * + * For Contributors: Object containing PropTypes types for {@link DocumentView} class. + * Also used to generate prop types for TS users. * To represent functions, please use {@link func}. * To represent "one of Config.Buttons values" or "an array of * Config.Buttons values", please use {@link oneOf} or {@link arrayOf}. + * @interface propTypes */ -const propTypes = { +export const propTypes = { + /** + * @type {string} + * @description The path or url to the document. Required. + * @example + * + */ document: PropTypes.string.isRequired, + /** + * @type {string} + * @optional + * @description The password of the document, if any. + * @example + * + */ password: PropTypes.string, + + /** + * @type {number} + * @optional + * @description Defines the initial page number that viewer displays when the document is opened. Note that page numbers are 1-indexed. + * @example + * + */ initialPageNumber: PropTypes.number, + + /** + * @type {number} + * @optional + * @description Defines the currently displayed page number. Different from {@link propTypes.initialPageNumber}, changing this prop value at runtime will change the page accordingly. + * @example + * + */ pageNumber: PropTypes.number, + + /** + * @type {object} + * @optional + * @description Defines custom headers to use with HTTP/HTTPS requests. + * @example + * + */ customHeaders: PropTypes.object, + + /** + * @type {string} + * @optional + * @description The file name of the icon to be used for the leading navigation button. The button will use the specified icon if it is valid, and the default icon otherwise. + * + * **Note**: to add the image file to your application, please follow the steps below: + * + * ##### Android + * 1. Add the image resource to the drawable directory in [`example/android/app/src/main/res`](./example/android/app/src/main/res). For details about supported file types and potential compression, check out [here](https://developer.android.com/guide/topics/graphics/drawables#drawables-from-images). + * + * demo-android + * + * 2. Now you can use the image in the viewer. For example, if you add `button_close.png` to drawable, you could use `'button_close'` in leadingNavButtonIcon. + * + * ##### iOS + * 1. After pods has been installed, open the `.xcworkspace` file for this application in Xcode (in this case, it's [`example.xcworkspace`](./example/ios/example.xcworkspace)), and navigate through the list below. This would allow you to add resources, in this case, an image, to your project. + * - "Project navigator" + * - "example" (or the app name) + * - "Build Phases" + * - "Copy Bundle Resources" + * - "+". + * + * demo-ios + * + * 2. Now you can use the image in the viewer. For example, if you add `button_open.png` to the bundle, you could use `'button_open.png'` in leadingNavButtonIcon. + * + * @example + * + */ leadingNavButtonIcon: PropTypes.string, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether to show the leading navigation button. + * @example + * + */ showLeadingNavButton: PropTypes.bool, + + /** + * @event + * @type {function} + * @optional + * @description This function is called when the leading navigation button is pressed. + * @example + * { + * console.log('The leading nav has been pressed'); + * }} + * /> + */ onLeadingNavButtonPressed: func<() => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when the document finishes loading. + * @param {string} path + * @example + * { + * console.log('The document has finished loading:', path); + * }} + * /> + */ onDocumentLoaded: func<(path: string) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when document opening encounters an error. + * @param {string} error + * @example + * { + * console.log('Error occured during document opening:', error); + * }} + * /> + */ onDocumentError: func<(error: string) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when the page number has been changed. + * @param {object} event + * @param {int} event.previousPageNumber the previous page number + * @param {int} event.pageNumber the current page number + * @example + * { + * console.log('Page number changes from', previousPageNumber, 'to', pageNumber); + * }} + * /> + */ onPageChanged: func<(event: {previousPageNumber: number, pageNumber: number}) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when the scroll position has been changed. + * @param {object} event + * @param {number} event.horizontal the horizontal position of the scroll + * @param {number} event.vertical the vertical position of the scroll + * @example + * { + * console.log('Current scroll position is', horizontal, 'horizontally, and', vertical, 'vertically.'); + * }} + * /> + */ onScrollChanged: func<(event: {horizontal: number, vertical: number}) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when the zoom scale has been changed. + * @param {object} event + * @param {double} event.zoom the current zoom ratio of the document + * @example + * { + * console.log('Current zoom ratio is', zoom); + * }} + * /> + */ onZoomChanged: func<(event: {zoom: number}) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when a zooming has been finished. For example, if zoom via gesture, this is called on gesture release. + * @param {object} event + * @param {number} event.zoom the current zoom ratio of the document + * @example (temp) + */ onZoomFinished: func<(event: {zoom: number}) => void>(), + + /** + * @type {number} + * @optional + */ zoom: PropTypes.number, + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.Buttons`](./src/Config/Config.js) constants, defaults to none. + * + * Defines buttons to be disabled for the viewer. + * @example + * + */ disabledElements: arrayOf(Config.Buttons), + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.Tools`](./src/Config/Config.js) constants, defaults to none. + * + * Defines tools to be disabled for the viewer. + * @example + * + */ disabledTools: arrayOf(Config.Tools), + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.LongPressMenu`](./src/Config/Config.js) constants, default contains all the items + * + * Defines menu items that can show when long press on text or blank space. + * @example + * + */ longPressMenuItems: arrayOf(Config.LongPressMenu), + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.LongPressMenu`](./src/Config/Config.js) constants, defaults to none. + * + * Defines the menu items on long press that will skip default behavior when pressed. They will still be displayed in the long press menu, and the function {onLongPressMenuPress}`](#onLongPressMenuPress) will be called where custom behavior can be implemented. + * @example + * + */ overrideLongPressMenuBehavior: arrayOf(Config.LongPressMenu), + + /** + * @event + * @type {function} + * @optional + * @description This function is called if the pressed long press menu item is passed in to [`overrideLongPressMenuBehavior`](#overrideLongPressMenuBehavior) + * @param {object} event + * @param {string} longPressMenu One of [`Config.LongPressMenu`](./src/Config/Config.js) constants, representing which item has been pressed + * @param {string} longPressText the selected text if pressed on text, empty otherwise + * @example + * { + * console.log('Long press menu item', longPressMenu, 'has been pressed'); + * if (longPressText !== '') { + * console.log('The selected text is', longPressText); + * } + * }} + * /> + */ onLongPressMenuPress: func<(event: {longPressMenu: string, longPressText: string}) => void>(), + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether to show the popup menu of options when the user long presses on text or blank space on the document. + * @example + * + */ longPressMenuEnabled: PropTypes.bool, + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.AnnotationMenu`](./src/Config/Config.js) constants, default contains all the items. + * + * Defines the menu items that can show when an annotation is selected. + * @example + * + */ annotationMenuItems: arrayOf(Config.AnnotationMenu), + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.AnnotationMenu`](./src/Config/Config.js) constants, defaults to none. + * + * Defines the menu items that will skip default behavior when pressed. They will still be displayed in the annotation menu, and the function [`onAnnotationMenuPress`](#onAnnotationMenuPress) will be called where custom behavior can be implemented. + * @example + * + */ overrideAnnotationMenuBehavior: arrayOf(Config.AnnotationMenu), + + /** + * @event + * @type {function} + * @optional + * @description This function is called when an annotation menu item passed in to [`overrideAnnotationMenuBehavior`](#overrideAnnotationMenuBehavior) is pressed. + * @param {string} annotationMenu One of [`Config.AnnotationMenu`](./src/Config/Config.js) constants, representing which item has been pressed + * @param {object[]} annotations An array of `{id: string, pageNumber: number, type: string, screenRect: object, pageRect: object}` objects. + * + * `id` is the annotation identifier and `type` is one of the [`Config.Tools`](./src/Config/Config.js) constants. + * + * `screenRect` was formerly called `rect`. + * + * Both rects are represented with `{x1: number, y1: number, x2: number, y2: number, width: number, height: number}` objects. + * @example + * { + * console.log('Annotation menu item', annotationMenu, 'has been pressed'); + * annotations.forEach(annotation => { + * console.log('The id of selected annotation is', annotation.id); + * console.log('The page number of selected annotation is', annotation.pageNumber); + * console.log('The type of selected annotation is', annotation.type); + * console.log('The screenRect of selected annotation is', annotation.screenRect); + * console.log('The pageRect of selected annotation is', annotation.pageRect); + * }); + * }} + * /> + */ onAnnotationMenuPress: func<(event: {annotationMenu: string, annotations: Array}) => void>(), + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.Tools`](./src/Config/Config.js) constants, optional, defaults to none + * + * Defines annotation types that will not show in the annotation (long-press) menu. + * @example + * + */ hideAnnotationMenu: arrayOf(Config.Tools), + + /** + * @type {string[]} + * @optional + * @description Array of [`Config.Actions`](./src/Config/Config.js) constants, defaults to none + * + * Defines actions that will skip default behavior, such as external link click. The function [`onBehaviorActivated`](#onBehaviorActivated) will be called where custom behavior can be implemented, whenever the defined actions occur. + * @example + * + */ overrideBehavior: arrayOf(Config.Actions), + + /** + * @event + * @type {function} + * @optional + * @description This function is called if the activated behavior is passed in to [`overrideBehavior`](#overrideBehavior) + * @param {string} action One of [`Config.Actions`](./src/Config/Config.js) constants, representing which action has been activated + * @param {object} data A JSON object that varies depending on the action. + * + * If action is `Config.Actions.linkPress`, data type is `{url: string}`. + * + * If action is `Config.Actions.stickyNoteShowPopUp`, data type is `{id: string, pageNumber: number, type: string, screenRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}, pageRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}}`, + * where `type` is one of the [`Config.Tools`](./src/Config/Config.js) constants, and `screenRect` was formerly called `rect`. + * @example + * { + * console.log('Activated action is', action); + * if (action === Config.Actions.linkPress) { + * console.log('The external link pressed is', data.url); + * } else if (action === Config.Actions.stickyNoteShowPopUp) { + * console.log('Sticky note has been activated, but it would not show a pop up window.'); + * } + * }} + * /> + */ onBehaviorActivated: func<(event: {action: Config.Actions, data: AnnotOptions.LinkPressData | AnnotOptions.StickyNoteData}) => void>(), + + /** + * @type {boolean} + * @optional + * @default true + * @deprecated Use [`hideTopAppNavBar`](#hideTopAppNavBar) prop instead. + */ topToolbarEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether the bottom toolbar of the viewer is enabled. + * @example + * + */ bottomToolbarEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether an unhandled tap in the viewer should toggle the visibility of the top and bottom toolbars. When false, the top and bottom toolbar visibility will not be toggled and the page content will fit between the bars, if any. + * @example + * + */ hideToolbarsOnTap: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether the document slider of the viewer is enabled. + * @example + * + */ documentSliderEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether to show the page indicator for the viewer. + * @example + * + */ pageIndicatorEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description iOS only + * + * Defines whether the keyboard shortcuts of the viewer are enabled. + * @example + * + */ keyboardShortcutsEnabled: PropTypes.bool, + + /** + * @event + * @type {function} + * @optional + * @description This function is called when an annotation(s) is selected. + * @param {object} event + * @param {object[]} annotations array of annotation data in the format `{id: string, pageNumber: number, type: string, screenRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}, pageRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}}`, representing the selected annotations. Type is one of the [`Config.Tools`](./src/Config/Config.js) constants. `screenRect` was formerly called `rect`. + * @example + * { + * annotations.forEach(annotation => { + * console.log('The id of selected annotation is', annotation.id); + * console.log('It is in page', annotation.pageNumber); + * console.log('Its type is', annotation.type); + * }); + * }} + * /> + */ onAnnotationsSelected: func<(event: {annotations: Array}) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called if a change has been made to an annotation(s) in the current document. + * @param {object} event + * @param {string} event.action the action that occurred (add, delete, modify) + * @param {object[]} event.annotations array of annotation data in the format `{id: string, pageNumber: number, type: string}`, representing the annotations that have been changed. `type` is one of the [`Config.Tools`](./src/Config/Config.js) constants + * @example + * { + * console.log('Annotation edit action is', action); + * annotations.forEach(annotation => { + * console.log('The id of changed annotation is', annotation.id); + * console.log('It is in page', annotation.pageNumber); + * console.log('Its type is', annotation.type); + * }); + * }} + * /> + */ onAnnotationChanged: func<(event: {action: string, annotations: Array}) => void>(), + + /** + * @event + * @type {function} + * @optional + * @description This function is called if a change has been made to form field values. + * @param {object} event + * @param {object[]} event.fields array of field data in the format `{fieldName: string, fieldType: string, fieldValue: any}`, representing the fields that have been changed + * @example + * { + * fields.forEach(field => { + * console.log('The name of the changed field is', field.fieldName); + * console.log('The type of the changed field is', field.fieldType); + * console.log('The value of the changed field is', field.fieldValue); + * }); + * }} + * /> + */ onFormFieldValueChanged: func<(event: {fields: Array}) => void>(), + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether the viewer is read-only. If true, the UI will not allow the user to change the document. + * @example + * + */ readOnly: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether user can modify the document using the thumbnail view (eg add/remove/rotate pages). + * @example + * + */ thumbnailViewEditingEnabled: PropTypes.bool, + + /** + * @type {string} + * @optional + * @default 'FitWidth' + * @description One of the [`Config.FitMode`](./src/Config/Config.js) constants. + * + * Defines the fit mode (default zoom level) of the viewer. + * @example + * + */ fitMode: oneOf(Config.FitMode), + + /** + * @type {string} + * @optional + * @default 'Continuous' + * @description One of the [`Config.LayoutMode`](./src/Config/Config.js) constants. + * + * Defines the layout mode of the viewer. + * @example + * + */ layoutMode: oneOf(Config.LayoutMode), + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onLayoutChanged: func<() => void>(), padStatusBar: PropTypes.bool, continuousAnnotationEditing: PropTypes.bool, @@ -71,6 +624,14 @@ const propTypes = { collabEnabled: PropTypes.bool, currentUser: PropTypes.string, currentUserName: PropTypes.string, + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onExportAnnotationCommand: func<(event: {action: string, xfdfCommand: string, annotations: Array}) => void>(), autoSaveEnabled: PropTypes.bool, pageChangeOnTap: PropTypes.bool, @@ -96,12 +657,43 @@ const propTypes = { hideAnnotationToolbarSwitcher: PropTypes.bool, hideTopToolbars: PropTypes.bool, hideTopAppNavBar: PropTypes.bool, + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onBookmarkChanged: func<(event: {bookmarkJson: string}) => void>(), hideThumbnailFilterModes: arrayOf(Config.ThumbnailFilterMode), + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onToolChanged: func<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), horizontalScrollPos: PropTypes.number, verticalScrollPos: PropTypes.number, + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onTextSearchStart: func<() => void>(), + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onTextSearchResult: func<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), hideViewModeItems: arrayOf(Config.ViewModePickerItem), pageStackEnabled: PropTypes.bool, @@ -114,6 +706,14 @@ const propTypes = { userBookmarksListEditingEnabled: PropTypes.bool, imageInReflowEnabled: PropTypes.bool, reflowOrientation: oneOf(Config.ReflowOrientation), + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onUndoRedoStateChanged: func<() => void>(), tabletLayoutEnabled: PropTypes.bool, initialToolbar: PropTypes.string, @@ -127,12 +727,20 @@ const propTypes = { openSavedCopyInNewTab: PropTypes.bool, excludedAnnotationListTypes: arrayOf(Config.Tools), replyReviewStateEnabled: PropTypes.bool, + + /** + * @event + * @type {function} + * @optional + * @description (temp) + * @example (temp) + */ onPageMoved: func<(event: {previousPageNumber: number, pageNumber: number}) => void>(), - ...ViewPropTypes, + //...ViewPropTypes, }; // Generates the prop types for TypeScript users, from PropTypes. -type DocumentViewProps = PropTypes.InferProps; +export type DocumentViewProps = PropTypes.InferProps; /** * Creates a custom PropType for functions. @@ -142,6 +750,7 @@ type DocumentViewProps = PropTypes.InferProps; * @returns {Requireable} A custom PropType constant. * @example * func<(path: string) => void>() +* @ignore */ function func () : Requireable { @@ -165,7 +774,8 @@ function func () : Requireable { * @example * oneOf(Config.Tools) * oneOf(Config.Tools, Config.Buttons) -*/ + * @ignore + */ function oneOf(obj: object, ...rest: object[]) : Requireable { if (rest.length > 0) { return PropTypes.oneOf(Object.values(Object.assign({}, obj, ...rest))); @@ -181,15 +791,24 @@ function oneOf(obj: object, ...rest: object[]) : Requireable { * @example * arrayOf(Config.Tools) * arrayOf(Config.Tools, Config.Buttons) + * @ignore */ function arrayOf(obj: object, ...rest: object[]) : Requireable { return PropTypes.arrayOf(oneOf(obj, ...rest)) as Requireable; } -export class DocumentView extends PureComponent { +/** + * @class + * @classdesc An all-in-one React component for displaying and editing documents of different types such as PDF, docx, pptx, xlsx and various image formats. + * @hideconstructor + */ + export class DocumentView extends PureComponent { _viewerRef: any; - static propTypes = propTypes; + /** + * Properties to pass into {@link DocumentView}. See {@link propTypes} for the full list of properties and their documentation. + */ + static propTypes = Object.assign(propTypes, {...ViewPropTypes}); onChange = (event: any) => { if (event.nativeEvent.onLeadingNavButtonPressed) { @@ -332,6 +951,15 @@ export class DocumentView extends PureComponent { // Methods + /** + * @method + * @description Returns the path of the current document. If {@link propTypes.document document} is true, this would be the path to the temporary pdf file converted from the base64 string in {@link propTypes.document document}. + * @returns {Promise} path - the document path. + * @example + * this._viewer.getDocumentPath().then((path) => { + * console.log('The path to current document is: ' + path); + * }); + */ getDocumentPath = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -340,7 +968,16 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - +/** + * @method + * @description Sets the current tool mode. + * @param {string} toolMode One of [`Config.Tools`](./src/Config/Config.js) constants, representing the tool mode to set. + * @returns {Promise} + * @example + * this._viewer.setToolMode(Config.Tools.annotationCreateFreeHand).then(() => { + * // done switching tools + * }); + */ setToolMode = (toolMode: Config.Tools): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -349,7 +986,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - commitTool = (): Promise => { + /** @method */ +commitTool = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.commitTool(tag); @@ -357,7 +995,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageCount = (): Promise => { + /** @method */ +getPageCount = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageCount(tag); @@ -365,7 +1004,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - importBookmarkJson = (bookmarkJson: string): Promise => { + /** @method */ +importBookmarkJson = (bookmarkJson: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.importBookmarkJson(tag, bookmarkJson); @@ -373,6 +1013,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** @method */ openBookmarkList = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -381,6 +1022,14 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + +/** + * @method + * @description Imports remote annotation command to local document. + * @param {string} xfdfCommand the XFDF command string + * @param {boolean} [initialLoad=false] whether this is for initial load. + * @returns {Promise} + */ importAnnotationCommand = (xfdfCommand: string, initialLoad?: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -396,7 +1045,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - importAnnotations = (xfdf: string): Promise => { + /** @method */ +importAnnotations = (xfdf: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.importAnnotations(tag, xfdf); @@ -404,7 +1054,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAnnotations = (options?: {annotList: Array}): Promise => { + /** @method */ +exportAnnotations = (options?: {annotList: Array}): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAnnotations(tag, options); @@ -412,6 +1063,16 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + +/** + * @method + * @description Flattens the forms and (optionally) annotations in the current document. + * @param {boolean} formsOnly Defines whether only forms are flattened. If false, all annotations will be flattened + * @returns {Promise} + * @example + * // flatten forms and annotations in the current document. + * this._viewer.flattenAnnotations(false); + */ flattenAnnotations = (formsOnly: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -420,7 +1081,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - deleteAnnotations = (annotations: Array): Promise => { + /** @method */ +deleteAnnotations = (annotations: Array): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.deleteAnnotations(tag, annotations); @@ -428,7 +1090,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - saveDocument = (): Promise => { + /** @method */ +saveDocument = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.saveDocument(tag); @@ -436,7 +1099,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { + /** @method */ +setFlagForFields = (fields: Array, flag: Config.FieldFlags, value: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.setFlagForFields(tag, fields, flag, value); @@ -444,7 +1108,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getField = (fieldName: string): Promise => { + /** @method */ +getField = (fieldName: string): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.getField(tag, fieldName); @@ -452,7 +1117,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - openAnnotationList = (): Promise => { + /** @method */ +openAnnotationList = (): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { return DocumentViewManager.openAnnotationList(tag); @@ -460,7 +1126,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - /** +/** + * @method * note: this function exists for supporting the old version. It simply calls setValuesForFields. * */ @@ -468,6 +1135,7 @@ export class DocumentView extends PureComponent { return this.setValuesForFields(fieldsMap); } + /** @method */ setValuesForFields = (fieldsMap: Record): Promise => { const tag = findNodeHandle(this._viewerRef); if(tag != null) { @@ -476,7 +1144,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - handleBackButton = (): Promise => { + /** @method */ +handleBackButton = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.handleBackButton(tag); @@ -484,15 +1153,20 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - /** - * note: this function exists for supporting the old version. It simply calls setFlagsForAnnotations. + * @method + * @description Sets flags for specified annotations in the current document. The `flagValue` controls whether a flag will be set to or removed from the annotation. + * Note: the old function `setFlagForAnnotations` is deprecated. Please use this one. + * + * @param {object} annotationFlagList A list of annotation flag operations. Each element is in the format {id: string, pageNumber: int, flag: One of AnnotationFlags constants, flagValue: bool} + * @returns {Promise} * */ setFlagForAnnotations = (annotationFlagList: Array): Promise => { return this.setFlagsForAnnotations(annotationFlagList); } + /** @method */ setFlagsForAnnotations = (annotationFlagList: Array): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -501,7 +1175,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - selectAnnotation = (id: string, pageNumber: number): Promise => { + /** @method */ +selectAnnotation = (id: string, pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.selectAnnotation(tag, id, pageNumber); @@ -509,7 +1184,9 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - /** +/** + * @method + * @description * note: this function exists for supporting the old version. It simply calls setPropertiesForAnnotation. * */ @@ -517,6 +1194,7 @@ export class DocumentView extends PureComponent { return this._viewerRef.setPropertiesForAnnotation(id, pageNumber, propertyMap); } + /** @method */ setPropertiesForAnnotation = (id: string, pageNumber: number, propertyMap: AnnotOptions.AnnotationProperties): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -525,7 +1203,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPropertiesForAnnotation = (id: string, pageNumber: number): Promise => { + /** @method */ +getPropertiesForAnnotation = (id: string, pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPropertiesForAnnotation(tag, id, pageNumber); @@ -533,7 +1212,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setDrawAnnotations = (drawAnnotations: boolean): Promise => { + /** @method */ +setDrawAnnotations = (drawAnnotations: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setDrawAnnotations(tag, drawAnnotations); @@ -541,7 +1221,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setVisibilityForAnnotation = (id: string, pageNumber: number, visibility: boolean): Promise => { + /** @method */ +setVisibilityForAnnotation = (id: string, pageNumber: number, visibility: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setVisibilityForAnnotation(tag, id, pageNumber, visibility); @@ -549,6 +1230,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** @method */ setHighlightFields = (highlightFields: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -557,7 +1239,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationAtPoint = (x: number, y: number, distanceThreshold: number, minimumLineWeight: number): Promise => { + /** @method */ +getAnnotationAtPoint = (x: number, y: number, distanceThreshold: number, minimumLineWeight: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationAt(tag, x, y, distanceThreshold, minimumLineWeight); @@ -565,7 +1248,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationListAt = (x1: number, y1: number, x2: number, y2: number): Promise> => { + /** @method */ +getAnnotationListAt = (x1: number, y1: number, x2: number, y2: number): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationListAt(tag, x1, y1, x2, y2); @@ -573,7 +1257,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getAnnotationsOnPage = (pageNumber: number): Promise> => { + /** @method */ +getAnnotationsOnPage = (pageNumber: number): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getAnnotationListOnPage(tag, pageNumber); @@ -581,7 +1266,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getCustomDataForAnnotation = (annotationID: string, pageNumber: number, key: string): Promise => { + /** @method */ +getCustomDataForAnnotation = (annotationID: string, pageNumber: number, key: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getCustomDataForAnnotation(tag, annotationID, pageNumber, key); @@ -589,7 +1275,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageCropBox = (pageNumber: number): Promise => { + /** @method */ +getPageCropBox = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageCropBox(tag, pageNumber); @@ -597,6 +1284,18 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } +/** + * @method + * @description Sets current page of the document. + * @param {integer} pageNumber the page number to be set as the current page; 1-indexed + * @returns {boolean} whether the setting process was successful + * @example + * this._viewer.setCurrentPage(4).then((success) => { + * if (success) { + * console.log("Current page is set to 4."); + * } + * }); + */ setCurrentPage = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -605,7 +1304,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getVisiblePages = (): Promise> => { + /** @method */ +getVisiblePages = (): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getVisiblePages(tag); @@ -613,7 +1313,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoPreviousPage = (): Promise => { + /** @method */ +gotoPreviousPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoPreviousPage(tag); @@ -621,7 +1322,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoNextPage = (): Promise => { + /** @method */ +gotoNextPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoNextPage(tag); @@ -629,7 +1331,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoFirstPage = (): Promise => { + /** @method */ +gotoFirstPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoFirstPage(tag); @@ -637,7 +1340,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - gotoLastPage = (): Promise => { + /** @method */ +gotoLastPage = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.gotoLastPage(tag); @@ -645,7 +1349,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - showGoToPageView = (): Promise => { + /** @method */ +showGoToPageView = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.showGoToPageView(tag); @@ -653,7 +1358,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - closeAllTabs = (): Promise => { + /** @method */ +closeAllTabs = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.closeAllTabs(tag); @@ -661,7 +1367,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - openTabSwitcher = (): Promise => { + /** @method */ +openTabSwitcher = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.openTabSwitcher(tag); @@ -669,7 +1376,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getZoom = (): Promise => { + /** @method */ +getZoom = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getZoom(tag); @@ -677,7 +1385,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setZoomLimits = (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number): Promise => { + /** @method */ +setZoomLimits = (zoomLimitMode: Config.ZoomLimitMode, minimum: number, maximum: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setZoomLimits(tag, zoomLimitMode, minimum, maximum); @@ -685,7 +1394,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - zoomWithCenter = (zoom: number, x: number, y: number): Promise => { + /** @method */ +zoomWithCenter = (zoom: number, x: number, y: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.zoomWithCenter(tag, zoom, x, y); @@ -693,7 +1403,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - zoomToRect = (pageNumber: number, rect: AnnotOptions.Rect): Promise => { + /** @method */ +zoomToRect = (pageNumber: number, rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.zoomToRect(tag, pageNumber, rect); @@ -701,7 +1412,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - smartZoom = (x: number, y: number, animated: boolean): Promise => { + /** @method */ +smartZoom = (x: number, y: number, animated: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.smartZoom(tag, x, y, animated); @@ -709,6 +1421,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** @method */ getScrollPos = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -717,6 +1430,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** @method */ getCanvasSize = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -725,7 +1439,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageRotation = (): Promise => { + /** @method */ +getPageRotation = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageRotation(tag); @@ -733,7 +1448,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - rotateClockwise = (): Promise => { + /** @method */ +rotateClockwise = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.rotateClockwise(tag); @@ -741,7 +1457,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - rotateCounterClockwise = (): Promise => { + /** @method */ +rotateCounterClockwise = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.rotateCounterClockwise(tag); @@ -749,7 +1466,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - + /** @method */ convertScreenPointsToPagePoints = (points: Array): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -758,7 +1475,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - convertPagePointsToScreenPoints = (points: Array): Promise> => { + /** @method */ +convertPagePointsToScreenPoints = (points: Array): Promise> => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.convertPagePointsToScreenPoints(tag, points); @@ -766,7 +1484,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getPageNumberFromScreenPoint = (x: number, y: number): Promise => { + /** @method */ +getPageNumberFromScreenPoint = (x: number, y: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getPageNumberFromScreenPoint(tag, x, y); @@ -774,7 +1493,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setProgressiveRendering = (progressiveRendering: boolean, initialDelay: number, interval: number): Promise => { + /** @method */ +setProgressiveRendering = (progressiveRendering: boolean, initialDelay: number, interval: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setProgressiveRendering(tag, progressiveRendering, initialDelay, interval); @@ -782,7 +1502,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setImageSmoothing = (imageSmoothing: boolean): Promise => { + /** @method */ +setImageSmoothing = (imageSmoothing: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setImageSmoothing(tag, imageSmoothing); @@ -790,7 +1511,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setOverprint = (overprint: Config.OverprintMode): Promise => { + /** @method */ +setOverprint = (overprint: Config.OverprintMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setOverprint(tag, overprint); @@ -798,7 +1520,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setColorPostProcessMode = (colorPostProcessMode: Config.ColorPostProcessMode): Promise => { + /** @method */ +setColorPostProcessMode = (colorPostProcessMode: Config.ColorPostProcessMode): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { DocumentViewManager.setColorPostProcessMode(tag, colorPostProcessMode); @@ -806,7 +1529,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setColorPostProcessColors = (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color): Promise => { + /** @method */ +setColorPostProcessColors = (whiteColor: AnnotOptions.Color, blackColor: AnnotOptions.Color): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setColorPostProcessColors(tag, whiteColor, blackColor); @@ -814,7 +1538,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - startSearchMode = (searchString: string, matchCase: boolean, matchWholeWord: boolean): Promise => { + /** @method */ +startSearchMode = (searchString: string, matchCase: boolean, matchWholeWord: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.startSearchMode(tag, searchString, matchCase, matchWholeWord); @@ -822,7 +1547,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exitSearchMode = (): Promise => { + /** @method */ +exitSearchMode = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exitSearchMode(tag); @@ -830,7 +1556,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - findText = (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean): Promise => { + /** @method */ +findText = (searchString: string, matchCase: boolean, matchWholeWord: boolean, searchUp: boolean, regExp: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.findText(tag, searchString, matchCase, matchWholeWord, searchUp, regExp); @@ -838,7 +1565,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - cancelFindText = (): Promise => { + /** @method */ +cancelFindText = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.cancelFindText(tag); @@ -846,7 +1574,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - openSearch = (): Promise => { + /** @method */ +openSearch = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.openSearch(tag); @@ -854,6 +1583,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** @method */ getSelection = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -862,7 +1592,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - hasSelection = (): Promise => { + /** @method */ +hasSelection = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.hasSelection(tag); @@ -870,7 +1601,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - clearSelection = (): Promise => { + /** @method */ +clearSelection = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.clearSelection(tag); @@ -878,7 +1610,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - getSelectionPageRange = (): Promise => { + /** @method */ +getSelectionPageRange = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.getSelectionPageRange(tag); @@ -886,7 +1619,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - hasSelectionOnPage = (pageNumber: number): Promise => { + /** @method */ +hasSelectionOnPage = (pageNumber: number): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.hasSelectionOnPage(tag, pageNumber); @@ -894,7 +1628,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - + /** @method */ + selectInRect = (rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -903,7 +1638,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - isThereTextInRect = (rect: AnnotOptions.Rect): Promise => { + /** @method */ +isThereTextInRect = (rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.isThereTextInRect(tag, rect); @@ -911,7 +1647,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - selectAll = (): Promise => { + /** @method */ +selectAll = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.selectAll(tag); @@ -919,7 +1656,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setPageBorderVisibility = (pageBorderVisibility: boolean): Promise => { + /** @method */ +setPageBorderVisibility = (pageBorderVisibility: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setPageBorderVisibility(tag, pageBorderVisibility); @@ -927,7 +1665,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setPageTransparencyGrid = (pageTransparencyGrid: boolean): Promise => { + /** @method */ +setPageTransparencyGrid = (pageTransparencyGrid: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setPageTransparencyGrid(tag, pageTransparencyGrid); @@ -935,7 +1674,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setDefaultPageColor = (defaultPageColor: AnnotOptions.Color): Promise => { + /** @method */ +setDefaultPageColor = (defaultPageColor: AnnotOptions.Color): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setDefaultPageColor(tag, defaultPageColor); @@ -943,7 +1683,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setBackgroundColor = (backgroundColor: AnnotOptions.Color): Promise => { + /** @method */ +setBackgroundColor = (backgroundColor: AnnotOptions.Color): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setBackgroundColor(tag, backgroundColor); @@ -951,7 +1692,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise => { + /** @method */ +exportAsImage = (pageNumber: number, dpi: number, exportFormat: Config.ExportFormat): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.exportAsImage(tag, pageNumber, dpi, exportFormat); @@ -959,7 +1701,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - undo = (): Promise => { + /** @method */ +undo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.undo(tag); @@ -967,7 +1710,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - redo = (): Promise => { + /** @method */ +redo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.redo(tag); @@ -975,7 +1719,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - canUndo = (): Promise => { + /** @method */ +canUndo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.canUndo(tag); @@ -983,7 +1728,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - canRedo = (): Promise => { + /** @method */ +canRedo = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.canRedo(tag); @@ -991,7 +1737,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - showCrop = (): Promise => { + /** @method */ +showCrop = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.showCrop(tag); @@ -999,7 +1746,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - setCurrentToolbar = (toolbar: string): Promise => { + /** @method */ +setCurrentToolbar = (toolbar: string): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.setCurrentToolbar(tag, toolbar); @@ -1007,6 +1755,7 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** @method */ showViewSettings = (rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -1015,7 +1764,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - showRotateDialog = (): Promise => { + /** @method */ +showRotateDialog = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.showRotateDialog(tag); @@ -1023,6 +1773,9 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } + /** + * @method + */ showAddPagesView = (rect: AnnotOptions.Rect): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -1031,7 +1784,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - isReflowMode = (): Promise => { + /** @method */ +isReflowMode = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.isReflowMode(tag); @@ -1039,7 +1793,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - toggleReflow = (): Promise => { + /** @method */ +toggleReflow = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.toggleReflow(tag); @@ -1047,7 +1802,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - shareCopy = (rect: AnnotOptions.Rect, flattening: boolean): Promise => { + /** @method */ +shareCopy = (rect: AnnotOptions.Rect, flattening: boolean): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.shareCopy(tag, rect, flattening); @@ -1063,7 +1819,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - openOutlineList = (): Promise => { + /** @method */ +openOutlineList = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.openOutlineList(tag); @@ -1071,7 +1828,8 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - openLayersList = (): Promise => { + /** @method */ +openLayersList = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { return DocumentViewManager.openLayersList(tag); @@ -1079,6 +1837,12 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } +/** + * @method + * @description Displays the existing list container. Its current tab will be the one last opened. + * @example this._viewer.openNavigationLists(); + */ + openNavigationLists = (): Promise => { const tag = findNodeHandle(this._viewerRef); if (tag != null) { @@ -1087,15 +1851,21 @@ export class DocumentView extends PureComponent { return Promise.resolve(); } - _setNativeRef = (ref: any) => { + /** @ignore */ +_setNativeRef = (ref: any) => { this._viewerRef = ref; }; + /** + * @ignore + * + */ render() { return ( // @ts-ignore ; +/** + * @class + * @classdesc A React component for displaying documents of different types such as PDF, docx, pptx, xlsx and various image formats. + * + * PDFViewCtrl is useful when a higher level of customization is required. For easy all-in-one document viewing and editing, use {@link DocumentView}. + * @hideconstructor + */ export class PDFViewCtrl extends PureComponent { static propTypes = propTypes; diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 000000000..69ab437d7 --- /dev/null +++ b/typedoc.json @@ -0,0 +1,6 @@ +{ + "entryPoints": ["index.ts", "src/"], + "out": "docs", + "disableSources": "true", + "readme": "DocHome.md" +} \ No newline at end of file From 6301683e5ad6ab028b85929766e29b4b94dc4bf8 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 2 Sep 2021 09:00:10 -0700 Subject: [PATCH 100/226] Added some comments to Config and PDFViewCtrl --- src/Config/Config.ts | 28 ++++++++++++++++++++++++++++ src/PDFViewCtrl/PDFViewCtrl.tsx | 1 + 2 files changed, 29 insertions(+) diff --git a/src/Config/Config.ts b/src/Config/Config.ts index 4d81a2787..9e5e90cec 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -271,8 +271,36 @@ export const Config = { }, } 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 == "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[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; export type Tools = ValueOf; diff --git a/src/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx index 8ac973fe4..fc3eff7b4 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.tsx +++ b/src/PDFViewCtrl/PDFViewCtrl.tsx @@ -11,6 +11,7 @@ const propTypes = { ...ViewPropTypes, } +// Generates the prop types for TypeScript users, from PropTypes. type PDFViewCtrlProps = InferProps; export class PDFViewCtrl extends PureComponent { From 5e0132a9225bd9f5f2ed6d8dd4d59f022a48b78b Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 2 Sep 2021 12:02:12 -0700 Subject: [PATCH 101/226] Switch ink-docstrap dependency, edit jsdoc config --- conf.json | 13 +------------ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/conf.json b/conf.json index e21a404e2..cc8f2fa5a 100644 --- a/conf.json +++ b/conf.json @@ -13,17 +13,6 @@ }, "templates": { "systemName" : "PDFTron React Native", - "includeDate" : "false", - "navType" : "vertical", - "theme" : "lumen", - "linenums" : "false", - "collapseSymbols" : "true", - "syntaxTheme" : "default", - "sort" : "true", - "search" : "true", - "inverseNav" : "false", - "outputSourceFiles" : "false" , - "outputSourcePath" : "false", - "useLongnameInNav": 1 + "collapseSymbols" : "true" } } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ee50d8e78..4f621309d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1060,8 +1060,8 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ink-docstrap": { - "version": "git+https://github.com/lbittner-pdftron/docstrap.git#ea00d500ce3316ae145fb312cd7b5d769d22fcc7", - "from": "git+https://github.com/lbittner-pdftron/docstrap.git", + "version": "git+https://github.com/akwanpdf/docstrap.git#2f673ef62151097288f96eb6c0de9ea4a3650d85", + "from": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", "requires": { "moment": "^2.14.1", "sanitize-html": "^1.13.0" diff --git a/package.json b/package.json index dfd4f5a7e..0a0724182 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "typescript": "*" }, "dependencies": { - "ink-docstrap": "https://github.com/lbittner-pdftron/docstrap.git", + "ink-docstrap": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", "typedoc": "^0.21.6" } } From 7e2c793097756684fe4ef0fbb6bd1dd89c72f3a6 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 2 Sep 2021 14:38:02 -0700 Subject: [PATCH 102/226] hide attributes in docs - Add contents to doc home - hide contributor's section from generated docs --- DocHome.md | 8 ++++++++ conf.json | 3 ++- src/DocumentView/DocumentView.tsx | 13 +++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/DocHome.md b/DocHome.md index aacd43707..8903ff35b 100644 --- a/DocHome.md +++ b/DocHome.md @@ -3,3 +3,11 @@ ## TypeScript PDFTron React Native now has support for TypeScript. Since not all customers use the language, the typings used in this document will be described using normal JavaScript types. For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](src). + +## Frequently used + +- [DocumentView](DocumentView.html) - An all-in-one React component for displaying and editing documents of different types. +- [DocumentView props](propTypes.html) - Properties to customize the viewer. +- [Config](Config.html) - Defines configuration constants for the viewer. +- [PDFViewCtrl](PDFViewCtrl.html) - A React component for displaying documents when a higher level of customization is required. +- [RNPdftron](RNPdftron.html) - Contains static methods for global library initialization, configuration, and utility methods. \ No newline at end of file diff --git a/conf.json b/conf.json index cc8f2fa5a..64d4a94a8 100644 --- a/conf.json +++ b/conf.json @@ -13,6 +13,7 @@ }, "templates": { "systemName" : "PDFTron React Native", - "collapseSymbols" : "true" + "collapseSymbols" : true, + "hideAttribs" : true } } \ No newline at end of file diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index b48a73341..06adb0f48 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -12,15 +12,20 @@ const { DocumentViewManager } = NativeModules; import {Config} from "../Config/Config"; import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; -/** - * For Users: {@link DocumentView} class props. +/** + * For Contributors: The propTypes interface below contains PropTypes types for + * the {@link DocumentView} class. + * It is also used to generate custom types for TS users. * - * For Contributors: Object containing PropTypes types for {@link DocumentView} class. - * Also used to generate prop types for TS users. * To represent functions, please use {@link func}. * To represent "one of Config.Buttons values" or "an array of * Config.Buttons values", please use {@link oneOf} or {@link arrayOf}. + */ + +/** * @interface propTypes + * This object outlines valid {@link DocumentView} class props. These + * can be passed into {@link DocumentView} to customize the viewer. */ export const propTypes = { /** From edad6ebf51f377a8c678ea4bb5fc43d18179ecc3 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 2 Sep 2021 14:48:06 -0700 Subject: [PATCH 103/226] Added the out folder to gitignore and npmignore --- .gitignore | 5 ++++- .npmignore | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a2a179893..70ab51518 100644 --- a/.gitignore +++ b/.gitignore @@ -49,4 +49,7 @@ example/android/app/src/main/assets/index.android.bundle example/android/app/src/main/assets/index.android.bundle.meta # Build -/lib \ No newline at end of file +/lib + +# Auto-gen Docs +/out \ No newline at end of file diff --git a/.npmignore b/.npmignore index ba0fcd823..269bb2265 100644 --- a/.npmignore +++ b/.npmignore @@ -46,4 +46,7 @@ buck-out/ *.keystore example/android/app/src/main/assets/index.android.bundle -example/android/app/src/main/assets/index.android.bundle.meta \ No newline at end of file +example/android/app/src/main/assets/index.android.bundle.meta + +# Auto-gen Docs +/out \ No newline at end of file From 736d6d9f79e8cd97c476a5fe25674940b09fd188 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 2 Sep 2021 14:50:33 -0700 Subject: [PATCH 104/226] for consistency, don't collapse member symbols --- conf.json | 2 +- src/DocumentView/DocumentView.tsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf.json b/conf.json index 64d4a94a8..af34aaf8d 100644 --- a/conf.json +++ b/conf.json @@ -13,7 +13,7 @@ }, "templates": { "systemName" : "PDFTron React Native", - "collapseSymbols" : true, + "collapseSymbols" : false, "hideAttribs" : true } } \ No newline at end of file diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 06adb0f48..942e567af 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -23,9 +23,9 @@ import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; */ /** - * @interface propTypes - * This object outlines valid {@link DocumentView} class props. These - * can be passed into {@link DocumentView} to customize the viewer. + * @interface + * @description This object outlines valid {@link DocumentView} class props. + * These can be passed into {@link DocumentView} to customize the viewer. */ export const propTypes = { /** From 499b470d94cf549cea52c40d457d910ea4a8f9c9 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 2 Sep 2021 15:09:16 -0700 Subject: [PATCH 105/226] Add more info and links to doc home page --- DocHome.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/DocHome.md b/DocHome.md index 8903ff35b..454164b17 100644 --- a/DocHome.md +++ b/DocHome.md @@ -1,13 +1,27 @@ # PDFTron React Native API +PDFTron's React Native PDF Library allows applications to use JavaScript to build cross-platform mobile apps. + +The application UI is rendered using native views to provide users the fluid look and feel of traditional native applications. + ## TypeScript -PDFTron React Native now has support for TypeScript. Since not all customers use the language, the typings used in this document will be described using normal JavaScript types. For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](src). +Starting with version 3.0.0, PDFTron React Native provides support for TypeScript! + +For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](src). + +The typings used in these API docs will be described using normal JavaScript types. ## Frequently used - [DocumentView](DocumentView.html) - An all-in-one React component for displaying and editing documents of different types. -- [DocumentView props](propTypes.html) - Properties to customize the viewer. +- [Props](propTypes.html) - Properties to customize the viewer. - [Config](Config.html) - Defines configuration constants for the viewer. - [PDFViewCtrl](PDFViewCtrl.html) - A React component for displaying documents when a higher level of customization is required. -- [RNPdftron](RNPdftron.html) - Contains static methods for global library initialization, configuration, and utility methods. \ No newline at end of file +- [RNPdftron](RNPdftron.html) - Contains static methods for global library initialization, configuration, and utility methods. + +## Links + +For instantiation, information, and source code, see our [GitHub](https://github.com/PDFTron/pdftron-react-native). + +For guides and support, visit our [PDFTron website](https://www.pdftron.com/documentation/guides/react-native/). \ No newline at end of file From de2176a744b19ee61d487f8625dc94e51eedaace Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Thu, 2 Sep 2021 16:33:09 -0700 Subject: [PATCH 106/226] Move doc generation options into file --- .gitignore | 3 ++- .npmignore | 3 ++- conf.json | 6 ++++++ DocHome.md => docs/DocHome.md | 0 package-lock.json | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) rename DocHome.md => docs/DocHome.md (100%) diff --git a/.gitignore b/.gitignore index 70ab51518..3e144bf49 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,5 @@ example/android/app/src/main/assets/index.android.bundle.meta /lib # Auto-gen Docs -/out \ No newline at end of file +docs/* +!docs/DocHome.md \ No newline at end of file diff --git a/.npmignore b/.npmignore index 269bb2265..8ce2ac57b 100644 --- a/.npmignore +++ b/.npmignore @@ -49,4 +49,5 @@ example/android/app/src/main/assets/index.android.bundle example/android/app/src/main/assets/index.android.bundle.meta # Auto-gen Docs -/out \ No newline at end of file +docs/* +!docs/DocHome.md \ No newline at end of file diff --git a/conf.json b/conf.json index af34aaf8d..d1ddf3f80 100644 --- a/conf.json +++ b/conf.json @@ -15,5 +15,11 @@ "systemName" : "PDFTron React Native", "collapseSymbols" : false, "hideAttribs" : true + }, + "opts": { + "template": "./node_modules/ink-docstrap/template-algolia", + "destination": "./docs/", + "recurse": true, + "readme": "./docs/DocHome.md" } } \ No newline at end of file diff --git a/DocHome.md b/docs/DocHome.md similarity index 100% rename from DocHome.md rename to docs/DocHome.md diff --git a/package-lock.json b/package-lock.json index 4f621309d..bec265681 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1060,7 +1060,7 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ink-docstrap": { - "version": "git+https://github.com/akwanpdf/docstrap.git#2f673ef62151097288f96eb6c0de9ea4a3650d85", + "version": "git+https://github.com/akwanpdf/docstrap.git#086d8b56d359ed15ed0ec88b05c5f4db2ad188bf", "from": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", "requires": { "moment": "^2.14.1", From 04d6e814194bbcda37214555ed2de7b729b4813e Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 2 Sep 2021 17:11:47 -0700 Subject: [PATCH 107/226] Added scripts in package.json to build docs --- docs/DocHome.md | 2 +- package.json | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/DocHome.md b/docs/DocHome.md index 454164b17..abd5ee5b7 100644 --- a/docs/DocHome.md +++ b/docs/DocHome.md @@ -8,7 +8,7 @@ The application UI is rendered using native views to provide users the fluid loo Starting with version 3.0.0, PDFTron React Native provides support for TypeScript! -For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](src). +For TypeScript users, type information is automatically provided while coding. They can also be found in our [TypeScript source files](https://github.com/PDFTron/pdftron-react-native/tree/master/src). The typings used in these API docs will be described using normal JavaScript types. diff --git a/package.json b/package.json index 0a0724182..cbc70c626 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "scripts": { "copy-to-repo": "cd scripts && python3 fileCopy.py toRepo && cd ..", "copy-to-node-modules": "cd scripts && python3 fileCopy.py toModule && cd ..", - "start": "tsc" + "start": "tsc", + "build-docs": "npx tsc && ./node_modules/.bin/jsdoc -c conf.json", + "build-docs-vanilla-theme": "npx tsc && ./node_modules/.bin/jsdoc -c conf.json -t ./node_modules/ink-docstrap/template-vanilla" }, "repository": { "type": "git", From 45a5dedb177230d9131adef717d18e720429b133 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Thu, 2 Sep 2021 17:42:25 -0700 Subject: [PATCH 108/226] Put space between image and bottom text in leadingNavButtonIcon --- src/DocumentView/DocumentView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 942e567af..c3fbde0f9 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -92,7 +92,7 @@ export const propTypes = { * 1. Add the image resource to the drawable directory in [`example/android/app/src/main/res`](./example/android/app/src/main/res). For details about supported file types and potential compression, check out [here](https://developer.android.com/guide/topics/graphics/drawables#drawables-from-images). * * demo-android - * + *

* 2. Now you can use the image in the viewer. For example, if you add `button_close.png` to drawable, you could use `'button_close'` in leadingNavButtonIcon. * * ##### iOS @@ -104,7 +104,7 @@ export const propTypes = { * - "+". * * demo-ios - * + *

* 2. Now you can use the image in the viewer. For example, if you add `button_open.png` to the bundle, you could use `'button_open.png'` in leadingNavButtonIcon. * * @example From 73218404779464fa131258c13705ca8040ff1454 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 11:45:48 -0700 Subject: [PATCH 109/226] Specify Pdftron return types - put details on same line --- conf.json | 3 ++- index.ts | 8 ++++---- package-lock.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conf.json b/conf.json index d1ddf3f80..736106dcd 100644 --- a/conf.json +++ b/conf.json @@ -14,7 +14,8 @@ "templates": { "systemName" : "PDFTron React Native", "collapseSymbols" : false, - "hideAttribs" : true + "hideAttribs" : true, + "detailsSameLine" : true }, "opts": { "template": "./node_modules/ink-docstrap/template-algolia", diff --git a/index.ts b/index.ts index 7a4e44565..6e53878f4 100644 --- a/index.ts +++ b/index.ts @@ -29,7 +29,7 @@ export interface Pdftron /** * @method * @description Gets the current PDFNet version. - * @returns version - currentPDFNet version + * @returns {Promise} version - currentPDFNet version * @example * RNPdftron.getVersion().then((version) => { * console.log("Current PDFNet version:", version); @@ -40,7 +40,7 @@ export interface Pdftron /** * @method * @description Gets the version of current platform (Android/iOS). - * @returns platformVersion - current platform version (Android/iOS) + * @returns {Promise} platformVersion - current platform version (Android/iOS) * @example * RNPdftron.getPlatformVersion().then((platformVersion) => { * console.log("App currently running on:", platformVersion); @@ -52,7 +52,7 @@ export interface Pdftron * @method * @description Gets the font list available on the OS (Android only). * This is typically useful when you are mostly working with non-ascii characters in the viewer. - * @returns fontList - the font list available on Android + * @returns {Promise} fontList - the font list available on Android * @example * RNPdftron.getSystemFontList().then((fontList) => { * console.log("OS font list:", fontList); @@ -92,7 +92,7 @@ export interface Pdftron * The user is responsible for cleaning up the temporary file that is generated. * @param {string} docxPath the local file path to the template file * @param {object} json the replacement data in the form of a JSON object - * @returns resultPdfPath - the local file path to the generated PDF + * @returns {Promise} resultPdfPath - the local file path to the generated PDF * @example * RNPdftron.pdfFromOfficeTemplate("/sdcard/Download/red.docx", json).then((resultPdfPath) => { * console.log(resultPdfPath); diff --git a/package-lock.json b/package-lock.json index bec265681..e094c754f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1060,7 +1060,7 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ink-docstrap": { - "version": "git+https://github.com/akwanpdf/docstrap.git#086d8b56d359ed15ed0ec88b05c5f4db2ad188bf", + "version": "git+https://github.com/akwanpdf/docstrap.git#78cf1b806507c759514927942bd32a7781a85fb7", "from": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", "requires": { "moment": "^2.14.1", From ce88ec37794f033320cc07e9dbe69aa8221dd1a5 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 12:36:53 -0700 Subject: [PATCH 110/226] add returnsInTable conf option - also removes duplicated return values --- conf.json | 3 ++- index.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/conf.json b/conf.json index 736106dcd..d2ea8d0e2 100644 --- a/conf.json +++ b/conf.json @@ -15,7 +15,8 @@ "systemName" : "PDFTron React Native", "collapseSymbols" : false, "hideAttribs" : true, - "detailsSameLine" : true + "detailsSameLine" : true, + "returnsInTable" : true }, "opts": { "template": "./node_modules/ink-docstrap/template-algolia", diff --git a/index.ts b/index.ts index 6e53878f4..bdf58aca8 100644 --- a/index.ts +++ b/index.ts @@ -53,6 +53,7 @@ export interface Pdftron * @description Gets the font list available on the OS (Android only). * This is typically useful when you are mostly working with non-ascii characters in the viewer. * @returns {Promise} fontList - the font list available on Android + * @returns {Promise} fontNumber - the font number available on iOS * @example * RNPdftron.getSystemFontList().then((fontList) => { * console.log("OS font list:", fontList); From 506a5f8d9db113589e01421bc18863dc941949cf Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 13:57:21 -0700 Subject: [PATCH 111/226] edit conf.json to hide method sigs from doc headers --- conf.json | 3 ++- package-lock.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conf.json b/conf.json index d2ea8d0e2..daf73d880 100644 --- a/conf.json +++ b/conf.json @@ -16,7 +16,8 @@ "collapseSymbols" : false, "hideAttribs" : true, "detailsSameLine" : true, - "returnsInTable" : true + "returnsInTable" : true, + "hideMethodSignature" : true }, "opts": { "template": "./node_modules/ink-docstrap/template-algolia", diff --git a/package-lock.json b/package-lock.json index e094c754f..db5634877 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1060,7 +1060,7 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ink-docstrap": { - "version": "git+https://github.com/akwanpdf/docstrap.git#78cf1b806507c759514927942bd32a7781a85fb7", + "version": "git+https://github.com/akwanpdf/docstrap.git#77b2d545e3475b20b09f86f9d64b68da20b6dddf", "from": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", "requires": { "moment": "^2.14.1", From 84a38326bd39f4c5d525c114144dde63e923a839 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 14:09:03 -0700 Subject: [PATCH 112/226] Remove temporary return value comment --- index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/index.ts b/index.ts index bdf58aca8..6e53878f4 100644 --- a/index.ts +++ b/index.ts @@ -53,7 +53,6 @@ export interface Pdftron * @description Gets the font list available on the OS (Android only). * This is typically useful when you are mostly working with non-ascii characters in the viewer. * @returns {Promise} fontList - the font list available on Android - * @returns {Promise} fontNumber - the font number available on iOS * @example * RNPdftron.getSystemFontList().then((fontList) => { * console.log("OS font list:", fontList); From 2bccc90c81a0e796bf020c3a6508e45d07e57b30 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 16:18:21 -0700 Subject: [PATCH 113/226] Change Config to class section --- src/Config/Config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/Config.ts b/src/Config/Config.ts index 0f4ded1c0..0efe6708a 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -1,6 +1,6 @@ /** * @constant - * @module + * @class * @name Config * @description Defines configuration constants for the viewer. * See [`Config.ts`](https://github.com/PDFTron/pdftron-react-native/blob/master/src/Config/Config.js) From b152f5e23a8cf3c0465377733e402fa56ca5adc9 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 16:25:11 -0700 Subject: [PATCH 114/226] Rename Pdftron interface to RNPdftron --- index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index d7a52229f..b52ab1b48 100644 --- a/index.ts +++ b/index.ts @@ -4,7 +4,7 @@ import { DocumentView } from './src/DocumentView/DocumentView'; import { Config } from './src/Config/Config'; import * as AnnotOptions from './src/AnnotOptions/AnnotOptions'; -export interface Pdftron { +interface RNPdftron { initialize(licenseKey: string) : void; enableJavaScript(enabled: boolean) : void; getVersion() : Promise; @@ -15,7 +15,7 @@ export interface Pdftron { pdfFromOfficeTemplate(docxPath: string, json: object) : Promise; } -const RNPdftron : Pdftron = NativeModules.RNPdftron; +const RNPdftron : RNPdftron = NativeModules.RNPdftron; export { RNPdftron, From 35f2e70b33d254a4c749c850baa0a8f69894b031 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 16:42:44 -0700 Subject: [PATCH 115/226] Rename Pdftron interface to RNPdftron --- index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.ts b/index.ts index 6e53878f4..95c6269e6 100644 --- a/index.ts +++ b/index.ts @@ -5,10 +5,10 @@ import { Config } from './src/Config/Config'; import * as AnnotOptions from './src/AnnotOptions/AnnotOptions'; /** - * @typedef Pdftron - * @description Contains {@link RNPdftron} methods. The Pdftron interface is implemented internally by PDFTron. + * @typedef RNPdftron + * @description RNPdftron contains static methods for global library initialization, configuration, and utility methods. */ -export interface Pdftron +interface RNPdftron { /** * @method @@ -103,11 +103,9 @@ export interface Pdftron /** * @class - * @classdesc RNPdftron contains static methods for global library initialization, configuration, and utility methods. - * @see {@link Pdftron} interface for RNPdftron method descriptions. * @hideconstructor */ -const RNPdftron : Pdftron = NativeModules.RNPdftron; +const RNPdftron : RNPdftron = NativeModules.RNPdftron; export { RNPdftron, From f8767ee8292d33149d03a3321760e6ad4c6fec83 Mon Sep 17 00:00:00 2001 From: Dominic Cupidon Date: Fri, 3 Sep 2021 16:44:17 -0700 Subject: [PATCH 116/226] Added prop info on PDFViewCtrl and changed package.json --- package-lock.json | 100 ++++++++++++++++++++++-------- package.json | 6 +- src/DocumentView/DocumentView.tsx | 10 +-- src/PDFViewCtrl/PDFViewCtrl.tsx | 24 +++++-- 4 files changed, 102 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index db5634877..c127e17e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -426,6 +426,7 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -501,7 +502,8 @@ "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "better-docs": { "version": "2.3.2", @@ -543,6 +545,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -626,6 +629,7 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -635,12 +639,14 @@ "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -680,6 +686,7 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "requires": { "color-name": "1.1.3" } @@ -687,7 +694,8 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true }, "colorette": { "version": "1.3.0", @@ -704,7 +712,8 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "constantinople": { "version": "3.1.2", @@ -795,6 +804,7 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "dev": true, "requires": { "domelementtype": "^2.0.1", "domhandler": "^4.2.0", @@ -805,6 +815,7 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "dev": true, "requires": { "domelementtype": "^2.2.0" } @@ -814,12 +825,14 @@ "domelementtype": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==" + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "dev": true }, "domhandler": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz", "integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==", + "dev": true, "requires": { "domelementtype": "^2.0.1" } @@ -828,6 +841,7 @@ "version": "2.8.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "dev": true, "requires": { "dom-serializer": "^1.0.1", "domelementtype": "^2.2.0", @@ -838,6 +852,7 @@ "version": "4.2.2", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "dev": true, "requires": { "domelementtype": "^2.2.0" } @@ -859,7 +874,8 @@ "entities": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", - "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==" + "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", + "dev": true }, "escalade": { "version": "3.1.1", @@ -919,7 +935,8 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "function-bind": { "version": "1.1.1", @@ -954,6 +971,7 @@ "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -979,6 +997,7 @@ "version": "4.7.7", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", + "dev": true, "requires": { "minimist": "^1.2.5", "neo-async": "^2.6.0", @@ -999,7 +1018,8 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true }, "has-symbols": { "version": "1.0.2", @@ -1038,6 +1058,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.1.0.tgz", "integrity": "sha512-4zDq1a1zhE4gQso/c5LP1OtrhYTncXNSpvJYtWJBtXAETPlMfi3IFNjGuQbYLuVY4ZR0QMqRVvo4Pdy9KLyP8Q==", + "dev": true, "requires": { "domelementtype": "^2.0.1", "domhandler": "^3.0.0", @@ -1049,6 +1070,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -1057,11 +1079,13 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "ink-docstrap": { - "version": "git+https://github.com/akwanpdf/docstrap.git#77b2d545e3475b20b09f86f9d64b68da20b6dddf", + "version": "git+https://github.com/akwanpdf/docstrap.git#ee1bd21ea4bad0a4124ca41935b566b84dcba5a9", "from": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", + "dev": true, "requires": { "moment": "^2.14.1", "sanitize-html": "^1.13.0" @@ -1225,6 +1249,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "dev": true, "requires": { "minimist": "^1.2.5" } @@ -1275,7 +1300,8 @@ "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true }, "lodash.get": { "version": "4.4.2", @@ -1308,6 +1334,7 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, "requires": { "yallist": "^3.0.2" } @@ -1315,7 +1342,8 @@ "lunr": { "version": "2.3.9", "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", - "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==" + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true }, "make-dir": { "version": "3.1.0", @@ -1348,7 +1376,8 @@ "marked": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz", - "integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==" + "integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==", + "dev": true }, "mdurl": { "version": "1.0.1", @@ -1366,6 +1395,7 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1373,7 +1403,8 @@ "minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true }, "mkdirp": { "version": "1.0.4", @@ -1384,12 +1415,14 @@ "moment": { "version": "2.29.1", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==" + "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", + "dev": true }, "neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dev": true }, "node-dir": { "version": "0.1.17", @@ -1416,6 +1449,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } @@ -1424,6 +1458,7 @@ "version": "2.2.5", "resolved": "https://registry.npmjs.org/onigasm/-/onigasm-2.2.5.tgz", "integrity": "sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==", + "dev": true, "requires": { "lru-cache": "^5.1.1" } @@ -1449,7 +1484,8 @@ "parse-srcset": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", - "integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE=" + "integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE=", + "dev": true }, "path-exists": { "version": "4.0.0", @@ -1460,7 +1496,8 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, "path-key": { "version": "3.1.1", @@ -1478,6 +1515,7 @@ "version": "7.0.36", "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.36.tgz", "integrity": "sha512-BebJSIUMwJHRH0HAQoxN4u1CN86glsrwsW0q7T+/m44eXOUAxSNdHRkNZPYz5vVUbg17hFgOQDE7fZk7li3pZw==", + "dev": true, "requires": { "chalk": "^2.4.2", "source-map": "^0.6.1", @@ -1493,7 +1531,8 @@ "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true }, "promise": { "version": "7.3.1", @@ -1818,6 +1857,7 @@ "version": "1.27.5", "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.27.5.tgz", "integrity": "sha512-M4M5iXDAUEcZKLXkmk90zSYWEtk5NH3JmojQxKxV371fnMh+x9t1rqdmXaGoyEHw3z/X/8vnFhKjGL5xFGOJ3A==", + "dev": true, "requires": { "htmlparser2": "^4.1.0", "lodash": "^4.17.15", @@ -1850,6 +1890,7 @@ "version": "0.9.7", "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.7.tgz", "integrity": "sha512-rOoAmwRWDiGKjQ1GaSKmbp1J5CamCera+I+DMM3wG/phbwNYQPt1mrjBBZbK66v80Vl1/A9TTLgXVHMbgtOCIQ==", + "dev": true, "requires": { "json5": "^2.2.0", "onigasm": "^2.2.5", @@ -1865,7 +1906,8 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true }, "sprintf-js": { "version": "1.0.3", @@ -1912,6 +1954,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -1961,6 +2004,7 @@ "version": "0.21.6", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.21.6.tgz", "integrity": "sha512-+4u3PEBjQdaL5/yfus5WJbjIdQHv7E/FpZq3cNki9BBdGmZhqnTF6JLIXDQ2EfVggojOJG9/soB5QVFgXRYnIw==", + "dev": true, "requires": { "glob": "^7.1.7", "handlebars": "^4.7.7", @@ -1975,7 +2019,8 @@ "typedoc-default-themes": { "version": "0.12.10", "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz", - "integrity": "sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==" + "integrity": "sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==", + "dev": true }, "typescript": { "version": "4.3.5", @@ -1993,6 +2038,7 @@ "version": "3.14.1", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.14.1.tgz", "integrity": "sha512-JhS3hmcVaXlp/xSo3PKY5R0JqKs5M3IV+exdLHW99qKvKivPO4Z8qbej6mte17SOPqAOVMjt/XGgWacnFSzM3g==", + "dev": true, "optional": true }, "uglify-to-browserify": { @@ -2036,7 +2082,8 @@ "vscode-textmate": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz", - "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==" + "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", + "dev": true }, "vue-docgen-api": { "version": "3.26.0", @@ -2141,7 +2188,8 @@ "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true }, "wrap-ansi": { "version": "7.0.0", @@ -2183,7 +2231,8 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "xmlcreate": { "version": "2.0.3", @@ -2200,7 +2249,8 @@ "yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true }, "yargs": { "version": "16.2.0", diff --git a/package.json b/package.json index cbc70c626..9d2ff94a8 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,9 @@ "@types/react": "*", "@types/react-native": "*", "better-docs": "^2.3.2", + "ink-docstrap": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", "jsdoc": "^3.6.7", + "typedoc": "^0.21.6", "typescript": "*" - }, - "dependencies": { - "ink-docstrap": "git+https://github.com/akwanpdf/docstrap.git#pdftron-react-native", - "typedoc": "^0.21.6" } } diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index c3fbde0f9..44699b10a 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -27,7 +27,7 @@ import * as AnnotOptions from "../AnnotOptions/AnnotOptions"; * @description This object outlines valid {@link DocumentView} class props. * These can be passed into {@link DocumentView} to customize the viewer. */ -export const propTypes = { +export const DocumentViewPropTypes = { /** * @type {string} * @description The path or url to the document. Required. @@ -745,7 +745,7 @@ export const propTypes = { }; // Generates the prop types for TypeScript users, from PropTypes. -export type DocumentViewProps = PropTypes.InferProps; +export type DocumentViewProps = PropTypes.InferProps; /** * Creates a custom PropType for functions. @@ -811,9 +811,9 @@ function arrayOf(obj: object, ...rest: object[]) : Requireable { _viewerRef: any; /** - * Properties to pass into {@link DocumentView}. See {@link propTypes} for the full list of properties and their documentation. + * Properties to pass into {@link DocumentView}. See {@link DocumentViewPropTypes} for the full list of properties and their documentation. */ - static propTypes = Object.assign(propTypes, {...ViewPropTypes}); + static propTypes = Object.assign(DocumentViewPropTypes, {...ViewPropTypes}); onChange = (event: any) => { if (event.nativeEvent.onLeadingNavButtonPressed) { @@ -1293,7 +1293,7 @@ getPageCropBox = (pageNumber: number): Promise => { * @method * @description Sets current page of the document. * @param {integer} pageNumber the page number to be set as the current page; 1-indexed - * @returns {boolean} whether the setting process was successful + * @returns {boolean} success - whether the setting process was successful * @example * this._viewer.setCurrentPage(4).then((success) => { * if (success) { diff --git a/src/PDFViewCtrl/PDFViewCtrl.tsx b/src/PDFViewCtrl/PDFViewCtrl.tsx index 1ceab070f..327d4d8b3 100644 --- a/src/PDFViewCtrl/PDFViewCtrl.tsx +++ b/src/PDFViewCtrl/PDFViewCtrl.tsx @@ -6,12 +6,24 @@ import { Platform } from 'react-native'; -const propTypes = { +/** + * @interface + * @description This object outlines valid {@link PDFViewCtrl} class props. + * These can be passed into {@link PDFViewCtrl} to customize the viewer. + */ +const PDFViewCtrlPropTypes = { + /** + * @type {string} + * @description The path or url to the document. Required. + * @example + * + */ document: PropTypes.string.isRequired, - ...ViewPropTypes, } -type PDFViewCtrlProps = InferProps; +type PDFViewCtrlProps = InferProps; /** * @class @@ -22,11 +34,15 @@ type PDFViewCtrlProps = InferProps; */ export class PDFViewCtrl extends PureComponent { - static propTypes = propTypes; + /** + * Properties to pass into {@link PDFViewCtrl}. See {@link PDFViewCtrlPropTypes} for the full list of properties and their documentation. + */ + static propTypes = Object.assign(PDFViewCtrlPropTypes, {...ViewPropTypes}); render() { return ( From 9eee11cd6c186d159caf5080368948cadd1c2f1a Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Fri, 3 Sep 2021 17:01:19 -0700 Subject: [PATCH 117/226] hide Config constructor --- src/Config/Config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Config/Config.ts b/src/Config/Config.ts index 0efe6708a..591796f5b 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -1,8 +1,9 @@ /** * @constant * @class + * @hideconstructor * @name Config - * @description Defines configuration constants for the viewer. + * @classdesc Defines configuration constants for the viewer. * See [`Config.ts`](https://github.com/PDFTron/pdftron-react-native/blob/master/src/Config/Config.js) * for the full list of constants. */ From e9b876354b8656bb240e598b3d39cc7cc23d0de2 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 7 Sep 2021 11:50:36 -0700 Subject: [PATCH 118/226] edit comments and fix links --- src/Config/Config.ts | 2 +- src/DocumentView/DocumentView.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Config/Config.ts b/src/Config/Config.ts index 591796f5b..71e2ccf31 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -1,6 +1,6 @@ /** * @constant - * @class + * @class (Assigned to class for documentation purposes.) * @hideconstructor * @name Config * @classdesc Defines configuration constants for the viewer. diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 44699b10a..2b4d3169c 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -62,7 +62,7 @@ export const DocumentViewPropTypes = { /** * @type {number} * @optional - * @description Defines the currently displayed page number. Different from {@link propTypes.initialPageNumber}, changing this prop value at runtime will change the page accordingly. + * @description Defines the currently displayed page number. Different from {@link DocumentViewPropTypes.initialPageNumber}, changing this prop value at runtime will change the page accordingly. * @example * (obj: object, ...rest: object[]) : Requireable { /** * @method - * @description Returns the path of the current document. If {@link propTypes.document document} is true, this would be the path to the temporary pdf file converted from the base64 string in {@link propTypes.document document}. + * @description Returns the path of the current document. If {@link DocumentViewPropTypes.document document} is true, this would be the path to the temporary pdf file converted from the base64 string in {@link DocumentViewPropTypes.document document}. * @returns {Promise} path - the document path. * @example * this._viewer.getDocumentPath().then((path) => { From 15fb42a39d377ba163ab3ae5d84982e4e551a3d6 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 7 Sep 2021 14:56:14 -0700 Subject: [PATCH 119/226] Add prop docs, document Config members, and show source links --- conf.json | 6 +- src/Config/Config.ts | 105 ++++++++--- src/DocumentView/DocumentView.tsx | 280 ++++++++++++++++++++++-------- 3 files changed, 292 insertions(+), 99 deletions(-) diff --git a/conf.json b/conf.json index daf73d880..07d5ac538 100644 --- a/conf.json +++ b/conf.json @@ -17,7 +17,11 @@ "hideAttribs" : true, "detailsSameLine" : true, "returnsInTable" : true, - "hideMethodSignature" : true + "hideMethodSignature" : true, + "outputSourceFiles" : true, + "outputSourcePath" : true, + "linenums" : true, + "sourceRoot" : "https://github.com/PDFTron/pdftron-react-native/blob/ts-master/" }, "opts": { "template": "./node_modules/ink-docstrap/template-algolia", diff --git a/src/Config/Config.ts b/src/Config/Config.ts index 71e2ccf31..3abcc6cfd 100644 --- a/src/Config/Config.ts +++ b/src/Config/Config.ts @@ -9,7 +9,10 @@ */ export const Config = { - // Buttons define the various kinds of buttons for the viewer + /** + * @member + * @description Buttons define the various kinds of buttons for the viewer + */ Buttons: { editToolButton: 'editToolButton', viewControlsButton: 'viewControlsButton', @@ -63,7 +66,10 @@ export const Config = { savePasswordCopyButton: 'savePasswordCopyButton', }, - // Tools define the various kinds of tools for the viewer + /** + * @member + * @description Tools define the various kinds of tools for the viewer + */ Tools: { annotationEdit: 'AnnotationEdit', textSelect: 'TextSelect', @@ -108,7 +114,10 @@ export const Config = { pencilKitDrawing: 'PencilKitDrawing', }, - // FitMode define how a page should fit relative to the viewer, alternatively, the default zoom level + /** + * @member + * @description FitMode define how a page should fit relative to the viewer, alternatively, the default zoom level + */ FitMode: { FitPage: 'FitPage', FitWidth: 'FitWidth', @@ -116,7 +125,10 @@ export const Config = { Zoom: 'Zoom', }, - // LayoutMode defines the layout mode of the viewer + /** + * @member + * @description LayoutMode defines the layout mode of the viewer + */ LayoutMode: { Single: 'Single', Continuous: 'Continuous', @@ -126,13 +138,19 @@ export const Config = { FacingCoverContinuous: 'FacingCoverContinuous', }, - // FieldFlags define the property flags for a form field + /** + * @member + * @description FieldFlags define the property flags for a form field + */ FieldFlags: { ReadOnly: 0, Required: 1, }, - // AnnotationMenu defines the menu items when an annotation is selected + /** + * @member + * @description AnnotationMenu defines the menu items when an annotation is selected + */ AnnotationMenu: { style: 'style', note: 'note', @@ -152,14 +170,20 @@ export const Config = { calibrate: 'calibrate', }, - // EraserType defines the type of earse that will be used when eraser is selected + /** + * @member + * @description EraserType defines the type of earse 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 + /** + * @member + * @description LongPressMenu defines the menu items when a long press on empty space or text occurs + */ LongPressMenu: { copy: 'copy', paste: 'paste', @@ -168,13 +192,19 @@ export const Config = { read: 'read', }, - // Actions define potentially overridable action to the viewer + /** + * @member + * @description Actions define potentially overridable action to the viewer + */ Actions: { linkPress: 'linkPress', stickyNoteShowPopUp: 'stickyNoteShowPopUp', }, - // AnnotationFlags define the flags for any annotation in the document + /** + * @member + * @description AnnotationFlags define the flags for any annotation in the document + */ AnnotationFlags: { hidden: "hidden", invisible: "invisible", @@ -188,7 +218,10 @@ export const Config = { toggleNoView: "toggleNoView" }, - // DefaultToolbars define a set of pre-designed toolbars for easier customization + /** + * @member + * @description DefaultToolbars define a set of pre-designed toolbars for easier customization + */ DefaultToolbars: { View: "PDFTron_View", Annotate: "PDFTron_Annotate", @@ -202,7 +235,10 @@ export const Config = { Favorite: "PDFTron_Favorite" }, - // ToolbarIcons define default toolbar icons for use for potential custom toolbars + /** + * @member + * @description ToolbarIcons define default toolbar icons for use for potential custom toolbars + */ ToolbarIcons: { View: "PDFTron_View", Annotate: "PDFTron_Annotate", @@ -216,7 +252,10 @@ export const Config = { Favorite: "PDFTron_Favorite" }, - // CustomToolbarKey defines the necessary keys for a custom toolbar + /** + * @member + * @description CustomToolbarKey defines the necessary keys for a custom toolbar + */ CustomToolbarKey: { Id: "id", Name: "name", @@ -224,41 +263,59 @@ export const Config = { Items: "items" }, - // ThumbnailFilterMode defines filter modes in the thumbnails browser + /** + * @member + * @description ThumbnailFilterMode defines filter modes in the thumbnails browser + */ ThumbnailFilterMode: { Annotated: "annotated", Bookmarked: "bookmarked", }, - // Conversion defines conversion sources and destinations + /** + * @member + * @description Conversion defines conversion sources and destinations + */ Conversion: { Screen: "screen", Canvas: "canvas", Page: "page", }, - // ViewModePickerItem defines view mode items in the view mode dialog + /** + * @member + * @description ViewModePickerItem defines view mode items in the view mode dialog + */ ViewModePickerItem: { Crop: "viewModeCrop", Rotation: "viewModeRotation", ColorMode: "viewModeColorMode", }, - // ZoomLimitMode defines the limit mode for zoom in the current document viewer + /** + * @member + * @description 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 + /** + * @member + * @description 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 + /** + * @member + * @description ColorPostProcessMode defines color modifications after rendering in the viewer + */ ColorPostProcessMode: { None: "none", Invert: "invert", @@ -266,13 +323,19 @@ export const Config = { NightMode: "nightMode" }, - // ReflowOrientation defines the scrolling direction when in reflow viewing mode + /** + * @member + * @description ReflowOrientation defines the scrolling direction when in reflow viewing mode + */ ReflowOrientation: { Horizontal: 'horizontal', Vertical: 'vertical', }, - // Export to format + /** + * @member + * @description Export to format + */ ExportFormat: { BMP: "BMP", JPEG: "JPEG", diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 2b4d3169c..0b9519f85 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -62,7 +62,7 @@ export const DocumentViewPropTypes = { /** * @type {number} * @optional - * @description Defines the currently displayed page number. Different from {@link DocumentViewPropTypes.initialPageNumber}, changing this prop value at runtime will change the page accordingly. + * @description Defines the currently displayed page number. Different from {@link DocumentViewPropTypes.initialPageNumber initialPageNumber}, changing this prop value at runtime will change the page accordingly. * @example * { @@ -192,9 +191,8 @@ export const DocumentViewPropTypes = { * @type {function} * @optional * @description This function is called when the scroll position has been changed. - * @param {object} event - * @param {number} event.horizontal the horizontal position of the scroll - * @param {number} event.vertical the vertical position of the scroll + * @param {number} horizontal the horizontal position of the scroll + * @param {number} vertical the vertical position of the scroll * @example * { @@ -209,8 +207,7 @@ export const DocumentViewPropTypes = { * @type {function} * @optional * @description This function is called when the zoom scale has been changed. - * @param {object} event - * @param {double} event.zoom the current zoom ratio of the document + * @param {double} zoom the current zoom ratio of the document * @example * { @@ -225,9 +222,13 @@ export const DocumentViewPropTypes = { * @type {function} * @optional * @description This function is called when a zooming has been finished. For example, if zoom via gesture, this is called on gesture release. - * @param {object} event - * @param {number} event.zoom the current zoom ratio of the document - * @example (temp) + * @param {double} zoom the current zoom ratio of the document + * @example + * { + * console.log('Current zoom ratio is', zoom); + * }} + * /> */ onZoomFinished: func<(event: {zoom: number}) => void>(), @@ -238,11 +239,10 @@ export const DocumentViewPropTypes = { zoom: PropTypes.number, /** - * @type {string[]} + * @type {Config.Buttons[]} * @optional - * @description Array of [`Config.Buttons`](./src/Config/Config.js) constants, defaults to none. - * - * Defines buttons to be disabled for the viewer. + * @default Defaults to none. + * @description Defines buttons to be disabled for the viewer. * @example * (Config.Buttons), /** - * @type {string[]} + * @type {Config.Tools[]} * @optional - * @description Array of [`Config.Tools`](./src/Config/Config.js) constants, defaults to none. - * - * Defines tools to be disabled for the viewer. + * @default Defaults to none. + * @description Defines tools to be disabled for the viewer. * @example * (Config.Tools), /** - * @type {string[]} + * @type {Config.LongPressMenu[]} * @optional - * @description Array of [`Config.LongPressMenu`](./src/Config/Config.js) constants, default contains all the items - * - * Defines menu items that can show when long press on text or blank space. + * @default Contains all the items. + * @description Defines menu items that can show when long press on text or blank space. * @example * (Config.LongPressMenu), /** - * @type {string[]} + * @type {Config.LongPressMenu[]} * @optional - * @description Array of [`Config.LongPressMenu`](./src/Config/Config.js) constants, defaults to none. - * - * Defines the menu items on long press that will skip default behavior when pressed. They will still be displayed in the long press menu, and the function {onLongPressMenuPress}`](#onLongPressMenuPress) will be called where custom behavior can be implemented. + * @default Defaults to none. + * @description Defines the menu items on long press that will skip default behavior when pressed. They will still be displayed in the long press menu, and the function {onLongPressMenuPress}`](#onLongPressMenuPress) will be called where custom behavior can be implemented. * @example * (Config.AnnotationMenu), /** - * @type {string[]} + * @type {Config.AnnotationMenu[]} * @optional - * @description Array of [`Config.AnnotationMenu`](./src/Config/Config.js) constants, defaults to none. - * - * Defines the menu items that will skip default behavior when pressed. They will still be displayed in the annotation menu, and the function [`onAnnotationMenuPress`](#onAnnotationMenuPress) will be called where custom behavior can be implemented. + * @default Defaults to none. + * @description Defines the menu items that will skip default behavior when pressed. They will still be displayed in the annotation menu, and the function {@link DocumentViewPropTypes.onAnnotationMenuPress onAnnotationMenuPress} will be called where custom behavior can be implemented. * @example * }) => void>(), /** - * @type {string[]} + * @type {Config.Tools[]} * @optional - * @description Array of [`Config.Tools`](./src/Config/Config.js) constants, optional, defaults to none - * - * Defines annotation types that will not show in the annotation (long-press) menu. + * @default Defaults to none. + * @description Defines annotation types that will not show in the annotation (long-press) menu. * @example * (Config.Tools), /** - * @type {string[]} - * @optional - * @description Array of [`Config.Actions`](./src/Config/Config.js) constants, defaults to none - * - * Defines actions that will skip default behavior, such as external link click. The function [`onBehaviorActivated`](#onBehaviorActivated) will be called where custom behavior can be implemented, whenever the defined actions occur. + * @type {Config.Actions[]} + * @optional + * @default Defaults to none. + * @description Defines actions that will skip default behavior, such as external link click. The function {@link DocumentViewPropTypes.onBehaviorActivated onBehaviorActivated} will be called where custom behavior can be implemented, whenever the defined actions occur. * @example * { @@ -432,7 +424,7 @@ export const DocumentViewPropTypes = { * @type {boolean} * @optional * @default true - * @deprecated Use [`hideTopAppNavBar`](#hideTopAppNavBar) prop instead. + * @deprecated Use {@link DocumentViewPropTypes.hideTopAppNavBar hideTopAppNavBar} prop instead. */ topToolbarEnabled: PropTypes.bool, @@ -503,8 +495,7 @@ export const DocumentViewPropTypes = { * @type {function} * @optional * @description This function is called when an annotation(s) is selected. - * @param {object} event - * @param {object[]} annotations array of annotation data in the format `{id: string, pageNumber: number, type: string, screenRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}, pageRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}}`, representing the selected annotations. Type is one of the [`Config.Tools`](./src/Config/Config.js) constants. `screenRect` was formerly called `rect`. + * @param {object[]} annotations array of annotation data in the format `{id: string, pageNumber: number, type: string, screenRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}, pageRect: {x1: number, y1: number, x2: number, y2: number, width: number, height: number}}`, representing the selected annotations. Type is one of the {@link Config.Tools} constants. `screenRect` was formerly called `rect`. * @example * { @@ -523,9 +514,8 @@ export const DocumentViewPropTypes = { * @type {function} * @optional * @description This function is called if a change has been made to an annotation(s) in the current document. - * @param {object} event - * @param {string} event.action the action that occurred (add, delete, modify) - * @param {object[]} event.annotations array of annotation data in the format `{id: string, pageNumber: number, type: string}`, representing the annotations that have been changed. `type` is one of the [`Config.Tools`](./src/Config/Config.js) constants + * @param {string} action the action that occurred (add, delete, modify) + * @param {object[]} annotations array of annotation data in the format `{id: string, pageNumber: number, type: string}`, representing the annotations that have been changed. `type` is one of the {@link Config.Tools} constants * @example * { @@ -545,8 +535,7 @@ export const DocumentViewPropTypes = { * @type {function} * @optional * @description This function is called if a change has been made to form field values. - * @param {object} event - * @param {object[]} event.fields array of field data in the format `{fieldName: string, fieldType: string, fieldValue: any}`, representing the fields that have been changed + * @param {object[]} fields array of field data in the format `{fieldName: string, fieldType: string, fieldValue: any}`, representing the fields that have been changed * @example * { @@ -585,12 +574,10 @@ export const DocumentViewPropTypes = { thumbnailViewEditingEnabled: PropTypes.bool, /** - * @type {string} + * @type {Config.FitMode} * @optional - * @default 'FitWidth' - * @description One of the [`Config.FitMode`](./src/Config/Config.js) constants. - * - * Defines the fit mode (default zoom level) of the viewer. + * @default Config.FitMode.FitWidth + * @description Defines the fit mode (default zoom level) of the viewer. * @example * (Config.FitMode), /** - * @type {string} + * @type {Config.LayoutMode} * @optional - * @default 'Continuous' - * @description One of the [`Config.LayoutMode`](./src/Config/Config.js) constants. - * - * Defines the layout mode of the viewer. + * @default Config.LayoutMode.Continuous + * @description Defines the layout mode of the viewer. * @example * { + * console.log('Layout has been updated.'); + * }} + * /> */ onLayoutChanged: func<() => void>(), + + /** + * @type {boolean} + * @optional + * @default false + * @description Android only + * + * Defines whether the viewer will add padding to take account of the system status bar. + * @example + * + */ padStatusBar: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description If true, the active annotation creation tool will remain in the current annotation creation tool. Otherwise, it will revert to the "pan tool" after an annotation is created. + * @example + * + */ continuousAnnotationEditing: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether an annotation is selected after it is created. On iOS, this functions for shape and text markup annotations only. + * @example + * + */ selectAnnotationAfterCreation: PropTypes.bool, + + /** + * @type {string} + * @optional + * @description Defines the author name for all annotations created on the current document. Exported xfdfCommand will include this piece of information. + * @example + * + */ annotationAuthor: PropTypes.string, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether to show saved signatures for re-use when using the signing tool. + * @example + * + */ showSavedSignatures: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description If true, {@link DocumentViewPropTypes.document document} prop will be treated as a base64 string. If it is not the base64 string of a pdf file, {@link DocumentViewPropTypes.base64FileExtension base64FileExtension} is required. + * + * When viewing a document initialized with a base64 string (i.e. a memory buffer), a temporary file is created on Android and iOS. + * @example + * + */ isBase64String: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether to enable realtime collaboration. If true then {@link DocumentViewPropTypes.currentUser currentUser} must be set as well for collaboration mode to work. Feature set may vary between local and collaboration mode. + * @example + * + */ collabEnabled: PropTypes.bool, + + /** + * @type {string} + * @description Required if {@link DocumentViewPropTypes.collabEnabled collabEnabled} is set to true. + * + * Defines the current user. Created annotations will have their title (author) set to this string. + * @example + * + */ currentUser: PropTypes.string, + + /** + * @type {string} + * @optional + * @description Defines the current user name. + * Will set the user name only if {@link DocumentViewPropTypes.collabEnabled collabEnabled} is true and {@link DocumentViewPropTypes.currentUser currentUser} is defined. + * This should be used only if you want the user's display name to be different than the annotation's title/author + * (in the case that {@link DocumentViewPropTypes.currentUser currentUser} is an ID rather than a human-friendly name.) + * @example + * + */ currentUserName: PropTypes.string, /** * @event * @type {function} * @optional - * @description (temp) - * @example (temp) + * @description This function is called if a change has been made to annotations in the current document. + * Unlike {@link DocumentViewPropTypes.onAnnotationChanged onAnnotationChanged}, this function has an XFDF command string as its parameter. + * If you are modifying or deleting multiple annotations, then on Android the function is only called once, and on iOS it is called for each annotation. + * + * **Known Issues** + * + * On iOS, there is currently a bug that prevents the last XFDF from being retrieved when modifying annotations while collaboration mode is enabled. + * @param {string} action the action that occurred (add, delete, modify) + * @param {string} xfdfCommand an xfdf string containing info about the edit + * @param {array} annotations an array of annotation data. + * When collaboration is enabled data comes in the format `{id: string}`, otherwise the format is `{id: string, pageNumber: number, type: string}`. + * In both cases, the data represents the annotations that have been changed. + * `type` is one of the {@link Config.Tools} constants. + * @example + * { + * console.log('Annotation edit action is', action); + * console.log('The exported xfdfCommand is', xfdfCommand); + * annotations.forEach((annotation) => { + * console.log('Annotation id is', annotation.id); + * if (!this.state.collabEnabled) { + * console.log('Annotation pageNumber is', annotation.pageNumber); + * console.log('Annotation type is', annotation.type); + * } + * }); + * }} + * collabEnabled={this.state.collabEnabled} + * currentUser={'Pdftron'} + * /> */ onExportAnnotationCommand: func<(event: {action: string, xfdfCommand: string, annotations: Array}) => void>(), autoSaveEnabled: PropTypes.bool, @@ -976,7 +1102,7 @@ function arrayOf(obj: object, ...rest: object[]) : Requireable { /** * @method * @description Sets the current tool mode. - * @param {string} toolMode One of [`Config.Tools`](./src/Config/Config.js) constants, representing the tool mode to set. + * @param {string} toolMode One of {@link Config.Tools} constants, representing the tool mode to set. * @returns {Promise} * @example * this._viewer.setToolMode(Config.Tools.annotationCreateFreeHand).then(() => { From 17185e23cde917ee3ff8b5e46e6ceb1a170fb0c7 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 7 Sep 2021 15:09:37 -0700 Subject: [PATCH 120/226] Document more props --- src/DocumentView/DocumentView.tsx | 130 ++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index 0b9519f85..b9cb6610e 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -764,15 +764,145 @@ export const DocumentViewPropTypes = { * /> */ onExportAnnotationCommand: func<(event: {action: string, xfdfCommand: string, annotations: Array}) => void>(), + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether document is automatically saved by the viewer. + * @example + * + */ autoSaveEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether the viewer should change pages when the user taps the edge of a page, when the viewer is in a horizontal viewing mode. + * @example + * + */ pageChangeOnTap: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Android and iOS 13+ only + * + * Defines whether the UI will appear in a dark color when the system is dark mode. If false, it will use viewer setting instead. + * @example + * + */ followSystemDarkMode: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether a stylus should act as a pen when in pan mode. If false, it will act as a finger. + * @example + * + */ useStylusAsPen: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether viewer will use tabs in order to have more than one document open simultaneously (like a web browser). + * Changing the {@link DocumentViewPropTypes.document document} prop value will cause a new tab to be opened with the associated file. + * @example + * + */ multiTabEnabled: PropTypes.bool, + + /** + * @type {string} + * @optional + * @default the file name + * @description Set the tab title if {@link DocumentViewPropTypes.multiTabEnabled multiTabEnabled} is true. + * @example + * + */ tabTitle: PropTypes.string, + + /** + * @type {number} + * @optional + * @default unlimited + * @description Sets the limit on the maximum number of tabs that the viewer could have at a time. + * Open more documents after reaching this limit will overwrite the old tabs. + * @example + * + */ maxTabCount: PropTypes.number, + + /** + * @type {boolean} + * @optional + * @default false + * @description + * Defines whether signature fields will be signed with image stamps. + * This is useful if you are saving XFDF to remote source. + * @example + * + */ signSignatureFieldsWithStamps: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether an annotation's permission flags will be respected when it is selected. + * For example, a locked annotation can not be resized or moved. + * @example + * + */ annotationPermissionCheckEnabled: PropTypes.bool, + + /** + * @type {Config.DefaultToolbars[]} + * @optional + * @default Defaults to none. + * @description Type can be array of {@link Config.DefaultToolbars} constants or custom toolbar objects. + * + * Defines custom toolbars. If passed in, the default toolbars will no longer appear. + * It is possible to mix and match with default toolbars. See example below. + * @example + * const myToolbar = { + * [Config.CustomToolbarKey.Id]: 'myToolbar', + * [Config.CustomToolbarKey.Name]: 'myToolbar', + * [Config.CustomToolbarKey.Icon]: Config.ToolbarIcons.FillAndSign, + * [Config.CustomToolbarKey.Items]: [Config.Tools.annotationCreateArrow, + * Config.Tools.annotationCreateCallout, Config.Buttons.undo] + * }; + * ... + * + */ annotationToolbars: PropTypes.arrayOf(PropTypes.oneOfType([ oneOf(Config.DefaultToolbars), PropTypes.exact({ From 5d0d7985c1265d3d9071a8f3fb249a6e8ab37053 Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 7 Sep 2021 15:19:45 -0700 Subject: [PATCH 121/226] Document more DocumentView props --- src/DocumentView/DocumentView.tsx | 100 ++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index b9cb6610e..b0afee952 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -912,28 +912,120 @@ export const DocumentViewPropTypes = { items: arrayOf(Config.Tools, Config.Buttons).isRequired }) ])), + + /** + * @type {Config.DefaultToolbars[]} + * @optional + * @default Defaults to none. + * @description Defines which default annotation toolbars should be hidden. + * Note that this prop should be used when {@link DocumentViewPropTypes.annotationToolbars annotationToolbars} is not defined. + * @example + * + */ hideDefaultAnnotationToolbars: arrayOf(Config.DefaultToolbars), + + /** + * @type {Config.Buttons[]} + * @optional + * @description iOS only + * + * Customizes the right bar section of the top app nav bar. If passed in, the default right bar section will not be used. + * @example + * + */ topAppNavBarRightBar: arrayOf(Config.Buttons), + + /** + * @type {Config.Buttons[]} + * @optional + * @description Only the outline list, thumbnail list, share, view mode, search, and reflow buttons are supported on Android. + * + * Defines a custom bottom toolbar. If passed in, the default bottom toolbar will not be used. + * @example + * + */ bottomToolbar: arrayOf(Config.Buttons), + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether to show the toolbar switcher in the top toolbar. + * @example + * + */ hideAnnotationToolbarSwitcher: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether to hide both the top app nav bar and the annotation toolbar. + * @example + * + */ hideTopToolbars: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether to hide the top navigation app bar. + * @example + * + */ hideTopAppNavBar: PropTypes.bool, /** * @event * @type {function} * @optional - * @description (temp) - * @example (temp) + * @description This function is called if a change has been made to user bookmarks. + * @param {string} bookmarkJson the list of current bookmarks in JSON format + * @example + * { + * console.log('Bookmarks have been changed. Current bookmark collection is', bookmarkJson); + * }} + * /> */ onBookmarkChanged: func<(event: {bookmarkJson: string}) => void>(), + + /** + * @type {Config.ThumbnailFilterMode[]} + * @optional + * @description Defines filter modes that should be hidden in the thumbnails browser. + * @example + * + */ hideThumbnailFilterModes: arrayOf(Config.ThumbnailFilterMode), /** * @event * @type {function} * @optional - * @description (temp) - * @example (temp) + * @description This function is called when the current tool changes to a new tool + * @param {string} previousTool the previous tool (one of the {@link Config.Tools} constants or "unknown tool"), representing the tool before change + * @param {string} tool the current tool (one of the {@link Config.Tools} constants or "unknown tool"), representing the current tool + * @example + * { + * console.log('Tool has been changed from', previousTool, 'to', tool); + * }} + * /> */ onToolChanged: func<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), horizontalScrollPos: PropTypes.number, From f3f7032474025f1a3cc1202bbd8b21642061f6de Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 7 Sep 2021 15:30:19 -0700 Subject: [PATCH 122/226] Document more DocumentView props --- src/DocumentView/DocumentView.tsx | 188 +++++++++++++++++++++++++++++- 1 file changed, 184 insertions(+), 4 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index b0afee952..e5fc0b544 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -1028,15 +1028,41 @@ export const DocumentViewPropTypes = { * /> */ onToolChanged: func<(event: {previousTool: Config.Tools | "unknown tool", tool: Config.Tools | "unknown tool"}) => void>(), + + /** + * @type {number} + * @optional + * @description Defines the horizontal scroll position in the current document viewer. + * @example + * + */ horizontalScrollPos: PropTypes.number, + + /** + * @type {number} + * @optional + * @description Defines the vertical scroll position in the current document viewer. + * @example + * + */ verticalScrollPos: PropTypes.number, /** * @event * @type {function} * @optional - * @description (temp) - * @example (temp) + * @description This function is called immediately before a text search begins, + * either through user actions, or function calls such as {@link DocumentViewPropTypes.findText findText}. + * @example + * { + * console.log('Text search has started'); + * }} + * /> */ onTextSearchStart: func<() => void>(), @@ -1044,20 +1070,174 @@ export const DocumentViewPropTypes = { * @event * @type {function} * @optional - * @description (temp) - * @example (temp) + * @description This function is called after a text search is finished or canceled. + * @param {boolean} found whether a result is found. If no, it could be caused by not finding a matching result in the document, invalid text input, or action cancellation (user actions or {@link DocumentViewPropTypes.cancelFindText cancelFindText} + * @param {object} textSelection the text selection, in the format `{html: string, unicode: string, pageNumber: number, quads: [[{x: number, y: number}, {x: number, y: number}, {x: number, y: number}, {x: number, y: number}], ...]}`. If no such selection could be found, this would be null + * + * Quads indicate the quad boundary boxes for the selection, which could have a size larger than 1 if selection spans across different lines. Each quad have 4 points with x, y coordinates specified in number, representing a boundary box. The 4 points are in counter-clockwise order, though the first point is not guaranteed to be on lower-left relatively to the box. + * @example + * { + * if (found) { + * console.log('Found selection on page', textSelection.pageNumber); + * for (let i = 0; i < textSelection.quads.length; i ++) { + * const quad = textSelection.quads[i]; + * console.log('selection boundary quad', i); + * for (const quadPoint of quad) { + * console.log('A quad point has coordinates', quadPoint.x, quadPoint.y); + * } + * } + * } + * }} + * /> */ onTextSearchResult: func<(event: {found: boolean, textSelection: AnnotOptions.TextSelectionResult | null}) => void>(), + + /** + * @type {Config.ViewModePickerItem[]} + * @optional + * @defaults Defaults to none. + * @description Defines view mode items to be hidden in the view mode dialog. + * @example + * + */ hideViewModeItems: arrayOf(Config.ViewModePickerItem), + + /** + * @type {boolean} + * @optional + * @default true + * @description Android only. + * + * Defines whether the page stack navigation buttons will appear in the viewer. + * @example + * + */ pageStackEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Android only + * + * Defines whether the quick navigation buttons will appear in the viewer. + * @example + * + */ showQuickNavigationButton: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true. + * @description Android only. + * + * Defines whether to show the option to pick images in the signature dialog. + * @example + * + */ photoPickerEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether to automatically resize the bounding box of free text annotations when editing. + * @example + * + */ autoResizeFreeTextEnabled: PropTypes.bool, + + /** + * @type {bool} + * @optional + * @default true + * @description Android only + * + * If document editing is enabled, then this value determines if the annotation list is editable. + * @example + * + */ annotationsListEditingEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true on Android and false on iOS + * @description Defines whether the navigation list will be displayed as a side panel on large devices such as iPads and tablets. + * @example + * + */ showNavigationListAsSidePanelOnLargeDevices: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default false + * @description Defines whether to restrict data usage when viewing online PDFs. + * @example + * + */ restrictDownloadUsage: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Defines whether the bookmark list can be edited. If the viewer is readonly then bookmarks on Android are + * still editable but are saved to the device rather than the PDF. + * @example + * + */ userBookmarksListEditingEnabled: PropTypes.bool, + + /** + * @type {boolean} + * @optional + * @default true + * @description Whether to show images in reflow mode. + * @example + * + */ imageInReflowEnabled: PropTypes.bool, + + /** + * @type {Config.ReflowOrientation} + * @optional + * @default Config.ReflowOrientation.Horizontal + * @description Android only. + * + * Sets the scrolling direction of the reflow control. + * @example + * + */ reflowOrientation: oneOf(Config.ReflowOrientation), /** From c670e891f2ac5b0b1f6aa9789c1109afe50459fa Mon Sep 17 00:00:00 2001 From: akwanpdf Date: Tue, 7 Sep 2021 15:41:25 -0700 Subject: [PATCH 123/226] Document more DocumentView props --- src/DocumentView/DocumentView.tsx | 191 ++++++++++++++++++++++++++++-- 1 file changed, 184 insertions(+), 7 deletions(-) diff --git a/src/DocumentView/DocumentView.tsx b/src/DocumentView/DocumentView.tsx index e5fc0b544..e1940c149 100644 --- a/src/DocumentView/DocumentView.tsx +++ b/src/DocumentView/DocumentView.tsx @@ -89,7 +89,7 @@ export const DocumentViewPropTypes = { * **Note**: to add the image file to your application, please follow the steps below: * * ##### Android - * 1. Add the image resource to the drawable directory in [`example/android/app/src/main/res`](./example/android/app/src/main/res). For details about supported file types and potential compression, check out [here](https://developer.android.com/guide/topics/graphics/drawables#drawables-from-images). + * 1. Add the image resource to the drawable directory in [`example/android/app/src/main/res`](https://github.com/PDFTron/pdftron-react-native/blob/master/example/android/app/src/main/res). For details about supported file types and potential compression, check out [here](https://developer.android.com/guide/topics/graphics/drawables#drawables-from-images). * * demo-android *

@@ -278,7 +278,8 @@ export const DocumentViewPropTypes = { * @type {Config.LongPressMenu[]} * @optional * @default Defaults to none. - * @description Defines the menu items on long press that will skip default behavior when pressed. They will still be displayed in the long press menu, and the function {onLongPressMenuPress}`](#onLongPressMenuPress) will be called where custom behavior can be implemented. + * @description Defines the menu items on long press that will skip default behavior when pressed. + * They will still be displayed in the long press menu, and the function {@link DocumentViewPropTypes.onLongPressMenuPress onLongPressMenuPress} will be called where custom behavior can be implemented. * @example *