You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The find re-port (d581e01/ddd852ee) wired the PdfViewerDemo "Find" button to
the imperative $expose handle (`$refs.viewer.find($data.query)`). On Angular a
child-component `ref` inside a @click listener compiles to a template-local
`ɵɵreference` that is out of scope in the listener closure, so clicking Find
threw `TypeError: viewer_r2 is not a function` and find-readout stayed 0 — the
exact non-uniformity the demo header already documented for page-nav (which is
why `page` is driven by a two-way model, not the handle). PdfViewerDemo was the
only demo driving a child handle from @click.
Fix: add a controlled, reactive `query` prop to PdfViewer (the search analog of
the `page` model). A lazy $watch runs find()/clearFind() on a consumer write, so
find works uniformly across all six targets with no handle call. The demo's Find
button now copies the input into `:query`; the imperative find/findNext/… verbs
remain in $expose (structural + docs coverage).
- PdfViewer.rozie: +query prop, +lazy $watch(query) → find/clearFind
- PdfViewerDemo.rozie: Find/Clear drive :query, drop unused ref + Next-match handle button
- regenerate 6 leaves + READMEs + docs props-table (11 props); surface gate 10→11 props
- verified: pdf.spec.ts 6/6 green (angular + lit + react …), pdf-* leaf typecheck 10/10
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lxeam8c3XSttraCZPxufKM
|`renderAllPages`|`Boolean`|`false`|| ✓ |`false` = single page with nav (the two-way `page` drives it). `true` = continuous scroll of every page; the most-visible page reflects back into `page` and the `pagechange` event via an `IntersectionObserver`. |
182
182
|`textLayer`|`Boolean`|`true`|| ✓ | Render PDF.js's selectable / copyable text-layer spans over each page canvas (the differentiator vs a dumb canvas image). The required `.textLayer` CSS + `--scale-factor` var ship with the component — no extra import. |
183
183
|`password`|`unknown`|`undefined`|| ✓ | Password for an encrypted PDF. If the document is encrypted and no (or a wrong) password is set, the `passwordrequest` event fires with `{ reason }`. Changing it reloads the document. |
184
+
|`query`|`unknown`|`undefined`|| ✓ | A reactive search query — the **controlled** alternative to the imperative `find()` handle. Setting it to a non-empty string scans every page, navigates to + coarse-highlights the first match, and emits `findresult` with the total occurrence count; clearing it (empty string / `null`) clears the highlight. Reactive so it works uniformly across all six targets (an Angular child-component `ref` cannot reach the `$expose` handle from a template event handler — the same reason `page` is a two-way model rather than a handle call). |
184
185
|`options`|`Object`|`{}`|| ✓ | Raw [`getDocument``DocumentInitParameters`](https://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib.html) passthrough — spread **before** the curated keys (explicit `src` / `password` win). For `cMapUrl`, `httpHeaders`, `withCredentials`, etc. |
Copy file name to clipboardExpand all lines: packages/ui/pdf/packages/angular/src/PdfViewer.ts
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,10 @@ export class PdfViewer {
109
109
* Password for an encrypted PDF. If the document is encrypted and no (or a wrong) password is set, the `passwordrequest` event fires with `{ reason }`. Changing it reloads the document.
110
110
*/
111
111
password=input<unknown>(undefined);
112
+
/**
113
+
* A reactive search query — the **controlled** alternative to the imperative `find()` handle. Setting it to a non-empty string scans every page, navigates to + coarse-highlights the first match, and emits `findresult` with the total occurrence count; clearing it (empty string / `null`) clears the highlight. Reactive so it works uniformly across all six targets (an Angular child-component `ref` cannot reach the `$expose` handle from a template event handler — the same reason `page` is a two-way model rather than a handle call).
114
+
*/
115
+
query=input<unknown>(undefined);
112
116
/**
113
117
* Raw `getDocument` `DocumentInitParameters` passthrough — spread **before** the curated keys (explicit `src` / `password` win). For `cMapUrl`, `httpHeaders`, `withCredentials`, etc.
* Password for an encrypted PDF. If the document is encrypted and no (or a wrong) password is set, the `passwordrequest` event fires with `{ reason }`. Changing it reloads the document.
* A reactive search query — the **controlled** alternative to the imperative `find()` handle. Setting it to a non-empty string scans every page, navigates to + coarse-highlights the first match, and emits `findresult` with the total occurrence count; clearing it (empty string / `null`) clears the highlight. Reactive so it works uniformly across all six targets (an Angular child-component `ref` cannot reach the `$expose` handle from a template event handler — the same reason `page` is a two-way model rather than a handle call).
* Password for an encrypted PDF. If the document is encrypted and no (or a wrong) password is set, the `passwordrequest` event fires with `{ reason }`. Changing it reloads the document.
44
44
*/
45
45
password?: unknown;
46
+
/**
47
+
* A reactive search query — the **controlled** alternative to the imperative `find()` handle. Setting it to a non-empty string scans every page, navigates to + coarse-highlights the first match, and emits `findresult` with the total occurrence count; clearing it (empty string / `null`) clears the highlight. Reactive so it works uniformly across all six targets (an Angular child-component `ref` cannot reach the `$expose` handle from a template event handler — the same reason `page` is a two-way model rather than a handle call).
48
+
*/
49
+
query?: unknown;
46
50
/**
47
51
* Raw `getDocument` `DocumentInitParameters` passthrough — spread **before** the curated keys (explicit `src` / `password` win). For `cMapUrl`, `httpHeaders`, `withCredentials`, etc.
Copy file name to clipboardExpand all lines: packages/ui/pdf/packages/react/src/PdfViewer.tsx
+16-3Lines changed: 16 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,10 @@ interface PdfViewerProps {
44
44
* Password for an encrypted PDF. If the document is encrypted and no (or a wrong) password is set, the `passwordrequest` event fires with `{ reason }`. Changing it reloads the document.
45
45
*/
46
46
password?: unknown;
47
+
/**
48
+
* A reactive search query — the **controlled** alternative to the imperative `find()` handle. Setting it to a non-empty string scans every page, navigates to + coarse-highlights the first match, and emits `findresult` with the total occurrence count; clearing it (empty string / `null`) clears the highlight. Reactive so it works uniformly across all six targets (an Angular child-component `ref` cannot reach the `$expose` handle from a template event handler — the same reason `page` is a two-way model rather than a handle call).
49
+
*/
50
+
query?: unknown;
47
51
/**
48
52
* Raw `getDocument` `DocumentInitParameters` passthrough — spread **before** the curated keys (explicit `src` / `password` win). For `cMapUrl`, `httpHeaders`, `withCredentials`, etc.
0 commit comments