rn-pdf-king 1.0.0 → 1.2.0

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.
@@ -45,7 +45,8 @@ data class Highlight(
45
45
  val id: String,
46
46
  val startIndex: Int,
47
47
  val endIndex: Int,
48
- val color: Int // Changed to Int for legacy Color
48
+ val color: Int, // Changed to Int for legacy Color
49
+ val radiusOfDot: Float? = null
49
50
  )
50
51
 
51
52
  // --- Internal Text Extractor ---
@@ -305,6 +306,8 @@ class PdfPageView @JvmOverloads constructor(
305
306
  private var textChars: List<TextChar> = emptyList()
306
307
  var preDefinedHighlights: List<Highlight> = emptyList()
307
308
  set(value) { field = value; invalidate() }
309
+ var preDefinedDottedHighlights: List<Highlight> = emptyList()
310
+ set(value) { field = value; invalidate() }
308
311
 
309
312
  // Selection State
310
313
  private var selectionStart: Int? = null
@@ -414,6 +417,12 @@ class PdfPageView @JvmOverloads constructor(
414
417
  drawHighlightRange(canvas, highlight.startIndex, highlight.endIndex, highlightPaint)
415
418
  }
416
419
 
420
+ // Draw Pre-defined Dotted Highlights
421
+ preDefinedDottedHighlights.forEach { highlight ->
422
+ highlightPaint.color = highlight.color
423
+ drawDottedHighlightRange(canvas, highlight.startIndex, highlight.endIndex, highlight.radiusOfDot ?: 5f, highlightPaint)
424
+ }
425
+
417
426
  // Draw Selection
418
427
  if (selectionStart != null && selectionEnd != null) {
419
428
  selectionPaint.color = selectionColor
@@ -456,6 +465,33 @@ class PdfPageView @JvmOverloads constructor(
456
465
  }
457
466
  }
458
467
  }
468
+
469
+ private fun drawDottedHighlightRange(canvas: Canvas, start: Int, end: Int, radius: Float, paint: Paint) {
470
+ val safeStart = max(0, start)
471
+ val safeEnd = min(textChars.size - 1, end)
472
+
473
+ if (safeStart <= safeEnd) {
474
+ for (i in safeStart..safeEnd) {
475
+ if (i in textChars.indices) {
476
+ val r = textChars[i].rect
477
+ // Draw dots along the bottom of the character
478
+ // We can draw one dot per char or fill the width
479
+ // Let's draw dots based on width
480
+
481
+ val left = r.left * scale
482
+ val right = r.right * scale
483
+ val bottom = r.bottom * scale
484
+ val width = right - left
485
+
486
+ // Center dot
487
+ val cx = left + width / 2
488
+ val cy = bottom + radius + 2 // Slightly below text
489
+
490
+ canvas.drawCircle(cx, cy, radius, paint)
491
+ }
492
+ }
493
+ }
494
+ }
459
495
 
460
496
  private fun drawHandle(canvas: Canvas, index: Int, isStart: Boolean) {
461
497
  if (index !in textChars.indices) return
@@ -512,7 +548,13 @@ class PdfPageView @JvmOverloads constructor(
512
548
  }
513
549
 
514
550
  private fun getHighlightAt(index: Int): String? {
515
- return preDefinedHighlights.firstOrNull { highlight ->
551
+ val normal = preDefinedHighlights.firstOrNull { highlight ->
552
+ index >= highlight.startIndex && index <= highlight.endIndex
553
+ }?.id
554
+
555
+ if (normal != null) return normal
556
+
557
+ return preDefinedDottedHighlights.firstOrNull { highlight ->
516
558
  index >= highlight.startIndex && index <= highlight.endIndex
517
559
  }?.id
518
560
  }
@@ -703,7 +745,7 @@ class PdfPageView @JvmOverloads constructor(
703
745
  return gestureHandled
704
746
  }
705
747
 
706
- private fun clearSelectionState() {
748
+ fun clearSelectionState() {
707
749
  draggingHandle = null
708
750
  isInteractingWithSelection = false
709
751
  selectionStart = null
@@ -168,6 +168,14 @@ class RnPdfKingModule : Module() {
168
168
  view.setHighlights(highlights)
169
169
  }
170
170
 
171
+ Prop("preDefinedDottedHighlights") { view: RnPdfKingView, highlights: List<Map<String, Any>> ->
172
+ view.setDottedHighlights(highlights)
173
+ }
174
+
175
+ AsyncFunction("clearSelection") { view: expo.modules.kotlin.views.ExpoView ->
176
+ (view as? RnPdfKingView)?.clearSelection()
177
+ }
178
+
171
179
  Prop("handleColor") { view: RnPdfKingView, color: Int ->
172
180
  view.setHandleColor(color)
173
181
  }
@@ -168,6 +168,37 @@ class RnPdfKingView(context: Context, appContext: AppContext) : ExpoView(context
168
168
  }
169
169
  pdfPageView.preDefinedHighlights = mapped
170
170
  }
171
+
172
+ fun setDottedHighlights(highlights: List<Map<String, Any>>) {
173
+ val mapped = highlights.mapNotNull { map ->
174
+ val id = map["id"] as? String
175
+ val start = (map["startIndex"] as? Number)?.toInt()
176
+ val end = (map["endIndex"] as? Number)?.toInt()
177
+
178
+ // Handle color specifically, it might be Double, Int, or Long
179
+ val colorVal = map["color"]
180
+ val color = if (colorVal is Number) {
181
+ colorVal.toInt()
182
+ } else {
183
+ null
184
+ }
185
+
186
+ val radius = (map["radiusOfDot"] as? Number)?.toFloat()
187
+
188
+ if (id != null && start != null && end != null && color != null) {
189
+ com.mobinx.pdfking.Highlight(id, start, end, color, radius)
190
+ } else {
191
+ null
192
+ }
193
+ }
194
+ pdfPageView.preDefinedDottedHighlights = mapped
195
+ }
196
+
197
+ fun clearSelection() {
198
+ post {
199
+ pdfPageView.clearSelectionState()
200
+ }
201
+ }
171
202
 
172
203
  fun setMode(m: String) {
173
204
  if (viewMode != m) {
@@ -6,6 +6,7 @@ export interface PdfPageProps extends ViewProps {
6
6
  width?: number;
7
7
  height?: number;
8
8
  preDefinedHighlights?: Highlight[];
9
+ preDefinedDottedHighlights?: Highlight[];
9
10
  handleColor?: string | number;
10
11
  selectionColor?: string | number;
11
12
  selectionEnabled?: boolean;
@@ -20,5 +21,8 @@ export interface PdfPageProps extends ViewProps {
20
21
  id: string;
21
22
  }>) => void;
22
23
  }
23
- export declare const PdfPage: React.FC<PdfPageProps>;
24
+ export interface PdfPageHandle {
25
+ clearSelectionState: () => void;
26
+ }
27
+ export declare const PdfPage: React.ForwardRefExoticComponent<PdfPageProps & React.RefAttributes<PdfPageHandle>>;
24
28
  //# sourceMappingURL=PdfPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfPage.d.ts","sourceRoot":"","sources":["../src/PdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAgB,MAAM,cAAc,CAAC;AA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ACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC;IACnC,0BAA0B,CAAC,EAAE,SAAS,EAAE,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;IACnI,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7D,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;CACpF;AAED,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,OAAO,oFAmDlB,CAAC"}
package/build/PdfPage.js CHANGED
@@ -1,13 +1,23 @@
1
- import React from 'react';
1
+ import React, { useRef, useImperativeHandle, forwardRef } from 'react';
2
2
  import { requireNativeViewManager } from 'expo-modules-core';
3
3
  import { processColor } from 'react-native';
4
4
  const NativePdfView = requireNativeViewManager('RnPdfKing');
5
- export const PdfPage = (props) => {
6
- const { width, height, preDefinedHighlights, handleColor, selectionColor, selectionEnabled, onSelectionChanged, onSelectionStarted, onSelectionEnded, onPreDefinedHighlightClick, ...rest } = props;
5
+ export const PdfPage = forwardRef((props, ref) => {
6
+ const { width, height, preDefinedHighlights, preDefinedDottedHighlights, handleColor, selectionColor, selectionEnabled, onSelectionChanged, onSelectionStarted, onSelectionEnded, onPreDefinedHighlightClick, ...rest } = props;
7
+ const nativeRef = useRef(null);
8
+ useImperativeHandle(ref, () => ({
9
+ clearSelectionState: () => {
10
+ nativeRef.current?.clearSelection?.();
11
+ }
12
+ }));
7
13
  const processedHighlights = preDefinedHighlights?.map(h => ({
8
14
  ...h,
9
15
  color: processColor(h.color)
10
16
  }));
11
- return (<NativePdfView pdfWidth={width} pdfHeight={height} preDefinedHighlights={processedHighlights} handleColor={processColor(handleColor)} selectionColor={processColor(selectionColor)} selectionEnabled={selectionEnabled} onSelectionChanged={onSelectionChanged} onSelectionStarted={onSelectionStarted} onSelectionEnded={onSelectionEnded} onPreDefinedHighlightClick={onPreDefinedHighlightClick} {...rest}/>);
12
- };
17
+ const processedDottedHighlights = preDefinedDottedHighlights?.map(h => ({
18
+ ...h,
19
+ color: processColor(h.color)
20
+ }));
21
+ return (<NativePdfView ref={nativeRef} pdfWidth={width} pdfHeight={height} preDefinedHighlights={processedHighlights} preDefinedDottedHighlights={processedDottedHighlights} handleColor={processColor(handleColor)} selectionColor={processColor(selectionColor)} selectionEnabled={selectionEnabled} onSelectionChanged={onSelectionChanged} onSelectionStarted={onSelectionStarted} onSelectionEnded={onSelectionEnded} onPreDefinedHighlightClick={onPreDefinedHighlightClick} {...rest}/>);
22
+ });
13
23
  //# sourceMappingURL=PdfPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfPage.js","sourceRoot":"","sources":["../src/PdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAmC,YAAY,EAAE,MAAM,cAAc,CAAC;AAG7E,MAAM,aAAa,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;AAgB5D,MAAM,CAAC,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,EAAE;IACvD,MAAM,EACJ,KAAK,EACL,MAAM,EACN,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,0BAA0B,EAC1B,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,mBAAmB,GAAG,oBAAoB,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC1D,GAAG,CAAC;QACJ,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;KAC7B,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,CAAC,aAAa,CACZ,QAAQ,CAAC,CAAC,KAAK,CAAC,CAChB,SAAS,CAAC,CAAC,MAAM,CAAC,CAClB,oBAAoB,CAAC,CAAC,mBAAmB,CAAC,CAC1C,WAAW,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CACvC,cAAc,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAC7C,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CACnC,kBAAkB,CAAC,CAAC,kBAAkB,CAAC,CACvC,kBAAkB,CAAC,CAAC,kBAAkB,CAAC,CACvC,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CACnC,0BAA0B,CAAC,CAAC,0BAA0B,CAAC,CACvD,IAAI,IAAI,CAAC,EACT,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport { ViewProps, NativeSyntheticEvent, processColor } from 'react-native';\nimport { Highlight } from './RnPdfKing.types';\n\nconst NativePdfView = requireNativeViewManager('RnPdfKing');\n\nexport interface PdfPageProps extends ViewProps {\n pageNo: number;\n width?: number;\n height?: number;\n preDefinedHighlights?: Highlight[];\n handleColor?: string | number;\n selectionColor?: string | number;\n selectionEnabled?: boolean;\n onSelectionChanged?: (event: NativeSyntheticEvent<{ selectedText: string; selectionStart: number; selectionEnd: number }>) => void;\n onSelectionStarted?: (event: NativeSyntheticEvent<{}>) => void;\n onSelectionEnded?: (event: NativeSyntheticEvent<{}>) => void;\n onPreDefinedHighlightClick?: (event: NativeSyntheticEvent<{ id: string }>) => void;\n}\n\nexport const PdfPage: React.FC<PdfPageProps> = (props) => {\n const { \n width, \n height, \n preDefinedHighlights,\n handleColor,\n selectionColor,\n selectionEnabled,\n onSelectionChanged, \n onSelectionStarted, \n onSelectionEnded,\n onPreDefinedHighlightClick,\n ...rest \n } = props;\n \n const processedHighlights = preDefinedHighlights?.map(h => ({\n ...h,\n color: processColor(h.color)\n }));\n \n return (\n <NativePdfView \n pdfWidth={width} \n pdfHeight={height} \n preDefinedHighlights={processedHighlights}\n handleColor={processColor(handleColor)}\n selectionColor={processColor(selectionColor)}\n selectionEnabled={selectionEnabled}\n onSelectionChanged={onSelectionChanged}\n onSelectionStarted={onSelectionStarted}\n onSelectionEnded={onSelectionEnded}\n onPreDefinedHighlightClick={onPreDefinedHighlightClick}\n {...rest} \n />\n );\n};\n"]}
1
+ {"version":3,"file":"PdfPage.js","sourceRoot":"","sources":["../src/PdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAmC,YAAY,EAAE,MAAM,cAAc,CAAC;AAG7E,MAAM,aAAa,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;AAqB5D,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAA8B,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC5E,MAAM,EACJ,KAAK,EACL,MAAM,EACN,oBAAoB,EACpB,0BAA0B,EAC1B,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,E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J,CAAC,CAAC,CAAC","sourcesContent":["import React, { useRef, useImperativeHandle, forwardRef } from 'react';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport { ViewProps, NativeSyntheticEvent, processColor } from 'react-native';\nimport { Highlight } from './RnPdfKing.types';\n\nconst NativePdfView = requireNativeViewManager('RnPdfKing');\n\nexport interface PdfPageProps extends ViewProps {\n pageNo: number;\n width?: number;\n height?: number;\n preDefinedHighlights?: Highlight[];\n preDefinedDottedHighlights?: Highlight[];\n handleColor?: string | number;\n selectionColor?: string | number;\n selectionEnabled?: boolean;\n onSelectionChanged?: (event: NativeSyntheticEvent<{ selectedText: string; selectionStart: number; selectionEnd: number }>) => void;\n onSelectionStarted?: (event: NativeSyntheticEvent<{}>) => void;\n onSelectionEnded?: (event: NativeSyntheticEvent<{}>) => void;\n onPreDefinedHighlightClick?: (event: NativeSyntheticEvent<{ id: string }>) => void;\n}\n\nexport interface PdfPageHandle {\n clearSelectionState: () => void;\n}\n\nexport const PdfPage = forwardRef<PdfPageHandle, PdfPageProps>((props, ref) => {\n const { \n width, \n height, \n preDefinedHighlights,\n preDefinedDottedHighlights,\n handleColor,\n selectionColor,\n selectionEnabled,\n onSelectionChanged, \n onSelectionStarted, \n onSelectionEnded,\n onPreDefinedHighlightClick,\n ...rest \n } = props;\n \n const nativeRef = useRef<any>(null);\n\n useImperativeHandle(ref, () => ({\n clearSelectionState: () => {\n nativeRef.current?.clearSelection?.();\n }\n }));\n \n const processedHighlights = preDefinedHighlights?.map(h => ({\n ...h,\n color: processColor(h.color)\n }));\n\n const processedDottedHighlights = preDefinedDottedHighlights?.map(h => ({\n ...h,\n color: processColor(h.color)\n }));\n \n return (\n <NativePdfView \n ref={nativeRef}\n pdfWidth={width} \n pdfHeight={height} \n preDefinedHighlights={processedHighlights}\n preDefinedDottedHighlights={processedDottedHighlights}\n handleColor={processColor(handleColor)}\n selectionColor={processColor(selectionColor)}\n selectionEnabled={selectionEnabled}\n onSelectionChanged={onSelectionChanged}\n onSelectionStarted={onSelectionStarted}\n onSelectionEnded={onSelectionEnded}\n onPreDefinedHighlightClick={onPreDefinedHighlightClick}\n {...rest} \n />\n );\n});\n"]}
@@ -4,6 +4,7 @@ export type Highlight = {
4
4
  startIndex: number;
5
5
  endIndex: number;
6
6
  color: ColorValue | number;
7
+ radiusOfDot?: number;
7
8
  };
8
9
  export type RnPdfKingModuleEvents = {
9
10
  onChange?: (event: {
@@ -24,6 +25,7 @@ export type RnPdfKingViewProps = {
24
25
  pdfWidth?: number;
25
26
  pdfHeight?: number;
26
27
  preDefinedHighlights?: Highlight[];
28
+ preDefinedDottedHighlights?: Highlight[];
27
29
  handleColor?: ColorValue | number;
28
30
  selectionColor?: ColorValue | number;
29
31
  selectionEnabled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"RnPdfKing.types.d.ts","sourceRoot":"","sources":["../src/RnPdfKing.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE3F,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9C,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7F,cAAc,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KA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AAC,KAAK,IAAI,CAAC;IACnI,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7D,0BAA0B,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE;YAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;CACxE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RnPdfKing.types.js","sourceRoot":"","sources":["../src/RnPdfKing.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle, NativeSyntheticEvent, ColorValue } from 'react-native';\n\nexport type Highlight = {\n id: string;\n startIndex: number;\n endIndex: number;\n color: ColorValue | number;\n};\n\nexport type RnPdfKingModuleEvents = {\n onChange?: (event: { value: string }) => void;\n onPdfLoadStarted: () => void;\n onPdfLoadSuccess: (event: { filePath: string; fileName: string; pageCount: number }) => void;\n onPdfLoadError: (event: { message: string }) => void;\n};\n\nexport type RnPdfKingViewProps = {\n pageNo: number;\n pdfWidth?: number;\n pdfHeight?: number;\n preDefinedHighlights?: Highlight[];\n handleColor?: ColorValue | number;\n selectionColor?: ColorValue | number;\n selectionEnabled?: boolean;\n style?: StyleProp<ViewStyle>;\n onSelectionChanged?: (event: NativeSyntheticEvent<{ selectedText: string; selectionStart: number; selectionEnd: number }>) => void;\n onSelectionStarted?: (event: NativeSyntheticEvent<{}>) => void;\n onSelectionEnded?: (event: NativeSyntheticEvent<{}>) => void;\n onPreDefinedHighlightClick?: (event: NativeSyntheticEvent<{ id: string }>) => void;\n url?: string;\n onLoad?: (event: { nativeEvent: { url: string | undefined } }) => void;\n};\n"]}
1
+ {"version":3,"file":"RnPdfKing.types.js","sourceRoot":"","sources":["../src/RnPdfKing.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle, NativeSyntheticEvent, ColorValue } from 'react-native';\n\nexport type Highlight = {\n id: string;\n startIndex: number;\n endIndex: number;\n color: ColorValue | number;\n radiusOfDot?: number;\n};\n\nexport type RnPdfKingModuleEvents = {\n onChange?: (event: { value: string }) => void;\n onPdfLoadStarted: () => void;\n onPdfLoadSuccess: (event: { filePath: string; fileName: string; pageCount: number }) => void;\n onPdfLoadError: (event: { message: string }) => void;\n};\n\nexport type RnPdfKingViewProps = {\n pageNo: number;\n pdfWidth?: number;\n pdfHeight?: number;\n preDefinedHighlights?: Highlight[];\n preDefinedDottedHighlights?: Highlight[];\n handleColor?: ColorValue | number;\n selectionColor?: ColorValue | number;\n selectionEnabled?: boolean;\n style?: StyleProp<ViewStyle>;\n onSelectionChanged?: (event: NativeSyntheticEvent<{ selectedText: string; selectionStart: number; selectionEnd: number }>) => void;\n onSelectionStarted?: (event: NativeSyntheticEvent<{}>) => void;\n onSelectionEnded?: (event: NativeSyntheticEvent<{}>) => void;\n onPreDefinedHighlightClick?: (event: NativeSyntheticEvent<{ id: string }>) => void;\n url?: string;\n onLoad?: (event: { nativeEvent: { url: string | undefined } }) => void;\n};\n"]}
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
- import { PdfPageProps } from './PdfPage';
3
+ import { PdfPageProps, PdfPageHandle } from './PdfPage';
4
4
  export interface ZoomablePdfPageProps extends PdfPageProps {
5
5
  width?: number;
6
6
  height: number;
7
7
  style?: StyleProp<ViewStyle>;
8
8
  }
9
- export declare const ZoomablePdfPage: React.FC<ZoomablePdfPageProps>;
9
+ export declare const ZoomablePdfPage: React.ForwardRefExoticComponent<ZoomablePdfPageProps & React.RefAttributes<PdfPageHandle>>;
10
10
  //# sourceMappingURL=ZoomablePdfPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZoomablePdfPage.d.ts","sourceRoot":"","sources":["../src/ZoomablePdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAW,YAAY,EAAE,MAAM,WAAW,CAAC;AAIlD,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqB1D,CAAC"}
1
+ {"version":3,"file":"ZoomablePdfPage.d.ts","sourceRoot":"","sources":["../src/ZoomablePdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAW,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAIjE,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,eAAe,4FAsB1B,CAAC"}
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import { PdfPage } from './PdfPage';
3
3
  import { ZoomablePage } from './ZoomablePage';
4
4
  import { useZoomableList } from './ZoomableList';
5
- export const ZoomablePdfPage = (props) => {
5
+ export const ZoomablePdfPage = forwardRef((props, ref) => {
6
6
  const { width: propWidth, height, style, selectionEnabled, ...pdfProps } = props;
7
7
  const { isPanning, isPinching, width: contextWidth } = useZoomableList();
8
8
  const width = propWidth ?? contextWidth;
@@ -11,7 +11,7 @@ export const ZoomablePdfPage = (props) => {
11
11
  ? (selectionEnabled && !isInteracting)
12
12
  : !isInteracting;
13
13
  return (<ZoomablePage width={width} height={height} style={style}>
14
- <PdfPage width={width} height={height} style={{ width, height }} selectionEnabled={shouldEnableSelection} {...pdfProps}/>
14
+ <PdfPage ref={ref} width={width} height={height} style={{ width, height }} selectionEnabled={shouldEnableSelection} {...pdfProps}/>
15
15
  </ZoomablePage>);
16
- };
16
+ });
17
17
  //# sourceMappingURL=ZoomablePdfPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZoomablePdfPage.js","sourceRoot":"","sources":["../src/ZoomablePdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAgB,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQjD,MAAM,CAAC,MAAM,eAAe,GAAmC,CAAC,KAAK,EAAE,EAAE;IACvE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IACjF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;IAEzE,MAAM,KAAK,GAAG,SAAS,IAAI,YAAY,CAAC;IACxC,MAAM,aAAa,GAAG,SAAS,IAAI,UAAU,CAAC;IAC9C,MAAM,qBAAqB,GAAG,gBAAgB,KAAK,SAAS;QAC1D,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,aAAa,CAAC;QACtC,CAAC,CAAC,CAAC,aAAa,CAAC;IAEnB,OAAO,CACL,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CACvD;MAAA,CAAC,OAAO,CACN,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CACzB,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CACxC,IAAI,QAAQ,CAAC,EAEjB;IAAA,EAAE,YAAY,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { PdfPage, PdfPageProps } from './PdfPage';\nimport { ZoomablePage } from './ZoomablePage';\nimport { useZoomableList } from './ZoomableList';\n\nexport interface ZoomablePdfPageProps extends PdfPageProps {\n width?: number;\n height: number;\n style?: StyleProp<ViewStyle>;\n}\n\nexport const ZoomablePdfPage: React.FC<ZoomablePdfPageProps> = (props) => {\n const { width: propWidth, height, style, selectionEnabled, ...pdfProps } = props;\n const { isPanning, isPinching, width: contextWidth } = useZoomableList();\n\n const width = propWidth ?? contextWidth;\n const isInteracting = isPanning || isPinching;\n const shouldEnableSelection = selectionEnabled !== undefined \n ? (selectionEnabled && !isInteracting) \n : !isInteracting;\n\n return (\n <ZoomablePage width={width} height={height} style={style}>\n <PdfPage\n width={width}\n height={height}\n style={{ width, height }}\n selectionEnabled={shouldEnableSelection}\n {...pdfProps}\n />\n </ZoomablePage>\n );\n};\n"]}
1
+ {"version":3,"file":"ZoomablePdfPage.js","sourceRoot":"","sources":["../src/ZoomablePdfPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,OAAO,EAA+B,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQjD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAsC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC5F,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC;IACjF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;IAEzE,MAAM,KAAK,GAAG,SAAS,IAAI,YAAY,CAAC;IACxC,MAAM,aAAa,GAAG,SAAS,IAAI,UAAU,CAAC;IAC9C,MAAM,qBAAqB,GAAG,gBAAgB,KAAK,SAAS;QAC1D,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,aAAa,CAAC;QACtC,CAAC,CAAC,CAAC,aAAa,CAAC;IAEnB,OAAO,CACL,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CACvD;MAAA,CAAC,OAAO,CACN,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CACzB,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CACxC,IAAI,QAAQ,CAAC,EAEjB;IAAA,EAAE,YAAY,CAAC,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\nimport { StyleProp, ViewStyle } from 'react-native';\nimport { PdfPage, PdfPageProps, PdfPageHandle } from './PdfPage';\nimport { ZoomablePage } from './ZoomablePage';\nimport { useZoomableList } from './ZoomableList';\n\nexport interface ZoomablePdfPageProps extends PdfPageProps {\n width?: number;\n height: number;\n style?: StyleProp<ViewStyle>;\n}\n\nexport const ZoomablePdfPage = forwardRef<PdfPageHandle, ZoomablePdfPageProps>((props, ref) => {\n const { width: propWidth, height, style, selectionEnabled, ...pdfProps } = props;\n const { isPanning, isPinching, width: contextWidth } = useZoomableList();\n\n const width = propWidth ?? contextWidth;\n const isInteracting = isPanning || isPinching;\n const shouldEnableSelection = selectionEnabled !== undefined \n ? (selectionEnabled && !isInteracting) \n : !isInteracting;\n\n return (\n <ZoomablePage width={width} height={height} style={style}>\n <PdfPage\n ref={ref}\n width={width}\n height={height}\n style={{ width, height }}\n selectionEnabled={shouldEnableSelection}\n {...pdfProps}\n />\n </ZoomablePage>\n );\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-pdf-king",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "The one and only best pdf library that efficiently handle 1000 page pdf with memeory mangement , easy selection , very customizable and allow pdf to edit",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
package/src/PdfPage.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useRef, useImperativeHandle, forwardRef } from 'react';
2
2
  import { requireNativeViewManager } from 'expo-modules-core';
3
3
  import { ViewProps, NativeSyntheticEvent, processColor } from 'react-native';
4
4
  import { Highlight } from './RnPdfKing.types';
@@ -10,6 +10,7 @@ export interface PdfPageProps extends ViewProps {
10
10
  width?: number;
11
11
  height?: number;
12
12
  preDefinedHighlights?: Highlight[];
13
+ preDefinedDottedHighlights?: Highlight[];
13
14
  handleColor?: string | number;
14
15
  selectionColor?: string | number;
15
16
  selectionEnabled?: boolean;
@@ -19,11 +20,16 @@ export interface PdfPageProps extends ViewProps {
19
20
  onPreDefinedHighlightClick?: (event: NativeSyntheticEvent<{ id: string }>) => void;
20
21
  }
21
22
 
22
- export const PdfPage: React.FC<PdfPageProps> = (props) => {
23
+ export interface PdfPageHandle {
24
+ clearSelectionState: () => void;
25
+ }
26
+
27
+ export const PdfPage = forwardRef<PdfPageHandle, PdfPageProps>((props, ref) => {
23
28
  const {
24
29
  width,
25
30
  height,
26
31
  preDefinedHighlights,
32
+ preDefinedDottedHighlights,
27
33
  handleColor,
28
34
  selectionColor,
29
35
  selectionEnabled,
@@ -34,16 +40,31 @@ export const PdfPage: React.FC<PdfPageProps> = (props) => {
34
40
  ...rest
35
41
  } = props;
36
42
 
43
+ const nativeRef = useRef<any>(null);
44
+
45
+ useImperativeHandle(ref, () => ({
46
+ clearSelectionState: () => {
47
+ nativeRef.current?.clearSelection?.();
48
+ }
49
+ }));
50
+
37
51
  const processedHighlights = preDefinedHighlights?.map(h => ({
38
52
  ...h,
39
53
  color: processColor(h.color)
40
54
  }));
55
+
56
+ const processedDottedHighlights = preDefinedDottedHighlights?.map(h => ({
57
+ ...h,
58
+ color: processColor(h.color)
59
+ }));
41
60
 
42
61
  return (
43
62
  <NativePdfView
63
+ ref={nativeRef}
44
64
  pdfWidth={width}
45
65
  pdfHeight={height}
46
66
  preDefinedHighlights={processedHighlights}
67
+ preDefinedDottedHighlights={processedDottedHighlights}
47
68
  handleColor={processColor(handleColor)}
48
69
  selectionColor={processColor(selectionColor)}
49
70
  selectionEnabled={selectionEnabled}
@@ -54,4 +75,4 @@ export const PdfPage: React.FC<PdfPageProps> = (props) => {
54
75
  {...rest}
55
76
  />
56
77
  );
57
- };
78
+ });
@@ -5,6 +5,7 @@ export type Highlight = {
5
5
  startIndex: number;
6
6
  endIndex: number;
7
7
  color: ColorValue | number;
8
+ radiusOfDot?: number;
8
9
  };
9
10
 
10
11
  export type RnPdfKingModuleEvents = {
@@ -19,6 +20,7 @@ export type RnPdfKingViewProps = {
19
20
  pdfWidth?: number;
20
21
  pdfHeight?: number;
21
22
  preDefinedHighlights?: Highlight[];
23
+ preDefinedDottedHighlights?: Highlight[];
22
24
  handleColor?: ColorValue | number;
23
25
  selectionColor?: ColorValue | number;
24
26
  selectionEnabled?: boolean;
@@ -1,6 +1,6 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
- import { PdfPage, PdfPageProps } from './PdfPage';
3
+ import { PdfPage, PdfPageProps, PdfPageHandle } from './PdfPage';
4
4
  import { ZoomablePage } from './ZoomablePage';
5
5
  import { useZoomableList } from './ZoomableList';
6
6
 
@@ -10,7 +10,7 @@ export interface ZoomablePdfPageProps extends PdfPageProps {
10
10
  style?: StyleProp<ViewStyle>;
11
11
  }
12
12
 
13
- export const ZoomablePdfPage: React.FC<ZoomablePdfPageProps> = (props) => {
13
+ export const ZoomablePdfPage = forwardRef<PdfPageHandle, ZoomablePdfPageProps>((props, ref) => {
14
14
  const { width: propWidth, height, style, selectionEnabled, ...pdfProps } = props;
15
15
  const { isPanning, isPinching, width: contextWidth } = useZoomableList();
16
16
 
@@ -23,6 +23,7 @@ export const ZoomablePdfPage: React.FC<ZoomablePdfPageProps> = (props) => {
23
23
  return (
24
24
  <ZoomablePage width={width} height={height} style={style}>
25
25
  <PdfPage
26
+ ref={ref}
26
27
  width={width}
27
28
  height={height}
28
29
  style={{ width, height }}
@@ -31,4 +32,4 @@ export const ZoomablePdfPage: React.FC<ZoomablePdfPageProps> = (props) => {
31
32
  />
32
33
  </ZoomablePage>
33
34
  );
34
- };
35
+ });