@iamjariwala/react-doc-viewer 0.2.1 → 1.1.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 +37 -27
- package/dist/components/common/Button.d.ts +11 -14
- package/dist/{index-dGGNa2HA.js → index-BRIDmekZ.js} +2 -2
- package/dist/index-BbWLdN1j.js +19664 -0
- package/dist/{index-CYjVmFQ0.cjs → index-C5fDV20X.cjs} +1 -1
- package/dist/{index-nyGAOsVK.js → index-Dr6cyq4L.js} +2 -2
- package/dist/{index-DHMTXjv6.cjs → index-DtsNvZYP.cjs} +1 -1
- package/dist/index-J-2Hm65K.cjs +46 -0
- package/dist/index.css +1 -1
- package/dist/models.d.ts +0 -3
- package/dist/react-doc-viewer.cjs +1 -1
- package/dist/react-doc-viewer.js +1 -1
- package/dist/{url-Dk8Xia2J.js → url-5wjrlwUG.js} +1 -1
- package/dist/{url-BH2U_nez.cjs → url-DLGc3bZT.cjs} +1 -1
- package/package.json +6 -8
- package/dist/index-BW6EMUiE.cjs +0 -797
- package/dist/index-Dg8HfAtq.js +0 -21246
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Most React document viewers only handle PDFs or require expensive commercial lic
|
|
|
23
23
|
| Feature | @iamjariwala/react-doc-viewer | react-pdf | @cyntler/react-doc-viewer | react-file-viewer |
|
|
24
24
|
| ------- | :--: | :--: | :--: | :--: |
|
|
25
25
|
| PDF rendering | Yes | Yes | Yes | Yes |
|
|
26
|
-
| Office docs (Word, Excel, PPT) |
|
|
26
|
+
| Office docs (Word, Excel, PPT) | Download card | -- | Yes | Partial |
|
|
27
27
|
| Images (PNG, JPG, GIF, WebP, TIFF, BMP) | Yes | -- | Yes | Partial |
|
|
28
28
|
| Video (MP4) | Yes | -- | Yes | Yes |
|
|
29
29
|
| CSV / TXT / HTML | Yes | -- | Yes | Partial |
|
|
@@ -35,7 +35,7 @@ Most React document viewers only handle PDFs or require expensive commercial lic
|
|
|
35
35
|
| Custom renderers | Yes | -- | Yes | -- |
|
|
36
36
|
| Theming | Yes | -- | Yes | -- |
|
|
37
37
|
| TypeScript | Yes | Yes | Yes | -- |
|
|
38
|
-
| Actively maintained (
|
|
38
|
+
| Actively maintained (2025+) | Yes | Yes | -- | -- |
|
|
39
39
|
| License | Apache-2.0 | MIT | MIT | MIT |
|
|
40
40
|
|
|
41
41
|
---
|
|
@@ -50,19 +50,20 @@ Most React document viewers only handle PDFs or require expensive commercial lic
|
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
### What's New in
|
|
53
|
+
### What's New in v1.1.0
|
|
54
54
|
|
|
55
|
-
- **
|
|
56
|
-
- **
|
|
57
|
-
- **
|
|
58
|
-
- **
|
|
55
|
+
- **Security: HTML XSS fix** -- HTML renderer now sanitizes content with DOMPurify before rendering
|
|
56
|
+
- **Security: MS Office docs** -- Removed external iframe dependency; Office files now render as download cards with file info
|
|
57
|
+
- **Removed styled-components** -- All styling migrated to plain CSS with CSS custom properties, reducing bundle size
|
|
58
|
+
- **Smaller bundle** -- Removed `styled-components`, `core-js`, and `ajv` dependencies (~300-400KB savings)
|
|
59
|
+
- **CSS custom properties** -- Theming now uses `--rdv-*` CSS variables for full customizability
|
|
59
60
|
|
|
60
61
|
## Table of Contents
|
|
61
62
|
|
|
62
63
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
63
64
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
65
|
+
## Table of Contents
|
|
64
66
|
|
|
65
|
-
- [Why @iamjariwala/react-doc-viewer?](#why-iamjariwalareact-doc-viewer)
|
|
66
67
|
- [Supported File Types](#supported-file-types)
|
|
67
68
|
- [Live Demo](#live-demo)
|
|
68
69
|
- [Installation](#installation)
|
|
@@ -114,16 +115,16 @@ Most React document viewers only handle PDFs or require expensive commercial lic
|
|
|
114
115
|
| txt | `text/plain` | |
|
|
115
116
|
| htm / html | `text/htm`, `text/html` | |
|
|
116
117
|
| mp4 | `video/mp4` | |
|
|
117
|
-
| doc | `application/msword` |
|
|
118
|
-
| docx | `application/vnd.openxmlformats-officedocument.wordprocessingml.document` |
|
|
119
|
-
| xls | `application/vnd.ms-excel` |
|
|
120
|
-
| xlsx | `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` |
|
|
121
|
-
| ppt | `application/vnd.ms-powerpoint` |
|
|
122
|
-
| pptx | `application/vnd.openxmlformats-officedocument.presentationml.presentation` |
|
|
118
|
+
| doc | `application/msword` | Download card |
|
|
119
|
+
| docx | `application/vnd.openxmlformats-officedocument.wordprocessingml.document` | Download card |
|
|
120
|
+
| xls | `application/vnd.ms-excel` | Download card |
|
|
121
|
+
| xlsx | `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` | Download card |
|
|
122
|
+
| ppt | `application/vnd.ms-powerpoint` | Download card |
|
|
123
|
+
| pptx | `application/vnd.openxmlformats-officedocument.presentationml.presentation` | Download card |
|
|
123
124
|
| odt | `application/vnd.oasis.opendocument.text` | |
|
|
124
125
|
|
|
125
|
-
> [!
|
|
126
|
-
> MS Office documents (doc, docx, xls, xlsx, ppt, pptx)
|
|
126
|
+
> [!NOTE]
|
|
127
|
+
> MS Office documents (doc, docx, xls, xlsx, ppt, pptx) render as download cards showing file name, type, and a download link. No external service or public URL is required.
|
|
127
128
|
|
|
128
129
|
## Live Demo
|
|
129
130
|
|
|
@@ -580,24 +581,33 @@ Customize the viewer's appearance with a theme object:
|
|
|
580
581
|
<DocViewer documents={docs} pluginRenderers={DocViewerRenderers} style={{ width: 500, height: 500 }} />
|
|
581
582
|
```
|
|
582
583
|
|
|
583
|
-
**
|
|
584
|
+
**Override internal elements with CSS classes:**
|
|
584
585
|
|
|
585
|
-
|
|
586
|
-
import styled from "styled-components";
|
|
587
|
-
import DocViewer from "@iamjariwala/react-doc-viewer";
|
|
586
|
+
All internal elements use `.rdv-*` class names that you can target:
|
|
588
587
|
|
|
589
|
-
|
|
588
|
+
```css
|
|
589
|
+
.rdv-container {
|
|
590
590
|
border-radius: 10px;
|
|
591
|
-
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.rdv-header-bar {
|
|
594
|
+
background-color: #faf;
|
|
595
|
+
}
|
|
592
596
|
|
|
593
|
-
|
|
597
|
+
.rdv-pdf-controls {
|
|
598
|
+
gap: 12px;
|
|
599
|
+
}
|
|
594
600
|
```
|
|
595
601
|
|
|
596
|
-
**Override
|
|
602
|
+
**Override CSS custom properties:**
|
|
603
|
+
|
|
604
|
+
Theming is powered by CSS variables. Override them on the container or globally:
|
|
597
605
|
|
|
598
606
|
```css
|
|
599
|
-
#react-doc-viewer
|
|
600
|
-
|
|
607
|
+
#react-doc-viewer {
|
|
608
|
+
--rdv-primary: #1a1a2e;
|
|
609
|
+
--rdv-secondary: #16213e;
|
|
610
|
+
--rdv-text-primary: #e94560;
|
|
601
611
|
}
|
|
602
612
|
```
|
|
603
613
|
|
|
@@ -681,7 +691,7 @@ Provide custom headers for authenticated requests:
|
|
|
681
691
|
Install `@iamjariwala/react-doc-viewer`, import `DocViewer` and `DocViewerRenderers`, pass your PDF URL as a document, and the component handles rendering, zoom, pagination, and page navigation automatically. See [Quick Start](#quick-start).
|
|
682
692
|
|
|
683
693
|
**Can I view Word, Excel, and PowerPoint files in React?**
|
|
684
|
-
Yes. This library
|
|
694
|
+
Yes. This library recognizes `.doc`, `.docx`, `.xls`, `.xlsx`, `.ppt`, and `.pptx` files and renders them as download cards showing file name, type, and a download link. No external service or public URL is required.
|
|
685
695
|
|
|
686
696
|
**Does it support annotations and highlighting?**
|
|
687
697
|
Yes. Enable annotations via config to get text highlighting, freehand drawing, comments, and an eraser tool. Annotations can be exported as JSON and pre-loaded from saved data. See [Annotations](#annotations).
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FC, ButtonHTMLAttributes, AnchorHTMLAttributes } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare const ButtonSecondary: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<Omit<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, keyof ButtonProps> & ButtonProps, "ref"> & {
|
|
14
|
-
ref?: ((instance: HTMLButtonElement | null) => void) | import('react').RefObject<HTMLButtonElement> | null | undefined;
|
|
15
|
-
}, never>> & string;
|
|
3
|
+
type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
4
|
+
className?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const Button: FC<ButtonProps>;
|
|
7
|
+
export declare const ButtonPrimary: FC<ButtonProps>;
|
|
8
|
+
export declare const ButtonSecondary: FC<ButtonProps>;
|
|
9
|
+
type LinkButtonProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const LinkButton: FC<LinkButtonProps>;
|
|
16
13
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as V, a as br, d as on, p as U, B as ce, g as an } from "./index-
|
|
2
|
-
import { u as fn } from "./url-
|
|
1
|
+
import { c as V, a as br, d as on, p as U, B as ce, g as an } from "./index-BbWLdN1j.js";
|
|
2
|
+
import { u as fn } from "./url-5wjrlwUG.js";
|
|
3
3
|
function un(e, t) {
|
|
4
4
|
for (var r = 0; r < t.length; r++) {
|
|
5
5
|
const n = t[r];
|