@files-preview-app/preview-file 1.3.0 → 1.3.2
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 +69 -0
- package/dist/angular.cjs +1477 -482
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.d.cts +1 -1
- package/dist/angular.d.ts +1 -1
- package/dist/angular.js +1477 -482
- package/dist/angular.js.map +1 -1
- package/dist/index.cjs +1477 -482
- package/dist/index.cjs.map +1 -1
- package/dist/index.d-B79v0jxi.d.cts +570 -0
- package/dist/index.d-B79v0jxi.d.ts +570 -0
- package/dist/index.d.cts +3227 -19
- package/dist/index.d.ts +3227 -19
- package/dist/index.js +1477 -482
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1477 -482
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -16
- package/dist/react.d.ts +1 -16
- package/dist/react.js +1477 -482
- package/dist/react.js.map +1 -1
- package/dist/styles.css +195 -14
- package/dist/vue.cjs +1477 -482
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +1477 -482
- package/dist/vue.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -490,6 +490,13 @@ Use directly with any build tool (Vite, Webpack, Rollup) or via `<script type="m
|
|
|
490
490
|
|---|---|---|---|
|
|
491
491
|
| `preview()` | `container: HTMLElement`, `source: FileSource`, `options?: PreviewViewerOptions` | `Promise<PreviewInstance>` | Renders any supported file into the target DOM element. Cleans up previous renders automatically. |
|
|
492
492
|
| `getInstance()` | None | `PreviewInstance \| null` | Returns the active preview instance, exposing zoom, navigation, export, and rotation methods. |
|
|
493
|
+
| `setToolbarConfig()` | `config: ToolbarConfig` | `void` | Dynamically reconfigures which toolbar buttons/actions are shown. |
|
|
494
|
+
| `getToolbarConfig()` | None | `ToolbarConfig` | Returns the active toolbar configuration. |
|
|
495
|
+
| `hideToolbarAction()` | `actionId: string` | `void` | Hides a specific toolbar action by ID or alias (e.g. `'zoomIn'`, `'print'`, `'download'`). |
|
|
496
|
+
| `showToolbarAction()` | `actionId: string` | `void` | Shows a previously hidden toolbar action. |
|
|
497
|
+
| `enableToolbarAction()` | `actionId: string` | `void` | Enables a disabled toolbar action button. |
|
|
498
|
+
| `disableToolbarAction()` | `actionId: string` | `void` | Disables a toolbar action button. |
|
|
499
|
+
| `fitToPage()` | None | `void` | Scales document page so it fills the frame width with minimal side margins. |
|
|
493
500
|
| `on()` | `event: string`, `handler: (data: any) => void` | `Unsubscribe: () => void` | Subscribes to lifecycle events. Returns an unsubscribe cleanup function. |
|
|
494
501
|
| `registerPlugin()` | `plugin: PreviewPlugin` | `this` | Registers a custom renderer plugin. |
|
|
495
502
|
| `registerPlugins()` | `plugins: PreviewPlugin[]` | `this` | Registers multiple renderer plugins at once. |
|
|
@@ -522,6 +529,68 @@ Retrieved via `viewer.getInstance()` or `previewRef.current.getInstance()`.
|
|
|
522
529
|
| **Export** | `download()` | `void` | Downloads original file with proper name & MIME | `instance.download()` |
|
|
523
530
|
| **Export** | `print()` | `void` | Opens browser print dialog formatted for clean output | `instance.print()` |
|
|
524
531
|
| **Lifecycle** | `destroy()` | `void` | Releases memory, cancels rendering, revokes blob URLs | `instance.destroy()` |
|
|
532
|
+
---
|
|
533
|
+
|
|
534
|
+
## 🛠️ Toolbar Configuration & Feature Toggles
|
|
535
|
+
|
|
536
|
+
All toolbar features and buttons are completely configurable through options and instance methods.
|
|
537
|
+
If an action is set to `false`, its button will not appear in the toolbar.
|
|
538
|
+
|
|
539
|
+
### Via Initialization Options:
|
|
540
|
+
```typescript
|
|
541
|
+
// Flat options:
|
|
542
|
+
await viewer.preview(container, file, {
|
|
543
|
+
zoomIn: false, // Hide zoom in button
|
|
544
|
+
print: false, // Hide print button
|
|
545
|
+
openWindow: false, // Hide "Open in Separate Full Window" button
|
|
546
|
+
download: true // Keep download enabled
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// Or nested toolbar object:
|
|
550
|
+
await viewer.preview(container, file, {
|
|
551
|
+
toolbar: {
|
|
552
|
+
zoomIn: false,
|
|
553
|
+
print: false,
|
|
554
|
+
copy: false
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### Via Runtime Instance Methods:
|
|
560
|
+
```typescript
|
|
561
|
+
// Hide an action dynamically
|
|
562
|
+
viewer.hideToolbarAction('zoomIn');
|
|
563
|
+
viewer.hideToolbarAction('print');
|
|
564
|
+
|
|
565
|
+
// Show a hidden action
|
|
566
|
+
viewer.showToolbarAction('zoomIn');
|
|
567
|
+
|
|
568
|
+
// Disable/enable an action button without removing it
|
|
569
|
+
viewer.disableToolbarAction('fitPage');
|
|
570
|
+
viewer.enableToolbarAction('fitPage');
|
|
571
|
+
|
|
572
|
+
// Reconfigure the entire toolbar at runtime
|
|
573
|
+
viewer.setToolbarConfig({
|
|
574
|
+
zoomIn: false,
|
|
575
|
+
zoomOut: false,
|
|
576
|
+
download: true
|
|
577
|
+
});
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### Available Toolbar Toggle Keys:
|
|
581
|
+
| Option Key | Corresponding Action | Description |
|
|
582
|
+
|---|---|---|
|
|
583
|
+
| `zoomIn` | Zoom In | Zoom in button |
|
|
584
|
+
| `zoomOut` | Zoom Out | Zoom out button |
|
|
585
|
+
| `fitPage` / `fitToPage` | Fit to Page | Scales document to fill frame width with minimal side margins |
|
|
586
|
+
| `rotate` / `rotateCW` | Rotate | 90° Clockwise rotation |
|
|
587
|
+
| `fullscreen` | Fullscreen | Fullscreen frame toggle |
|
|
588
|
+
| `thumbnails` | Thumbnails | Sidebar thumbnail toggle |
|
|
589
|
+
| `download` | Download | File download button |
|
|
590
|
+
| `print` | Print | Browser clean print button |
|
|
591
|
+
| `openWindow` / `openSeparateWindow` | Open in Separate Window | Opens preview in a standalone window |
|
|
592
|
+
| `copy` | Copy Text | Copy document text to clipboard |
|
|
593
|
+
| `pageNav` / `pagination` | Pagination | Previous, next, and jump-to-page input |
|
|
525
594
|
|
|
526
595
|
---
|
|
527
596
|
|