pdf-search-highlight 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -18,6 +18,7 @@ npm install pdf-search-highlight pdfjs-dist
18
18
  - **Multi-context search** — search multiple queries simultaneously, each highlighted with a different color
19
19
  - Cross-span highlight using `<mark>` elements
20
20
  - Navigate between matches (next/prev, auto-scroll)
21
+ - Toggle auto-scroll on/off — disable scrolling to active match when needed
21
22
  - Zoom in/out with configurable scale
22
23
  - Download loaded PDF files
23
24
  - Case sensitive toggle
@@ -25,6 +26,17 @@ npm install pdf-search-highlight pdfjs-dist
25
26
  - Separate UI and PDF rendering — put search bar anywhere
26
27
  - Search highlights preserved across zoom changes
27
28
 
29
+ ## Setup pdfjs-dist
30
+
31
+ This library requires `pdfjs-dist` as a peer dependency. You need to configure the worker before using it:
32
+
33
+ ```js
34
+ import * as pdfjsLib from "pdfjs-dist";
35
+
36
+ // Use the standard build worker (not legacy)
37
+ pdfjsLib.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjsLib.version}/pdf.worker.min.js`;
38
+ ```
39
+
28
40
  ## Usage
29
41
 
30
42
  ### Vanilla JS
@@ -84,6 +96,7 @@ import 'pdf-search-highlight/styles.css';
84
96
  const viewer = new PDFSearchViewer(container, pdfjsLib, {
85
97
  scale: 'auto', // or a number like 1.5
86
98
  pageGap: 20,
99
+ autoScroll: true, // set false to disable scroll-to-match
87
100
  });
88
101
 
89
102
  await viewer.loadPDF(file);
@@ -236,11 +249,15 @@ renderer.cleanup(); // Release resources
236
249
 
237
250
  ```js
238
251
  const search = new SearchController({
239
- classNames: { highlight: 'my-hl', activeHighlight: 'my-active' }
252
+ classNames: { highlight: 'my-hl', activeHighlight: 'my-active' },
253
+ autoScroll: true, // set false to disable scroll-to-match
240
254
  });
241
255
 
242
256
  search.setPages(pages);
243
257
 
258
+ // Toggle auto-scroll at runtime
259
+ search.autoScroll = false;
260
+
244
261
  // Single search
245
262
  search.search('query', { caseSensitive: false, flexibleWhitespace: true });
246
263
  search.search('query', { fuzzy: true, fuzzyThreshold: 0.6 });
@@ -310,6 +327,7 @@ interface PDFSearchViewerOptions {
310
327
  scale?: number | 'auto'; // Default: 'auto' (fit container width)
311
328
  workerSrc?: string; // Path to pdf.js worker
312
329
  pageGap?: number; // Gap between pages in px (default: 20)
330
+ autoScroll?: boolean; // Auto-scroll to active match (default: true)
313
331
  classNames?: ClassNames; // Custom CSS class names
314
332
  }
315
333
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-search-highlight",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Drop-in PDF viewer with text search and highlight. Vanilla JS core + React wrapper.",
5
5
  "type": "module",
6
6
  "main": "./dist/core/index.cjs",