@amafil/react-native-pdf-toolkit 1.1.3 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/android/.gradle/8.5/executionHistory/executionHistory.bin +0 -0
  2. package/android/.gradle/8.5/executionHistory/executionHistory.lock +0 -0
  3. package/android/.gradle/8.5/fileHashes/fileHashes.bin +0 -0
  4. package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
  5. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  7. package/android/.gradle/file-system.probe +0 -0
  8. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
  9. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
  10. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
  11. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView$1.dex +0 -0
  12. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationHit.dex +0 -0
  13. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationSelectionHit.dex +0 -0
  14. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$AnnotationOverlayView.dex +0 -0
  15. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$PageRenderInfo.dex +0 -0
  16. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
  17. package/android/build/.transforms/2892d280277a194daf04e3af971b529e/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  18. package/android/build/.transforms/e40f3b884607647e8beb6dabe8165962/transformed/classes/classes_dex/classes.dex +0 -0
  19. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  20. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  21. package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +1 -1
  22. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +1 -1
  23. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +1 -1
  24. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$1.class +0 -0
  25. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$2.class +0 -0
  26. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$3.class +0 -0
  27. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView$1.class +0 -0
  28. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationHit.class +0 -0
  29. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationSelectionHit.class +0 -0
  30. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$AnnotationOverlayView.class +0 -0
  31. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView$PageRenderInfo.class +0 -0
  32. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/wonday/pdf/PdfView.class +0 -0
  33. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$1.class +0 -0
  34. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$2.class +0 -0
  35. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$3.class +0 -0
  36. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView$1.class +0 -0
  37. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationHit.class +0 -0
  38. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView$AnnotationSelectionHit.class +0 -0
  39. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$AnnotationOverlayView.class +0 -0
  40. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView$PageRenderInfo.class +0 -0
  41. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/org/wonday/pdf/PdfView.class +0 -0
  42. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  43. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId7 +0 -0
  44. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/{PdfView$1.class.uniqueId0 → PdfView$1.class.uniqueId3} +0 -0
  45. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$2.class.uniqueId5 +0 -0
  46. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView$1.class.uniqueId6 +0 -0
  47. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView$AnnotationHit.class.uniqueId1 +0 -0
  48. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView$AnnotationSelectionHit.class.uniqueId9 +0 -0
  49. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$AnnotationOverlayView.class.uniqueId8 +0 -0
  50. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$PageRenderInfo.class.uniqueId0 +0 -0
  51. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView.class.uniqueId2 +0 -0
  52. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  53. package/android/src/main/java/org/wonday/pdf/PdfManager.java +6 -7
  54. package/android/src/main/java/org/wonday/pdf/PdfView.java +155 -91
  55. package/index.d.ts +2 -1
  56. package/index.js +2 -0
  57. package/index.js.flow +2 -1
  58. package/ios/RNPDFPdf/RNPDFPdfView.mm +199 -83
  59. package/package.json +1 -1
  60. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/results.bin +0 -1
  61. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
  62. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
  63. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/BuildConfig.dex +0 -0
  64. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
  65. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
  66. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
  67. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
  68. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
  69. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/RNPDFPackage.dex +0 -0
  70. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/events/TopChangeEvent.dex +0 -0
  71. package/android/build/.transforms/3337b950908a4f6985ba400cb8386b0b/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  72. package/android/build/.transforms/787b9137f14dcc9eebbb21ac62a7be22/results.bin +0 -1
  73. package/android/build/.transforms/787b9137f14dcc9eebbb21ac62a7be22/transformed/classes/classes_dex/classes.dex +0 -0
  74. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/results.bin +0 -1
  75. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerDelegate.dex +0 -0
  76. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/facebook/react/viewmanagers/RNPDFPdfViewManagerInterface.dex +0 -0
  77. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/BuildConfig.dex +0 -0
  78. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfManager.dex +0 -0
  79. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$1.dex +0 -0
  80. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$2.dex +0 -0
  81. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView$3.dex +0 -0
  82. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/PdfView.dex +0 -0
  83. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/RNPDFPackage.dex +0 -0
  84. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/org/wonday/pdf/events/TopChangeEvent.dex +0 -0
  85. package/android/build/.transforms/79ca1220a602ed0c9c23366e0e92a6d1/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  86. package/android/build/.transforms/c29f40a753b0ae1d85db8c8c5812fc85/results.bin +0 -1
  87. package/android/build/.transforms/c29f40a753b0ae1d85db8c8c5812fc85/transformed/classes/classes_dex/classes.dex +0 -0
  88. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
  89. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  90. package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
  91. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -5
  92. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  93. package/android/build/intermediates/annotation_processor_list/debugAndroidTest/annotationProcessors.json +0 -1
  94. package/android/build/intermediates/annotation_processor_list/debugUnitTest/annotationProcessors.json +0 -1
  95. package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
  96. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  97. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
  98. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -8
  99. package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-react-native-pdf.jar +0 -0
  100. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
  101. package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
  102. package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
  103. package/android/build/outputs/aar/react-native-pdf-debug.aar +0 -0
  104. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId3 +0 -0
  105. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfManager.class.uniqueId4 +0 -0
  106. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$2.class.uniqueId6 +0 -0
  107. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$3.class.uniqueId4 +0 -0
  108. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView$3.class.uniqueId5 +0 -0
  109. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/PdfView.class.uniqueId3 +0 -0
  110. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPackage.class.uniqueId2 +0 -0
  111. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPdfViewManagerDelegate.class.uniqueId7 +0 -0
  112. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNPDFPdfViewManagerInterface.class.uniqueId1 +0 -0
  113. /package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/{RNPDFPackage.class.uniqueId1 → RNPDFPackage.class.uniqueId4} +0 -0
package/index.js CHANGED
@@ -567,6 +567,8 @@ export default class Pdf extends Component {
567
567
  this._annotationSavePromise.reject(new Error(annotationError || 'Annotation save failed'));
568
568
  this._annotationSavePromise = null;
569
569
  }
570
+ } else if (message[0] === 'strokeEnd') {
571
+ this.props.onAnnotationStrokeEnd && this.props.onAnnotationStrokeEnd();
570
572
  }
571
573
  }
572
574
 
package/index.js.flow CHANGED
@@ -26,7 +26,7 @@ export type Source = {
26
26
 
27
27
  export type AnnotationRotation = 0 | 90 | 180 | 270;
28
28
  export type AnnotationIdMode = 'auto' | 'manual';
29
- export type AnnotationTool = 'select' | 'ink' | 'text' | 'highlight';
29
+ export type AnnotationTool = 'select' | 'ink' | 'text';
30
30
  export type AnnotationTextAlign = 'left' | 'center' | 'right';
31
31
 
32
32
  export type AnnotationPoint = {
@@ -121,6 +121,7 @@ export type Props = {
121
121
  onPageSingleTap?: (page: number, x: number, y: number) => void,
122
122
  onScaleChanged?: (scale: number) => void,
123
123
  onPressLink?: (url: string) => void,
124
+ onAnnotationStrokeEnd?: () => void,
124
125
  page?: number,
125
126
  password?: string,
126
127
  progressContainerStyle?: ViewStyleProp,
@@ -53,6 +53,7 @@
53
53
 
54
54
  const float MAX_SCALE = 3.0f;
55
55
  const float MIN_SCALE = 1.0f;
56
+ static void *RNPDFPdfScrollViewContentOffsetContext = &RNPDFPdfScrollViewContentOffsetContext;
56
57
 
57
58
  @class RNPDFAnnotationOverlay;
58
59
 
@@ -122,7 +123,8 @@ const float MIN_SCALE = 1.0f;
122
123
  BOOL _isAutoScrolling;
123
124
  BOOL _isUserDragging;
124
125
  UIScrollView *_pdfScrollView;
125
- __weak id<UIScrollViewDelegate> _originalScrollDelegate;
126
+ UIPanGestureRecognizer *_pdfScrollPanRecognizer;
127
+ BOOL _isObservingPdfScrollView;
126
128
  CGFloat _autoScrollCurrentOffset; // float accumulator – avoids re-reading UIKit's quantized contentOffset
127
129
  }
128
130
 
@@ -155,9 +157,12 @@ using namespace facebook::react;
155
157
  {
156
158
  const auto &newProps = *std::static_pointer_cast<const RNPDFPdfViewProps>(props);
157
159
  NSMutableArray<NSString *> *updatedPropNames = [NSMutableArray new];
158
- if (_path != RCTNSStringFromStringNilIfEmpty(newProps.path)) {
159
- _path = RCTNSStringFromStringNilIfEmpty(newProps.path);
160
- [updatedPropNames addObject:@"path"];
160
+ {
161
+ NSString *newPath = RCTNSStringFromStringNilIfEmpty(newProps.path);
162
+ if (_path != newPath && ![_path isEqualToString:newPath]) {
163
+ _path = newPath;
164
+ [updatedPropNames addObject:@"path"];
165
+ }
161
166
  }
162
167
  if (_page != newProps.page) {
163
168
  _page = newProps.page;
@@ -195,9 +200,12 @@ using namespace facebook::react;
195
200
  _enableDoubleTapZoom = newProps.enableDoubleTapZoom;
196
201
  [updatedPropNames addObject:@"enableDoubleTapZoom"];
197
202
  }
198
- if (_annotations != RCTNSStringFromStringNilIfEmpty(newProps.annotations)) {
199
- _annotations = RCTNSStringFromStringNilIfEmpty(newProps.annotations);
200
- [updatedPropNames addObject:@"annotations"];
203
+ {
204
+ NSString *newAnnotations = RCTNSStringFromStringNilIfEmpty(newProps.annotations);
205
+ if (_annotations != newAnnotations && ![_annotations isEqualToString:newAnnotations]) {
206
+ _annotations = newAnnotations;
207
+ [updatedPropNames addObject:@"annotations"];
208
+ }
201
209
  }
202
210
  if (_annotationMode != newProps.annotationMode) {
203
211
  _annotationMode = newProps.annotationMode;
@@ -257,7 +265,9 @@ using namespace facebook::react;
257
265
  [self didSetProps:updatedPropNames];
258
266
 
259
267
  if (_annotationOverlay) {
260
- [_annotationOverlay replaceAnnotationsJSONString:_annotations editable:_annotationEditable idMode:_annotationIdMode];
268
+ if ([updatedPropNames containsObject:@"annotations"] || [updatedPropNames containsObject:@"path"]) {
269
+ [_annotationOverlay replaceAnnotationsJSONString:_annotations editable:_annotationEditable idMode:_annotationIdMode];
270
+ }
261
271
  [_annotationOverlay setAnnotationMode:_annotationMode tool:_annotationTool editable:_annotationEditable idMode:_annotationIdMode];
262
272
  [_annotationOverlay setInkDefaultsColor:_annotationInkColor thickness:_annotationInkThickness];
263
273
  _annotationOverlay.pdfView = _pdfView;
@@ -276,8 +286,7 @@ using namespace facebook::react;
276
286
  [super prepareForRecycle];
277
287
 
278
288
  [self stopAutoScroll];
279
- _pdfScrollView = nil;
280
- _originalScrollDelegate = nil;
289
+ [self unbindPdfScrollViewObservation];
281
290
 
282
291
  [_pdfView removeFromSuperview];
283
292
  _pdfDocument = Nil;
@@ -392,7 +401,8 @@ using namespace facebook::react;
392
401
  _isAutoScrolling = NO;
393
402
  _isUserDragging = NO;
394
403
  _pdfScrollView = nil;
395
- _originalScrollDelegate = nil;
404
+ _pdfScrollPanRecognizer = nil;
405
+ _isObservingPdfScrollView = NO;
396
406
  _autoScrollCurrentOffset = 0.0;
397
407
 
398
408
  [self addSubview:_pdfView];
@@ -643,22 +653,12 @@ using namespace facebook::react;
643
653
  [self setScrollIndicators:self horizontal:_showsHorizontalScrollIndicator vertical:_showsVerticalScrollIndicator depth:0];
644
654
  }
645
655
 
646
- if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"scrollEnabled"])) {
647
- if (_scrollEnabled) {
648
- for (UIView *subview in _pdfView.subviews) {
649
- if ([subview isKindOfClass:[UIScrollView class]]) {
650
- UIScrollView *scrollView = (UIScrollView *)subview;
651
- scrollView.scrollEnabled = YES;
652
- }
653
- }
654
- } else {
655
- for (UIView *subview in _pdfView.subviews) {
656
- if ([subview isKindOfClass:[UIScrollView class]]) {
657
- UIScrollView *scrollView = (UIScrollView *)subview;
658
- scrollView.scrollEnabled = NO;
659
- }
660
- }
661
- }
656
+ if ([changedProps containsObject:@"path"] ||
657
+ [changedProps containsObject:@"scrollEnabled"] ||
658
+ [changedProps containsObject:@"annotationMode"] ||
659
+ [changedProps containsObject:@"enablePaging"] ||
660
+ [changedProps containsObject:@"singlePage"]) {
661
+ [self updatePdfScrollInteractionMode];
662
662
  }
663
663
 
664
664
  if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"enablePaging"] || [changedProps containsObject:@"horizontal"] || [changedProps containsObject:@"page"])) {
@@ -691,7 +691,9 @@ using namespace facebook::react;
691
691
  }
692
692
 
693
693
  if (_annotationOverlay) {
694
- [_annotationOverlay replaceAnnotationsJSONString:_annotations editable:_annotationEditable idMode:_annotationIdMode];
694
+ if ([changedProps containsObject:@"annotations"] || [changedProps containsObject:@"path"]) {
695
+ [_annotationOverlay replaceAnnotationsJSONString:_annotations editable:_annotationEditable idMode:_annotationIdMode];
696
+ }
695
697
  [_annotationOverlay setAnnotationMode:_annotationMode tool:_annotationTool editable:_annotationEditable idMode:_annotationIdMode];
696
698
  [_annotationOverlay setInkDefaultsColor:_annotationInkColor thickness:_annotationInkThickness];
697
699
  _annotationOverlay.pdfView = _pdfView;
@@ -700,6 +702,7 @@ using namespace facebook::react;
700
702
 
701
703
  _pdfView.backgroundColor = [UIColor clearColor];
702
704
  [_pdfView layoutDocumentView];
705
+ [self refreshPdfScrollViewBinding];
703
706
  [self setNeedsDisplay];
704
707
  }
705
708
  }
@@ -735,6 +738,7 @@ using namespace facebook::react;
735
738
  - (void)dealloc{
736
739
 
737
740
  [self stopAutoScroll];
741
+ [self unbindPdfScrollViewObservation];
738
742
 
739
743
  _pdfDocument = Nil;
740
744
  _pdfView = Nil;
@@ -1001,6 +1005,13 @@ using namespace facebook::react;
1001
1005
  [_annotationOverlay createTextAnnotationAtViewPoint:point page:pdfPage];
1002
1006
  return;
1003
1007
  }
1008
+
1009
+ if ([_annotationTool isEqualToString:@"ink"]) {
1010
+ [_annotationOverlay beginInkAtViewPoint:point page:pdfPage];
1011
+ [_annotationOverlay endInk];
1012
+ [self notifyOnChangeWithMessage:@"strokeEnd"];
1013
+ return;
1014
+ }
1004
1015
  }
1005
1016
 
1006
1017
  [self notifyOnChangeWithMessage:
@@ -1066,20 +1077,15 @@ using namespace facebook::react;
1066
1077
  if (sender.state == UIGestureRecognizerStateBegan) {
1067
1078
  if ([_annotationTool isEqualToString:@"ink"]) {
1068
1079
  [_annotationOverlay beginInkAtViewPoint:point page:pdfPage];
1069
- } else if ([_annotationTool isEqualToString:@"highlight"]) {
1070
- [_annotationOverlay beginMarkupAtViewPoint:point page:pdfPage type:_annotationTool];
1071
1080
  }
1072
1081
  } else if (sender.state == UIGestureRecognizerStateChanged) {
1073
1082
  if ([_annotationTool isEqualToString:@"ink"]) {
1074
1083
  [_annotationOverlay appendInkPointAtViewPoint:point page:pdfPage];
1075
- } else if ([_annotationTool isEqualToString:@"highlight"]) {
1076
- [_annotationOverlay updateMarkupAtViewPoint:point page:pdfPage];
1077
1084
  }
1078
1085
  } else if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed) {
1079
1086
  if ([_annotationTool isEqualToString:@"ink"]) {
1080
1087
  [_annotationOverlay endInk];
1081
- } else if ([_annotationTool isEqualToString:@"highlight"]) {
1082
- [_annotationOverlay endMarkup];
1088
+ [self notifyOnChangeWithMessage:@"strokeEnd"];
1083
1089
  }
1084
1090
  }
1085
1091
  }
@@ -1188,7 +1194,7 @@ using namespace facebook::react;
1188
1194
  return [_annotationOverlay annotationSelectionHitAtPoint:point includeHandles:YES] != nil;
1189
1195
  }
1190
1196
 
1191
- return [@[@"ink", @"highlight"] containsObject:_annotationTool];
1197
+ return [_annotationTool isEqualToString:@"ink"];
1192
1198
  }
1193
1199
 
1194
1200
  return !_singlePage;
@@ -1220,19 +1226,116 @@ using namespace facebook::react;
1220
1226
  }
1221
1227
  }
1222
1228
 
1229
+ - (void)updatePdfScrollInteractionMode
1230
+ {
1231
+ [self refreshPdfScrollViewBinding];
1232
+ [self applyScrollInteractionModeToView:_pdfView depth:0];
1233
+ }
1234
+
1235
+ - (void)unbindPdfScrollViewObservation
1236
+ {
1237
+ if (_pdfScrollPanRecognizer != nil) {
1238
+ [_pdfScrollPanRecognizer removeTarget:self action:@selector(handlePdfScrollPanGesture:)];
1239
+ _pdfScrollPanRecognizer = nil;
1240
+ }
1241
+
1242
+ if (_isObservingPdfScrollView && _pdfScrollView != nil) {
1243
+ [_pdfScrollView removeObserver:self forKeyPath:@"contentOffset" context:RNPDFPdfScrollViewContentOffsetContext];
1244
+ _isObservingPdfScrollView = NO;
1245
+ }
1246
+
1247
+ _pdfScrollView = nil;
1248
+ }
1249
+
1250
+ - (UIScrollView *)preferredPdfScrollViewInView:(UIView *)view depth:(int)depth
1251
+ {
1252
+ if (view == nil || depth > 10) {
1253
+ return nil;
1254
+ }
1255
+
1256
+ UIScrollView *bestScrollView = nil;
1257
+ CGFloat bestScrollableExtent = 0.0f;
1258
+
1259
+ if ([view isKindOfClass:[UIScrollView class]]) {
1260
+ UIScrollView *scrollView = (UIScrollView *)view;
1261
+ CGFloat verticalOverflow = MAX(scrollView.contentSize.height - scrollView.bounds.size.height, 0.0f);
1262
+ CGFloat horizontalOverflow = MAX(scrollView.contentSize.width - scrollView.bounds.size.width, 0.0f);
1263
+ bestScrollableExtent = MAX(verticalOverflow, horizontalOverflow);
1264
+ bestScrollView = scrollView;
1265
+ }
1266
+
1267
+ for (UIView *subview in view.subviews) {
1268
+ UIScrollView *candidate = [self preferredPdfScrollViewInView:subview depth:depth + 1];
1269
+ if (!candidate) {
1270
+ continue;
1271
+ }
1272
+
1273
+ CGFloat candidateVerticalOverflow = MAX(candidate.contentSize.height - candidate.bounds.size.height, 0.0f);
1274
+ CGFloat candidateHorizontalOverflow = MAX(candidate.contentSize.width - candidate.bounds.size.width, 0.0f);
1275
+ CGFloat candidateScrollableExtent = MAX(candidateVerticalOverflow, candidateHorizontalOverflow);
1276
+ if (bestScrollView == nil || candidateScrollableExtent >= bestScrollableExtent) {
1277
+ bestScrollView = candidate;
1278
+ bestScrollableExtent = candidateScrollableExtent;
1279
+ }
1280
+ }
1281
+
1282
+ return bestScrollView;
1283
+ }
1284
+
1285
+ - (void)refreshPdfScrollViewBinding
1286
+ {
1287
+ UIScrollView *preferredScrollView = [self preferredPdfScrollViewInView:_pdfView depth:0];
1288
+ if (preferredScrollView == _pdfScrollView) {
1289
+ return;
1290
+ }
1291
+
1292
+ [self unbindPdfScrollViewObservation];
1293
+
1294
+ _pdfScrollView = preferredScrollView;
1295
+
1296
+ if (preferredScrollView) {
1297
+ _pdfScrollPanRecognizer = preferredScrollView.panGestureRecognizer;
1298
+ if (_pdfScrollPanRecognizer != nil) {
1299
+ [_pdfScrollPanRecognizer addTarget:self action:@selector(handlePdfScrollPanGesture:)];
1300
+ }
1301
+
1302
+ [preferredScrollView addObserver:self
1303
+ forKeyPath:@"contentOffset"
1304
+ options:NSKeyValueObservingOptionNew
1305
+ context:RNPDFPdfScrollViewContentOffsetContext];
1306
+ _isObservingPdfScrollView = YES;
1307
+
1308
+ [_annotationOverlay refreshDisplay];
1309
+ }
1310
+ }
1311
+
1312
+ - (void)applyScrollInteractionModeToView:(UIView *)view depth:(int)depth
1313
+ {
1314
+ if (view == nil || depth > 10) {
1315
+ return;
1316
+ }
1317
+
1318
+ if ([view isKindOfClass:[UIScrollView class]]) {
1319
+ UIScrollView *scrollView = (UIScrollView *)view;
1320
+ scrollView.scrollEnabled = _scrollEnabled && !_singlePage;
1321
+
1322
+ UIPanGestureRecognizer *panRecognizer = scrollView.panGestureRecognizer;
1323
+ if (panRecognizer != nil) {
1324
+ panRecognizer.minimumNumberOfTouches = _annotationMode ? 2 : 1;
1325
+ }
1326
+ }
1327
+
1328
+ for (UIView *subview in view.subviews) {
1329
+ [self applyScrollInteractionModeToView:subview depth:depth + 1];
1330
+ }
1331
+ }
1332
+
1223
1333
  #pragma mark - Autoscroll
1224
1334
 
1225
1335
  - (UIScrollView *)findPdfScrollView
1226
1336
  {
1337
+ [self refreshPdfScrollViewBinding];
1227
1338
  if (_pdfScrollView) return _pdfScrollView;
1228
- for (UIView *subview in _pdfView.subviews) {
1229
- if ([subview isKindOfClass:[UIScrollView class]]) {
1230
- _pdfScrollView = (UIScrollView *)subview;
1231
- _originalScrollDelegate = _pdfScrollView.delegate;
1232
- _pdfScrollView.delegate = self;
1233
- return _pdfScrollView;
1234
- }
1235
- }
1236
1339
  return nil;
1237
1340
  }
1238
1341
 
@@ -1326,53 +1429,54 @@ using namespace facebook::react;
1326
1429
  }
1327
1430
  }
1328
1431
 
1329
- #pragma mark - UIScrollViewDelegate (autoscroll pause/resume)
1330
-
1331
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
1332
- {
1333
- _isUserDragging = YES;
1334
- [self stopDisplayLink];
1335
- [_autoScrollResumeTimer invalidate];
1336
- _autoScrollResumeTimer = nil;
1337
-
1338
- if ([_originalScrollDelegate respondsToSelector:@selector(scrollViewWillBeginDragging:)]) {
1339
- [_originalScrollDelegate scrollViewWillBeginDragging:scrollView];
1340
- }
1341
- }
1342
-
1343
- - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
1432
+ - (void)handlePdfScrollPanGesture:(UIPanGestureRecognizer *)gestureRecognizer
1344
1433
  {
1345
- if (!decelerate) {
1346
- _isUserDragging = NO;
1347
- if (_isAutoScrolling) {
1348
- [self scheduleAutoScrollResume];
1349
- }
1434
+ if (!_isAutoScrolling || gestureRecognizer != _pdfScrollPanRecognizer) {
1435
+ return;
1350
1436
  }
1351
1437
 
1352
- if ([_originalScrollDelegate respondsToSelector:@selector(scrollViewDidEndDragging:willDecelerate:)]) {
1353
- [_originalScrollDelegate scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
1438
+ UIGestureRecognizerState state = gestureRecognizer.state;
1439
+ if (state == UIGestureRecognizerStateBegan) {
1440
+ _isUserDragging = YES;
1441
+ [self stopDisplayLink];
1442
+ [_autoScrollResumeTimer invalidate];
1443
+ _autoScrollResumeTimer = nil;
1444
+ return;
1354
1445
  }
1355
- }
1356
1446
 
1357
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
1358
- {
1359
- _isUserDragging = NO;
1360
- if (_isAutoScrolling) {
1447
+ if ((state == UIGestureRecognizerStateEnded ||
1448
+ state == UIGestureRecognizerStateCancelled ||
1449
+ state == UIGestureRecognizerStateFailed) &&
1450
+ _pdfScrollView != nil &&
1451
+ !_pdfScrollView.isDragging &&
1452
+ !_pdfScrollView.isDecelerating) {
1453
+ _isUserDragging = NO;
1361
1454
  [self scheduleAutoScrollResume];
1362
1455
  }
1363
-
1364
- if ([_originalScrollDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
1365
- [_originalScrollDelegate scrollViewDidEndDecelerating:scrollView];
1366
- }
1367
1456
  }
1368
1457
 
1369
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
1458
+ - (void)observeValueForKeyPath:(NSString *)keyPath
1459
+ ofObject:(id)object
1460
+ change:(NSDictionary<NSKeyValueChangeKey,id> *)change
1461
+ context:(void *)context
1370
1462
  {
1371
- if ([_originalScrollDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) {
1372
- [_originalScrollDelegate scrollViewDidScroll:scrollView];
1463
+ if (context == RNPDFPdfScrollViewContentOffsetContext) {
1464
+ if (object == _pdfScrollView) {
1465
+ [_annotationOverlay refreshDisplay];
1466
+
1467
+ if (_isAutoScrolling &&
1468
+ _isUserDragging &&
1469
+ _pdfScrollView != nil &&
1470
+ !_pdfScrollView.isDragging &&
1471
+ !_pdfScrollView.isDecelerating) {
1472
+ _isUserDragging = NO;
1473
+ [self scheduleAutoScrollResume];
1474
+ }
1475
+ }
1476
+ return;
1373
1477
  }
1374
1478
 
1375
- [_annotationOverlay refreshDisplay];
1479
+ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
1376
1480
  }
1377
1481
 
1378
1482
  @end
@@ -1397,10 +1501,11 @@ static UIColor *RNPDFColorFromHexString(NSString *hexString, UIColor *fallback)
1397
1501
  if (cleanHex.length == 8) {
1398
1502
  NSScanner *scanner = [NSScanner scannerWithString:cleanHex];
1399
1503
  [scanner scanHexInt:&rgbValue];
1400
- return [UIColor colorWithRed:((rgbValue & 0x00FF0000) >> 16) / 255.0f
1401
- green:((rgbValue & 0x0000FF00) >> 8) / 255.0f
1402
- blue:(rgbValue & 0x000000FF) / 255.0f
1403
- alpha:((rgbValue & 0xFF000000) >> 24) / 255.0f];
1504
+ // CSS/RN standard: #RRGGBBAA (alpha is last two hex digits)
1505
+ return [UIColor colorWithRed:((rgbValue & 0xFF000000) >> 24) / 255.0f
1506
+ green:((rgbValue & 0x00FF0000) >> 16) / 255.0f
1507
+ blue:((rgbValue & 0x0000FF00) >> 8) / 255.0f
1508
+ alpha:(rgbValue & 0x000000FF) / 255.0f];
1404
1509
  }
1405
1510
 
1406
1511
  return fallback;
@@ -2133,7 +2238,18 @@ static NSString *RNPDFGenerateAnnotationId(void)
2133
2238
  NSString *type = [self normalizedAnnotationType:annotation[@"type"]];
2134
2239
  if ([type isEqualToString:@"ink"]) {
2135
2240
  NSArray *points = annotation[@"points"];
2136
- if (points.count < 2) {
2241
+ if (points.count == 0) {
2242
+ continue;
2243
+ }
2244
+
2245
+ if (points.count == 1) {
2246
+ NSDictionary *point = points[0];
2247
+ CGPoint normalizedPoint = CGPointMake([point[@"x"] doubleValue], [point[@"y"] doubleValue]);
2248
+ CGPoint viewPoint = [self viewPointForNormalizedPoint:normalizedPoint page:page];
2249
+ CGFloat radius = [self lineWidthForAnnotation:annotation] / 2.0;
2250
+ CGRect dotRect = CGRectMake(viewPoint.x - radius, viewPoint.y - radius, radius * 2, radius * 2);
2251
+ [[self colorForAnnotationType:type style:annotation[@"style"]] setFill];
2252
+ [[UIBezierPath bezierPathWithOvalInRect:dotRect] fill];
2137
2253
  continue;
2138
2254
  }
2139
2255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amafil/react-native-pdf-toolkit",
3
- "version": "1.1.3",
3
+ "version": "1.1.18",
4
4
  "summary": "A react native PDF view component",
5
5
  "description": "A react native PDF view component, support ios and android platform",
6
6
  "main": "index.js",
@@ -1 +0,0 @@
1
- o/bundleLibRuntimeToDirDebug
@@ -1 +0,0 @@
1
- o/bundleLibRuntimeToDirDebug
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="org.wonday.pdf" >
4
-
5
- <uses-sdk android:minSdkVersion="21" />
6
-
7
- </manifest>
@@ -1,18 +0,0 @@
1
- {
2
- "version": 3,
3
- "artifactType": {
4
- "type": "AAPT_FRIENDLY_MERGED_MANIFESTS",
5
- "kind": "Directory"
6
- },
7
- "applicationId": "org.wonday.pdf",
8
- "variantName": "debug",
9
- "elements": [
10
- {
11
- "type": "SINGLE",
12
- "filters": [],
13
- "attributes": [],
14
- "outputFile": "AndroidManifest.xml"
15
- }
16
- ],
17
- "elementType": "File"
18
- }
@@ -1,5 +0,0 @@
1
- aarFormatVersion=1.0
2
- aarMetadataVersion=1.0
3
- minCompileSdk=1
4
- minCompileSdkExtension=0
5
- minAndroidGradlePluginVersion=1.0.0
@@ -1,2 +0,0 @@
1
- R_DEF: Internal format may change without notice
2
- local
@@ -1,8 +0,0 @@
1
- 1<?xml version="1.0" encoding="utf-8"?>
2
- 2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- 3 package="org.wonday.pdf" >
4
- 4
5
- 5 <uses-sdk android:minSdkVersion="21" />
6
- 5-->/Users/filippo/Documents/react-native-pdf/android/src/main/AndroidManifestNew.xml
7
- 6
8
- 7</manifest>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="org.wonday.pdf" >
4
-
5
- <uses-sdk android:minSdkVersion="21" />
6
-
7
- </manifest>
@@ -1,18 +0,0 @@
1
- {
2
- "version": 3,
3
- "artifactType": {
4
- "type": "PACKAGED_MANIFESTS",
5
- "kind": "Directory"
6
- },
7
- "applicationId": "org.wonday.pdf",
8
- "variantName": "debug",
9
- "elements": [
10
- {
11
- "type": "SINGLE",
12
- "filters": [],
13
- "attributes": [],
14
- "outputFile": "../../merged_manifest/debug/AndroidManifest.xml"
15
- }
16
- ],
17
- "elementType": "File"
18
- }