@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 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) | Yes | -- | Yes | Partial |
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 (2024+) | Yes | Yes | -- | -- |
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 v0.2.0
53
+ ### What's New in v1.1.0
54
54
 
55
- - **Drag & Drop** -- Drop files directly onto the viewer to add or replace documents
56
- - **Thumbnail Sidebar** -- Visual page navigation with auto-scroll for PDFs
57
- - **Annotations** -- Highlight text, freehand draw, and add comments with export support
58
- - **Page Jump** -- Navigate to any page programmatically via ref or prop
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` | Public URLs only |
118
- | docx | `application/vnd.openxmlformats-officedocument.wordprocessingml.document` | Public URLs only |
119
- | xls | `application/vnd.ms-excel` | Public URLs only |
120
- | xlsx | `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` | Public URLs only |
121
- | ppt | `application/vnd.ms-powerpoint` | Public URLs only |
122
- | pptx | `application/vnd.openxmlformats-officedocument.presentationml.presentation` | Public URLs only |
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
- > [!IMPORTANT]
126
- > MS Office documents (doc, docx, xls, xlsx, ppt, pptx) use Microsoft's online viewing service via iframe and **require publicly accessible URLs**.
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
- **Styled Components:**
584
+ **Override internal elements with CSS classes:**
584
585
 
585
- ```tsx
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
- const MyDocViewer = styled(DocViewer)`
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
- <MyDocViewer documents={docs} />;
597
+ .rdv-pdf-controls {
598
+ gap: 12px;
599
+ }
594
600
  ```
595
601
 
596
- **Override internal elements by DOM ID:**
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 #header-bar {
600
- background-color: #faf;
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 renders `.doc`, `.docx`, `.xls`, `.xlsx`, `.ppt`, and `.pptx` files using Microsoft's online viewing service. The files must be accessible via a public URL.
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 { IStyledProps } from '../..';
1
+ import { FC, ButtonHTMLAttributes, AnchorHTMLAttributes } from 'react';
2
2
 
3
- interface ButtonProps extends IStyledProps {
4
- disabled?: boolean;
5
- }
6
- export declare const ButtonPrimaryStyle: import('styled-components').RuleSet<object>;
7
- export declare const ButtonSecondaryStyle: import('styled-components').RuleSet<object>;
8
- export declare const Button: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, ButtonProps>> & string;
9
- export declare const LinkButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>> & string;
10
- export declare const ButtonPrimary: 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"> & {
11
- ref?: ((instance: HTMLButtonElement | null) => void) | import('react').RefObject<HTMLButtonElement> | null | undefined;
12
- }, never>> & string;
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-Dg8HfAtq.js";
2
- import { u as fn } from "./url-Dk8Xia2J.js";
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];