@june24/expo-pdf-reader 0.1.1 → 0.1.3

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/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import ExpoPdfReaderView from './ExpoPdfReaderView';
2
- import { ExpoPdfReaderViewProps } from './ExpoPdfReader.types';
3
- export { ExpoPdfReaderView, ExpoPdfReaderViewProps };
1
+ import ExpoPdfReaderView, { ExpoPdfReaderRef } from './ExpoPdfReaderView';
2
+ import { ExpoPdfReaderViewProps, Annotation, AnnotationOptions, AnnotationTool, AnnotationChangeEvent, PageChangeEvent, ScrollEvent, SearchResult, DisplayMode } from './ExpoPdfReader.types';
3
+ export { ExpoPdfReaderView, ExpoPdfReaderRef, ExpoPdfReaderViewProps, Annotation, AnnotationOptions, AnnotationTool, AnnotationChangeEvent, PageChangeEvent, ScrollEvent, SearchResult, DisplayMode, };
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,EAAE,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAG,MAAM,uBAAuB,CAAC;AAE/L,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,GAAG,CAAC"}
package/build/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import ExpoPdfReaderView from './ExpoPdfReaderView';
2
- export { ExpoPdfReaderView };
2
+ export { ExpoPdfReaderView, };
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,iBAAiB,EAA0B,CAAC","sourcesContent":["import ExpoPdfReaderView from './ExpoPdfReaderView';\nimport { ExpoPdfReaderViewProps } from './ExpoPdfReader.types';\n\nexport { ExpoPdfReaderView, ExpoPdfReaderViewProps };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAuC,MAAM,qBAAqB,CAAC;AAG1E,OAAO,EAAE,iBAAiB,GAA4K,CAAC","sourcesContent":["import ExpoPdfReaderView, { ExpoPdfReaderRef } from './ExpoPdfReaderView';\nimport { ExpoPdfReaderViewProps, Annotation, AnnotationOptions, AnnotationTool, AnnotationChangeEvent, PageChangeEvent, ScrollEvent, SearchResult, DisplayMode, } from './ExpoPdfReader.types';\n\nexport { ExpoPdfReaderView, ExpoPdfReaderRef, ExpoPdfReaderViewProps, Annotation, AnnotationOptions, AnnotationTool, AnnotationChangeEvent, PageChangeEvent, ScrollEvent, SearchResult, DisplayMode, };\n"]}
@@ -1,7 +1,7 @@
1
1
  import ExpoModulesCore
2
2
  import PDFKit
3
3
 
4
- class ExpoPdfReaderView: ExpoView {
4
+ class ExpoPdfReaderView: ExpoView, UIGestureRecognizerDelegate {
5
5
  let pdfView = PDFView()
6
6
  var currentTool: String = "none"
7
7
  var currentColor: UIColor = .black
@@ -40,7 +40,9 @@ class ExpoPdfReaderView: ExpoView {
40
40
 
41
41
  // Setup gestures
42
42
  panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:)))
43
+ panGesture?.delegate = self
43
44
  tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
45
+ tapGesture?.delegate = self
44
46
 
45
47
  // Initially disabled
46
48
  panGesture?.isEnabled = false
@@ -76,12 +78,15 @@ class ExpoPdfReaderView: ExpoView {
76
78
 
77
79
  private func notifyScroll() {
78
80
  let bounds = pdfView.bounds
79
- let contentSize = pdfView.document?.bounds(for: .mediaBox).size ?? .zero
80
81
 
81
- // Get scroll position from PDFView
82
- let visibleRect = pdfView.visiblePageRect
83
- let scrollX = visibleRect.origin.x
84
- let scrollY = visibleRect.origin.y
82
+ // Get scroll info from the underlying UIScrollView instead of PDFView helpers
83
+ guard let scrollView = pdfView.subviews.first(where: { $0 is UIScrollView }) as? UIScrollView else {
84
+ return
85
+ }
86
+
87
+ let contentSize = scrollView.contentSize
88
+ let scrollX = scrollView.contentOffset.x
89
+ let scrollY = scrollView.contentOffset.y
85
90
 
86
91
  onScroll([
87
92
  "x": scrollX,
@@ -192,11 +197,18 @@ class ExpoPdfReaderView: ExpoView {
192
197
  let isDrawing = tool == "pen" || tool == "highlighter"
193
198
  let isEraser = tool == "eraser"
194
199
  panGesture?.isEnabled = isDrawing || isEraser
195
- pdfView.isUserInteractionEnabled = !isDrawing && !isEraser // Disable PDF interaction when drawing/erasing to prevent scrolling
196
200
 
197
- // Re-enable scrolling if not drawing or erasing
198
- if !isDrawing && !isEraser {
199
- pdfView.isUserInteractionEnabled = true
201
+ // Disable PDF's built-in gestures when drawing/erasing
202
+ if isDrawing || isEraser {
203
+ // Disable scroll and other PDF interactions
204
+ if let scrollView = pdfView.subviews.first(where: { $0 is UIScrollView }) as? UIScrollView {
205
+ scrollView.isScrollEnabled = false
206
+ }
207
+ } else {
208
+ // Re-enable scrolling
209
+ if let scrollView = pdfView.subviews.first(where: { $0 is UIScrollView }) as? UIScrollView {
210
+ scrollView.isScrollEnabled = true
211
+ }
200
212
  }
201
213
 
202
214
  if tool == "text" || tool == "note" {
@@ -387,17 +399,14 @@ class ExpoPdfReaderView: ExpoView {
387
399
  // Simplified extraction logic
388
400
 
389
401
  var colorHex = "#000000"
390
- if let color = annotation.color {
391
- colorHex = color.toHex() ?? "#000000"
392
- }
402
+ let strokeColor = annotation.color
403
+ colorHex = strokeColor.toHex() ?? "#000000"
393
404
 
394
405
  var type = "pen"
395
- if let color = annotation.color {
396
- var a: CGFloat = 0
397
- color.getWhite(nil, alpha: &a)
398
- if a < 0.5 {
399
- type = "highlighter"
400
- }
406
+ var a: CGFloat = 0
407
+ strokeColor.getWhite(nil, alpha: &a)
408
+ if a < 0.5 {
409
+ type = "highlighter"
401
410
  }
402
411
 
403
412
  annotationsData.append([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@june24/expo-pdf-reader",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "A PDF reader for Expo apps with annotation and zoom controls",
5
5
  "homepage": "git@gitlab.com:june_241/expo-pdf-reader.git",
6
6
  "main": "build/index.js",
@@ -22,7 +22,7 @@
22
22
  "author": "User",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "expo-modules-core": "^4.0.0"
25
+ "expo-modules-core": "^3.0.29"
26
26
  },
27
27
  "devDependencies": {
28
28
  "expo-module-scripts": "^5.0.8",
@@ -89,7 +89,7 @@ export type NativeExpoPdfReaderViewProps = ViewProps & {
89
89
  annotationColor?: string; // Hex color
90
90
  annotationFontSize?: number;
91
91
  annotationText?: string; // Default text to place
92
- // Native-only props derived from AnnotationOptions
92
+ // Native-only props derived from AnnotationOptions
93
93
  annotationStrokeWidth?: number;
94
94
  initialAnnotations?: Annotation[];
95
95
  onAnnotationChange?: (event: AnnotationChangeEvent) => void;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import ExpoPdfReaderView from './ExpoPdfReaderView';
2
- import { ExpoPdfReaderViewProps } from './ExpoPdfReader.types';
1
+ import ExpoPdfReaderView, { ExpoPdfReaderRef } from './ExpoPdfReaderView';
2
+ import { ExpoPdfReaderViewProps, Annotation, AnnotationOptions, AnnotationTool, AnnotationChangeEvent, PageChangeEvent, ScrollEvent, SearchResult, DisplayMode, } from './ExpoPdfReader.types';
3
3
 
4
- export { ExpoPdfReaderView, ExpoPdfReaderViewProps };
4
+ export { ExpoPdfReaderView, ExpoPdfReaderRef, ExpoPdfReaderViewProps, Annotation, AnnotationOptions, AnnotationTool, AnnotationChangeEvent, PageChangeEvent, ScrollEvent, SearchResult, DisplayMode, };