@amafil/react-native-pdf-toolkit 1.1.2 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -57
- package/android/.gradle/8.5/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.5/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
- package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/e40f3b884607647e8beb6dabe8165962/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +0 -30
- package/android/build/generated/source/codegen/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +0 -10
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/Props.cpp +0 -35
- package/android/build/generated/source/codegen/jni/react/renderer/components/rnpdf/Props.h +0 -7
- package/android/build/generated/source/codegen/schema.json +1 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfManager.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$3.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfManager.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/src/main/java/org/wonday/pdf/PdfManager.java +6 -63
- package/android/src/main/java/org/wonday/pdf/PdfView.java +4 -1189
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java +0 -30
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java +0 -10
- package/fabric/RNPDFPdfNativeComponent.js +3 -18
- package/index.d.ts +1 -102
- package/index.js +0 -110
- package/index.js.flow +0 -72
- package/ios/RNPDFPdf/RNPDFPdfView.h +0 -11
- package/ios/RNPDFPdf/RNPDFPdfView.mm +0 -1242
- package/ios/RNPDFPdf/RNPDFPdfViewManager.mm +0 -37
- package/package.json +5 -6
- package/annotationDocumentUtils.js +0 -74
package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.java
CHANGED
|
@@ -62,27 +62,6 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
|
|
|
62
62
|
case "enableDoubleTapZoom":
|
|
63
63
|
mViewManager.setEnableDoubleTapZoom(view, value == null ? false : (boolean) value);
|
|
64
64
|
break;
|
|
65
|
-
case "annotations":
|
|
66
|
-
mViewManager.setAnnotations(view, value == null ? null : (String) value);
|
|
67
|
-
break;
|
|
68
|
-
case "annotationMode":
|
|
69
|
-
mViewManager.setAnnotationMode(view, value == null ? false : (boolean) value);
|
|
70
|
-
break;
|
|
71
|
-
case "annotationTool":
|
|
72
|
-
mViewManager.setAnnotationTool(view, value == null ? null : (String) value);
|
|
73
|
-
break;
|
|
74
|
-
case "annotationEditable":
|
|
75
|
-
mViewManager.setAnnotationEditable(view, value == null ? false : (boolean) value);
|
|
76
|
-
break;
|
|
77
|
-
case "annotationIdMode":
|
|
78
|
-
mViewManager.setAnnotationIdMode(view, value == null ? null : (String) value);
|
|
79
|
-
break;
|
|
80
|
-
case "annotationInkColor":
|
|
81
|
-
mViewManager.setAnnotationInkColor(view, value == null ? null : (String) value);
|
|
82
|
-
break;
|
|
83
|
-
case "annotationInkThickness":
|
|
84
|
-
mViewManager.setAnnotationInkThickness(view, value == null ? 0f : ((Double) value).floatValue());
|
|
85
|
-
break;
|
|
86
65
|
case "enableAntialiasing":
|
|
87
66
|
mViewManager.setEnableAntialiasing(view, value == null ? false : (boolean) value);
|
|
88
67
|
break;
|
|
@@ -108,15 +87,6 @@ public class RNPDFPdfViewManagerDelegate<T extends View, U extends BaseViewManag
|
|
|
108
87
|
case "setNativePage":
|
|
109
88
|
mViewManager.setNativePage(view, args.getInt(0));
|
|
110
89
|
break;
|
|
111
|
-
case "saveAnnotations":
|
|
112
|
-
mViewManager.saveAnnotations(view);
|
|
113
|
-
break;
|
|
114
|
-
case "deleteSelectedAnnotation":
|
|
115
|
-
mViewManager.deleteSelectedAnnotation(view);
|
|
116
|
-
break;
|
|
117
|
-
case "deleteAllAnnotations":
|
|
118
|
-
mViewManager.deleteAllAnnotations(view);
|
|
119
|
-
break;
|
|
120
90
|
}
|
|
121
91
|
}
|
|
122
92
|
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.java
CHANGED
|
@@ -26,20 +26,10 @@ public interface RNPDFPdfViewManagerInterface<T extends View> {
|
|
|
26
26
|
void setEnableRTL(T view, boolean value);
|
|
27
27
|
void setEnableAnnotationRendering(T view, boolean value);
|
|
28
28
|
void setEnableDoubleTapZoom(T view, boolean value);
|
|
29
|
-
void setAnnotations(T view, @Nullable String value);
|
|
30
|
-
void setAnnotationMode(T view, boolean value);
|
|
31
|
-
void setAnnotationTool(T view, @Nullable String value);
|
|
32
|
-
void setAnnotationEditable(T view, boolean value);
|
|
33
|
-
void setAnnotationIdMode(T view, @Nullable String value);
|
|
34
|
-
void setAnnotationInkColor(T view, @Nullable String value);
|
|
35
|
-
void setAnnotationInkThickness(T view, float value);
|
|
36
29
|
void setEnableAntialiasing(T view, boolean value);
|
|
37
30
|
void setFitPolicy(T view, int value);
|
|
38
31
|
void setSpacing(T view, int value);
|
|
39
32
|
void setPassword(T view, @Nullable String value);
|
|
40
33
|
void setSinglePage(T view, boolean value);
|
|
41
34
|
void setNativePage(T view, int page);
|
|
42
|
-
void saveAnnotations(T view);
|
|
43
|
-
void deleteSelectedAnnotation(T view);
|
|
44
|
-
void deleteAllAnnotations(T view);
|
|
45
35
|
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
8
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
8
9
|
|
|
9
10
|
type ChangeEvent = $ReadOnly<{|
|
|
10
11
|
message: ?string,
|
|
@@ -29,13 +30,6 @@
|
|
|
29
30
|
fitPolicy: ?Int32,
|
|
30
31
|
spacing: ?Int32,
|
|
31
32
|
password: ?string,
|
|
32
|
-
annotations: ?string,
|
|
33
|
-
annotationMode: ?boolean,
|
|
34
|
-
annotationTool: ?string,
|
|
35
|
-
annotationEditable: ?boolean,
|
|
36
|
-
annotationIdMode: ?string,
|
|
37
|
-
annotationInkColor: ?string,
|
|
38
|
-
annotationInkThickness: ?Float,
|
|
39
33
|
onChange: ?BubblingEventHandler<ChangeEvent>,
|
|
40
34
|
singlePage: ?boolean,
|
|
41
35
|
|}>;
|
|
@@ -53,19 +47,10 @@
|
|
|
53
47
|
+stopNativeAutoScroll: (
|
|
54
48
|
viewRef: React.ElementRef<ComponentType>,
|
|
55
49
|
) => void;
|
|
56
|
-
+saveAnnotations: (
|
|
57
|
-
viewRef: React.ElementRef<ComponentType>,
|
|
58
|
-
) => void;
|
|
59
|
-
+deleteSelectedAnnotation: (
|
|
60
|
-
viewRef: React.ElementRef<ComponentType>,
|
|
61
|
-
) => void;
|
|
62
|
-
+deleteAllAnnotations: (
|
|
63
|
-
viewRef: React.ElementRef<ComponentType>,
|
|
64
|
-
) => void;
|
|
65
50
|
}
|
|
66
51
|
|
|
67
52
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
68
|
-
supportedCommands: ['setNativePage', 'startNativeAutoScroll', 'stopNativeAutoScroll'
|
|
53
|
+
supportedCommands: ['setNativePage', 'startNativeAutoScroll', 'stopNativeAutoScroll'],
|
|
69
54
|
});
|
|
70
55
|
|
|
71
56
|
export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
|
package/index.d.ts
CHANGED
|
@@ -27,68 +27,6 @@ export type Source = {
|
|
|
27
27
|
method?: string;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export type AnnotationRotation = 0 | 90 | 180 | 270;
|
|
31
|
-
export type AnnotationIdMode = 'auto' | 'manual';
|
|
32
|
-
export type AnnotationTool = 'select' | 'ink' | 'text' | 'highlight';
|
|
33
|
-
export type AnnotationTextAlign = 'left' | 'center' | 'right';
|
|
34
|
-
|
|
35
|
-
export type AnnotationPoint = {
|
|
36
|
-
x: number,
|
|
37
|
-
y: number,
|
|
38
|
-
pressure?: number,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type AnnotationBounds = {
|
|
42
|
-
x: number,
|
|
43
|
-
y: number,
|
|
44
|
-
width: number,
|
|
45
|
-
height: number,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export type AnnotationStyle = {
|
|
49
|
-
color?: string,
|
|
50
|
-
thickness?: number,
|
|
51
|
-
fontFamily?: string,
|
|
52
|
-
fontSize?: number,
|
|
53
|
-
textAlign?: AnnotationTextAlign,
|
|
54
|
-
rotation?: AnnotationRotation,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type AnnotationBase = {
|
|
58
|
-
id: string,
|
|
59
|
-
page: number,
|
|
60
|
-
locked?: boolean,
|
|
61
|
-
createdAt?: number,
|
|
62
|
-
updatedAt?: number,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type InkAnnotation = AnnotationBase & {
|
|
66
|
-
type: 'ink',
|
|
67
|
-
points: AnnotationPoint[],
|
|
68
|
-
style?: AnnotationStyle,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type TextAnnotation = AnnotationBase & {
|
|
72
|
-
type: 'text',
|
|
73
|
-
bounds: AnnotationBounds,
|
|
74
|
-
text: string,
|
|
75
|
-
style?: AnnotationStyle,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type MarkupAnnotation = AnnotationBase & {
|
|
79
|
-
type: 'highlight',
|
|
80
|
-
bounds: AnnotationBounds,
|
|
81
|
-
style?: AnnotationStyle,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type Annotation = InkAnnotation | TextAnnotation | MarkupAnnotation;
|
|
85
|
-
|
|
86
|
-
export type AnnotationDocument = {
|
|
87
|
-
editable?: boolean,
|
|
88
|
-
idMode?: AnnotationIdMode,
|
|
89
|
-
annotations: Annotation[],
|
|
90
|
-
};
|
|
91
|
-
|
|
92
30
|
export type TextSelectionChangeEvent = {
|
|
93
31
|
nativeEvent:
|
|
94
32
|
| {
|
|
@@ -120,34 +58,6 @@ export interface PdfProps {
|
|
|
120
58
|
enableRTL?: boolean,
|
|
121
59
|
enableAnnotationRendering?: boolean,
|
|
122
60
|
enableDoubleTapZoom?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Initial annotation document to render in the overlay.
|
|
125
|
-
*/
|
|
126
|
-
annotations?: AnnotationDocument,
|
|
127
|
-
/**
|
|
128
|
-
* Enable annotation editing mode.
|
|
129
|
-
*/
|
|
130
|
-
annotationMode?: boolean,
|
|
131
|
-
/**
|
|
132
|
-
* Active tool used while annotation editing is enabled.
|
|
133
|
-
*/
|
|
134
|
-
annotationTool?: AnnotationTool,
|
|
135
|
-
/**
|
|
136
|
-
* Allow in-place annotation edits.
|
|
137
|
-
*/
|
|
138
|
-
annotationEditable?: boolean,
|
|
139
|
-
/**
|
|
140
|
-
* Controls how annotation IDs are generated and preserved.
|
|
141
|
-
*/
|
|
142
|
-
annotationIdMode?: AnnotationIdMode,
|
|
143
|
-
/**
|
|
144
|
-
* Default color applied to newly created ink annotations.
|
|
145
|
-
*/
|
|
146
|
-
annotationInkColor?: string,
|
|
147
|
-
/**
|
|
148
|
-
* Default thickness applied to newly created ink annotations.
|
|
149
|
-
*/
|
|
150
|
-
annotationInkThickness?: number,
|
|
151
61
|
/**
|
|
152
62
|
* Only works on iOS. Defaults to `true`.
|
|
153
63
|
*/
|
|
@@ -170,22 +80,11 @@ export interface PdfProps {
|
|
|
170
80
|
onPressLink?: (url: string) => void,
|
|
171
81
|
onAutoScrollEnd?: () => void,
|
|
172
82
|
onTextSelectionChange?: (event: TextSelectionChangeEvent) => void,
|
|
83
|
+
onAutoScrollEnd?: () => void,
|
|
173
84
|
}
|
|
174
85
|
|
|
175
86
|
export interface PdfRef {
|
|
176
87
|
setPage(pageNumber: number): void
|
|
177
|
-
/**
|
|
178
|
-
* Resolves with the current annotation document serialized by native code.
|
|
179
|
-
*/
|
|
180
|
-
saveAnnotations(): Promise<AnnotationDocument>
|
|
181
|
-
/**
|
|
182
|
-
* Deletes the currently selected custom annotation.
|
|
183
|
-
*/
|
|
184
|
-
deleteSelectedAnnotation(): void
|
|
185
|
-
/**
|
|
186
|
-
* Deletes all custom annotations in the current overlay draft.
|
|
187
|
-
*/
|
|
188
|
-
deleteAllAnnotations(): void
|
|
189
88
|
/**
|
|
190
89
|
* Start smooth automatic vertical scrolling using the display refresh rate.
|
|
191
90
|
* @param dpPerSecond - Scroll speed in density-independent pixels (dp) per second (default: 15). Produces consistent physical speed across screen densities.
|
package/index.js
CHANGED
|
@@ -23,11 +23,6 @@ import PdfViewNativeComponent, {
|
|
|
23
23
|
import ReactNativeBlobUtil from 'react-native-blob-util'
|
|
24
24
|
import {ViewPropTypes} from 'deprecated-react-native-prop-types';
|
|
25
25
|
const SHA1 = require('crypto-js/sha1');
|
|
26
|
-
import {
|
|
27
|
-
joinAnnotationMessagePayload,
|
|
28
|
-
parseAnnotationMessagePayload,
|
|
29
|
-
stringifyAnnotationDocument,
|
|
30
|
-
} from './annotationDocumentUtils';
|
|
31
26
|
import PdfView from './PdfView';
|
|
32
27
|
|
|
33
28
|
export default class Pdf extends Component {
|
|
@@ -62,13 +57,6 @@ export default class Pdf extends Component {
|
|
|
62
57
|
fitPolicy: PropTypes.number,
|
|
63
58
|
trustAllCerts: PropTypes.bool,
|
|
64
59
|
singlePage: PropTypes.bool,
|
|
65
|
-
annotations: PropTypes.object,
|
|
66
|
-
annotationMode: PropTypes.bool,
|
|
67
|
-
annotationTool: PropTypes.oneOf(['select', 'ink', 'text', 'highlight']),
|
|
68
|
-
annotationEditable: PropTypes.bool,
|
|
69
|
-
annotationIdMode: PropTypes.oneOf(['auto', 'manual']),
|
|
70
|
-
annotationInkColor: PropTypes.string,
|
|
71
|
-
annotationInkThickness: PropTypes.number,
|
|
72
60
|
onLoadComplete: PropTypes.func,
|
|
73
61
|
onPageChanged: PropTypes.func,
|
|
74
62
|
onError: PropTypes.func,
|
|
@@ -108,13 +96,6 @@ export default class Pdf extends Component {
|
|
|
108
96
|
trustAllCerts: true,
|
|
109
97
|
usePDFKit: true,
|
|
110
98
|
singlePage: false,
|
|
111
|
-
annotations: null,
|
|
112
|
-
annotationMode: false,
|
|
113
|
-
annotationTool: 'select',
|
|
114
|
-
annotationEditable: true,
|
|
115
|
-
annotationIdMode: 'auto',
|
|
116
|
-
annotationInkColor: '#111111',
|
|
117
|
-
annotationInkThickness: 2,
|
|
118
99
|
onLoadProgress: (percent) => {
|
|
119
100
|
},
|
|
120
101
|
onLoadComplete: (numberOfPages, path) => {
|
|
@@ -146,7 +127,6 @@ export default class Pdf extends Component {
|
|
|
146
127
|
};
|
|
147
128
|
|
|
148
129
|
this.lastRNBFTask = null;
|
|
149
|
-
this._annotationSavePromise = null;
|
|
150
130
|
|
|
151
131
|
}
|
|
152
132
|
|
|
@@ -176,10 +156,6 @@ export default class Pdf extends Component {
|
|
|
176
156
|
componentWillUnmount() {
|
|
177
157
|
this._mounted = false;
|
|
178
158
|
this.stopAutoScroll();
|
|
179
|
-
if (this._annotationSavePromise) {
|
|
180
|
-
this._annotationSavePromise.reject(new Error('Pdf unmounted before annotation save completed'));
|
|
181
|
-
this._annotationSavePromise = null;
|
|
182
|
-
}
|
|
183
159
|
if (this.lastRNBFTask) {
|
|
184
160
|
// this.lastRNBFTask.cancel(err => {
|
|
185
161
|
// });
|
|
@@ -396,70 +372,6 @@ export default class Pdf extends Component {
|
|
|
396
372
|
|
|
397
373
|
}
|
|
398
374
|
|
|
399
|
-
saveAnnotations() {
|
|
400
|
-
if (this._annotationSavePromise) {
|
|
401
|
-
return Promise.reject(new Error('An annotation save is already in progress'));
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
return new Promise((resolve, reject) => {
|
|
405
|
-
if (!this._root) {
|
|
406
|
-
reject(new Error('Pdf is not mounted'));
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
this._annotationSavePromise = {resolve, reject};
|
|
411
|
-
|
|
412
|
-
if (!!global?.nativeFabricUIManager) {
|
|
413
|
-
if (PdfViewCommands.saveAnnotations) {
|
|
414
|
-
PdfViewCommands.saveAnnotations(this._root);
|
|
415
|
-
} else {
|
|
416
|
-
this._annotationSavePromise = null;
|
|
417
|
-
reject(new Error('Annotation save command is not available'));
|
|
418
|
-
}
|
|
419
|
-
} else {
|
|
420
|
-
const ReactNative = require('react-native');
|
|
421
|
-
try {
|
|
422
|
-
ReactNative.UIManager.dispatchViewManagerCommand(
|
|
423
|
-
ReactNative.findNodeHandle(this._root),
|
|
424
|
-
'saveAnnotations',
|
|
425
|
-
[],
|
|
426
|
-
);
|
|
427
|
-
} catch (error) {
|
|
428
|
-
this._annotationSavePromise = null;
|
|
429
|
-
reject(error);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
deleteSelectedAnnotation() {
|
|
436
|
-
this._dispatchAnnotationCommand('deleteSelectedAnnotation', PdfViewCommands.deleteSelectedAnnotation);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
deleteAllAnnotations() {
|
|
440
|
-
this._dispatchAnnotationCommand('deleteAllAnnotations', PdfViewCommands.deleteAllAnnotations);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
_dispatchAnnotationCommand(commandName, fabricCommand) {
|
|
444
|
-
if (!this._root) {
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
if (!!global?.nativeFabricUIManager) {
|
|
449
|
-
if (fabricCommand) {
|
|
450
|
-
fabricCommand(this._root);
|
|
451
|
-
}
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
const ReactNative = require('react-native');
|
|
456
|
-
ReactNative.UIManager.dispatchViewManagerCommand(
|
|
457
|
-
ReactNative.findNodeHandle(this._root),
|
|
458
|
-
commandName,
|
|
459
|
-
[],
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
375
|
startAutoScroll( dpPerSecond = 15, resumeDelay = 3000 ) {
|
|
464
376
|
this._isAutoScrollActive = true;
|
|
465
377
|
if (!!global?.nativeFabricUIManager) {
|
|
@@ -553,20 +465,6 @@ export default class Pdf extends Component {
|
|
|
553
465
|
} else if (message[0] === 'autoScrollEnd') {
|
|
554
466
|
this._isAutoScrollActive = false;
|
|
555
467
|
this.props.onAutoScrollEnd && this.props.onAutoScrollEnd();
|
|
556
|
-
} else if (message[0] === 'annotationSaveComplete') {
|
|
557
|
-
const annotationDocument = parseAnnotationMessagePayload(message);
|
|
558
|
-
|
|
559
|
-
if (this._annotationSavePromise) {
|
|
560
|
-
this._annotationSavePromise.resolve(annotationDocument);
|
|
561
|
-
this._annotationSavePromise = null;
|
|
562
|
-
}
|
|
563
|
-
} else if (message[0] === 'annotationSaveError') {
|
|
564
|
-
const annotationError = joinAnnotationMessagePayload(message);
|
|
565
|
-
|
|
566
|
-
if (this._annotationSavePromise) {
|
|
567
|
-
this._annotationSavePromise.reject(new Error(annotationError || 'Annotation save failed'));
|
|
568
|
-
this._annotationSavePromise = null;
|
|
569
|
-
}
|
|
570
468
|
}
|
|
571
469
|
}
|
|
572
470
|
|
|
@@ -578,13 +476,7 @@ export default class Pdf extends Component {
|
|
|
578
476
|
|
|
579
477
|
};
|
|
580
478
|
|
|
581
|
-
_getNativeAnnotations = () => {
|
|
582
|
-
return stringifyAnnotationDocument(this.props.annotations, this._onError);
|
|
583
|
-
};
|
|
584
|
-
|
|
585
479
|
render() {
|
|
586
|
-
const nativeAnnotations = this._getNativeAnnotations();
|
|
587
|
-
|
|
588
480
|
if (Platform.OS === "android" || Platform.OS === "ios" || Platform.OS === "windows") {
|
|
589
481
|
return (
|
|
590
482
|
<View style={[this.props.style,{overflow: 'hidden'}]}>
|
|
@@ -600,7 +492,6 @@ export default class Pdf extends Component {
|
|
|
600
492
|
<PdfCustom
|
|
601
493
|
ref={component => (this._root = component)}
|
|
602
494
|
{...this.props}
|
|
603
|
-
annotations={nativeAnnotations}
|
|
604
495
|
style={[{flex:1,backgroundColor: '#EEE'}, this.props.style]}
|
|
605
496
|
path={this.state.path}
|
|
606
497
|
onChange={this._onChange}
|
|
@@ -610,7 +501,6 @@ export default class Pdf extends Component {
|
|
|
610
501
|
<PdfCustom
|
|
611
502
|
ref={component => (this._root = component)}
|
|
612
503
|
{...this.props}
|
|
613
|
-
annotations={nativeAnnotations}
|
|
614
504
|
style={[{backgroundColor: '#EEE',overflow: 'hidden'}, this.props.style]}
|
|
615
505
|
path={this.state.path}
|
|
616
506
|
onChange={this._onChange}
|
package/index.js.flow
CHANGED
|
@@ -24,68 +24,6 @@ export type Source = {
|
|
|
24
24
|
uri: string
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export type AnnotationRotation = 0 | 90 | 180 | 270;
|
|
28
|
-
export type AnnotationIdMode = 'auto' | 'manual';
|
|
29
|
-
export type AnnotationTool = 'select' | 'ink' | 'text' | 'highlight';
|
|
30
|
-
export type AnnotationTextAlign = 'left' | 'center' | 'right';
|
|
31
|
-
|
|
32
|
-
export type AnnotationPoint = {
|
|
33
|
-
x: number,
|
|
34
|
-
y: number,
|
|
35
|
-
pressure?: number,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type AnnotationBounds = {
|
|
39
|
-
x: number,
|
|
40
|
-
y: number,
|
|
41
|
-
width: number,
|
|
42
|
-
height: number,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type AnnotationStyle = {
|
|
46
|
-
color?: string,
|
|
47
|
-
thickness?: number,
|
|
48
|
-
fontFamily?: string,
|
|
49
|
-
fontSize?: number,
|
|
50
|
-
textAlign?: AnnotationTextAlign,
|
|
51
|
-
rotation?: AnnotationRotation,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type AnnotationBase = {
|
|
55
|
-
id: string,
|
|
56
|
-
page: number,
|
|
57
|
-
locked?: boolean,
|
|
58
|
-
createdAt?: number,
|
|
59
|
-
updatedAt?: number,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type InkAnnotation = AnnotationBase & {
|
|
63
|
-
type: 'ink',
|
|
64
|
-
points: Array<AnnotationPoint>,
|
|
65
|
-
style?: AnnotationStyle,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type TextAnnotation = AnnotationBase & {
|
|
69
|
-
type: 'text',
|
|
70
|
-
bounds: AnnotationBounds,
|
|
71
|
-
text: string,
|
|
72
|
-
style?: AnnotationStyle,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export type MarkupAnnotation = AnnotationBase & {
|
|
76
|
-
type: 'highlight',
|
|
77
|
-
bounds: AnnotationBounds,
|
|
78
|
-
style?: AnnotationStyle,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export type Annotation = InkAnnotation | TextAnnotation | MarkupAnnotation;
|
|
82
|
-
|
|
83
|
-
export type AnnotationDocument = {
|
|
84
|
-
editable?: boolean,
|
|
85
|
-
idMode?: AnnotationIdMode,
|
|
86
|
-
annotations: Array<Annotation>,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
27
|
export type TableContent = {
|
|
90
28
|
children: TableContent[],
|
|
91
29
|
mNativePtr: number,
|
|
@@ -95,13 +33,6 @@ export type TableContent = {
|
|
|
95
33
|
|
|
96
34
|
export type Props = {
|
|
97
35
|
renderActivityIndicator?: (progress: number) => Node,
|
|
98
|
-
annotations?: AnnotationDocument,
|
|
99
|
-
annotationMode?: boolean,
|
|
100
|
-
annotationTool?: AnnotationTool,
|
|
101
|
-
annotationEditable?: boolean,
|
|
102
|
-
annotationIdMode?: AnnotationIdMode,
|
|
103
|
-
annotationInkColor?: string,
|
|
104
|
-
annotationInkThickness?: number,
|
|
105
36
|
enableAnnotationRendering?: boolean,
|
|
106
37
|
enableAntialiasing?: boolean,
|
|
107
38
|
enablePaging?: boolean,
|
|
@@ -133,7 +64,4 @@ export type Props = {
|
|
|
133
64
|
|
|
134
65
|
declare export default class Pdf extends Component<Props> {
|
|
135
66
|
setPage: (pageNumber: number) => void;
|
|
136
|
-
saveAnnotations: () => Promise<AnnotationDocument>;
|
|
137
|
-
deleteSelectedAnnotation: () => void;
|
|
138
|
-
deleteAllAnnotations: () => void;
|
|
139
67
|
}
|
|
@@ -49,13 +49,6 @@ UIView
|
|
|
49
49
|
@property(nonatomic) BOOL enableRTL;
|
|
50
50
|
@property(nonatomic) BOOL enableAnnotationRendering;
|
|
51
51
|
@property(nonatomic) BOOL enableDoubleTapZoom;
|
|
52
|
-
@property(nonatomic, strong) NSString *annotations;
|
|
53
|
-
@property(nonatomic) BOOL annotationMode;
|
|
54
|
-
@property(nonatomic, strong) NSString *annotationTool;
|
|
55
|
-
@property(nonatomic) BOOL annotationEditable;
|
|
56
|
-
@property(nonatomic, strong) NSString *annotationIdMode;
|
|
57
|
-
@property(nonatomic, strong) NSString *annotationInkColor;
|
|
58
|
-
@property(nonatomic) float annotationInkThickness;
|
|
59
52
|
@property(nonatomic) int fitPolicy;
|
|
60
53
|
@property(nonatomic) int spacing;
|
|
61
54
|
@property(nonatomic, strong) NSString *password;
|
|
@@ -63,10 +56,6 @@ UIView
|
|
|
63
56
|
|
|
64
57
|
@property(nonatomic, copy) RCTBubblingEventBlock onChange;
|
|
65
58
|
|
|
66
|
-
- (void)saveAnnotations;
|
|
67
|
-
- (void)deleteSelectedAnnotation;
|
|
68
|
-
- (void)deleteAllAnnotations;
|
|
69
|
-
|
|
70
59
|
@property(nonatomic, strong) NSString *selectedText;
|
|
71
60
|
@property(nonatomic) BOOL enableTextSelection;
|
|
72
61
|
@property(nonatomic, strong) PDFSelection *currentPDFSelection;
|