@embedpdf/plugin-search 3.0.0 → 3.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.
- package/README.md +70 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!-- Generated from docs/content/headless/text/search.mdx by docs/content/scripts/readmes.mjs. Edit there, then run `pnpm readme:sync`. -->
|
|
2
|
+
|
|
3
|
+
# @embedpdf/plugin-search
|
|
4
|
+
|
|
5
|
+
Text search for EmbedPDF: finds text across a document and shows every match.
|
|
6
|
+
|
|
7
|
+
This plugin comes with each EmbedPDF framework package. Import it from the one you use:
|
|
8
|
+
|
|
9
|
+
| Framework | Import from | Docs |
|
|
10
|
+
| :-------- | :---------- | :--- |
|
|
11
|
+
| React | `@embedpdf/react/search` | [Search](https://www.embedpdf.com/docs/headless/react/text/search) |
|
|
12
|
+
| Vue | `@embedpdf/vue/search` | [Search](https://www.embedpdf.com/docs/headless/vue/text/search) |
|
|
13
|
+
| Svelte | `@embedpdf/svelte/search` | [Search](https://www.embedpdf.com/docs/headless/svelte/text/search) |
|
|
14
|
+
| Angular | `@embedpdf/angular/search` | [Search](https://www.embedpdf.com/docs/headless/angular/text/search) |
|
|
15
|
+
|
|
16
|
+
## In React
|
|
17
|
+
|
|
18
|
+
The search plugin finds text in the whole document and highlights every match. Register
|
|
19
|
+
`searchPlugin()`, put `<SearchLayer>` in each page, and search from your own search box:
|
|
20
|
+
|
|
21
|
+
**`search-box.tsx`**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { RenderLayer } from '@embedpdf/react/render';
|
|
25
|
+
import { SearchLayer, useSearch, useSearchState } from '@embedpdf/react/search';
|
|
26
|
+
import { Stage } from '@embedpdf/react/stage';
|
|
27
|
+
|
|
28
|
+
export function SearchBox() {
|
|
29
|
+
const search = useSearch();
|
|
30
|
+
const { hitCount, activeHitIndex, status } = useSearchState();
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<form onSubmit={(event) => event.preventDefault()}>
|
|
34
|
+
<input onChange={(event) => search.search({ text: event.target.value })} />
|
|
35
|
+
{status === 'searching' && <span>Searching…</span>}
|
|
36
|
+
{hitCount > 0 && (
|
|
37
|
+
<span>
|
|
38
|
+
{activeHitIndex + 1} of {hitCount}
|
|
39
|
+
</span>
|
|
40
|
+
)}
|
|
41
|
+
<button type="button" onClick={() => search.previousHit()}>↑</button>
|
|
42
|
+
<button type="button" onClick={() => search.nextHit()}>↓</button>
|
|
43
|
+
</form>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function Pages() {
|
|
48
|
+
return (
|
|
49
|
+
<Stage>
|
|
50
|
+
{() => (
|
|
51
|
+
<>
|
|
52
|
+
<RenderLayer />
|
|
53
|
+
<SearchLayer />
|
|
54
|
+
</>
|
|
55
|
+
)}
|
|
56
|
+
</Stage>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- **Matches appear as they're found.** Large documents are searched a few pages at a time, and the
|
|
62
|
+
count and the highlights grow as the search goes.
|
|
63
|
+
- **Searching again replaces the search.** Type another letter and the old search stops; an empty
|
|
64
|
+
`text` clears it.
|
|
65
|
+
- **The first match becomes the active one** without moving the view. `nextHit()`, `previousHit()`
|
|
66
|
+
and `goToHit(hit)` move to a match and bring it into view, and wrap around at the ends.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-search",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Text search for EmbedPDF: finds text across a document and shows every match.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@embedpdf/core": "3.
|
|
26
|
-
"@embedpdf/core-geometry": "3.
|
|
27
|
-
"@embedpdf/
|
|
28
|
-
"@embedpdf/
|
|
25
|
+
"@embedpdf/core": "3.2.0",
|
|
26
|
+
"@embedpdf/core-geometry": "3.2.0",
|
|
27
|
+
"@embedpdf/plugin-stage": "3.2.0",
|
|
28
|
+
"@embedpdf/engine-core": "3.2.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.0.0",
|