react-pdf-highlighter-plus 1.0.3 → 1.0.5

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 (85) hide show
  1. package/dist/esm/index.d.ts +1348 -19
  2. package/dist/esm/index.js +3557 -18
  3. package/dist/esm/index.js.map +1 -1
  4. package/package.json +3 -2
  5. package/dist/esm/components/AreaHighlight.d.ts +0 -82
  6. package/dist/esm/components/AreaHighlight.js +0 -109
  7. package/dist/esm/components/AreaHighlight.js.map +0 -1
  8. package/dist/esm/components/DrawingCanvas.d.ts +0 -48
  9. package/dist/esm/components/DrawingCanvas.js +0 -277
  10. package/dist/esm/components/DrawingCanvas.js.map +0 -1
  11. package/dist/esm/components/DrawingHighlight.d.ts +0 -70
  12. package/dist/esm/components/DrawingHighlight.js +0 -164
  13. package/dist/esm/components/DrawingHighlight.js.map +0 -1
  14. package/dist/esm/components/FreetextHighlight.d.ts +0 -112
  15. package/dist/esm/components/FreetextHighlight.js +0 -193
  16. package/dist/esm/components/FreetextHighlight.js.map +0 -1
  17. package/dist/esm/components/HighlightLayer.d.ts +0 -49
  18. package/dist/esm/components/HighlightLayer.js +0 -37
  19. package/dist/esm/components/HighlightLayer.js.map +0 -1
  20. package/dist/esm/components/ImageHighlight.d.ts +0 -63
  21. package/dist/esm/components/ImageHighlight.js +0 -65
  22. package/dist/esm/components/ImageHighlight.js.map +0 -1
  23. package/dist/esm/components/MonitoredHighlightContainer.d.ts +0 -37
  24. package/dist/esm/components/MonitoredHighlightContainer.js +0 -42
  25. package/dist/esm/components/MonitoredHighlightContainer.js.map +0 -1
  26. package/dist/esm/components/MouseMonitor.d.ts +0 -34
  27. package/dist/esm/components/MouseMonitor.js +0 -30
  28. package/dist/esm/components/MouseMonitor.js.map +0 -1
  29. package/dist/esm/components/MouseSelection.d.ts +0 -66
  30. package/dist/esm/components/MouseSelection.js +0 -122
  31. package/dist/esm/components/MouseSelection.js.map +0 -1
  32. package/dist/esm/components/PdfHighlighter.d.ts +0 -184
  33. package/dist/esm/components/PdfHighlighter.js +0 -410
  34. package/dist/esm/components/PdfHighlighter.js.map +0 -1
  35. package/dist/esm/components/PdfLoader.d.ts +0 -55
  36. package/dist/esm/components/PdfLoader.js +0 -57
  37. package/dist/esm/components/PdfLoader.js.map +0 -1
  38. package/dist/esm/components/ShapeCanvas.d.ts +0 -51
  39. package/dist/esm/components/ShapeCanvas.js +0 -205
  40. package/dist/esm/components/ShapeCanvas.js.map +0 -1
  41. package/dist/esm/components/ShapeHighlight.d.ts +0 -107
  42. package/dist/esm/components/ShapeHighlight.js +0 -140
  43. package/dist/esm/components/ShapeHighlight.js.map +0 -1
  44. package/dist/esm/components/SignaturePad.d.ts +0 -40
  45. package/dist/esm/components/SignaturePad.js +0 -138
  46. package/dist/esm/components/SignaturePad.js.map +0 -1
  47. package/dist/esm/components/TextHighlight.d.ts +0 -93
  48. package/dist/esm/components/TextHighlight.js +0 -115
  49. package/dist/esm/components/TextHighlight.js.map +0 -1
  50. package/dist/esm/components/TipContainer.d.ts +0 -27
  51. package/dist/esm/components/TipContainer.js +0 -58
  52. package/dist/esm/components/TipContainer.js.map +0 -1
  53. package/dist/esm/contexts/HighlightContext.d.ts +0 -44
  54. package/dist/esm/contexts/HighlightContext.js +0 -16
  55. package/dist/esm/contexts/HighlightContext.js.map +0 -1
  56. package/dist/esm/contexts/PdfHighlighterContext.d.ts +0 -89
  57. package/dist/esm/contexts/PdfHighlighterContext.js +0 -16
  58. package/dist/esm/contexts/PdfHighlighterContext.js.map +0 -1
  59. package/dist/esm/lib/coordinates.d.ts +0 -16
  60. package/dist/esm/lib/coordinates.js +0 -69
  61. package/dist/esm/lib/coordinates.js.map +0 -1
  62. package/dist/esm/lib/export-pdf.d.ts +0 -81
  63. package/dist/esm/lib/export-pdf.js +0 -511
  64. package/dist/esm/lib/export-pdf.js.map +0 -1
  65. package/dist/esm/lib/get-bounding-rect.d.ts +0 -3
  66. package/dist/esm/lib/get-bounding-rect.js +0 -35
  67. package/dist/esm/lib/get-bounding-rect.js.map +0 -1
  68. package/dist/esm/lib/get-client-rects.d.ts +0 -3
  69. package/dist/esm/lib/get-client-rects.js +0 -43
  70. package/dist/esm/lib/get-client-rects.js.map +0 -1
  71. package/dist/esm/lib/group-highlights-by-page.d.ts +0 -6
  72. package/dist/esm/lib/group-highlights-by-page.js +0 -23
  73. package/dist/esm/lib/group-highlights-by-page.js.map +0 -1
  74. package/dist/esm/lib/optimize-client-rects.d.ts +0 -3
  75. package/dist/esm/lib/optimize-client-rects.js +0 -65
  76. package/dist/esm/lib/optimize-client-rects.js.map +0 -1
  77. package/dist/esm/lib/pdfjs-dom.d.ts +0 -9
  78. package/dist/esm/lib/pdfjs-dom.js +0 -55
  79. package/dist/esm/lib/pdfjs-dom.js.map +0 -1
  80. package/dist/esm/lib/screenshot.d.ts +0 -4
  81. package/dist/esm/lib/screenshot.js +0 -24
  82. package/dist/esm/lib/screenshot.js.map +0 -1
  83. package/dist/esm/types.d.ts +0 -213
  84. package/dist/esm/types.js +0 -2
  85. package/dist/esm/types.js.map +0 -1
@@ -1,19 +1,1348 @@
1
- import { PdfHighlighter, PdfHighlighterProps } from "./components/PdfHighlighter";
2
- import { TextHighlight, TextHighlightProps, TextHighlightStyle } from "./components/TextHighlight";
3
- import { MonitoredHighlightContainer, MonitoredHighlightContainerProps } from "./components/MonitoredHighlightContainer";
4
- import { AreaHighlight, AreaHighlightProps, AreaHighlightStyle } from "./components/AreaHighlight";
5
- import { FreetextHighlight, FreetextHighlightProps, FreetextStyle } from "./components/FreetextHighlight";
6
- import { ImageHighlight, ImageHighlightProps } from "./components/ImageHighlight";
7
- import { SignaturePad, SignaturePadProps } from "./components/SignaturePad";
8
- import { DrawingCanvas, DrawingCanvasProps } from "./components/DrawingCanvas";
9
- import { DrawingHighlight, DrawingHighlightProps } from "./components/DrawingHighlight";
10
- import { ShapeCanvas, ShapeCanvasProps } from "./components/ShapeCanvas";
11
- import { ShapeHighlight, ShapeHighlightProps, ShapeStyle } from "./components/ShapeHighlight";
12
- import { PdfLoader, PdfLoaderProps } from "./components/PdfLoader";
13
- import { HighlightContainerUtils, useHighlightContainerContext } from "./contexts/HighlightContext";
14
- import { viewportPositionToScaled, scaledPositionToViewport } from "./lib/coordinates";
15
- import { exportPdf, ExportPdfOptions, ExportableHighlight } from "./lib/export-pdf";
16
- import { PdfHighlighterUtils, usePdfHighlighterContext } from "./contexts/PdfHighlighterContext";
17
- export { PdfHighlighter, PdfLoader, TextHighlight, MonitoredHighlightContainer, AreaHighlight, FreetextHighlight, ImageHighlight, SignaturePad, DrawingCanvas, DrawingHighlight, ShapeCanvas, ShapeHighlight, useHighlightContainerContext, viewportPositionToScaled, scaledPositionToViewport, usePdfHighlighterContext, exportPdf, };
18
- export type { HighlightContainerUtils, PdfHighlighterUtils, PdfHighlighterProps, TextHighlightProps, TextHighlightStyle, MonitoredHighlightContainerProps, AreaHighlightProps, AreaHighlightStyle, FreetextHighlightProps, FreetextStyle, ImageHighlightProps, SignaturePadProps, DrawingCanvasProps, DrawingHighlightProps, ShapeCanvasProps, ShapeHighlightProps, ShapeStyle, PdfLoaderProps, ExportPdfOptions, ExportableHighlight, };
19
- export * from "./types";
1
+ import { PDFDocumentProxy, OnProgressParameters } from 'pdfjs-dist';
2
+ import React, { ReactNode, CSSProperties, MouseEvent as MouseEvent$1 } from 'react';
3
+ import { Root } from 'react-dom/client';
4
+ import { PDFViewer } from 'pdfjs-dist/types/web/pdf_viewer';
5
+ import { PDFViewer as PDFViewer$1 } from 'pdfjs-dist/web/pdf_viewer.mjs';
6
+ import { TypedArray, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
7
+
8
+ /**
9
+ * A rectangle as measured by the viewport.
10
+ *
11
+ * @category Type
12
+ */
13
+ type LTWH = {
14
+ /** The x coordinate of the top-left of the rectangle. */
15
+ left: number;
16
+ /** The y coordinate of the top-left of the rectangle. */
17
+ top: number;
18
+ /** Width of the rectangle, relative to top left of the viewport. */
19
+ width: number;
20
+ /** Height of the rectangle, relative to top left of the viewport. */
21
+ height: number;
22
+ };
23
+ /** @category Type */
24
+ type LTWHP = LTWH & {
25
+ /** 1-Indexed page number */
26
+ pageNumber: number;
27
+ };
28
+ /**
29
+ * "scaled" means that data structure stores (0, 1) coordinates.
30
+ * for clarity reasons I decided not to store actual (0, 1) coordinates but
31
+ * provide width and height, so user can compute ratio himself if needed
32
+ *
33
+ * @category Type
34
+ * @author Artem Tyurin <artem.tyurin@gmail.com>
35
+ */
36
+ type Scaled = {
37
+ x1: number;
38
+ y1: number;
39
+ x2: number;
40
+ y2: number;
41
+ width: number;
42
+ height: number;
43
+ /** 1-Indexed page number */
44
+ pageNumber: number;
45
+ };
46
+ /**
47
+ * Position of a Highlight relative to the viewport.
48
+ *
49
+ * @category Type
50
+ */
51
+ type ViewportPosition = {
52
+ /** Bounding rectangle for the entire highlight. */
53
+ boundingRect: LTWHP;
54
+ /** For text highlights, the rectangular highlights for each block of text. */
55
+ rects: Array<LTWHP>;
56
+ };
57
+ /**
58
+ * Position of a Highlight with normalised coordinates.
59
+ *
60
+ * @category Type
61
+ */
62
+ type ScaledPosition = {
63
+ /** Bounding rectangle for the entire highlight. */
64
+ boundingRect: Scaled;
65
+ /** For text highlights, the rectangular highlights for each block of text. */
66
+ rects: Array<Scaled>;
67
+ /** Rarely applicable property of whether coordinates should be in PDF coordinate space. */
68
+ usePdfCoordinates?: boolean;
69
+ };
70
+ /**
71
+ * A point in a drawing stroke.
72
+ *
73
+ * @category Type
74
+ */
75
+ type DrawingPoint = {
76
+ x: number;
77
+ y: number;
78
+ };
79
+ /**
80
+ * A stroke in a drawing, with its own color and width.
81
+ *
82
+ * @category Type
83
+ */
84
+ type DrawingStroke = {
85
+ points: DrawingPoint[];
86
+ color: string;
87
+ width: number;
88
+ };
89
+ /**
90
+ * Shape types for shape annotations.
91
+ *
92
+ * @category Type
93
+ */
94
+ type ShapeType = "rectangle" | "circle" | "arrow";
95
+ /**
96
+ * Shape data for shape highlights.
97
+ *
98
+ * @category Type
99
+ */
100
+ type ShapeData = {
101
+ shapeType: ShapeType;
102
+ strokeColor: string;
103
+ strokeWidth: number;
104
+ /** For arrows: start point as percentage of bounding box (0-1) */
105
+ startPoint?: {
106
+ x: number;
107
+ y: number;
108
+ };
109
+ /** For arrows: end point as percentage of bounding box (0-1) */
110
+ endPoint?: {
111
+ x: number;
112
+ y: number;
113
+ };
114
+ };
115
+ /**
116
+ * The content of a highlight
117
+ *
118
+ * @category Type
119
+ */
120
+ type Content = {
121
+ text?: string;
122
+ image?: string;
123
+ /** For drawing highlights, store the stroke data for later editing */
124
+ strokes?: DrawingStroke[];
125
+ /** For shape highlights, store the shape data */
126
+ shape?: ShapeData;
127
+ };
128
+ /**
129
+ * What type the highlight is. This is the ideal way to determine whether to
130
+ * render it in an AreaHighlight or TextHighlight.
131
+ *
132
+ * @category Type
133
+ */
134
+ type HighlightType = "text" | "area" | "freetext" | "image" | "drawing" | "shape";
135
+ /**
136
+ * This represents a selected (text/mouse) area that has been turned into a
137
+ * highlight. If you are storing highlights, they should be stored as this type.
138
+ *
139
+ * @category Type
140
+ */
141
+ interface Highlight {
142
+ id: string;
143
+ /**
144
+ * This property is planned to be non-optional in future.
145
+ */
146
+ type?: HighlightType;
147
+ /**
148
+ * @deprecated If you want your highlight to store content after being a
149
+ * GhostHighlight, you should create your own interface extended off this. If
150
+ * you are currently using this property to determine what kind of highlight
151
+ * to render, please use {@link type}.
152
+ */
153
+ content?: Content;
154
+ position: ScaledPosition;
155
+ }
156
+ /**
157
+ * This represents a temporary highlight and is ideal as an intermediary between
158
+ * a selection and a highlight.
159
+ *
160
+ * @category Type
161
+ */
162
+ interface GhostHighlight extends Required<Omit<Highlight, "id">> {
163
+ content: Content;
164
+ }
165
+ /**
166
+ * This represents a rendered highlight, with its position defined by the page
167
+ * viewport.
168
+ *
169
+ * @category Type
170
+ */
171
+ type ViewportHighlight<T extends Highlight = Highlight> = Omit<T, "position"> & {
172
+ position: ViewportPosition;
173
+ };
174
+ /**
175
+ * An area or text selection in a PDF Document.
176
+ *
177
+ * @category Type
178
+ */
179
+ type PdfSelection = GhostHighlight & {
180
+ /** Convert the current selection into a temporary highlight */
181
+ makeGhostHighlight(): GhostHighlight;
182
+ };
183
+ /**
184
+ * A PDF.js page representation. This is the reference type for every page in the PdfHighlighter.
185
+ *
186
+ * @category Type
187
+ */
188
+ type Page = {
189
+ node: HTMLElement;
190
+ /** 1-Index page number */
191
+ number: number;
192
+ };
193
+ /**
194
+ * All the DOM refs for a group of highlights on one page
195
+ *
196
+ * @category Type
197
+ */
198
+ type HighlightBindings = {
199
+ reactRoot: Root;
200
+ container: Element;
201
+ textLayer: HTMLElement;
202
+ };
203
+ /**
204
+ * A popup that can be viewed inside a PdfHighlighter.
205
+ *
206
+ * @category Type
207
+ */
208
+ type Tip = {
209
+ position: ViewportPosition;
210
+ content: ReactNode;
211
+ };
212
+ /**
213
+ * The accepted scale values by the PDF.js viewer.
214
+ * Numeric entries accept floats, e.g. 1.2 = 120%
215
+ *
216
+ * @category Type
217
+ */
218
+ type PdfScaleValue = "page-actual" | "page-width" | "page-height" | "page-fit" | "auto" | number;
219
+
220
+ /**
221
+ * A set of utilities for to control the behaviour of {@link PdfHighlighter}.
222
+ *
223
+ * @category Context
224
+ */
225
+ type PdfHighlighterUtils = {
226
+ /**
227
+ * Checks whether a selection is progress, a ghost highlight, or an edit.
228
+ *
229
+ * @returns - `true` if editing, ghost highlighting, or selecting.
230
+ */
231
+ isEditingOrHighlighting(): boolean;
232
+ /**
233
+ * Get currently selected area or text selection.
234
+ *
235
+ * @returns - current selection or `null` if no selection is being made.
236
+ */
237
+ getCurrentSelection(): PdfSelection | null;
238
+ /**
239
+ * Get the currently present ghost highlight.
240
+ *
241
+ * @return - currently present ghost highlight or `null` if non-existent.
242
+ */
243
+ getGhostHighlight(): GhostHighlight | null;
244
+ /**
245
+ * Cancel any ghost highlight.
246
+ * The selected area will stay selected until the user clicks away.
247
+ */
248
+ removeGhostHighlight(): void;
249
+ /**
250
+ * If enabled, automatic tips/popups inside of a PdfHighlighter will be disabled.
251
+ * Additional niceties will also be provided to prevent new highlights being made.
252
+ */
253
+ toggleEditInProgress(flag?: boolean): void;
254
+ /**
255
+ * Whether an AreaHighlight is being moved/resized, or a manual highlight edit has
256
+ * been toggled.
257
+ *
258
+ * @returns - `true` if AreaHighlight is being edited or edit mode was set.
259
+ */
260
+ isEditInProgress(): boolean;
261
+ /**
262
+ * Whether a mouse selection or text selection is currently being performed.
263
+ *
264
+ * @returns - `true` if mouse selection or text selection is being performed.
265
+ */
266
+ isSelectionInProgress(): boolean;
267
+ /**
268
+ * Scroll to a highlight in this viewer.
269
+ *
270
+ * @param highlight - A highlight provided to the {@link PdfHighlighter} to
271
+ * scroll to.
272
+ */
273
+ scrollToHighlight(highlight: Highlight): void;
274
+ /**
275
+ * Get a reference to the currently used instance of a PDF Viewer.
276
+ *
277
+ * @returns - The currently active PDF Viewer.
278
+ */
279
+ getViewer(): PDFViewer | null;
280
+ /**
281
+ * Get the currently active tip, if any.
282
+ *
283
+ * @returns - the currently active tip or `null` if inactive.
284
+ */
285
+ getTip(): Tip | null;
286
+ /**
287
+ * Set a tip to be displayed in the current PDF Viewer.
288
+ *
289
+ * @param tip - tip to be displayed, or `null` to hide any tip.
290
+ */
291
+ setTip(tip: Tip | null): void;
292
+ /**
293
+ * Callback to update any currently active tip's position. This will make sure
294
+ * the tip is visible above/below its highlight.
295
+ */
296
+ updateTipPosition(): void;
297
+ };
298
+ /**
299
+ * Custom hook for providing {@link PdfHighlighterUtils}. Must be used
300
+ * within a child of {@link PdfHighlighter}.
301
+ *
302
+ * @category Context
303
+ */
304
+ declare const usePdfHighlighterContext: () => PdfHighlighterUtils;
305
+
306
+ /**
307
+ * The props type for {@link PdfHighlighter}.
308
+ *
309
+ * @category Component Properties
310
+ */
311
+ interface PdfHighlighterProps {
312
+ /**
313
+ * Array of all highlights to be organised and fed through to the child
314
+ * highlight container.
315
+ */
316
+ highlights: Array<Highlight>;
317
+ /**
318
+ * Event is called only once whenever the user changes scroll after
319
+ * the autoscroll function, scrollToHighlight, has been called.
320
+ */
321
+ onScrollAway?(): void;
322
+ /**
323
+ * What scale to render the PDF at inside the viewer.
324
+ */
325
+ pdfScaleValue?: PdfScaleValue;
326
+ /**
327
+ * Callback triggered whenever a user finishes making a mouse selection or has
328
+ * selected text.
329
+ *
330
+ * @param PdfSelection - Content and positioning of the selection. NOTE:
331
+ * `makeGhostHighlight` will not work if the selection disappears.
332
+ */
333
+ onSelection?(PdfSelection: PdfSelection): void;
334
+ /**
335
+ * Callback triggered whenever a ghost (non-permanent) highlight is created.
336
+ *
337
+ * @param ghostHighlight - Ghost Highlight that has been created.
338
+ */
339
+ onCreateGhostHighlight?(ghostHighlight: GhostHighlight): void;
340
+ /**
341
+ * Callback triggered whenever a ghost (non-permanent) highlight is removed.
342
+ *
343
+ * @param ghostHighlight - Ghost Highlight that has been removed.
344
+ */
345
+ onRemoveGhostHighlight?(ghostHighlight: GhostHighlight): void;
346
+ /**
347
+ * Optional element that can be displayed as a tip whenever a user makes a
348
+ * selection.
349
+ */
350
+ selectionTip?: ReactNode;
351
+ /**
352
+ * Condition to check before any mouse selection starts.
353
+ *
354
+ * @param event - mouse event associated with the new selection.
355
+ * @returns - `True` if mouse selection should start.
356
+ */
357
+ enableAreaSelection?(event: MouseEvent): boolean;
358
+ /**
359
+ * When true, shows crosshair cursor indicating area selection mode is active.
360
+ * Use this when area selection should be persistently enabled (not just on modifier key).
361
+ */
362
+ areaSelectionMode?: boolean;
363
+ /**
364
+ * Optional CSS styling for the rectangular mouse selection.
365
+ */
366
+ mouseSelectionStyle?: CSSProperties;
367
+ /**
368
+ * PDF document to view and overlay highlights.
369
+ */
370
+ pdfDocument: PDFDocumentProxy;
371
+ /**
372
+ * This should be a highlight container/renderer of some sorts. It will be
373
+ * given appropriate context for a single highlight which it can then use to
374
+ * render a TextHighlight, AreaHighlight, etc. in the correct place.
375
+ */
376
+ children: ReactNode;
377
+ /**
378
+ * Coloring for unhighlighted, selected text.
379
+ */
380
+ textSelectionColor?: string;
381
+ /**
382
+ * Creates a reference to the PdfHighlighterContext above the component.
383
+ *
384
+ * @param pdfHighlighterUtils - various useful tools with a PdfHighlighter.
385
+ * See {@link PdfHighlighterContext} for more description.
386
+ */
387
+ utilsRef(pdfHighlighterUtils: PdfHighlighterUtils): void;
388
+ /**
389
+ * Style properties for the PdfHighlighter (scrollbar, background, etc.), NOT
390
+ * the PDF.js viewer it encloses. If you want to edit the latter, use the
391
+ * other style props like `textSelectionColor` or overwrite pdf_viewer.css
392
+ */
393
+ style?: CSSProperties;
394
+ /**
395
+ * Condition to check before freetext creation starts.
396
+ *
397
+ * @param event - mouse event associated with the click.
398
+ * @returns - `True` if freetext creation should occur.
399
+ */
400
+ enableFreetextCreation?(event: MouseEvent): boolean;
401
+ /**
402
+ * Callback triggered when user clicks to create a freetext annotation.
403
+ *
404
+ * @param position - Scaled position where the click occurred.
405
+ */
406
+ onFreetextClick?(position: ScaledPosition): void;
407
+ /**
408
+ * Condition to check before image creation starts.
409
+ *
410
+ * @param event - mouse event associated with the click.
411
+ * @returns - `True` if image creation should occur.
412
+ */
413
+ enableImageCreation?(event: MouseEvent): boolean;
414
+ /**
415
+ * Callback triggered when user clicks to create an image annotation.
416
+ *
417
+ * @param position - Scaled position where the click occurred.
418
+ */
419
+ onImageClick?(position: ScaledPosition): void;
420
+ /**
421
+ * Whether drawing mode is enabled.
422
+ */
423
+ enableDrawingMode?: boolean;
424
+ /**
425
+ * Callback triggered when a drawing is completed.
426
+ *
427
+ * @param dataUrl - The drawing as a PNG data URL.
428
+ * @param position - Scaled position of the drawing on the page.
429
+ * @param strokes - The stroke data for later editing.
430
+ */
431
+ onDrawingComplete?(dataUrl: string, position: ScaledPosition, strokes: DrawingStroke[]): void;
432
+ /**
433
+ * Callback triggered when drawing is cancelled.
434
+ */
435
+ onDrawingCancel?(): void;
436
+ /**
437
+ * Stroke color for drawing mode.
438
+ * @default "#000000"
439
+ */
440
+ drawingStrokeColor?: string;
441
+ /**
442
+ * Stroke width for drawing mode.
443
+ * @default 3
444
+ */
445
+ drawingStrokeWidth?: number;
446
+ /**
447
+ * The type of shape to create, or null if shape mode is not active.
448
+ */
449
+ enableShapeMode?: ShapeType | null;
450
+ /**
451
+ * Callback triggered when a shape is completed.
452
+ *
453
+ * @param position - Scaled position of the shape on the page.
454
+ * @param shape - The shape data (type, color, width).
455
+ */
456
+ onShapeComplete?(position: ScaledPosition, shape: ShapeData): void;
457
+ /**
458
+ * Callback triggered when shape creation is cancelled.
459
+ */
460
+ onShapeCancel?(): void;
461
+ /**
462
+ * Stroke color for shape mode.
463
+ * @default "#000000"
464
+ */
465
+ shapeStrokeColor?: string;
466
+ /**
467
+ * Stroke width for shape mode.
468
+ * @default 2
469
+ */
470
+ shapeStrokeWidth?: number;
471
+ }
472
+ /**
473
+ * This is a large-scale PDF viewer component designed to facilitate
474
+ * highlighting. It should be used as a child to a {@link PdfLoader} to ensure
475
+ * proper document loading. This does not itself render any highlights, but
476
+ * instead its child should be the container component for each individual
477
+ * highlight. This component will be provided appropriate HighlightContext for
478
+ * rendering.
479
+ *
480
+ * @category Component
481
+ */
482
+ 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, }: PdfHighlighterProps) => React.JSX.Element;
483
+
484
+ /**
485
+ * Style options for text highlight appearance.
486
+ */
487
+ interface TextHighlightStyle {
488
+ highlightColor?: string;
489
+ highlightStyle?: "highlight" | "underline" | "strikethrough";
490
+ }
491
+ /**
492
+ * The props type for {@link TextHighlight}.
493
+ *
494
+ * @category Component Properties
495
+ */
496
+ interface TextHighlightProps {
497
+ /**
498
+ * Highlight to render over text.
499
+ */
500
+ highlight: ViewportHighlight;
501
+ /**
502
+ * Callback triggered whenever the user clicks on the part of a highlight.
503
+ *
504
+ * @param event - Mouse event associated with click.
505
+ */
506
+ onClick?(event: MouseEvent$1<HTMLDivElement>): void;
507
+ /**
508
+ * Callback triggered whenever the user enters the area of a text highlight.
509
+ *
510
+ * @param event - Mouse event associated with movement.
511
+ */
512
+ onMouseOver?(event: MouseEvent$1<HTMLDivElement>): void;
513
+ /**
514
+ * Callback triggered whenever the user leaves the area of a text highlight.
515
+ *
516
+ * @param event - Mouse event associated with movement.
517
+ */
518
+ onMouseOut?(event: MouseEvent$1<HTMLDivElement>): void;
519
+ /**
520
+ * Indicates whether the component is autoscrolled into view, affecting
521
+ * default theming.
522
+ */
523
+ isScrolledTo: boolean;
524
+ /**
525
+ * Callback triggered whenever the user tries to open context menu on highlight.
526
+ *
527
+ * @param event - Mouse event associated with click.
528
+ */
529
+ onContextMenu?(event: MouseEvent$1<HTMLDivElement>): void;
530
+ /**
531
+ * Optional CSS styling applied to each TextHighlight part.
532
+ */
533
+ style?: CSSProperties;
534
+ /**
535
+ * Background/line color for the highlight.
536
+ * Default: "rgba(255, 226, 143, 1)" (yellow)
537
+ */
538
+ highlightColor?: string;
539
+ /**
540
+ * Style mode for the highlight.
541
+ * - "highlight": Solid background color (default)
542
+ * - "underline": Line under the text
543
+ * - "strikethrough": Line through the text
544
+ */
545
+ highlightStyle?: "highlight" | "underline" | "strikethrough";
546
+ /**
547
+ * Callback triggered when the style changes.
548
+ */
549
+ onStyleChange?(style: TextHighlightStyle): void;
550
+ /**
551
+ * Callback triggered when the delete button is clicked.
552
+ */
553
+ onDelete?(): void;
554
+ /**
555
+ * Custom style icon. Replaces the default palette icon.
556
+ */
557
+ styleIcon?: ReactNode;
558
+ /**
559
+ * Custom delete icon. Replaces the default trash icon.
560
+ */
561
+ deleteIcon?: ReactNode;
562
+ /**
563
+ * Custom color presets for the style panel.
564
+ * Default: ["rgba(255, 226, 143, 1)", "#ffcdd2", "#c8e6c9", "#bbdefb", "#e1bee7"]
565
+ */
566
+ colorPresets?: string[];
567
+ }
568
+ /**
569
+ * A component for displaying a highlighted text area.
570
+ *
571
+ * @category Component
572
+ */
573
+ declare const TextHighlight: ({ highlight, onClick, onMouseOver, onMouseOut, isScrolledTo, onContextMenu, style, highlightColor, highlightStyle, onStyleChange, onDelete, styleIcon, deleteIcon, colorPresets, }: TextHighlightProps) => React.JSX.Element;
574
+
575
+ /**
576
+ * The props type for {@link MonitoredHighlightContainer}.
577
+ *
578
+ * @category Component Properties
579
+ */
580
+ interface MonitoredHighlightContainerProps {
581
+ /**
582
+ * A callback triggered whenever the mouse hovers over a highlight.
583
+ */
584
+ onMouseEnter?(): void;
585
+ /**
586
+ * What tip to automatically display whenever a mouse hovers over a highlight.
587
+ * The tip will persist even as the user puts their mouse over it and not the
588
+ * highlight, but will disappear once it no longer hovers both.
589
+ */
590
+ highlightTip?: Tip;
591
+ /**
592
+ * A callback triggered whenever the mouse completely moves out from both the
593
+ * highlight (children) and any highlightTip.
594
+ */
595
+ onMouseLeave?(): void;
596
+ /**
597
+ * Component to monitor mouse activity over. This should be a highlight within the {@link PdfHighlighter}.
598
+ */
599
+ children: ReactNode;
600
+ }
601
+ /**
602
+ * A container for a highlight component that monitors whether a mouse is over a
603
+ * highlight and over some secondary highlight tip. It will display the tip
604
+ * whenever the mouse is over the highlight and it will hide the tip only when
605
+ * the mouse has left the highlight AND the tip.
606
+ *
607
+ * @category Component
608
+ */
609
+ declare const MonitoredHighlightContainer: ({ onMouseEnter, highlightTip, onMouseLeave, children, }: MonitoredHighlightContainerProps) => React.JSX.Element;
610
+
611
+ /**
612
+ * Style options for area highlight appearance.
613
+ */
614
+ interface AreaHighlightStyle {
615
+ highlightColor?: string;
616
+ }
617
+ /**
618
+ * The props type for {@link AreaHighlight}.
619
+ *
620
+ * @category Component Properties
621
+ */
622
+ interface AreaHighlightProps {
623
+ /**
624
+ * The highlight to be rendered as an {@link AreaHighlight}.
625
+ */
626
+ highlight: ViewportHighlight;
627
+ /**
628
+ * A callback triggered whenever the highlight area is either finished
629
+ * being moved or resized.
630
+ *
631
+ * @param rect - The updated highlight area.
632
+ */
633
+ onChange?(rect: LTWHP): void;
634
+ /**
635
+ * Has the highlight been auto-scrolled into view? By default, this will render the highlight red.
636
+ */
637
+ isScrolledTo?: boolean;
638
+ /**
639
+ * react-rnd bounds on the highlight area. This is useful for preventing the user
640
+ * moving the highlight off the viewer/page. See [react-rnd docs](https://github.com/bokuweb/react-rnd).
641
+ */
642
+ bounds?: string | Element;
643
+ /**
644
+ * A callback triggered whenever a context menu is opened on the highlight area.
645
+ *
646
+ * @param event - The mouse event associated with the context menu.
647
+ */
648
+ onContextMenu?(event: MouseEvent$1<HTMLDivElement>): void;
649
+ /**
650
+ * Event called whenever the user tries to move or resize an {@link AreaHighlight}.
651
+ */
652
+ onEditStart?(): void;
653
+ /**
654
+ * Custom styling to be applied to the {@link AreaHighlight} component.
655
+ */
656
+ style?: CSSProperties;
657
+ /**
658
+ * Background color for the highlight.
659
+ * Default: "rgba(255, 226, 143, 1)" (yellow)
660
+ */
661
+ highlightColor?: string;
662
+ /**
663
+ * Callback triggered when the style changes.
664
+ */
665
+ onStyleChange?(style: AreaHighlightStyle): void;
666
+ /**
667
+ * Callback triggered when the delete button is clicked.
668
+ */
669
+ onDelete?(): void;
670
+ /**
671
+ * Custom style icon. Replaces the default palette icon.
672
+ */
673
+ styleIcon?: ReactNode;
674
+ /**
675
+ * Custom delete icon. Replaces the default trash icon.
676
+ */
677
+ deleteIcon?: ReactNode;
678
+ /**
679
+ * Custom color presets for the style panel.
680
+ * Default: ["rgba(255, 226, 143, 1)", "#ffcdd2", "#c8e6c9", "#bbdefb", "#e1bee7"]
681
+ */
682
+ colorPresets?: string[];
683
+ }
684
+ /**
685
+ * Renders a resizeable and interactive rectangular area for a highlight.
686
+ *
687
+ * @category Component
688
+ */
689
+ declare const AreaHighlight: ({ highlight, onChange, isScrolledTo, bounds, onContextMenu, onEditStart, style, highlightColor, onStyleChange, onDelete, styleIcon, deleteIcon, colorPresets, }: AreaHighlightProps) => React.JSX.Element;
690
+
691
+ /**
692
+ * Style options for freetext highlight appearance.
693
+ */
694
+ interface FreetextStyle {
695
+ color?: string;
696
+ backgroundColor?: string;
697
+ fontFamily?: string;
698
+ fontSize?: string;
699
+ }
700
+ /**
701
+ * The props type for {@link FreetextHighlight}.
702
+ *
703
+ * @category Component Properties
704
+ */
705
+ interface FreetextHighlightProps {
706
+ /**
707
+ * The highlight to be rendered as a {@link FreetextHighlight}.
708
+ */
709
+ highlight: ViewportHighlight;
710
+ /**
711
+ * A callback triggered whenever the highlight position changes (drag).
712
+ *
713
+ * @param rect - The updated highlight area.
714
+ */
715
+ onChange?(rect: LTWHP): void;
716
+ /**
717
+ * A callback triggered whenever the text content changes.
718
+ *
719
+ * @param text - The new text content.
720
+ */
721
+ onTextChange?(text: string): void;
722
+ /**
723
+ * A callback triggered whenever the style changes.
724
+ *
725
+ * @param style - The new style options.
726
+ */
727
+ onStyleChange?(style: FreetextStyle): void;
728
+ /**
729
+ * Has the highlight been auto-scrolled into view?
730
+ */
731
+ isScrolledTo?: boolean;
732
+ /**
733
+ * react-rnd bounds on the highlight area.
734
+ */
735
+ bounds?: string | Element;
736
+ /**
737
+ * A callback triggered on context menu.
738
+ */
739
+ onContextMenu?(event: MouseEvent$1<HTMLDivElement>): void;
740
+ /**
741
+ * Event called when editing begins (drag or text edit).
742
+ */
743
+ onEditStart?(): void;
744
+ /**
745
+ * Event called when editing ends.
746
+ */
747
+ onEditEnd?(): void;
748
+ /**
749
+ * Custom styling for the container.
750
+ */
751
+ style?: CSSProperties;
752
+ /**
753
+ * Text color.
754
+ */
755
+ color?: string;
756
+ /**
757
+ * Background color.
758
+ */
759
+ backgroundColor?: string;
760
+ /**
761
+ * Font family.
762
+ */
763
+ fontFamily?: string;
764
+ /**
765
+ * Font size (e.g., "14px").
766
+ */
767
+ fontSize?: string;
768
+ /**
769
+ * Custom drag icon. Receives default icon as child if not provided.
770
+ */
771
+ dragIcon?: ReactNode;
772
+ /**
773
+ * Custom edit icon. Receives default icon as child if not provided.
774
+ */
775
+ editIcon?: ReactNode;
776
+ /**
777
+ * Custom style/settings icon. Receives default icon as child if not provided.
778
+ */
779
+ styleIcon?: ReactNode;
780
+ /**
781
+ * Custom background color presets for the style panel.
782
+ * Default: ["#ffffc8", "#ffcdd2", "#c8e6c9", "#bbdefb", "#e1bee7"]
783
+ */
784
+ backgroundColorPresets?: string[];
785
+ /**
786
+ * Custom text color presets for the style panel.
787
+ * Default: ["#333333", "#d32f2f", "#1976d2", "#388e3c", "#7b1fa2"]
788
+ */
789
+ textColorPresets?: string[];
790
+ /**
791
+ * Callback triggered when the delete button is clicked.
792
+ */
793
+ onDelete?(): void;
794
+ /**
795
+ * Custom delete icon. Replaces the default trash icon.
796
+ */
797
+ deleteIcon?: ReactNode;
798
+ }
799
+ 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;
800
+
801
+ /**
802
+ * The props type for {@link ImageHighlight}.
803
+ *
804
+ * @category Component Properties
805
+ */
806
+ interface ImageHighlightProps {
807
+ /**
808
+ * The highlight to be rendered as an {@link ImageHighlight}.
809
+ * The highlight.content.image should contain the image data URL.
810
+ */
811
+ highlight: ViewportHighlight;
812
+ /**
813
+ * A callback triggered whenever the highlight position or size changes.
814
+ *
815
+ * @param rect - The updated highlight area.
816
+ */
817
+ onChange?(rect: LTWHP): void;
818
+ /**
819
+ * Has the highlight been auto-scrolled into view?
820
+ */
821
+ isScrolledTo?: boolean;
822
+ /**
823
+ * react-rnd bounds on the highlight area.
824
+ */
825
+ bounds?: string | Element;
826
+ /**
827
+ * A callback triggered on context menu.
828
+ */
829
+ onContextMenu?(event: MouseEvent$1<HTMLDivElement>): void;
830
+ /**
831
+ * Event called when editing begins (drag or resize).
832
+ */
833
+ onEditStart?(): void;
834
+ /**
835
+ * Event called when editing ends.
836
+ */
837
+ onEditEnd?(): void;
838
+ /**
839
+ * Custom styling for the container.
840
+ */
841
+ style?: CSSProperties;
842
+ /**
843
+ * Custom drag icon. Replaces the default 6-dot grid icon.
844
+ */
845
+ dragIcon?: ReactNode;
846
+ /**
847
+ * Callback triggered when the delete button is clicked.
848
+ */
849
+ onDelete?(): void;
850
+ /**
851
+ * Custom delete icon. Replaces the default trash icon.
852
+ */
853
+ deleteIcon?: ReactNode;
854
+ }
855
+ /**
856
+ * Renders a draggable, resizable image/signature annotation.
857
+ *
858
+ * @category Component
859
+ */
860
+ declare const ImageHighlight: ({ highlight, onChange, isScrolledTo, bounds, onContextMenu, onEditStart, onEditEnd, style, dragIcon, onDelete, deleteIcon, }: ImageHighlightProps) => React.JSX.Element;
861
+
862
+ /**
863
+ * The props type for {@link SignaturePad}.
864
+ *
865
+ * @category Component Properties
866
+ */
867
+ interface SignaturePadProps {
868
+ /**
869
+ * Whether the signature pad modal is open.
870
+ */
871
+ isOpen: boolean;
872
+ /**
873
+ * Callback when signature is completed.
874
+ *
875
+ * @param dataUrl - The signature as a PNG data URL.
876
+ */
877
+ onComplete: (dataUrl: string) => void;
878
+ /**
879
+ * Callback when the modal is closed/cancelled.
880
+ */
881
+ onClose: () => void;
882
+ /**
883
+ * Canvas width in pixels.
884
+ * @default 400
885
+ */
886
+ width?: number;
887
+ /**
888
+ * Canvas height in pixels.
889
+ * @default 200
890
+ */
891
+ height?: number;
892
+ }
893
+ /**
894
+ * A modal component with a canvas for drawing signatures.
895
+ * Supports both mouse and touch input.
896
+ *
897
+ * @category Component
898
+ */
899
+ declare const SignaturePad: ({ isOpen, onComplete, onClose, width, height, }: SignaturePadProps) => React.JSX.Element | null;
900
+
901
+ /**
902
+ * The props type for {@link DrawingCanvas}.
903
+ *
904
+ * @category Component Properties
905
+ */
906
+ interface DrawingCanvasProps {
907
+ /**
908
+ * Whether drawing mode is active.
909
+ */
910
+ isActive: boolean;
911
+ /**
912
+ * Stroke color for drawing.
913
+ * @default "#000000"
914
+ */
915
+ strokeColor?: string;
916
+ /**
917
+ * Stroke width for drawing.
918
+ * @default 3
919
+ */
920
+ strokeWidth?: number;
921
+ /**
922
+ * The PDF viewer instance.
923
+ */
924
+ viewer: InstanceType<typeof PDFViewer$1>;
925
+ /**
926
+ * Callback when drawing is complete.
927
+ *
928
+ * @param dataUrl - The drawing as a PNG data URL.
929
+ * @param position - Scaled position of the drawing on the page.
930
+ * @param strokes - The stroke data for later editing.
931
+ */
932
+ onComplete: (dataUrl: string, position: ScaledPosition, strokes: DrawingStroke[]) => void;
933
+ /**
934
+ * Callback when drawing is cancelled.
935
+ */
936
+ onCancel: () => void;
937
+ }
938
+ /**
939
+ * A transparent overlay canvas for freehand drawing on PDF pages.
940
+ * Supports mouse and touch input.
941
+ *
942
+ * @category Component
943
+ */
944
+ declare const DrawingCanvas: ({ isActive, strokeColor, strokeWidth, viewer, onComplete, onCancel, }: DrawingCanvasProps) => React.JSX.Element | null;
945
+
946
+ /**
947
+ * The props type for {@link DrawingHighlight}.
948
+ *
949
+ * @category Component Properties
950
+ */
951
+ interface DrawingHighlightProps {
952
+ /**
953
+ * The highlight to be rendered as a {@link DrawingHighlight}.
954
+ * The highlight.content.image should contain the drawing as a PNG data URL.
955
+ */
956
+ highlight: ViewportHighlight;
957
+ /**
958
+ * A callback triggered whenever the highlight position or size changes.
959
+ *
960
+ * @param rect - The updated highlight area.
961
+ */
962
+ onChange?(rect: LTWHP): void;
963
+ /**
964
+ * Has the highlight been auto-scrolled into view?
965
+ */
966
+ isScrolledTo?: boolean;
967
+ /**
968
+ * react-rnd bounds on the highlight area.
969
+ */
970
+ bounds?: string | Element;
971
+ /**
972
+ * A callback triggered on context menu.
973
+ */
974
+ onContextMenu?(event: MouseEvent$1<HTMLDivElement>): void;
975
+ /**
976
+ * Event called when editing begins (drag or resize).
977
+ */
978
+ onEditStart?(): void;
979
+ /**
980
+ * Event called when editing ends.
981
+ */
982
+ onEditEnd?(): void;
983
+ /**
984
+ * Custom styling for the container.
985
+ */
986
+ style?: CSSProperties;
987
+ /**
988
+ * Custom drag icon. Replaces the default 6-dot grid icon.
989
+ */
990
+ dragIcon?: ReactNode;
991
+ /**
992
+ * Callback when drawing style changes (color or stroke width).
993
+ * The newImage is the re-rendered PNG data URL with updated styles.
994
+ * The newStrokes contain the updated stroke data.
995
+ */
996
+ onStyleChange?(newImage: string, newStrokes: DrawingStroke[]): void;
997
+ /**
998
+ * Callback triggered when the delete button is clicked.
999
+ */
1000
+ onDelete?(): void;
1001
+ /**
1002
+ * Custom delete icon. Replaces the default trash icon.
1003
+ */
1004
+ deleteIcon?: ReactNode;
1005
+ }
1006
+ /**
1007
+ * Renders a draggable, resizable freehand drawing annotation.
1008
+ * Drawings are stored as PNG images with transparent backgrounds.
1009
+ *
1010
+ * @category Component
1011
+ */
1012
+ declare const DrawingHighlight: ({ highlight, onChange, isScrolledTo, bounds, onContextMenu, onEditStart, onEditEnd, style, dragIcon, onStyleChange, onDelete, deleteIcon, }: DrawingHighlightProps) => React.JSX.Element;
1013
+
1014
+ /**
1015
+ * The props type for {@link ShapeCanvas}.
1016
+ *
1017
+ * @category Component Properties
1018
+ */
1019
+ interface ShapeCanvasProps {
1020
+ /**
1021
+ * Whether shape mode is active.
1022
+ */
1023
+ isActive: boolean;
1024
+ /**
1025
+ * The type of shape to create.
1026
+ */
1027
+ shapeType: ShapeType;
1028
+ /**
1029
+ * Stroke color for the shape.
1030
+ * @default "#000000"
1031
+ */
1032
+ strokeColor?: string;
1033
+ /**
1034
+ * Stroke width for the shape.
1035
+ * @default 2
1036
+ */
1037
+ strokeWidth?: number;
1038
+ /**
1039
+ * The PDF viewer instance.
1040
+ */
1041
+ viewer: InstanceType<typeof PDFViewer$1>;
1042
+ /**
1043
+ * Callback when shape creation is complete.
1044
+ *
1045
+ * @param position - Scaled position of the shape on the page.
1046
+ * @param shape - The shape data.
1047
+ */
1048
+ onComplete: (position: ScaledPosition, shape: ShapeData) => void;
1049
+ /**
1050
+ * Callback when shape creation is cancelled.
1051
+ */
1052
+ onCancel: () => void;
1053
+ }
1054
+ /**
1055
+ * A transparent overlay for creating shape annotations on PDF pages.
1056
+ * Supports mouse and touch input with click-and-drag to define shape bounds.
1057
+ *
1058
+ * @category Component
1059
+ */
1060
+ declare const ShapeCanvas: ({ isActive, shapeType, strokeColor, strokeWidth, viewer, onComplete, onCancel, }: ShapeCanvasProps) => React.JSX.Element | null;
1061
+
1062
+ /**
1063
+ * Style options for shape highlight appearance.
1064
+ */
1065
+ interface ShapeStyle {
1066
+ strokeColor?: string;
1067
+ strokeWidth?: number;
1068
+ }
1069
+ /**
1070
+ * The props type for {@link ShapeHighlight}.
1071
+ *
1072
+ * @category Component Properties
1073
+ */
1074
+ interface ShapeHighlightProps {
1075
+ /**
1076
+ * The highlight to be rendered as a {@link ShapeHighlight}.
1077
+ */
1078
+ highlight: ViewportHighlight;
1079
+ /**
1080
+ * A callback triggered whenever the highlight position or size changes.
1081
+ *
1082
+ * @param rect - The updated highlight area.
1083
+ */
1084
+ onChange?(rect: LTWHP): void;
1085
+ /**
1086
+ * Has the highlight been auto-scrolled into view?
1087
+ */
1088
+ isScrolledTo?: boolean;
1089
+ /**
1090
+ * react-rnd bounds on the highlight area.
1091
+ */
1092
+ bounds?: string | Element;
1093
+ /**
1094
+ * A callback triggered on context menu.
1095
+ */
1096
+ onContextMenu?(event: MouseEvent$1<HTMLDivElement>): void;
1097
+ /**
1098
+ * Event called when editing begins (drag or resize).
1099
+ */
1100
+ onEditStart?(): void;
1101
+ /**
1102
+ * Event called when editing ends.
1103
+ */
1104
+ onEditEnd?(): void;
1105
+ /**
1106
+ * Custom styling for the container.
1107
+ */
1108
+ style?: CSSProperties;
1109
+ /**
1110
+ * The type of shape to render.
1111
+ * @default "rectangle"
1112
+ */
1113
+ shapeType?: ShapeType;
1114
+ /**
1115
+ * Stroke color for the shape.
1116
+ * @default "#000000"
1117
+ */
1118
+ strokeColor?: string;
1119
+ /**
1120
+ * Stroke width for the shape.
1121
+ * @default 2
1122
+ */
1123
+ strokeWidth?: number;
1124
+ /**
1125
+ * Callback triggered when the style changes.
1126
+ */
1127
+ onStyleChange?(style: ShapeStyle): void;
1128
+ /**
1129
+ * Callback triggered when the delete button is clicked.
1130
+ */
1131
+ onDelete?(): void;
1132
+ /**
1133
+ * Custom style icon. Replaces the default palette icon.
1134
+ */
1135
+ styleIcon?: ReactNode;
1136
+ /**
1137
+ * Custom delete icon. Replaces the default trash icon.
1138
+ */
1139
+ deleteIcon?: ReactNode;
1140
+ /**
1141
+ * Custom color presets for the style panel.
1142
+ */
1143
+ colorPresets?: string[];
1144
+ /**
1145
+ * For arrows: start point as percentage of bounding box (0-1).
1146
+ */
1147
+ startPoint?: {
1148
+ x: number;
1149
+ y: number;
1150
+ };
1151
+ /**
1152
+ * For arrows: end point as percentage of bounding box (0-1).
1153
+ */
1154
+ endPoint?: {
1155
+ x: number;
1156
+ y: number;
1157
+ };
1158
+ }
1159
+ /**
1160
+ * Renders a draggable, resizable shape annotation.
1161
+ * Supports rectangle, circle/ellipse, and arrow shapes.
1162
+ *
1163
+ * @category Component
1164
+ */
1165
+ declare const ShapeHighlight: ({ highlight, onChange, isScrolledTo, bounds, onContextMenu, onEditStart, onEditEnd, style, shapeType, strokeColor, strokeWidth, onStyleChange, onDelete, styleIcon, deleteIcon, colorPresets, startPoint, endPoint, }: ShapeHighlightProps) => React.JSX.Element;
1166
+
1167
+ /**
1168
+ * The props type for {@link PdfLoader}.
1169
+ *
1170
+ * @category Component Properties
1171
+ */
1172
+ interface PdfLoaderProps {
1173
+ /**
1174
+ * The document to be loaded by PDF.js.
1175
+ * If you need to pass HTTP headers, auth parameters,
1176
+ * or other pdf settings, do it through here.
1177
+ */
1178
+ document: string | URL | TypedArray | DocumentInitParameters;
1179
+ /**
1180
+ * Callback to render content before the PDF document is loaded.
1181
+ *
1182
+ * @param progress - PDF.js progress status.
1183
+ * @returns - Component to be rendered in space of the PDF document while loading.
1184
+ */
1185
+ beforeLoad?(progress: OnProgressParameters): ReactNode;
1186
+ /**
1187
+ * Component to render in the case of any PDF loading errors.
1188
+ *
1189
+ * @param error - PDF loading error.
1190
+ * @returns - Component to be rendered in space of the PDF document.
1191
+ */
1192
+ errorMessage?(error: Error): ReactNode;
1193
+ /**
1194
+ * Child components to use/render the loaded PDF document.
1195
+ *
1196
+ * @param pdfDocument - The loaded PDF document.
1197
+ * @returns - Component to render once PDF document is loaded.
1198
+ */
1199
+ children(pdfDocument: PDFDocumentProxy): ReactNode;
1200
+ /**
1201
+ * Callback triggered whenever an error occurs.
1202
+ *
1203
+ * @param error - PDF Loading error triggering the event.
1204
+ * @returns - Component to be rendered in space of the PDF document.
1205
+ */
1206
+ onError?(error: Error): void;
1207
+ /**
1208
+ * NOTE: This will be applied to all PdfLoader instances.
1209
+ * If you want to only apply a source to this instance, use the document parameters.
1210
+ */
1211
+ workerSrc?: string;
1212
+ }
1213
+ /**
1214
+ * A component for loading a PDF document and passing it to a child.
1215
+ *
1216
+ * @category Component
1217
+ */
1218
+ declare const PdfLoader: ({ document, beforeLoad, errorMessage, children, onError, workerSrc, }: PdfLoaderProps) => React.ReactNode;
1219
+
1220
+ /**
1221
+ * A set of utilities for rendering highlights. Designed to be used within a
1222
+ * highlight container.
1223
+ *
1224
+ * @category Context
1225
+ */
1226
+ type HighlightContainerUtils<T extends Highlight = Highlight> = {
1227
+ /**
1228
+ * The highlight being rendered at this component.
1229
+ */
1230
+ highlight: ViewportHighlight<T>;
1231
+ /**
1232
+ * Convert a Viewport rectangle to a scaled rectangle. Can be used
1233
+ * for storing and updating area selection highlights, for example.
1234
+ *
1235
+ * @returns - Scaled/display agnostic rectangle.
1236
+ */
1237
+ viewportToScaled(rect: LTWHP): Scaled;
1238
+ /**
1239
+ * Capture a PNG data url of a viewport rectangle.
1240
+ *
1241
+ * @returns - PNG data url. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
1242
+ */
1243
+ screenshot(position: LTWH): string;
1244
+ /**
1245
+ * Whether the highlight has been autoscrolled to.
1246
+ */
1247
+ isScrolledTo: boolean;
1248
+ /**
1249
+ * All the DOM refs for the highlights shared on the same page
1250
+ * as `highlight`
1251
+ */
1252
+ highlightBindings: HighlightBindings;
1253
+ };
1254
+ /**
1255
+ * Custom hook for providing {@link HighlightContainerUtils}. Must be used
1256
+ * within a child of {@link PdfHighlighter}.
1257
+ *
1258
+ * @category Context
1259
+ */
1260
+ declare const useHighlightContainerContext: <T extends Highlight = Highlight>() => HighlightContainerUtils<T>;
1261
+
1262
+ /** @category Utilities */
1263
+ declare const viewportPositionToScaled: ({ boundingRect, rects }: ViewportPosition, viewer: PDFViewer) => ScaledPosition;
1264
+ /** @category Utilities */
1265
+ declare const scaledPositionToViewport: ({ boundingRect, rects, usePdfCoordinates }: ScaledPosition, viewer: PDFViewer) => ViewportPosition;
1266
+
1267
+ /**
1268
+ * Options for the PDF export function.
1269
+ *
1270
+ * @category Type
1271
+ */
1272
+ interface ExportPdfOptions {
1273
+ /** Default color for text highlights. Default: "rgba(255, 226, 143, 0.5)" */
1274
+ textHighlightColor?: string;
1275
+ /** Default color for area highlights. Default: "rgba(255, 226, 143, 0.5)" */
1276
+ areaHighlightColor?: string;
1277
+ /** Default text color for freetext. Default: "#333333" */
1278
+ defaultFreetextColor?: string;
1279
+ /** Default background for freetext. Default: "#ffffc8" */
1280
+ defaultFreetextBgColor?: string;
1281
+ /** Default font size for freetext. Default: 14 */
1282
+ defaultFreetextFontSize?: number;
1283
+ /** Progress callback for large PDFs */
1284
+ onProgress?: (current: number, total: number) => void;
1285
+ }
1286
+ /**
1287
+ * A highlight that can be exported to PDF.
1288
+ *
1289
+ * @category Type
1290
+ */
1291
+ interface ExportableHighlight {
1292
+ id: string;
1293
+ type?: "text" | "area" | "freetext" | "image" | "drawing" | "shape";
1294
+ content?: {
1295
+ text?: string;
1296
+ image?: string;
1297
+ shape?: ShapeData;
1298
+ };
1299
+ position: ScaledPosition;
1300
+ /** Per-highlight color override (for text/area highlights) */
1301
+ highlightColor?: string;
1302
+ /** Style mode for text highlights: "highlight" (default), "underline", or "strikethrough" */
1303
+ highlightStyle?: "highlight" | "underline" | "strikethrough";
1304
+ /** Text color for freetext highlights */
1305
+ color?: string;
1306
+ /** Background color for freetext highlights */
1307
+ backgroundColor?: string;
1308
+ /** Font size for freetext highlights */
1309
+ fontSize?: string;
1310
+ /** Font family for freetext highlights (not used in export, Helvetica is always used) */
1311
+ fontFamily?: string;
1312
+ /** Shape type for shape highlights */
1313
+ shapeType?: "rectangle" | "circle" | "arrow";
1314
+ /** Stroke color for shape highlights */
1315
+ strokeColor?: string;
1316
+ /** Stroke width for shape highlights */
1317
+ strokeWidth?: number;
1318
+ }
1319
+ /**
1320
+ * Export a PDF with annotations embedded.
1321
+ *
1322
+ * @param pdfSource - The source PDF as a URL string, Uint8Array, or ArrayBuffer
1323
+ * @param highlights - Array of highlights to embed in the PDF
1324
+ * @param options - Export options for customizing colors and behavior
1325
+ * @returns Promise<Uint8Array> - The modified PDF as bytes
1326
+ *
1327
+ * @example
1328
+ * ```typescript
1329
+ * const pdfBytes = await exportPdf(pdfUrl, highlights, {
1330
+ * textHighlightColor: "rgba(255, 255, 0, 0.4)",
1331
+ * onProgress: (current, total) => console.log(`${current}/${total} pages`)
1332
+ * });
1333
+ *
1334
+ * // Download the file
1335
+ * const blob = new Blob([pdfBytes], { type: "application/pdf" });
1336
+ * const url = URL.createObjectURL(blob);
1337
+ * const a = document.createElement("a");
1338
+ * a.href = url;
1339
+ * a.download = "annotated.pdf";
1340
+ * a.click();
1341
+ * URL.revokeObjectURL(url);
1342
+ * ```
1343
+ *
1344
+ * @category Function
1345
+ */
1346
+ declare function exportPdf(pdfSource: string | Uint8Array | ArrayBuffer, highlights: ExportableHighlight[], options?: ExportPdfOptions): Promise<Uint8Array>;
1347
+
1348
+ export { AreaHighlight, type AreaHighlightProps, type AreaHighlightStyle, type Content, DrawingCanvas, type DrawingCanvasProps, DrawingHighlight, type DrawingHighlightProps, type DrawingPoint, type DrawingStroke, type ExportPdfOptions, type ExportableHighlight, FreetextHighlight, type FreetextHighlightProps, type FreetextStyle, type GhostHighlight, type Highlight, type HighlightBindings, type HighlightContainerUtils, type HighlightType, ImageHighlight, type ImageHighlightProps, type LTWH, type LTWHP, MonitoredHighlightContainer, type MonitoredHighlightContainerProps, type Page, PdfHighlighter, type PdfHighlighterProps, type PdfHighlighterUtils, PdfLoader, type PdfLoaderProps, type PdfScaleValue, type PdfSelection, type Scaled, type ScaledPosition, ShapeCanvas, type ShapeCanvasProps, type ShapeData, ShapeHighlight, type ShapeHighlightProps, type ShapeStyle, type ShapeType, SignaturePad, type SignaturePadProps, TextHighlight, type TextHighlightProps, type TextHighlightStyle, type Tip, type ViewportHighlight, type ViewportPosition, exportPdf, scaledPositionToViewport, useHighlightContainerContext, usePdfHighlighterContext, viewportPositionToScaled };