react-pdf-highlighter-plus 1.1.3 → 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.
@@ -1,6 +1,6 @@
1
- import { PDFDocumentProxy, OnProgressParameters } from 'pdfjs-dist';
2
1
  import React, { ReactNode, CSSProperties, MouseEvent as MouseEvent$1 } from 'react';
3
2
  import { Root } from 'react-dom/client';
3
+ import { PDFDocumentProxy, OnProgressParameters } from 'pdfjs-dist';
4
4
  import { PDFViewer as PDFViewer$2 } from 'pdfjs-dist/types/web/pdf_viewer';
5
5
  import { PDFViewer as PDFViewer$3 } from 'pdfjs-dist/web/pdf_viewer.mjs';
6
6
  import { TypedArray, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
@@ -249,6 +249,102 @@ interface ThumbnailData {
249
249
  */
250
250
  type LeftPanelTab = 'outline' | 'thumbnails';
251
251
 
252
+ /**
253
+ * Options for the PDF export function.
254
+ *
255
+ * @category Type
256
+ */
257
+ interface ExportPdfOptions {
258
+ /** Default color for text highlights. Default: "rgba(255, 226, 143, 0.5)" */
259
+ textHighlightColor?: string;
260
+ /** Default color for area highlights. Default: "rgba(255, 226, 143, 0.5)" */
261
+ areaHighlightColor?: string;
262
+ /** Default text color for freetext. Default: "#333333" */
263
+ defaultFreetextColor?: string;
264
+ /** Default background for freetext. Default: "#ffffc8" */
265
+ defaultFreetextBgColor?: string;
266
+ /** Default font size for freetext. Default: 14 */
267
+ defaultFreetextFontSize?: number;
268
+ /** Progress callback for large PDFs */
269
+ onProgress?: (current: number, total: number) => void;
270
+ }
271
+ /**
272
+ * A highlight that can be exported to PDF.
273
+ *
274
+ * @category Type
275
+ */
276
+ interface ExportableHighlight {
277
+ id: string;
278
+ type?: "text" | "area" | "freetext" | "image" | "drawing" | "shape";
279
+ content?: {
280
+ text?: string;
281
+ image?: string;
282
+ shape?: ShapeData;
283
+ };
284
+ position: ScaledPosition;
285
+ /** Per-highlight color override (for text/area highlights) */
286
+ highlightColor?: string;
287
+ /** Style mode for text highlights: "highlight" (default), "underline", or "strikethrough" */
288
+ highlightStyle?: "highlight" | "underline" | "strikethrough";
289
+ /** Text color for freetext highlights */
290
+ color?: string;
291
+ /** Background color for freetext highlights */
292
+ backgroundColor?: string;
293
+ /** Font size for freetext highlights */
294
+ fontSize?: string;
295
+ /** Font family for freetext highlights (not used in export, Helvetica is always used) */
296
+ fontFamily?: string;
297
+ /** Shape type for shape highlights */
298
+ shapeType?: "rectangle" | "circle" | "arrow";
299
+ /** Stroke color for shape highlights */
300
+ strokeColor?: string;
301
+ /** Stroke width for shape highlights */
302
+ strokeWidth?: number;
303
+ }
304
+ /**
305
+ * Export a PDF with annotations embedded.
306
+ *
307
+ * @param pdfSource - The source PDF as a URL string, Uint8Array, or ArrayBuffer
308
+ * @param highlights - Array of highlights to embed in the PDF
309
+ * @param options - Export options for customizing colors and behavior
310
+ * @returns Promise<Uint8Array> - The modified PDF as bytes
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * const pdfBytes = await exportPdf(pdfUrl, highlights, {
315
+ * textHighlightColor: "rgba(255, 255, 0, 0.4)",
316
+ * onProgress: (current, total) => console.log(`${current}/${total} pages`)
317
+ * });
318
+ *
319
+ * // Download the file
320
+ * const blob = new Blob([pdfBytes], { type: "application/pdf" });
321
+ * const url = URL.createObjectURL(blob);
322
+ * const a = document.createElement("a");
323
+ * a.href = url;
324
+ * a.download = "annotated.pdf";
325
+ * a.click();
326
+ * URL.revokeObjectURL(url);
327
+ * ```
328
+ *
329
+ * @category Function
330
+ */
331
+ declare function exportPdf$1(pdfSource: string | Uint8Array | ArrayBuffer, highlights: ExportableHighlight[], options?: ExportPdfOptions): Promise<Uint8Array>;
332
+
333
+ /**
334
+ * Options for searching text in the PDF document.
335
+ *
336
+ * @category Type
337
+ */
338
+ type PdfSearchOptions = {
339
+ /** If true, search is case-sensitive. */
340
+ caseSensitive?: boolean;
341
+ /** If true, only whole-word matches are returned. */
342
+ entireWord?: boolean;
343
+ /** If true, all matches are highlighted, not just the selected match. */
344
+ highlightAll?: boolean;
345
+ /** If true, diacritics must match exactly. */
346
+ matchDiacritics?: boolean;
347
+ };
252
348
  /**
253
349
  * A set of utilities for to control the behaviour of {@link PdfHighlighter}.
254
350
  *
@@ -344,6 +440,25 @@ type PdfHighlighterUtils = {
344
440
  * @param pageNumber - 1-indexed page number to navigate to.
345
441
  */
346
442
  goToPage(pageNumber: number): void;
443
+ /**
444
+ * Search for text in the PDF document.
445
+ *
446
+ * @param query - Search text.
447
+ * @param options - Search options.
448
+ */
449
+ search(query: string, options?: PdfSearchOptions): void;
450
+ /**
451
+ * Move to the next search result.
452
+ */
453
+ findNext(): void;
454
+ /**
455
+ * Move to the previous search result.
456
+ */
457
+ findPrevious(): void;
458
+ /**
459
+ * Clear active search highlights.
460
+ */
461
+ clearSearch(): void;
347
462
  };
348
463
  /**
349
464
  * Custom hook for providing {@link PdfHighlighterUtils}. Must be used
@@ -361,8 +476,8 @@ declare const usePdfHighlighterContext: () => PdfHighlighterUtils;
361
476
  */
362
477
  interface PdfHighlighterTheme {
363
478
  /**
364
- * Theme mode - controls PDF page color inversion.
365
- * In dark mode, PDF pages are inverted for comfortable reading.
479
+ * Theme mode. In dark mode, pages are recolored at draw time (hue-preserving,
480
+ * photos kept) using {@link PdfHighlighterTheme.darkModeColors}.
366
481
  * @default "light"
367
482
  */
368
483
  mode?: "light" | "dark";
@@ -389,8 +504,24 @@ interface PdfHighlighterTheme {
389
504
  * - 0.85 = Softer gray ~#262626 (very comfortable)
390
505
  * - 0.8 = Medium gray ~#333333 (maximum softness)
391
506
  * @default 0.9
507
+ * @deprecated Dark mode now recolors at draw time (OKLab, hue-preserving,
508
+ * photos untouched) instead of a CSS `invert()` filter. This value is
509
+ * ignored. Use {@link PdfHighlighterTheme.darkModeColors} instead.
392
510
  */
393
511
  darkModeInvertIntensity?: number;
512
+ /**
513
+ * Dark-mode recolor palette. White paper maps to `background` and black
514
+ * text/line-art to `foreground`, recolored per-color at draw time (OKLab
515
+ * ramp) so hues are preserved and embedded photos keep their pixels.
516
+ * Only used when `mode === "dark"`.
517
+ * @default { background: "#141210", foreground: "#eae6e0" }
518
+ */
519
+ darkModeColors?: {
520
+ /** Replaces the white paper background. */
521
+ background: string;
522
+ /** Replaces black text and line art. */
523
+ foreground: string;
524
+ };
394
525
  }
395
526
  /**
396
527
  * The props type for {@link PdfHighlighter}.
@@ -412,6 +543,27 @@ interface PdfHighlighterProps {
412
543
  * What scale to render the PDF at inside the viewer.
413
544
  */
414
545
  pdfScaleValue?: PdfScaleValue;
546
+ /**
547
+ * Fired when the user changes zoom by pinch / ctrl+wheel gesture, with the new
548
+ * numeric scale. Use it to keep an external zoom indicator / `pdfScaleValue`
549
+ * state in sync.
550
+ *
551
+ * @param scale - The new numeric scale (e.g. 1.25).
552
+ */
553
+ onZoomChange?(scale: number): void;
554
+ /**
555
+ * Page to scroll to once the document first finishes loading (1-indexed).
556
+ * Use for deep-linking (e.g. `?page=12`) or restoring a saved position.
557
+ * Applied only on initial load, not on subsequent re-renders.
558
+ */
559
+ initialPage?: number;
560
+ /**
561
+ * Callback fired whenever the current (most visible) page changes, including
562
+ * the initial page. Use to sync the page into a URL/localStorage.
563
+ *
564
+ * @param pageNumber - The new current page (1-indexed).
565
+ */
566
+ onPageChange?(pageNumber: number): void;
415
567
  /**
416
568
  * Callback triggered whenever a user finishes making a mouse selection or has
417
569
  * selected text.
@@ -575,7 +727,7 @@ interface PdfHighlighterProps {
575
727
  *
576
728
  * @category Component
577
729
  */
578
- declare const PdfHighlighter: ({ highlights, onScrollAway, pdfScaleValue, onSelection: onSelectionFinished, onCreateGhostHighlight, onRemoveGhostHighlight, selectionTip, enableAreaSelection, areaSelectionMode, mouseSelectionStyle, pdfDocument, children, textSelectionColor, utilsRef, style, enableFreetextCreation, onFreetextClick, enableImageCreation, onImageClick, enableDrawingMode, onDrawingComplete, onDrawingCancel, drawingStrokeColor, drawingStrokeWidth, enableShapeMode, onShapeComplete, onShapeCancel, shapeStrokeColor, shapeStrokeWidth, theme: userTheme, }: PdfHighlighterProps) => React.JSX.Element;
730
+ declare const PdfHighlighter: ({ highlights, onScrollAway, pdfScaleValue, onZoomChange, initialPage, onPageChange, onSelection: onSelectionFinished, onCreateGhostHighlight, onRemoveGhostHighlight, selectionTip, enableAreaSelection, areaSelectionMode, mouseSelectionStyle, pdfDocument, children, textSelectionColor, utilsRef, style, enableFreetextCreation, onFreetextClick, enableImageCreation, onImageClick, enableDrawingMode, onDrawingComplete, onDrawingCancel, drawingStrokeColor: drawingStrokeColorProp, drawingStrokeWidth, enableShapeMode, onShapeComplete, onShapeCancel, shapeStrokeColor: shapeStrokeColorProp, shapeStrokeWidth, theme: userTheme, }: PdfHighlighterProps) => React.JSX.Element;
579
731
 
580
732
  /**
581
733
  * Style options for text highlight appearance.
@@ -643,6 +795,10 @@ interface TextHighlightProps {
643
795
  * Callback triggered when the style changes.
644
796
  */
645
797
  onStyleChange?(style: TextHighlightStyle): void;
798
+ /**
799
+ * Text to copy for this highlight.
800
+ */
801
+ copyText?: string;
646
802
  /**
647
803
  * Callback triggered when the delete button is clicked.
648
804
  */
@@ -666,7 +822,7 @@ interface TextHighlightProps {
666
822
  *
667
823
  * @category Component
668
824
  */
669
- declare const TextHighlight: ({ highlight, onClick, onMouseOver, onMouseOut, isScrolledTo, onContextMenu, style, highlightColor, highlightStyle, onStyleChange, onDelete, styleIcon, deleteIcon, colorPresets, }: TextHighlightProps) => React.JSX.Element;
825
+ declare const TextHighlight: ({ highlight, onClick, onMouseOver, onMouseOut, isScrolledTo, onContextMenu, style, highlightColor, highlightStyle, onStyleChange, onDelete, styleIcon, deleteIcon, copyText, colorPresets, }: TextHighlightProps) => React.JSX.Element;
670
826
 
671
827
  /**
672
828
  * The props type for {@link MonitoredHighlightContainer}.
@@ -759,6 +915,10 @@ interface AreaHighlightProps {
759
915
  * Callback triggered when the style changes.
760
916
  */
761
917
  onStyleChange?(style: AreaHighlightStyle): void;
918
+ /**
919
+ * Text to copy for this area highlight.
920
+ */
921
+ copyText?: string;
762
922
  /**
763
923
  * Callback triggered when the delete button is clicked.
764
924
  */
@@ -782,7 +942,7 @@ interface AreaHighlightProps {
782
942
  *
783
943
  * @category Component
784
944
  */
785
- declare const AreaHighlight: ({ highlight, onChange, isScrolledTo, bounds, onContextMenu, onEditStart, style, highlightColor, onStyleChange, onDelete, styleIcon, deleteIcon, colorPresets, }: AreaHighlightProps) => React.JSX.Element;
945
+ declare const AreaHighlight: ({ highlight, onChange, isScrolledTo, bounds, onContextMenu, onEditStart, style, highlightColor, onStyleChange, onDelete, styleIcon, deleteIcon, copyText, colorPresets, }: AreaHighlightProps) => React.JSX.Element;
786
946
 
787
947
  /**
788
948
  * Style options for freetext highlight appearance.
@@ -891,8 +1051,20 @@ interface FreetextHighlightProps {
891
1051
  * Custom delete icon. Replaces the default trash icon.
892
1052
  */
893
1053
  deleteIcon?: ReactNode;
1054
+ /**
1055
+ * Render the note as a compact marker until opened.
1056
+ */
1057
+ compact?: boolean;
1058
+ /**
1059
+ * Size of the compact marker in pixels.
1060
+ */
1061
+ compactSize?: number;
1062
+ /**
1063
+ * Custom compact marker icon.
1064
+ */
1065
+ compactIcon?: ReactNode;
894
1066
  }
895
- declare const FreetextHighlight: ({ highlight, onChange, onTextChange, onStyleChange, isScrolledTo, bounds, onContextMenu, onEditStart, onEditEnd, style, color, backgroundColor, fontFamily, fontSize, dragIcon, editIcon, styleIcon, backgroundColorPresets, textColorPresets, onDelete, deleteIcon, }: FreetextHighlightProps) => React.JSX.Element;
1067
+ declare const FreetextHighlight: ({ highlight, onChange, onTextChange, onStyleChange, isScrolledTo, bounds, onContextMenu, onEditStart, onEditEnd, style, color, backgroundColor, fontFamily, fontSize, dragIcon, editIcon, styleIcon, backgroundColorPresets, textColorPresets, onDelete, deleteIcon, compact, compactSize, compactIcon, }: FreetextHighlightProps) => React.JSX.Element;
896
1068
 
897
1069
  /**
898
1070
  * The props type for {@link ImageHighlight}.
@@ -1273,12 +1445,13 @@ interface PdfLoaderProps {
1273
1445
  */
1274
1446
  document: string | URL | TypedArray | DocumentInitParameters;
1275
1447
  /**
1276
- * Callback to render content before the PDF document is loaded.
1448
+ * Callback to render content before the PDF document is loaded. Receives the
1449
+ * PDF.js progress, or `null` before any progress is known (e.g. a cache hit).
1277
1450
  *
1278
- * @param progress - PDF.js progress status.
1451
+ * @param progress - PDF.js progress status, or null.
1279
1452
  * @returns - Component to be rendered in space of the PDF document while loading.
1280
1453
  */
1281
- beforeLoad?(progress: OnProgressParameters): ReactNode;
1454
+ beforeLoad?(progress: OnProgressParameters | null): ReactNode;
1282
1455
  /**
1283
1456
  * Component to render in the case of any PDF loading errors.
1284
1457
  *
@@ -1301,17 +1474,40 @@ interface PdfLoaderProps {
1301
1474
  */
1302
1475
  onError?(error: Error): void;
1303
1476
  /**
1304
- * NOTE: This will be applied to all PdfLoader instances.
1305
- * If you want to only apply a source to this instance, use the document parameters.
1477
+ * Optional PDF.js worker source override. By default, PdfLoader resolves the
1478
+ * worker from the installed pdfjs-dist package so bundlers can emit it locally.
1306
1479
  */
1307
1480
  workerSrc?: string;
1481
+ /**
1482
+ * Only fetch the pages needed to render, instead of background-downloading the
1483
+ * whole file. Makes the first page appear fast for large PDFs served over an
1484
+ * API — provided the server supports HTTP range requests (`Accept-Ranges:
1485
+ * bytes`). Has no effect for servers without range support or for raw bytes.
1486
+ * @default true
1487
+ */
1488
+ disableAutoFetch?: boolean;
1489
+ /** Disable progressive streaming of the response. @default false */
1490
+ disableStream?: boolean;
1491
+ /** Size (bytes) of each range request when streaming. PDF.js default ~64KB. */
1492
+ rangeChunkSize?: number;
1493
+ /** Send credentials (cookies) with the document request. */
1494
+ withCredentials?: boolean;
1495
+ /** Extra HTTP headers for the document request (e.g. an auth token). */
1496
+ httpHeaders?: Record<string, string>;
1497
+ /**
1498
+ * Cache the loaded document so re-opening the same URL (or a StrictMode/
1499
+ * remount) reuses it instead of re-downloading. Only URL-based documents are
1500
+ * cached. Disable if the same URL can return different content.
1501
+ * @default true
1502
+ */
1503
+ enableCache?: boolean;
1308
1504
  }
1309
1505
  /**
1310
1506
  * A component for loading a PDF document and passing it to a child.
1311
1507
  *
1312
1508
  * @category Component
1313
1509
  */
1314
- declare const PdfLoader: ({ document, beforeLoad, errorMessage, children, onError, workerSrc, }: PdfLoaderProps) => React.ReactNode;
1510
+ declare const PdfLoader: ({ document, beforeLoad, errorMessage, children, onError, workerSrc, disableAutoFetch, disableStream, rangeChunkSize, withCredentials, httpHeaders, enableCache, }: PdfLoaderProps) => React.ReactNode;
1315
1511
 
1316
1512
  /**
1317
1513
  * A set of utilities for rendering highlights. Designed to be used within a
@@ -1360,86 +1556,108 @@ declare const viewportPositionToScaled: ({ boundingRect, rects }: ViewportPositi
1360
1556
  /** @category Utilities */
1361
1557
  declare const scaledPositionToViewport: ({ boundingRect, rects, usePdfCoordinates }: ScaledPosition, viewer: PDFViewer$2) => ViewportPosition;
1362
1558
 
1363
- /**
1364
- * Options for the PDF export function.
1365
- *
1366
- * @category Type
1367
- */
1368
- interface ExportPdfOptions {
1369
- /** Default color for text highlights. Default: "rgba(255, 226, 143, 0.5)" */
1370
- textHighlightColor?: string;
1371
- /** Default color for area highlights. Default: "rgba(255, 226, 143, 0.5)" */
1372
- areaHighlightColor?: string;
1373
- /** Default text color for freetext. Default: "#333333" */
1374
- defaultFreetextColor?: string;
1375
- /** Default background for freetext. Default: "#ffffc8" */
1376
- defaultFreetextBgColor?: string;
1377
- /** Default font size for freetext. Default: 14 */
1378
- defaultFreetextFontSize?: number;
1379
- /** Progress callback for large PDFs */
1380
- onProgress?: (current: number, total: number) => void;
1381
- }
1382
- /**
1383
- * A highlight that can be exported to PDF.
1559
+ type PdfTextItem = {
1560
+ text: string;
1561
+ index: number;
1562
+ pageNumber: number;
1563
+ rect: LTWHP;
1564
+ fontName?: string;
1565
+ columnIndex?: number;
1566
+ };
1567
+ type PdfTextColumn = {
1568
+ index: number;
1569
+ left: number;
1570
+ right: number;
1571
+ width: number;
1572
+ textItemIndexes: number[];
1573
+ };
1574
+ type PdfExtractedPage = {
1575
+ pageNumber: number;
1576
+ width: number;
1577
+ height: number;
1578
+ textItems: PdfTextItem[];
1579
+ columns?: PdfTextColumn[];
1580
+ };
1581
+ type PdfTextUnitType = "paragraph" | "title" | "heading" | "author" | "affiliation" | "footnote" | "reference" | "unknown";
1582
+ type PdfTextUnit = {
1583
+ id: string;
1584
+ type: PdfTextUnitType;
1585
+ text: string;
1586
+ rawText: string;
1587
+ pageNumber: number;
1588
+ indexInPage: number;
1589
+ columnIndex?: number;
1590
+ position?: ScaledPosition;
1591
+ source?: {
1592
+ textItemIndexes: number[];
1593
+ };
1594
+ };
1595
+ type PdfSentenceSource = {
1596
+ startOffset: number;
1597
+ endOffset: number;
1598
+ textItemIndexes: number[];
1599
+ };
1600
+ type PdfSentence = {
1601
+ id: string;
1602
+ text: string;
1603
+ rawText: string;
1604
+ pageNumber: number;
1605
+ indexInPage: number;
1606
+ globalIndex: number;
1607
+ columnIndex?: number;
1608
+ position?: ScaledPosition;
1609
+ source?: PdfSentenceSource;
1610
+ };
1611
+ type PdfReadingOrder = "auto" | "document" | "position";
1612
+ type PdfColumnDetection = "auto" | "none";
1613
+ type ExtractSentencesOptions = {
1614
+ pages?: "all" | number[];
1615
+ includePositions?: boolean;
1616
+ includeSources?: boolean;
1617
+ normalize?: boolean;
1618
+ locale?: string;
1619
+ idPrefix?: string;
1620
+ includeTextUnitTypes?: PdfTextUnitType[];
1621
+ readingOrder?: PdfReadingOrder;
1622
+ columnDetection?: PdfColumnDetection;
1623
+ };
1624
+ declare const extractTextUnits: (pdfDocument: PDFDocumentProxy, options?: ExtractSentencesOptions) => Promise<PdfTextUnit[]>;
1625
+ declare const extractPageTextItems: (pdfDocument: PDFDocumentProxy, options?: Pick<ExtractSentencesOptions, "pages" | "columnDetection">) => Promise<PdfExtractedPage[]>;
1626
+ declare const extractSentences: (pdfDocument: PDFDocumentProxy, options?: ExtractSentencesOptions) => Promise<PdfSentence[]>;
1627
+ declare const sentenceToHighlight: (sentence: PdfSentence, options?: {
1628
+ id?: string;
1629
+ }) => Highlight;
1630
+ /**
1631
+ * The result of {@link getTextPosition}.
1384
1632
  *
1385
1633
  * @category Type
1386
1634
  */
1387
- interface ExportableHighlight {
1388
- id: string;
1389
- type?: "text" | "area" | "freetext" | "image" | "drawing" | "shape";
1390
- content?: {
1391
- text?: string;
1392
- image?: string;
1393
- shape?: ShapeData;
1394
- };
1635
+ interface TextPositionMatch {
1636
+ /** Scaled position of the matched text, ready to use as a highlight position. */
1395
1637
  position: ScaledPosition;
1396
- /** Per-highlight color override (for text/area highlights) */
1397
- highlightColor?: string;
1398
- /** Style mode for text highlights: "highlight" (default), "underline", or "strikethrough" */
1399
- highlightStyle?: "highlight" | "underline" | "strikethrough";
1400
- /** Text color for freetext highlights */
1401
- color?: string;
1402
- /** Background color for freetext highlights */
1403
- backgroundColor?: string;
1404
- /** Font size for freetext highlights */
1405
- fontSize?: string;
1406
- /** Font family for freetext highlights (not used in export, Helvetica is always used) */
1407
- fontFamily?: string;
1408
- /** Shape type for shape highlights */
1409
- shapeType?: "rectangle" | "circle" | "arrow";
1410
- /** Stroke color for shape highlights */
1411
- strokeColor?: string;
1412
- /** Stroke width for shape highlights */
1413
- strokeWidth?: number;
1638
+ /** 1-indexed page the match was found on. */
1639
+ pageNumber: number;
1640
+ /** The exact document text that was matched. */
1641
+ matchedText: string;
1642
+ /** "exact" = whitespace-insensitive verbatim, "fuzzy" = approximate match. */
1643
+ confidence: "exact" | "fuzzy";
1414
1644
  }
1415
1645
  /**
1416
- * Export a PDF with annotations embedded.
1417
- *
1418
- * @param pdfSource - The source PDF as a URL string, Uint8Array, or ArrayBuffer
1419
- * @param highlights - Array of highlights to embed in the PDF
1420
- * @param options - Export options for customizing colors and behavior
1421
- * @returns Promise<Uint8Array> - The modified PDF as bytes
1422
- *
1423
- * @example
1424
- * ```typescript
1425
- * const pdfBytes = await exportPdf(pdfUrl, highlights, {
1426
- * textHighlightColor: "rgba(255, 255, 0, 0.4)",
1427
- * onProgress: (current, total) => console.log(`${current}/${total} pages`)
1428
- * });
1646
+ * Locate a piece of text in the PDF and return its precise position — the rects
1647
+ * of the exact phrase (sub-item, per-line), not a whole sentence. Use it to turn
1648
+ * an external quote / citation into a highlight you can render or scroll to.
1429
1649
  *
1430
- * // Download the file
1431
- * const blob = new Blob([pdfBytes], { type: "application/pdf" });
1432
- * const url = URL.createObjectURL(blob);
1433
- * const a = document.createElement("a");
1434
- * a.href = url;
1435
- * a.download = "annotated.pdf";
1436
- * a.click();
1437
- * URL.revokeObjectURL(url);
1438
- * ```
1650
+ * Robust to PDF quirks: matching ignores whitespace (so line-wraps and spacing
1651
+ * differences don't matter) and falls back to bounded fuzzy matching for minor
1652
+ * differences (hyphenation, OCR, slight paraphrase). Returns the first match
1653
+ * (optionally restrict the page range), or null.
1439
1654
  *
1440
- * @category Function
1655
+ * @category Utility
1441
1656
  */
1442
- declare function exportPdf(pdfSource: string | Uint8Array | ArrayBuffer, highlights: ExportableHighlight[], options?: ExportPdfOptions): Promise<Uint8Array>;
1657
+ declare const getTextPosition: (pdfDocument: PDFDocumentProxy, query: string, options?: {
1658
+ pages?: "all" | number[];
1659
+ fuzzy?: boolean;
1660
+ }) => Promise<TextPositionMatch | null>;
1443
1661
 
1444
1662
  /** Style configuration for outline items */
1445
1663
  interface OutlineItemStyles {
@@ -1720,7 +1938,10 @@ interface LeftPanelProps {
1720
1938
  thumbnailWidth?: number;
1721
1939
  /** Children for custom content */
1722
1940
  children?: React.ReactNode;
1723
- /** Theme customization */
1941
+ /** Color scheme. "dark" swaps in a dark default palette; `theme` overrides
1942
+ * individual colors on top of whichever preset is chosen. @default "light" */
1943
+ mode?: "light" | "dark";
1944
+ /** Theme customization (merged over the mode preset) */
1724
1945
  theme?: LeftPanelTheme;
1725
1946
  /** Show page count in footer */
1726
1947
  showFooter?: boolean;
@@ -1902,4 +2123,6 @@ interface UsePageNavigationResult {
1902
2123
  */
1903
2124
  declare function usePageNavigation(options: UsePageNavigationOptions): UsePageNavigationResult;
1904
2125
 
1905
- export { AreaHighlight, type AreaHighlightProps, type AreaHighlightStyle, type Content, DocumentOutline, type DocumentOutlineClassNames, type DocumentOutlineProps, type DocumentOutlineStyles, DrawingCanvas, type DrawingCanvasProps, DrawingHighlight, type DrawingHighlightProps, type DrawingPoint, type DrawingStroke, type ExportPdfOptions, type ExportableHighlight, type FooterClassNames, type FooterStyles, FreetextHighlight, type FreetextHighlightProps, type FreetextStyle, type GhostHighlight, type Highlight, type HighlightBindings, type HighlightContainerUtils, type HighlightType, ImageHighlight, type ImageHighlightProps, type LTWH, type LTWHP, LeftPanel, type LeftPanelProps, type LeftPanelTab, type LeftPanelTheme, type LeftPanelUtils, MonitoredHighlightContainer, type MonitoredHighlightContainerProps, OutlineItem, type OutlineItemClassNames, type OutlineItemProps, type OutlineItemRenderProps, type OutlineItemStyles, type Page, PdfHighlighter, type PdfHighlighterProps, type PdfHighlighterTheme, type PdfHighlighterUtils, PdfLoader, type PdfLoaderProps, type PdfScaleValue, type PdfSelection, type ProcessedOutlineItem, type Scaled, type ScaledPosition, ShapeCanvas, type ShapeCanvasProps, type ShapeData, ShapeHighlight, type ShapeHighlightProps, type ShapeStyle, type ShapeType, SignaturePad, type SignaturePadProps, type TabClassNames, type TabStyles, TextHighlight, type TextHighlightProps, type TextHighlightStyle, type ThumbnailData, ThumbnailItem, type ThumbnailItemProps, ThumbnailPanel, type ThumbnailPanelProps, type Tip, type ToggleButtonClassNames, type ToggleButtonStyles, type ViewportHighlight, type ViewportPosition, exportPdf, scaledPositionToViewport, useDocumentOutline, useHighlightContainerContext, useLeftPanelContext, usePageNavigation, usePdfHighlighterContext, useThumbnails, viewportPositionToScaled };
2126
+ declare const exportPdf: typeof exportPdf$1;
2127
+
2128
+ export { AreaHighlight, type AreaHighlightProps, type AreaHighlightStyle, type Content, DocumentOutline, type DocumentOutlineClassNames, type DocumentOutlineProps, type DocumentOutlineStyles, DrawingCanvas, type DrawingCanvasProps, DrawingHighlight, type DrawingHighlightProps, type DrawingPoint, type DrawingStroke, type ExportPdfOptions, type ExportableHighlight, type ExtractSentencesOptions, type FooterClassNames, type FooterStyles, FreetextHighlight, type FreetextHighlightProps, type FreetextStyle, type GhostHighlight, type Highlight, type HighlightBindings, type HighlightContainerUtils, type HighlightType, ImageHighlight, type ImageHighlightProps, type LTWH, type LTWHP, LeftPanel, type LeftPanelProps, type LeftPanelTab, type LeftPanelTheme, type LeftPanelUtils, MonitoredHighlightContainer, type MonitoredHighlightContainerProps, OutlineItem, type OutlineItemClassNames, type OutlineItemProps, type OutlineItemRenderProps, type OutlineItemStyles, type Page, type PdfColumnDetection, type PdfExtractedPage, PdfHighlighter, type PdfHighlighterProps, type PdfHighlighterTheme, type PdfHighlighterUtils, PdfLoader, type PdfLoaderProps, type PdfReadingOrder, type PdfScaleValue, type PdfSearchOptions, type PdfSelection, type PdfSentence, type PdfSentenceSource, type PdfTextColumn, type PdfTextItem, type PdfTextUnit, type PdfTextUnitType, type ProcessedOutlineItem, type Scaled, type ScaledPosition, ShapeCanvas, type ShapeCanvasProps, type ShapeData, ShapeHighlight, type ShapeHighlightProps, type ShapeStyle, type ShapeType, SignaturePad, type SignaturePadProps, type TabClassNames, type TabStyles, TextHighlight, type TextHighlightProps, type TextHighlightStyle, type TextPositionMatch, type ThumbnailData, ThumbnailItem, type ThumbnailItemProps, ThumbnailPanel, type ThumbnailPanelProps, type Tip, type ToggleButtonClassNames, type ToggleButtonStyles, type ViewportHighlight, type ViewportPosition, exportPdf, extractPageTextItems, extractSentences, extractTextUnits, getTextPosition, scaledPositionToViewport, sentenceToHighlight, useDocumentOutline, useHighlightContainerContext, useLeftPanelContext, usePageNavigation, usePdfHighlighterContext, useThumbnails, viewportPositionToScaled };