teamsync-pdf-viewer 1.8.1 → 2.2.1
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/CHANGELOG.md +94 -0
- package/README.md +91 -23
- package/dist/src/annotations/ids.d.ts +1 -0
- package/dist/src/components/DocumentViewer.d.ts +19 -1
- package/dist/src/components/FormFieldEditorModal.d.ts +11 -0
- package/dist/src/components/FormFieldLayer.d.ts +19 -0
- package/dist/src/components/FormFillerActions.d.ts +8 -0
- package/dist/src/components/FormSignatureModal.d.ts +15 -0
- package/dist/src/components/FormUsersModal.d.ts +11 -0
- package/dist/src/components/FormsToolbar.d.ts +15 -0
- package/dist/src/components/PageRenderer.d.ts +9 -1
- package/dist/src/components/SignatureIndexFlags.d.ts +9 -0
- package/dist/src/core/ViewerInstance.d.ts +102 -11
- package/dist/src/core/export.d.ts +3 -0
- package/dist/src/core/types.d.ts +68 -2
- package/dist/src/forms/FormManager.d.ts +105 -0
- package/dist/src/forms/types.d.ts +179 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/office/useOfficeDocument.d.ts +0 -4
- package/dist/src/utils/linkUtils.d.ts +6 -0
- package/dist/teamsync-pdf-viewer.js +8535 -2917
- package/dist/teamsync-pdf-viewer.js.map +1 -1
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,100 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `teamsync-pdf-viewer` are documented here.
|
|
4
4
|
|
|
5
|
+
## [2.2.1] — 2026-11-03
|
|
6
|
+
|
|
7
|
+
### Security
|
|
8
|
+
- **Cryptographically Secure Identifier Generation**: Replaced pseudo-random number generator routines with cryptographically secure random values (`crypto.randomUUID()` and `crypto.getRandomValues()`) across fallback blob URLs, manual redactions, and form roles, resolving CodeQL alert CWE-338.
|
|
9
|
+
- **Vulnerability Patches & Dependency Updates**:
|
|
10
|
+
- Upgraded `vite` to `^8.3.5` resolving launch-editor command execution and filesystem bypass advisories.
|
|
11
|
+
- Upgraded `vitest` to `^5.0.5` (resolving to `5.1.0`) fixing `@vitest/mocker` code injection and path traversal advisories.
|
|
12
|
+
- Upgraded `vite-plugin-dts` to `^5.1.2` resolving `minimatch` glob amplification denial-of-service advisory.
|
|
13
|
+
- Upgraded `undici` to `^8.12.3` resolving cache poisoning, TLS options dropping, and DoS advisories.
|
|
14
|
+
- Upgraded `fast-uri` to `^3.1.9` and `source-map-js` to `^1.2.2`.
|
|
15
|
+
- Achieved clean `npm audit` with 0 reported vulnerabilities.
|
|
16
|
+
|
|
17
|
+
## [2.2.0] — 2026-10-20
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- **Network Authentication Headers**: Added `httpHeaders` and `customHeaders` options to `WebViewerOptions` and `loadDocument(url, options)` allowing authenticated document requests with session tokens and custom HTTP headers.
|
|
21
|
+
- **Progressive Streaming Controls**: Added `rangeChunkSize`, `disableStream`, `disableAutoFetch`, and `disableRange` options to control document downloading behavior and prevent background bandwidth consumption.
|
|
22
|
+
- **Cross-Environment Compatibility**: Enhanced `createBlobUrl` fallback for environments lacking native `URL.createObjectURL(blob)` support (e.g. Node 22 / jsdom).
|
|
23
|
+
|
|
24
|
+
## [2.0.0] — 2026-09-26
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **Multi-Role Form Templates & Host Application User Context**:
|
|
28
|
+
- **Decoupled Form Roles from User Identity**: Form templates assign fields to abstract roles (`FormRole`) such as `applicant`, `tenant`, `landlord`, or `reviewer`.
|
|
29
|
+
- **Host Application Current User Integration**: Applications pass the logged-in user profile (`ViewerUser`) containing `id`, `name`, `email`, and `role`. Setting a user automatically activates their role in the form session without hardcoding user IDs into templates.
|
|
30
|
+
- **Audit-Grade Signature Capture**: Electronic and digital signatures adopted in the viewer automatically bind the active signer's name, email, role, and cryptographic SHA-256 seal.
|
|
31
|
+
- **Signature Sticky / Index Flags**:
|
|
32
|
+
- **Side-Docked Visual Flags**: Sticky index flags positioned along the right edge of the viewport indicate pending signatures assigned to the current user's role.
|
|
33
|
+
- **Cross-Page Accessibility**: Flags are visible even when viewing page 1 while signature fields reside on page 2 or later, giving users immediate visibility into required actions.
|
|
34
|
+
- **1-Click Jump & Sign**: Clicking a sticky flag smoothly scrolls the document directly to the target signature field and activates signature capture.
|
|
35
|
+
- **Filtered by Active Role**: Only flags relevant to the current user's role are displayed, preventing clutter and cross-user confusion.
|
|
36
|
+
- **Form SDK & Programmatic Feature Control**:
|
|
37
|
+
- **SDK Methods on `WebViewerInstance`**:
|
|
38
|
+
- `getFormRoles()`, `setFormRoles()`, `addFormRole()`, `updateFormRole()`, `removeFormRole()`
|
|
39
|
+
- `getCurrentRole()`, `setCurrentRole()`
|
|
40
|
+
- `getCurrentUser()`, `setCurrentUser()`
|
|
41
|
+
- `getFormFields()`, `setFormFields()`, `getFormData()`, `setFormData()`, `clearFormData()`
|
|
42
|
+
- `validateForm(roleId?)`, `nextFormField(roleId?)`, `previousFormField(roleId?)`
|
|
43
|
+
- `getFormOptions()`, `setFormOptions()`
|
|
44
|
+
- **Granular Feature Visibility Controls (`FormFeatureOptions`)**:
|
|
45
|
+
- `allowRoleSwitching`: Lock users to their assigned role or allow role switching in filler mode.
|
|
46
|
+
- `showRoleSelector`: Toggle visibility of the role selector dropdown in the toolbar.
|
|
47
|
+
- `otherRoleFieldsMode`: Configure how fields assigned to other roles are rendered (`'interactive'`, `'view-only'`, or `'hidden'`).
|
|
48
|
+
- `showSignatureFlags`: Toggle sticky index flags on or off.
|
|
49
|
+
- `showFlowNavigation`, `showValidation`, `showReset`, `showExport`, `hideToolbar`: Fine-grained visibility toggles for the filler toolbar.
|
|
50
|
+
|
|
51
|
+
### Breaking Changes
|
|
52
|
+
- **Standardized on Roles**: Removed legacy assignee terminology and aliases (`FormAssignee`, `assigneeId`, `setUser`, `setAssignees`, `actualUser`, etc.) across all models, types, and components in favor of `FormRole`, `FormField.roleId`, and `currentUser`.
|
|
53
|
+
|
|
54
|
+
## [1.9.0] — 2026-09-25
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
- **Interactive PDF Forms Builder ("Forms" Tab)**:
|
|
58
|
+
- Added a dedicated 3rd navigation tab ("Forms") alongside "View" and "Annotate" for designing interactive forms directly over loaded PDF documents.
|
|
59
|
+
- **Comprehensive Form Field Controls**:
|
|
60
|
+
- **Textbox**: Single-line text input for short answers, names, codes, emails.
|
|
61
|
+
- **Text Area**: Multi-line expandable text area for comments, descriptions, notes.
|
|
62
|
+
- **Date and Time Picker**: Calendar and clock selector supporting `date`, `time`, or `datetime` format modes.
|
|
63
|
+
- **Check List**: Multi-item checklist allowing authors to configure selectable items and respondents to check/uncheck choices independently (plus single-checkbox mode).
|
|
64
|
+
- **Dropdown**: Single-select dropdown list with customizable choices.
|
|
65
|
+
- **Radio Group**: Mutually exclusive single-choice options.
|
|
66
|
+
- **Visual Form Field Canvas Layer**:
|
|
67
|
+
- Drag-to-create bounding box with live visual preview.
|
|
68
|
+
- Click-to-select with 8 interactive resize handles (`nw`, `n`, `ne`, `e`, `se`, `s`, `sw`, `w`) and drag-to-move repositioning.
|
|
69
|
+
- Floating field action bar with quick properties edit, duplicate, and delete actions.
|
|
70
|
+
- Keyboard delete support (`Delete` / `Backspace`).
|
|
71
|
+
- **Field Properties Editor**:
|
|
72
|
+
- Modal dialog to configure field key name, display label, placeholder text, mandatory/required toggle (`*`), date format, default value, and item options management (add, edit, remove, reorder).
|
|
73
|
+
- **Forms Toolbar**:
|
|
74
|
+
- Undo and Redo buttons for form layout modifications.
|
|
75
|
+
- One-click tool selection for Textbox, Text Area, Date & Time, Check List, Dropdown, and Radio Group.
|
|
76
|
+
- Form schema management: Export Schema (JSON), Import Schema (JSON), Clear All Fields, and quick toggle to test in View mode.
|
|
77
|
+
|
|
78
|
+
- **Interactive Form Filler (View Tab)**:
|
|
79
|
+
- Form fields render directly on top of the PDF pages at their exact unscaled PDF coordinates, zooming and rotating with the canvas.
|
|
80
|
+
- Live interactive HTML inputs embedded directly over pages for single-line text, multi-line textareas, date-time pickers, checklist checkboxes, dropdowns, and radio groups.
|
|
81
|
+
- Real-time two-way data binding to central `FormManager` state.
|
|
82
|
+
- **Form Filler Actions Bar**: Utility header displayed in View mode showing completion progress, required field count, form validation with feedback, JSON data export, and form reset.
|
|
83
|
+
|
|
84
|
+
- **Role & Permissions Architecture**:
|
|
85
|
+
- Added `canCreateForms?: boolean` (default: `true`) to `SDKPermissions` controlling access to the Forms builder tab. When set to `false`, the Forms tab is omitted and users are restricted to View/Annotate.
|
|
86
|
+
- Added `canFillForms?: boolean` (default: `true`) to `SDKPermissions` controlling whether fields in View mode can be edited or remain read-only.
|
|
87
|
+
- Automatic normalization to View tab if a restricted user attempts to switch to Forms tab.
|
|
88
|
+
|
|
89
|
+
- **Native PDF AcroForm Baking & Export**:
|
|
90
|
+
- Integrated with `pdf-lib` to bake interactive form fields into native PDF AcroForms upon export (`createTextField`, `createCheckBox`, `createDropdown`, multiline text areas, and checklist items) preserving user-filled values.
|
|
91
|
+
- Exported public SDK methods on `WebViewerInstance`: `getFormFields()`, `setFormFields()`, `getFormData()`, `setFormData()`, `clearFormData()`, `validateForm()`, and `exportFormData()`.
|
|
92
|
+
- Exported `FormManager` and all related form types from the top-level package.
|
|
93
|
+
|
|
94
|
+
### Security
|
|
95
|
+
- **SSRF Prevention & Edge Converter Hardening**: Added strict content-type validation and upstream error sanitization to the edge conversion function.
|
|
96
|
+
- **Protocol Sanitization for PDF Links**: Enforced URI sanitization rejecting `javascript:`, `vbscript:`, and `data:` schemes.
|
|
97
|
+
- **Diff Engine Memory Bounds**: Added bounded edit distance to Myers diff to prevent memory exhaustion on divergent pages.
|
|
98
|
+
|
|
5
99
|
## [1.8.1] — 2026-09-19
|
|
6
100
|
|
|
7
101
|
### Added
|
package/README.md
CHANGED
|
@@ -4,30 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Advanced Web PDF Viewer, Annotation and PDF Forms with PDF Enterprise SDK.
|
|
8
8
|
|
|
9
|
-
[](LICENSE)
|
|
10
9
|
[](https://pdfviewer.teamsync.com/)
|
|
11
10
|
[](https://www.npmjs.com/package/teamsync-pdf-viewer)
|
|
12
11
|
[](https://reactjs.org/)
|
|
13
12
|
[](https://vitejs.dev/)
|
|
14
13
|
[](https://www.typescriptlang.org/)
|
|
15
14
|
|
|
16
|
-
*No paywalls. No vendor lock-in. No server dependencies.*
|
|
17
15
|
Try the **[Interactive Live Demo](https://pdfviewer.teamsync.com/)** or integrate the high-performance PDF Viewer SDK directly into your React applications.
|
|
18
16
|
|
|
19
17
|
</div>
|
|
20
18
|
|
|
21
19
|
---
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
**TeamSync PDF Viewer** allows developers to embed advanced viewing, annotation, and forms capabilities directly into any web application.
|
|
22
|
+
|
|
23
|
+
⚡ **Universal Document Viewing**: It accurately renders PDFs, Microsoft Office files (Word, Excel, PowerPoint), CAD drawings, and images directly in the browser. It handles massive, complex files smoothly with vector-based zooming and lightning-fast rendering.
|
|
24
|
+
|
|
25
|
+
• **True Client-Side Processing**: Because it processes everything locally using the browser's resources, sensitive files never leave the user's device. This makes it ideal for highly secure environments (like finance, healthcare, or legal apps) and significantly reduces server infrastructure costs.
|
|
26
|
+
|
|
27
|
+
• **Rich Annotation & Collaboration**: It provides built-in UI tools for highlighting text, adding sticky notes, drawing shapes, stamping, and text callouts. It supports real-time collaboration so multiple users can comment and mark up the same document simultaneously.
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
• **Interactive Forms & Digital Signatures**: Users can fill out existing PDF forms, build new forms from scratch, and apply secure e-signatures or digital signatures.
|
|
30
|
+
|
|
31
|
+
• **Advanced Text Editing & Redaction**: It allows users to edit underlying text directly within a PDF as if they were in a word processor. It also features programmatic and manual redaction, permanently wiping sensitive data from the document's code.
|
|
26
32
|
|
|
27
|
-
- 💰 **Zero-Cost, Transparent Licensing**: Uncapped usage, no per-server fees, and no commercial paywalls. 100% free and open-source under CPAL 1.0.
|
|
28
|
-
- ⚡ **100% Client-Side PDF Processing**: Documents never leave the browser sandbox. Process, redact, and render PDFs entirely on the client.
|
|
29
|
-
- 🔌 **Universal WebViewer API**: Clean, intuitive `WebViewer({...})` API interface that makes integrating into your web applications effortless.
|
|
30
|
-
- 🎨 **Headless & Customizable**: Built for modern React 19 SPA lifecycles. No bloated iFrames to fight—customize toolbars, sidebars, context menus, and controls natively.
|
|
31
33
|
|
|
32
34
|
---
|
|
33
35
|
|
|
@@ -65,14 +67,14 @@ If installing from GitHub Packages registry:
|
|
|
65
67
|
|
|
66
68
|
Explore detailed SDK guides, parameter options, code snippets, and architecture deep dives:
|
|
67
69
|
|
|
68
|
-
- 🏠 **[Wiki Home](
|
|
69
|
-
- 🚀 **[Getting Started Guide](
|
|
70
|
-
- ⚙️ **[API Reference & Options](
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
- 🔌 **[Plugin Architecture Guide](
|
|
70
|
+
- 🏠 **[Wiki Home](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Home)**: Main documentation index & overview.
|
|
71
|
+
- 🚀 **[Getting Started Guide](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Getting-Started)**: Installation, CDN, and framework setups.
|
|
72
|
+
- ⚙️ **[API Reference & Options](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/API-Reference-&-Options)**: Complete parameter list for `WebViewerOptions` & `SDKPermissions`.
|
|
73
|
+
- 📝 **[Interactive Forms & Multi-Role Signatures](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Interactive-Forms-&-Multi-Role-Signatures)**: PDF form designer, multi-role template assignment, signature sticky index flags & SDK.
|
|
74
|
+
- 🎨 **[Annotations & Markup Guide](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Annotations-&-Markup-Guide)**: Freehand drawing, vector shapes, callouts & links.
|
|
75
|
+
- 🛡️ **[Redactions & PII Sanitization Guide](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Redactions-&-PII-Sanitization)**: Binary redactions, regex PII scanning & discard options.
|
|
76
|
+
- 💧 **[Forensic Watermarking Guide](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Forensic-Watermarking)**: Dynamic single and tiled watermark setup.
|
|
77
|
+
- 🔌 **[Plugin Architecture Guide](https://github.com/angelbot-ai/TeamSync-PDF-Viewer/wiki/Plugin-Architecture)**: Writing custom extension plugins.
|
|
76
78
|
|
|
77
79
|
---
|
|
78
80
|
|
|
@@ -80,12 +82,30 @@ Explore detailed SDK guides, parameter options, code snippets, and architecture
|
|
|
80
82
|
|
|
81
83
|
Everything you need to build collaborative, secure document workflows.
|
|
82
84
|
|
|
85
|
+
### 📝 Interactive PDF Forms & Multi-Role Signatures (v2.0 & v2.1)
|
|
86
|
+
- **Visual Forms Designer ("Forms" Tab)**: Dedicated builder tab to design interactive forms with drag-to-create bounding boxes, 8 interactive resize handles, drag-to-move, and keyboard shortcuts.
|
|
87
|
+
- **Comprehensive Form Field Controls**: Textbox, Text Area, Date & Time Picker (calendar/clock modes), Multi-Choice Checklist, Single-Select Dropdown, and Radio Groups.
|
|
88
|
+
- **Multi-Role Form Templates**: Decoupled template roles (`FormRole`) such as `applicant`, `tenant`, `landlord`, or `reviewer`. Design reusable form templates without hardcoding user IDs.
|
|
89
|
+
- **Host Application User Integration**: Pass the logged-in user profile (`ViewerUser`) containing `id`, `name`, `email`, and `role`. Setting the user automatically activates their role in the form session.
|
|
90
|
+
- **Signature Sticky / Index Flags & Cross-Page Navigation**: Visual sticky index flags docked along the viewport edge indicate pending signatures for the current user's role. Clicking a flag navigates across pages, smoothly scrolls the field into view (`scrollIntoView`), and triggers a glowing pulse highlight.
|
|
91
|
+
- **Audit-Grade Signatures**: Electronic signatures (canvas drawing, typed handwriting, image upload) and digital certificate signatures (cryptographic SHA-256 seal) automatically recording signer name, email, role, and timestamp.
|
|
92
|
+
- **Interactive Form Filler ("View" Tab)**: Embedded live inputs positioned over PDF pages at exact coordinates, with sequential filling flow, per-page re-render isolation, per-role validation, JSON export, and native PDF AcroForm baking.
|
|
93
|
+
|
|
83
94
|
### 🎨 Smart Markup & Annotations
|
|
84
95
|
- **Full Drawing Toolkit**: Freehand ink (`brush`), highlighters, geometric shapes (rectangles, ellipses), arrows, and lines.
|
|
85
96
|
- **Notes & Callouts**: Sticky notes, callout text boxes with directional arrows, and text annotations.
|
|
86
97
|
- **Interactive Hyperlinks**: Create internal page-jump links (`#page=N`) or external web URL links directly on document selections.
|
|
87
98
|
|
|
88
|
-
###
|
|
99
|
+
### ⚡ Viewport Virtualization & High-DPI Scaling (v2.1)
|
|
100
|
+
- **Continuous Scroll Canvas Virtualization**: Built-in `IntersectionObserver` with an 800px lookahead buffer. Off-screen canvases unmount and release high-DPI GPU backbuffers immediately (`canvas.width = 0; canvas.height = 0`) while preserving exact wrapper layout geometry. Supports 1,000+ page documents without crashing mobile Safari or bloating tab memory.
|
|
101
|
+
- **Isolated Form Re-renders**: Typing keystrokes only re-evaluate fields on the active page, producing 0 re-renders across all other mounted pages in large documents.
|
|
102
|
+
- **Retina 60 FPS Zoom & Pan**: High-DPI `devicePixelRatio` scaling eliminates blurred text. Micro-debounced rendering enables buttery-smooth 60 FPS trackpad pinching and 360° mouse drag panning.
|
|
103
|
+
- **Contextual Document Search**: Instant client-side text search with real-time match highlighting, result jumping, and match counting.
|
|
104
|
+
|
|
105
|
+
### 🛡️ Enterprise Security & Redaction (v2.1)
|
|
106
|
+
- **SVG XSS & Stored Injection Protection**: Typed signatures strictly escape XML entities before rendering SVG templates, and fallback signatures are Base64 encoded.
|
|
107
|
+
- **Strict Image Upload MIME Validation**: Enforces whitelist checks (`image/png`, `image/jpeg`, `image/webp`) to prevent executable SVG/HTML payloads.
|
|
108
|
+
- **In-Memory Data URL Decoding**: AcroForm export decodes Base64 data URLs in-memory without external network `fetch()`, blocking SSRF and network errors.
|
|
89
109
|
- **Binary-Level Data Obliteration**: We don't just place black boxes over text—redactions are permanently rasterized and burned into the underlying PDF vector structure.
|
|
90
110
|
- **Text Layer Sanitization**: Redacted text is automatically stripped from the DOM `textLayer` and PDF content streams, preventing copy/paste extraction and search indexing.
|
|
91
111
|
- **Automatic Regex Redactions**: Programmatically locate and redact sensitive PII in a single click.
|
|
@@ -95,10 +115,6 @@ Everything you need to build collaborative, secure document workflows.
|
|
|
95
115
|
- **Fit to Width & Fit to Page**: Container-aware dynamic scaling calculations for responsive reading on any screen size.
|
|
96
116
|
- **Synchronized Page Rotation**: 360° page rotation with real-time vector coordinate transforms so annotations rotate seamlessly with document content.
|
|
97
117
|
|
|
98
|
-
### 🔍 High-DPI Canvas Rendering & Search
|
|
99
|
-
- **Retina 60 FPS Zoom & Pan**: High-DPI `devicePixelRatio` scaling eliminates blurred text. Micro-debounced rendering enables buttery-smooth 60 FPS trackpad pinching and 360° mouse drag panning.
|
|
100
|
-
- **Contextual Document Search**: Instant client-side text search with real-time match highlighting, result jumping, and match counting.
|
|
101
|
-
|
|
102
118
|
### 💧 Dynamic Forensic Watermarking
|
|
103
119
|
- Programmatic, non-destructive watermarks rendered on the fly (single centered or full-page tiled) with customizable text, color, opacity, font size, and rotation.
|
|
104
120
|
|
|
@@ -165,6 +181,53 @@ function App() {
|
|
|
165
181
|
}
|
|
166
182
|
```
|
|
167
183
|
|
|
184
|
+
### Multi-Role Forms & Electronic Signatures (v2.0)
|
|
185
|
+
|
|
186
|
+
For multi-party form workflows, role assignment, and signature collection:
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { TeamSyncViewer, WebViewerInstance } from 'teamsync-pdf-viewer';
|
|
190
|
+
import 'teamsync-pdf-viewer/style.css';
|
|
191
|
+
|
|
192
|
+
function ContractSigningPortal() {
|
|
193
|
+
const currentUser = {
|
|
194
|
+
id: 'usr_98124',
|
|
195
|
+
name: 'Robert Davis',
|
|
196
|
+
email: 'robert@domain.com',
|
|
197
|
+
role: 'tenant', // Automatically activates 'tenant' role & signature flags
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const formRoles = [
|
|
201
|
+
{ id: 'tenant', name: 'Tenant', color: '#2563eb' },
|
|
202
|
+
{ id: 'landlord', name: 'Landlord', color: '#10b981' },
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div style={{ width: '100vw', height: '100vh' }}>
|
|
207
|
+
<TeamSyncViewer
|
|
208
|
+
initialDoc="/lease-agreement.pdf"
|
|
209
|
+
currentUser={currentUser}
|
|
210
|
+
formRoles={formRoles}
|
|
211
|
+
formOptions={{
|
|
212
|
+
allowRoleSwitching: false, // Locked to respondent's assigned role
|
|
213
|
+
otherRoleFieldsMode: 'view-only', // Read-only for landlord fields
|
|
214
|
+
showSignatureFlags: true, // Display side sticky index flags
|
|
215
|
+
}}
|
|
216
|
+
onViewerReady={(instance: WebViewerInstance) => {
|
|
217
|
+
// Programmatic Form SDK
|
|
218
|
+
console.log('Active Role:', instance.getCurrentRole());
|
|
219
|
+
console.log('Form Fields:', instance.getFormFields());
|
|
220
|
+
|
|
221
|
+
// Validate current role's required fields
|
|
222
|
+
const result = instance.validateForm();
|
|
223
|
+
if (!result.valid) console.warn('Incomplete:', result.errors);
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
168
231
|
---
|
|
169
232
|
|
|
170
233
|
## 🛠️ Local Development Quick Start
|
|
@@ -226,7 +289,10 @@ WebViewer({
|
|
|
226
289
|
```
|
|
227
290
|
TeamSync-PDF-Viewer/
|
|
228
291
|
├── src/
|
|
229
|
-
│ ├── components/ # Native React UI (Header, DocumentViewer,
|
|
292
|
+
│ ├── components/ # Native React UI (Header, DocumentViewer, Forms, Modals)
|
|
293
|
+
│ ├── forms/ # Interactive Forms Engine (FormManager, Roles, AcroForm, Signatures)
|
|
294
|
+
│ ├── office/ # Native Microsoft Office document viewing and conversion
|
|
295
|
+
│ ├── annotations/ # Annotation manager, vector rendering, and XFDF engine
|
|
230
296
|
│ ├── hooks/ # Search & Keyboard shortcut hooks
|
|
231
297
|
│ ├── utils/ # Redaction algorithms, rotation transforms & vector helpers
|
|
232
298
|
│ ├── plugins/ # Plugin API interfaces & registry
|
|
@@ -244,6 +310,8 @@ TeamSync-PDF-Viewer/
|
|
|
244
310
|
Distributed under the **CPAL 1.0 (Common Public Attribution License)**.
|
|
245
311
|
100% Free and Open Source for personal and commercial usage.
|
|
246
312
|
|
|
313
|
+
[](LICENSE)
|
|
314
|
+
|
|
247
315
|
---
|
|
248
316
|
|
|
249
317
|
<div align="center">
|
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
* Stable, collision-free annotation ids. They double as the XFDF `name` attribute, which hosts use
|
|
4
4
|
* to match persisted rows to live annotations, so they must never be timestamps.
|
|
5
5
|
*/
|
|
6
|
+
export declare function generateSecureId(prefix?: string): string;
|
|
6
7
|
export declare function newAnnotationId(): string;
|
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { Annotation } from '../annotations/types';
|
|
3
3
|
import { AnnotationManager } from '../annotations/AnnotationManager';
|
|
4
4
|
import { Redaction, WatermarkOptions, SDKPermissions, PdfAssetPaths, TransientHighlight, InitialScale, LinkClickEvent, WebViewerInstance } from '../core/types';
|
|
5
|
+
import { FormManager } from '../forms/FormManager';
|
|
5
6
|
import * as pdfjsLib from 'pdfjs-dist';
|
|
6
7
|
export interface DocumentLoadErrorInfo {
|
|
7
8
|
url: string;
|
|
@@ -18,6 +19,20 @@ interface DocumentViewerProps {
|
|
|
18
19
|
loadNonce?: number;
|
|
19
20
|
/** Send cookies with the document request. */
|
|
20
21
|
withCredentials?: boolean;
|
|
22
|
+
/** Custom HTTP headers sent with every document request (e.g. Authorization: Bearer <token>). */
|
|
23
|
+
httpHeaders?: Record<string, string>;
|
|
24
|
+
/** Alias for `httpHeaders` providing an alternative headers option. */
|
|
25
|
+
customHeaders?: Record<string, string>;
|
|
26
|
+
/** Maximum number of bytes fetched per HTTP 206 range request. Default is 65536. */
|
|
27
|
+
rangeChunkSize?: number;
|
|
28
|
+
/** Disable chunked streaming of PDF file data. Default false. */
|
|
29
|
+
disableStream?: boolean;
|
|
30
|
+
/** Disable automatic background pre-fetching of remaining PDF file chunks. Default false. */
|
|
31
|
+
disableAutoFetch?: boolean;
|
|
32
|
+
/** Disable HTTP 206 range requests entirely, forcing full PDF download. Default false. */
|
|
33
|
+
disableRange?: boolean;
|
|
34
|
+
/** Password for password-protected PDFs. */
|
|
35
|
+
password?: string;
|
|
21
36
|
/** pdf.js asset locations, applied right before the document is opened. */
|
|
22
37
|
assets?: PdfAssetPaths;
|
|
23
38
|
/** Render the thumbnails (left) and comments/search (right) panels. Default true. */
|
|
@@ -72,6 +87,9 @@ interface DocumentViewerProps {
|
|
|
72
87
|
page?: number;
|
|
73
88
|
} | null> | null;
|
|
74
89
|
onLinkClick?: (event: LinkClickEvent) => boolean | void | Promise<void>;
|
|
90
|
+
formManager?: FormManager;
|
|
91
|
+
setActiveTab?: (tab: string) => void;
|
|
92
|
+
onDownloadFilledPdf?: () => void;
|
|
75
93
|
}
|
|
76
|
-
export default function DocumentViewer({ leftSidebarOpen, rightSidebarOpen, activeTab, annotationManager, initialDoc, loadNonce, withCredentials, assets, sidebars, redactions, regexRedactions, scale, setScale, sidebarTab, setSidebarTab, onAnnotationsChange, onRedactionsChange, onRedactionsApplied, onDocumentLoaded, onLoadError, onFirstPageRendered, onPageRendered, onPageChange, pageTransition, pageLayout, rotation, setRotation, watermark, watermarkText, enableAnnotations: _enableAnnotations, initialPage, page, transientHighlights, permissions, hideAnnotationsUntilPageRendered, enableTextSelection, defaultTool, showSelectionTooltip, initialScale, initialWidthRatio, responsive, instance, targetViewer, resolveLinkUrl, onLinkClick, }: DocumentViewerProps): React.JSX.Element;
|
|
94
|
+
export default function DocumentViewer({ leftSidebarOpen, rightSidebarOpen, activeTab, annotationManager, initialDoc, loadNonce, withCredentials, httpHeaders, customHeaders, rangeChunkSize, disableStream, disableAutoFetch, disableRange, password, assets, sidebars, redactions, regexRedactions, scale, setScale, sidebarTab, setSidebarTab, onAnnotationsChange, onRedactionsChange, onRedactionsApplied, onDocumentLoaded, onLoadError, onFirstPageRendered, onPageRendered, onPageChange, pageTransition, pageLayout, rotation, setRotation, watermark, watermarkText, enableAnnotations: _enableAnnotations, initialPage, page, transientHighlights, permissions, hideAnnotationsUntilPageRendered, enableTextSelection, defaultTool, showSelectionTooltip, initialScale, initialWidthRatio, responsive, instance, targetViewer, resolveLinkUrl, onLinkClick, formManager, setActiveTab, onDownloadFilledPdf, }: DocumentViewerProps): React.JSX.Element;
|
|
77
95
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormField, FormRole } from '../forms/types';
|
|
3
|
+
interface FormFieldEditorModalProps {
|
|
4
|
+
field: FormField;
|
|
5
|
+
roles?: FormRole[];
|
|
6
|
+
onAddRole?: (role: FormRole) => void;
|
|
7
|
+
onSave: (updated: Partial<FormField>) => void;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const FormFieldEditorModal: React.FC<FormFieldEditorModalProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormToolType } from '../forms/types';
|
|
3
|
+
import { FormManager } from '../forms/FormManager';
|
|
4
|
+
interface FormFieldLayerProps {
|
|
5
|
+
pageNum: number;
|
|
6
|
+
scale: number;
|
|
7
|
+
rotation: number;
|
|
8
|
+
basePageWidth: number;
|
|
9
|
+
basePageHeight: number;
|
|
10
|
+
activeTab: string;
|
|
11
|
+
activeTool: FormToolType;
|
|
12
|
+
setActiveTool: (tool: FormToolType) => void;
|
|
13
|
+
formManager: FormManager;
|
|
14
|
+
canFillForms?: boolean;
|
|
15
|
+
showFlowOrder?: boolean;
|
|
16
|
+
selectedRoleFilter?: string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare const FormFieldLayer: React.FC<FormFieldLayerProps>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormManager } from '../forms/FormManager';
|
|
3
|
+
interface FormFillerActionsProps {
|
|
4
|
+
formManager: FormManager;
|
|
5
|
+
onDownloadFilledPdf?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const FormFillerActions: React.FC<FormFillerActionsProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormField, FormSignatureValue, FormRole } from '../forms/types';
|
|
3
|
+
import { ViewerUser } from '../core/types';
|
|
4
|
+
interface FormSignatureModalProps {
|
|
5
|
+
field: FormField;
|
|
6
|
+
role?: FormRole;
|
|
7
|
+
currentUser?: ViewerUser | null;
|
|
8
|
+
currentValue?: FormSignatureValue | any;
|
|
9
|
+
defaultSignerName?: string;
|
|
10
|
+
onSave: (value: FormSignatureValue) => void;
|
|
11
|
+
onClear?: () => void;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const FormSignatureModal: React.FC<FormSignatureModalProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormManager } from '../forms/FormManager';
|
|
3
|
+
import { FormRole } from '../forms/types';
|
|
4
|
+
interface FormUsersModalProps {
|
|
5
|
+
formManager: FormManager;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onRoleAdded?: (role: FormRole) => void;
|
|
8
|
+
onUserAdded?: (role: FormRole) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const FormUsersModal: React.FC<FormUsersModalProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormToolType } from '../forms/types';
|
|
3
|
+
import { FormManager } from '../forms/FormManager';
|
|
4
|
+
interface FormsToolbarProps {
|
|
5
|
+
activeTool: FormToolType;
|
|
6
|
+
setActiveTool: (tool: FormToolType) => void;
|
|
7
|
+
formManager: FormManager;
|
|
8
|
+
onSwitchToView?: () => void;
|
|
9
|
+
showFlowOrder?: boolean;
|
|
10
|
+
setShowFlowOrder?: (show: boolean) => void;
|
|
11
|
+
selectedRoleFilter?: string | null;
|
|
12
|
+
setSelectedRoleFilter?: (id: string | null) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const FormsToolbar: React.FC<FormsToolbarProps>;
|
|
15
|
+
export {};
|
|
@@ -2,6 +2,8 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { SearchResult } from '../hooks/usePdfSearch';
|
|
3
3
|
import { Redaction, WatermarkOptions, TransientHighlight } from '../core/types';
|
|
4
4
|
import { Annotation } from '../annotations/types';
|
|
5
|
+
import { FormManager } from '../forms/FormManager';
|
|
6
|
+
import { FormToolType } from '../forms/types';
|
|
5
7
|
import * as pdfjsLib from 'pdfjs-dist';
|
|
6
8
|
export type { Annotation };
|
|
7
9
|
interface PageRendererProps {
|
|
@@ -41,7 +43,13 @@ interface PageRendererProps {
|
|
|
41
43
|
/** Whether to hide annotations and transient highlights until the page canvas has finished rendering. Default: true. */
|
|
42
44
|
hideAnnotationsUntilPageRendered?: boolean;
|
|
43
45
|
onLinkClick?: (url: string, annotation?: Annotation, e?: React.MouseEvent) => void;
|
|
46
|
+
formManager?: FormManager;
|
|
47
|
+
activeFormTool?: FormToolType;
|
|
48
|
+
setActiveFormTool?: (tool: FormToolType) => void;
|
|
49
|
+
canFillForms?: boolean;
|
|
50
|
+
showFlowOrder?: boolean;
|
|
51
|
+
selectedRoleFilter?: string | null;
|
|
44
52
|
}
|
|
45
|
-
declare function PageRendererComponent({ pageNum, pdfDoc, scale, rotation, containerWidth: _containerWidth, containerHeight: _containerHeight, scrollTop: _scrollTop, scrollLeft: _scrollLeft, pageTop, pageLeft, basePageWidth, basePageHeight, activeTab, activeTool, annotations, selectedAnnotationId, activeSearchResult, transientHighlights, onMouseDown, onMouseMove, onMouseUp, onAnnotationClick, onAnnotationDoubleClick, onStartResize, onStartMove, onAnnotationMouseEnter, onClearSelection, watermark, watermarkText, redactions, onDiscardRedaction, onRendered, hideAnnotationsUntilPageRendered, onLinkClick }: PageRendererProps): React.JSX.Element;
|
|
53
|
+
declare function PageRendererComponent({ pageNum, pdfDoc, scale, rotation, containerWidth: _containerWidth, containerHeight: _containerHeight, scrollTop: _scrollTop, scrollLeft: _scrollLeft, pageTop, pageLeft, basePageWidth, basePageHeight, activeTab, activeTool, annotations, selectedAnnotationId, activeSearchResult, transientHighlights, onMouseDown, onMouseMove, onMouseUp, onAnnotationClick, onAnnotationDoubleClick, onStartResize, onStartMove, onAnnotationMouseEnter, onClearSelection, watermark, watermarkText, redactions, onDiscardRedaction, onRendered, hideAnnotationsUntilPageRendered, onLinkClick, formManager, activeFormTool, setActiveFormTool, canFillForms, showFlowOrder, selectedRoleFilter }: PageRendererProps): React.JSX.Element;
|
|
46
54
|
declare const PageRenderer: React.MemoExoticComponent<typeof PageRendererComponent>;
|
|
47
55
|
export default PageRenderer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormManager } from '../forms/FormManager';
|
|
3
|
+
interface SignatureIndexFlagsProps {
|
|
4
|
+
formManager: FormManager;
|
|
5
|
+
activeTab: string;
|
|
6
|
+
onJumpToPage?: (page: number) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const SignatureIndexFlags: React.FC<SignatureIndexFlagsProps>;
|
|
9
|
+
export {};
|
|
@@ -3,9 +3,51 @@ import { ViewerBus } from './eventBus';
|
|
|
3
3
|
import { ExportOptions } from './export';
|
|
4
4
|
import { Annotation } from '../annotations/types';
|
|
5
5
|
import { AnnotationManager } from '../annotations/AnnotationManager';
|
|
6
|
-
import { Redaction, WatermarkOptions, ViewerEventMap, ViewerEventType, TransientHighlight } from './types';
|
|
6
|
+
import { Redaction, WatermarkOptions, ViewerEventMap, ViewerEventType, TransientHighlight, ViewerUser } from './types';
|
|
7
7
|
import { SearchResult } from '../hooks/usePdfSearch';
|
|
8
|
+
import { FormManager } from '../forms/FormManager';
|
|
9
|
+
import { FormField, FormDataRecord, FormValidationResult, FormRole, FormFeatureOptions } from '../forms/types';
|
|
8
10
|
import type * as pdfjsLib from 'pdfjs-dist';
|
|
11
|
+
/** Options passed to `instance.loadDocument(url, options)`. */
|
|
12
|
+
export interface LoadDocumentOptions {
|
|
13
|
+
page?: number;
|
|
14
|
+
initialPage?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Custom HTTP headers sent with every document request (e.g. Authorization: Bearer <token>).
|
|
17
|
+
* Passed directly to the underlying PDF.js engine.
|
|
18
|
+
*/
|
|
19
|
+
httpHeaders?: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Alias for `httpHeaders` providing an alternative headers option.
|
|
22
|
+
*/
|
|
23
|
+
customHeaders?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum number of bytes fetched per HTTP 206 range request.
|
|
26
|
+
* Default is 65536 (= 64 KB).
|
|
27
|
+
*/
|
|
28
|
+
rangeChunkSize?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Disable chunked streaming of PDF file data.
|
|
31
|
+
* Default is false.
|
|
32
|
+
*/
|
|
33
|
+
disableStream?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Disable automatic background pre-fetching of remaining PDF file chunks when range requests are enabled.
|
|
36
|
+
* When true, only pages explicitly navigated to are fetched.
|
|
37
|
+
* Automatically disables streaming as required by the underlying PDF.js engine.
|
|
38
|
+
* Default is false.
|
|
39
|
+
*/
|
|
40
|
+
disableAutoFetch?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Disable HTTP 206 range requests entirely, forcing the full PDF to download.
|
|
43
|
+
* Default is false.
|
|
44
|
+
*/
|
|
45
|
+
disableRange?: boolean;
|
|
46
|
+
/** Send cookies with the document request (same-origin session-bound URLs). Default false. */
|
|
47
|
+
withCredentials?: boolean;
|
|
48
|
+
/** Password for password-protected PDFs. */
|
|
49
|
+
password?: string;
|
|
50
|
+
}
|
|
9
51
|
/** Callbacks the React component installs so the instance can reach live state. */
|
|
10
52
|
export interface ViewerBinding {
|
|
11
53
|
getAnnotations(): Annotation[];
|
|
@@ -17,7 +59,7 @@ export interface ViewerBinding {
|
|
|
17
59
|
getCurrentUserName(): string | undefined;
|
|
18
60
|
getCurrentPage(): number;
|
|
19
61
|
getPageCount(): number;
|
|
20
|
-
loadDocument(url: string): void;
|
|
62
|
+
loadDocument(url: string, options?: LoadDocumentOptions): void;
|
|
21
63
|
goToPage(pageNumber: number, options?: {
|
|
22
64
|
smooth?: boolean;
|
|
23
65
|
}): void;
|
|
@@ -37,6 +79,8 @@ export declare class WebViewerInstance {
|
|
|
37
79
|
readonly bus: ViewerBus;
|
|
38
80
|
/** Annotation list, history, permissions and XFDF import/export. */
|
|
39
81
|
readonly annotationManager: AnnotationManager;
|
|
82
|
+
/** Form fields schema, values, validation, and history. */
|
|
83
|
+
readonly formManager: FormManager;
|
|
40
84
|
/** Root element of the viewer once mounted. */
|
|
41
85
|
element: HTMLElement | null;
|
|
42
86
|
/** Unique identifier for this instance. */
|
|
@@ -45,7 +89,7 @@ export declare class WebViewerInstance {
|
|
|
45
89
|
private unmountRoot;
|
|
46
90
|
private destroyed;
|
|
47
91
|
private targetViewerTarget;
|
|
48
|
-
constructor(bus: ViewerBus, annotationManager?: AnnotationManager, id?: string);
|
|
92
|
+
constructor(bus: ViewerBus, annotationManager?: AnnotationManager, id?: string, formManager?: FormManager);
|
|
49
93
|
/** Sets the target viewer instance, ref, getter, or ID to receive cross-document links. */
|
|
50
94
|
setTargetViewer(target: WebViewerInstance | React.RefObject<WebViewerInstance | null> | (() => WebViewerInstance | null) | string | null): void;
|
|
51
95
|
/** Resolves the target viewer instance if configured. */
|
|
@@ -66,10 +110,7 @@ export declare class WebViewerInstance {
|
|
|
66
110
|
on<K extends ViewerEventType>(type: K, listener: (detail: ViewerEventMap[K]) => void): () => void;
|
|
67
111
|
off<K extends ViewerEventType>(type: K, listener: (detail: ViewerEventMap[K]) => void): void;
|
|
68
112
|
/** Load (or reload) a document by URL. Resolves when loaded, rejects on load error. */
|
|
69
|
-
loadDocument(url: string, options?: {
|
|
70
|
-
page?: number;
|
|
71
|
-
initialPage?: number;
|
|
72
|
-
}): Promise<{
|
|
113
|
+
loadDocument(url: string, options?: LoadDocumentOptions): Promise<{
|
|
73
114
|
url: string;
|
|
74
115
|
numPages: number;
|
|
75
116
|
}>;
|
|
@@ -77,10 +118,7 @@ export declare class WebViewerInstance {
|
|
|
77
118
|
* Loads a document or navigates to a page within it. If the document is already loaded,
|
|
78
119
|
* directly navigates to the requested page without reloading.
|
|
79
120
|
*/
|
|
80
|
-
loadOrNavigate(url: string, options?: {
|
|
81
|
-
page?: number;
|
|
82
|
-
initialPage?: number;
|
|
83
|
-
}): Promise<{
|
|
121
|
+
loadOrNavigate(url: string, options?: LoadDocumentOptions): Promise<{
|
|
84
122
|
url: string;
|
|
85
123
|
numPages: number;
|
|
86
124
|
} | void>;
|
|
@@ -162,6 +200,57 @@ export declare class WebViewerInstance {
|
|
|
162
200
|
getRedactions(): Redaction[];
|
|
163
201
|
/** Print the exported document (annotations, redactions and watermark baked in). */
|
|
164
202
|
print(): void;
|
|
203
|
+
/** Returns all defined form fields across all pages. */
|
|
204
|
+
getFormFields(): FormField[];
|
|
205
|
+
/** Sets the form fields schema. */
|
|
206
|
+
setFormFields(fields: FormField[]): void;
|
|
207
|
+
/** Returns current filled form data values. */
|
|
208
|
+
getFormData(): FormDataRecord;
|
|
209
|
+
/** Sets current filled form data values. */
|
|
210
|
+
setFormData(data: FormDataRecord): void;
|
|
211
|
+
/** Clears all filled form data values. */
|
|
212
|
+
clearFormData(): void;
|
|
213
|
+
/** Validates all required form fields (or only those assigned to the specified role). */
|
|
214
|
+
validateForm(roleId?: string | null): FormValidationResult;
|
|
215
|
+
/** Exports filled form data as a JSON string. */
|
|
216
|
+
exportFormData(_format?: 'json'): Promise<string>;
|
|
217
|
+
/** Imports form data from a record object or JSON string. */
|
|
218
|
+
importFormData(data: FormDataRecord | string): void;
|
|
219
|
+
/** Returns all configured form template roles. */
|
|
220
|
+
getFormRoles(): FormRole[];
|
|
221
|
+
/** Sets the list of form template roles. */
|
|
222
|
+
setFormRoles(roles: FormRole[]): void;
|
|
223
|
+
/** Adds a new form template role. */
|
|
224
|
+
addFormRole(role: FormRole): void;
|
|
225
|
+
/** Updates an existing form template role. */
|
|
226
|
+
updateFormRole(id: string, updates: Partial<Omit<FormRole, 'id'>>): void;
|
|
227
|
+
/** Removes a form template role and unbinds any fields associated with it. */
|
|
228
|
+
removeFormRole(id: string): void;
|
|
229
|
+
/** Returns the active form role ID (or null for all). */
|
|
230
|
+
getCurrentRole(): string | null;
|
|
231
|
+
/** Sets the active form role ID (or null for all). */
|
|
232
|
+
setCurrentRole(roleId: string | null): void;
|
|
233
|
+
/** Returns the current logged-in user details passed by the host application. */
|
|
234
|
+
getCurrentUser(): ViewerUser | null;
|
|
235
|
+
/**
|
|
236
|
+
* Sets the current logged-in user details passed by the host application.
|
|
237
|
+
* If the user specifies a role, that role is automatically activated in the viewer.
|
|
238
|
+
*/
|
|
239
|
+
setCurrentUser(user: ViewerUser | null): void;
|
|
240
|
+
/** Returns current form feature options and visibility rules. */
|
|
241
|
+
getFormOptions(): FormFeatureOptions;
|
|
242
|
+
/**
|
|
243
|
+
* Programmatically sets form feature options.
|
|
244
|
+
* Controls what form features are visible and interactive for the user
|
|
245
|
+
* (e.g. allowUserSwitching, showSignatureFlags, showFlowNavigation, otherUserFieldsMode, etc.).
|
|
246
|
+
*/
|
|
247
|
+
setFormOptions(options: Partial<FormFeatureOptions>): void;
|
|
248
|
+
/** Advances focus to the next form field in the sequence. */
|
|
249
|
+
nextFormField(roleId?: string | null): FormField | null;
|
|
250
|
+
/** Moves focus to the previous form field in the sequence. */
|
|
251
|
+
previousFormField(roleId?: string | null): FormField | null;
|
|
252
|
+
/** Focuses a specific form field by ID. */
|
|
253
|
+
focusFormField(fieldId: string): void;
|
|
165
254
|
/**
|
|
166
255
|
* Build the exported PDF (annotations + watermark baked, redacted pages rasterized).
|
|
167
256
|
* Uses the bytes of the loaded document; never re-fetches the URL.
|
|
@@ -201,6 +290,8 @@ export declare class WebViewerInstance {
|
|
|
201
290
|
readonly Core: {
|
|
202
291
|
/** The real AnnotationManager (XFDF import/export, granular events, permissions). */
|
|
203
292
|
readonly annotationManager: AnnotationManager;
|
|
293
|
+
/** The FormManager (form schema, values, validation). */
|
|
294
|
+
readonly formManager: FormManager;
|
|
204
295
|
documentViewer: {
|
|
205
296
|
addEventListener: (event: string, callback: (detail: unknown) => void) => (() => void);
|
|
206
297
|
removeEventListener: (event: string, callback: (detail: unknown) => void) => void;
|