@doc-preview/react 1.0.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/LICENSE +21 -0
- package/README.md +121 -0
- package/dist/DemoReactApp.d.ts +3 -0
- package/dist/DemoReactApp.d.ts.map +1 -0
- package/dist/DemoReactApp.js +290 -0
- package/dist/DemoReactApp.js.map +1 -0
- package/dist/DocPreview.d.ts +14 -0
- package/dist/DocPreview.d.ts.map +1 -0
- package/dist/DocPreview.js +108 -0
- package/dist/DocPreview.js.map +1 -0
- package/dist/demo-mount.d.ts +3 -0
- package/dist/demo-mount.d.ts.map +1 -0
- package/dist/demo-mount.js +9 -0
- package/dist/demo-mount.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rajkishor Sahu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @doc-preview/react
|
|
2
|
+
|
|
3
|
+
React component for multi-format document preview, built on [`@doc-preview/core`](https://www.npmjs.com/package/@doc-preview/core). Same viewer as Angular and vanilla JS — PDF, DOCX, images, optional Office pack, and Enterprise annotations, watermark, split view, print, search, redaction, and diff.
|
|
4
|
+
|
|
5
|
+
**Current release: 1.0.0** — Depends on `@doc-preview/core` **^1.0.0**. See [monorepo CHANGELOG](../../CHANGELOG.md).
|
|
6
|
+
|
|
7
|
+
**Repository & docs:** [github.com/rajkishorsahu89/doc-preview](https://github.com/rajkishorsahu89/doc-preview)
|
|
8
|
+
|
|
9
|
+
**Demo:** [doc-preview-app.vercel.app](https://doc-preview-app.vercel.app/) — [tool](https://doc-preview-app.vercel.app/tool) · [demo](https://doc-preview-app.vercel.app/demo) · [guide](https://doc-preview-app.vercel.app/guide)
|
|
10
|
+
|
|
11
|
+
> Ships as ESM with TypeScript declarations. Works with **React 18** and **19**. Import [`@doc-preview/themes`](https://www.npmjs.com/package/@doc-preview/themes) CSS once in your app.
|
|
12
|
+
|
|
13
|
+
**Keywords:** `doc-preview` `react` `document-viewer` `pdf` `docx` `file-preview` `annotations`
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @doc-preview/react @doc-preview/themes
|
|
19
|
+
# Adds @doc-preview/core automatically.
|
|
20
|
+
# Peer deps: react ^18 || ^19, react-dom ^18 || ^19.
|
|
21
|
+
# Optional:
|
|
22
|
+
npm install @doc-preview/enterprise @doc-preview/office
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage — component
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { DocPreview } from "@doc-preview/react";
|
|
29
|
+
import "@doc-preview/themes/doc-preview.css";
|
|
30
|
+
|
|
31
|
+
export function Viewer() {
|
|
32
|
+
return (
|
|
33
|
+
<DocPreview
|
|
34
|
+
documents={[{ uri: "/sample.pdf", fileName: "sample.pdf" }]}
|
|
35
|
+
onPhaseChange={(e) => console.log(e.phase)}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage — upload & Blob
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { DocPreview } from "@doc-preview/react";
|
|
45
|
+
import { createPreviewDocumentsFromFiles } from "@doc-preview/core";
|
|
46
|
+
|
|
47
|
+
<DocPreview
|
|
48
|
+
documents={docs}
|
|
49
|
+
config={{ upload: { enabled: true, accept: ".pdf,.png,.docx" } }}
|
|
50
|
+
onFilesSelected={(files) => setDocs(createPreviewDocumentsFromFiles(files))}
|
|
51
|
+
/>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage — Enterprise
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<DocPreview
|
|
58
|
+
documents={docs}
|
|
59
|
+
enterpriseLicenseKey="DP-ENT-DEMO-0001-ANNOTATIONS-SPLIT"
|
|
60
|
+
config={{
|
|
61
|
+
enterprise: {
|
|
62
|
+
watermarkText: "CONFIDENTIAL",
|
|
63
|
+
enableAnnotations: true,
|
|
64
|
+
enablePrint: true,
|
|
65
|
+
splitView: true
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
onEnterpriseStatusChange={(licensed) => console.log(licensed)}
|
|
69
|
+
/>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage — Office pack
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { registerBuiltinPreviewRenderers } from "@doc-preview/core";
|
|
76
|
+
import { registerOfficePreviewRenderers } from "@doc-preview/office";
|
|
77
|
+
|
|
78
|
+
registerBuiltinPreviewRenderers();
|
|
79
|
+
registerOfficePreviewRenderers();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API — `DocPreview` props
|
|
83
|
+
|
|
84
|
+
Extends `PreviewHostOptions` from core plus:
|
|
85
|
+
|
|
86
|
+
| Prop | Type | Description |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| `documents` | `PreviewDocument[]` | **Required.** |
|
|
89
|
+
| `config` | `PreviewConfig` | Upload, PDF, enterprise, office options. |
|
|
90
|
+
| `enterpriseLicenseKey` | `string` | Enterprise licence key. |
|
|
91
|
+
| `dark` | `boolean` | Dark theme. |
|
|
92
|
+
| `theme` | `PreviewThemeTokens` | CSS token overrides. |
|
|
93
|
+
| `slots` | `PreviewSlots` | Header slot overrides. |
|
|
94
|
+
| `className` / `style` | — | Host wrapper styling. |
|
|
95
|
+
| `onPhaseChange` | `(event) => void` | Loading / error phases. |
|
|
96
|
+
| `onDocumentChange` | `(doc, index) => void` | Active document changed. |
|
|
97
|
+
| `onFilesSelected` | `(files) => void` | Built-in upload picker. |
|
|
98
|
+
| `onEnterpriseStatusChange` | `(licensed) => void` | Licence status. |
|
|
99
|
+
|
|
100
|
+
Re-exports all public symbols from `@doc-preview/core`.
|
|
101
|
+
|
|
102
|
+
## React vs Angular naming
|
|
103
|
+
|
|
104
|
+
| React | Angular |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| `<DocPreview />` | `<doc-preview>` |
|
|
107
|
+
| `onPhaseChange` | `(phaseChange)` |
|
|
108
|
+
| `onFilesSelected` | `(filesSelected)` |
|
|
109
|
+
|
|
110
|
+
## Related packages
|
|
111
|
+
|
|
112
|
+
- [`@doc-preview/core`](https://www.npmjs.com/package/@doc-preview/core)
|
|
113
|
+
- [`@doc-preview/angular`](https://www.npmjs.com/package/@doc-preview/angular)
|
|
114
|
+
- [`@doc-preview/js`](https://www.npmjs.com/package/@doc-preview/js)
|
|
115
|
+
- [`@doc-preview/themes`](https://www.npmjs.com/package/@doc-preview/themes)
|
|
116
|
+
- [`@doc-preview/enterprise`](https://www.npmjs.com/package/@doc-preview/enterprise)
|
|
117
|
+
- [`@doc-preview/office`](https://www.npmjs.com/package/@doc-preview/office)
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
[MIT](./LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DemoReactApp.d.ts","sourceRoot":"","sources":["../src/DemoReactApp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAwK7D,wBAAgB,YAAY,IAAI,YAAY,CA6c3C"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { DocPreview } from "@doc-preview/react";
|
|
4
|
+
import { createPreviewDocumentFromBase64, createPreviewDocumentFromBlob, createPreviewDocumentsFromFiles } from "@doc-preview/core";
|
|
5
|
+
const DEMO_KEY = "DP-ENT-DEMO-0001-ANNOTATIONS-SPLIT";
|
|
6
|
+
const COMMUNITY_SAMPLE_CATEGORIES = [
|
|
7
|
+
{
|
|
8
|
+
id: "text",
|
|
9
|
+
label: "Text & data",
|
|
10
|
+
samples: [
|
|
11
|
+
{
|
|
12
|
+
uri: "/assets/samples/readme.txt",
|
|
13
|
+
fileName: "readme.txt",
|
|
14
|
+
ext: "TXT",
|
|
15
|
+
hint: "Plain text — no licence required",
|
|
16
|
+
tier: "community"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
uri: "/assets/samples/data.csv",
|
|
20
|
+
fileName: "data.csv",
|
|
21
|
+
ext: "CSV",
|
|
22
|
+
hint: "Tabular spreadsheet preview",
|
|
23
|
+
tier: "community"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "markup",
|
|
29
|
+
label: "Markup",
|
|
30
|
+
samples: [
|
|
31
|
+
{
|
|
32
|
+
uri: "/assets/samples/page.html",
|
|
33
|
+
fileName: "page.html",
|
|
34
|
+
ext: "HTML",
|
|
35
|
+
hint: "Styled HTML page",
|
|
36
|
+
tier: "community"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "office",
|
|
42
|
+
label: "Office",
|
|
43
|
+
samples: [
|
|
44
|
+
{
|
|
45
|
+
uri: "/assets/samples/sample.docx",
|
|
46
|
+
fileName: "sample.docx",
|
|
47
|
+
ext: "DOCX",
|
|
48
|
+
hint: "DOCX preview with in-document search",
|
|
49
|
+
tier: "community"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
uri: "/assets/samples/sample.doc",
|
|
53
|
+
fileName: "sample.doc",
|
|
54
|
+
ext: "DOC",
|
|
55
|
+
hint: "Legacy Word .doc (RTF/OLE text)",
|
|
56
|
+
tier: "community"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
uri: "/assets/samples/legacy.convertme",
|
|
60
|
+
fileName: "legacy.convertme",
|
|
61
|
+
ext: "CONV",
|
|
62
|
+
hint: "Mock server conversion → HTML preview",
|
|
63
|
+
tier: "community"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
const ENTERPRISE_SAMPLE_CATEGORIES = [
|
|
69
|
+
{
|
|
70
|
+
id: "pdf",
|
|
71
|
+
label: "PDF (Enterprise)",
|
|
72
|
+
samples: [
|
|
73
|
+
{
|
|
74
|
+
uri: "/assets/samples/sample.pdf",
|
|
75
|
+
fileName: "sample.pdf",
|
|
76
|
+
ext: "PDF",
|
|
77
|
+
hint: "Annotations, search, redaction, print, watermark",
|
|
78
|
+
tier: "enterprise"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
async function mockDemoConversion(input) {
|
|
84
|
+
if (!input.fileName.toLowerCase().endsWith(".convertme")) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const text = await input.blob.text();
|
|
88
|
+
const html = `<!DOCTYPE html><html><body style="font-family:Segoe UI,sans-serif;padding:1.5rem"><h1>Converted preview</h1><p><strong>${input.fileName}</strong> was converted via <code>config.conversion.convert</code>.</p><pre>${text.replace(/</g, "<")}</pre></body></html>`;
|
|
89
|
+
return new Blob([html], { type: "text/html" });
|
|
90
|
+
}
|
|
91
|
+
const FLAT_COMMUNITY_SAMPLES = COMMUNITY_SAMPLE_CATEGORIES.flatMap((c) => [...c.samples]);
|
|
92
|
+
const FLAT_SAMPLES = [
|
|
93
|
+
...FLAT_COMMUNITY_SAMPLES,
|
|
94
|
+
...ENTERPRISE_SAMPLE_CATEGORIES.flatMap((c) => [...c.samples])
|
|
95
|
+
];
|
|
96
|
+
const ENTERPRISE_FEATURES = [
|
|
97
|
+
"Annotations",
|
|
98
|
+
"Print",
|
|
99
|
+
"Watermark",
|
|
100
|
+
"Compare doc",
|
|
101
|
+
"Search",
|
|
102
|
+
"Redaction"
|
|
103
|
+
];
|
|
104
|
+
const COMMUNITY_CONFIG = {
|
|
105
|
+
upload: {
|
|
106
|
+
accept: ".pdf,.doc,.docx,.xlsx,.xls,.ppt,.pptx,.png,.jpg,.jpeg,.gif,.webp,.mp4,.webm,.mp3,.wav,.txt,.html,.htm,.csv,.json,.xml,.md",
|
|
107
|
+
multiple: true,
|
|
108
|
+
showDropZone: true,
|
|
109
|
+
autoOpenPicker: false,
|
|
110
|
+
buttonText: "Choose file"
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const ENTERPRISE_CONFIG = {
|
|
114
|
+
...COMMUNITY_CONFIG,
|
|
115
|
+
enterprise: {
|
|
116
|
+
watermarkText: "CONFIDENTIAL",
|
|
117
|
+
enableAnnotations: true,
|
|
118
|
+
enablePrint: true,
|
|
119
|
+
enableSearch: true,
|
|
120
|
+
enableRedaction: true,
|
|
121
|
+
diffView: true
|
|
122
|
+
},
|
|
123
|
+
pdf: {
|
|
124
|
+
showControls: true,
|
|
125
|
+
showThumbnails: true,
|
|
126
|
+
fitPageOnLoad: true,
|
|
127
|
+
enableSearch: true,
|
|
128
|
+
enableRedaction: true,
|
|
129
|
+
annotations: {
|
|
130
|
+
storageKey: "doc-preview-demo-react",
|
|
131
|
+
documentId: "react-demo-pdf"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const SOURCE_MODES = [
|
|
136
|
+
{ id: "upload", label: "Upload", icon: "↑" },
|
|
137
|
+
{ id: "url", label: "URL", icon: "🔗" },
|
|
138
|
+
{ id: "blob", label: "Blob", icon: "📄" },
|
|
139
|
+
{ id: "base64", label: "Base64", icon: "⌗" }
|
|
140
|
+
];
|
|
141
|
+
export function DemoReactApp() {
|
|
142
|
+
const [sourceMode, setSourceMode] = useState("url");
|
|
143
|
+
const [documents, setDocuments] = useState([FLAT_COMMUNITY_SAMPLES[0]]);
|
|
144
|
+
const [licenseKeyInput, setLicenseKeyInput] = useState("");
|
|
145
|
+
const [activeLicenseKey, setActiveLicenseKey] = useState("");
|
|
146
|
+
const isEnterpriseLicensed = activeLicenseKey.trim().length > 0;
|
|
147
|
+
const [pdfPassword, setPdfPassword] = useState("");
|
|
148
|
+
const [watermarkText, setWatermarkText] = useState("CONFIDENTIAL");
|
|
149
|
+
const [mockConversion, setMockConversion] = useState(true);
|
|
150
|
+
const [sidebarOpen, setSidebarOpen] = useState(true);
|
|
151
|
+
const [phase, setPhase] = useState("idle");
|
|
152
|
+
const [urlInput, setUrlInput] = useState("/assets/samples/readme.txt");
|
|
153
|
+
const [urlFileName, setUrlFileName] = useState("readme.txt");
|
|
154
|
+
const [base64Input, setBase64Input] = useState("aGVsbG8=");
|
|
155
|
+
const [base64Mime, setBase64Mime] = useState("text/plain");
|
|
156
|
+
const [base64FileName, setBase64FileName] = useState("hello.txt");
|
|
157
|
+
const viewerConfig = useMemo(() => {
|
|
158
|
+
const base = isEnterpriseLicensed ? ENTERPRISE_CONFIG : COMMUNITY_CONFIG;
|
|
159
|
+
const pwd = pdfPassword.trim();
|
|
160
|
+
const wm = watermarkText.trim();
|
|
161
|
+
const config = isEnterpriseLicensed
|
|
162
|
+
? {
|
|
163
|
+
...base,
|
|
164
|
+
...(mockConversion ? { conversion: { convert: mockDemoConversion } } : {}),
|
|
165
|
+
enterprise: {
|
|
166
|
+
...ENTERPRISE_CONFIG.enterprise,
|
|
167
|
+
watermarkText: wm || undefined
|
|
168
|
+
},
|
|
169
|
+
pdf: {
|
|
170
|
+
...ENTERPRISE_CONFIG.pdf,
|
|
171
|
+
password: pwd || undefined
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
: {
|
|
175
|
+
...base,
|
|
176
|
+
...(mockConversion ? { conversion: { convert: mockDemoConversion } } : {})
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
...config,
|
|
180
|
+
upload: {
|
|
181
|
+
...config.upload,
|
|
182
|
+
enabled: sourceMode === "upload"
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}, [isEnterpriseLicensed, pdfPassword, watermarkText, mockConversion, sourceMode]);
|
|
186
|
+
function applyLicenseKey() {
|
|
187
|
+
setActiveLicenseKey(licenseKeyInput.trim());
|
|
188
|
+
}
|
|
189
|
+
function clearLicenseKey() {
|
|
190
|
+
setLicenseKeyInput("");
|
|
191
|
+
setActiveLicenseKey("");
|
|
192
|
+
}
|
|
193
|
+
function fillDemoLicenseKey() {
|
|
194
|
+
setLicenseKeyInput(DEMO_KEY);
|
|
195
|
+
setActiveLicenseKey(DEMO_KEY);
|
|
196
|
+
}
|
|
197
|
+
const activeDocLabel = documents.length === 0
|
|
198
|
+
? "No document selected"
|
|
199
|
+
: (documents[0].fileName ?? documents[0].uri ?? "Document");
|
|
200
|
+
const phaseClass = phase === "ready"
|
|
201
|
+
? "demo-phase-pill demo-phase-pill--ready"
|
|
202
|
+
: phase === "error"
|
|
203
|
+
? "demo-phase-pill demo-phase-pill--error"
|
|
204
|
+
: phase === "loading"
|
|
205
|
+
? "demo-phase-pill demo-phase-pill--loading"
|
|
206
|
+
: "demo-phase-pill";
|
|
207
|
+
function loadSample(sample) {
|
|
208
|
+
setDocuments([{ uri: sample.uri, fileName: sample.fileName }]);
|
|
209
|
+
setUrlInput(sample.uri);
|
|
210
|
+
setUrlFileName(sample.fileName);
|
|
211
|
+
setSourceMode("url");
|
|
212
|
+
}
|
|
213
|
+
function applyUrl() {
|
|
214
|
+
const uri = urlInput.trim();
|
|
215
|
+
if (!uri) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const name = urlFileName.trim();
|
|
219
|
+
setDocuments([{ uri, ...(name ? { fileName: name } : {}) }]);
|
|
220
|
+
}
|
|
221
|
+
function applyBase64() {
|
|
222
|
+
const base64 = base64Input.trim();
|
|
223
|
+
if (!base64) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
setDocuments([
|
|
228
|
+
createPreviewDocumentFromBase64({
|
|
229
|
+
base64,
|
|
230
|
+
fileName: base64FileName || "document",
|
|
231
|
+
mimeType: base64Mime || undefined
|
|
232
|
+
})
|
|
233
|
+
]);
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
console.error(err);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function clearDocument() {
|
|
240
|
+
if (sourceMode === "upload") {
|
|
241
|
+
setDocuments([]);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
setDocuments([FLAT_COMMUNITY_SAMPLES[0]]);
|
|
245
|
+
setUrlInput(FLAT_COMMUNITY_SAMPLES[0].uri);
|
|
246
|
+
setUrlFileName(FLAT_COMMUNITY_SAMPLES[0].fileName);
|
|
247
|
+
}
|
|
248
|
+
setPhase("idle");
|
|
249
|
+
}
|
|
250
|
+
function onPhase(e) {
|
|
251
|
+
setPhase(e.phase);
|
|
252
|
+
}
|
|
253
|
+
function isActiveSample(sample) {
|
|
254
|
+
const doc = documents[0];
|
|
255
|
+
if (!doc) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return doc.uri === sample.uri || doc.fileName === sample.fileName;
|
|
259
|
+
}
|
|
260
|
+
return (_jsxs("div", { className: "demo-workbench__inner", children: [_jsx("button", { type: "button", className: "demo-sidebar-toggle", onClick: () => setSidebarOpen((open) => !open), "aria-expanded": sidebarOpen, children: sidebarOpen ? "Hide controls" : "Show controls" }), _jsxs("aside", { className: `demo-sidebar${sidebarOpen ? " demo-sidebar--open" : ""}`, children: [_jsxs("div", { className: "demo-sidebar__section", children: [_jsx("h2", { className: "demo-sidebar__heading", children: "Document source" }), _jsx("div", { className: "demo-source-tabs", role: "tablist", "aria-label": "Source mode", children: SOURCE_MODES.map((mode) => (_jsxs("button", { type: "button", className: `demo-source-tab${sourceMode === mode.id ? " demo-source-tab--active" : ""}`, role: "tab", "aria-selected": sourceMode === mode.id, onClick: () => {
|
|
261
|
+
setSourceMode(mode.id);
|
|
262
|
+
if (mode.id === "upload") {
|
|
263
|
+
setDocuments([]);
|
|
264
|
+
}
|
|
265
|
+
else if (mode.id === "url" && documents.length === 0) {
|
|
266
|
+
setDocuments([FLAT_SAMPLES[0]]);
|
|
267
|
+
}
|
|
268
|
+
}, children: [_jsx("span", { className: "demo-source-tab__icon", "aria-hidden": "true", children: mode.icon }), mode.label] }, mode.id))) }), sourceMode === "upload" && (_jsxs("p", { className: "demo-hint", children: ["Drop a file on the viewer or use ", _jsx("strong", { children: "Choose file" }), ". Supports PDF, Office, images, audio, and video."] })), sourceMode === "url" && (_jsxs(_Fragment, { children: [_jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "URL or path" }), _jsx("input", { className: "demo-field__input", value: urlInput, onChange: (e) => setUrlInput(e.target.value) })] }), _jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "fileName (optional)" }), _jsx("input", { className: "demo-field__input", value: urlFileName, onChange: (e) => setUrlFileName(e.target.value), placeholder: "report.pdf" })] }), _jsx("button", { type: "button", className: "btn brand demo-apply-btn", onClick: applyUrl, children: "Preview URL" })] })), sourceMode === "blob" && (_jsxs(_Fragment, { children: [_jsxs("p", { className: "demo-hint", children: ["Pick a local file \u2014 passed as ", _jsx("code", { children: "file: Blob" }), " to the viewer."] }), _jsxs("label", { className: "demo-file-drop", children: [_jsx("input", { className: "demo-file-input", type: "file", onChange: (e) => {
|
|
269
|
+
const file = e.target.files?.[0];
|
|
270
|
+
if (file) {
|
|
271
|
+
setDocuments([createPreviewDocumentFromBlob(file)]);
|
|
272
|
+
}
|
|
273
|
+
} }), _jsx("span", { className: "demo-file-drop__label", children: "Browse file\u2026" })] })] })), sourceMode === "base64" && (_jsxs(_Fragment, { children: [_jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "MIME type" }), _jsx("input", { className: "demo-field__input", value: base64Mime, onChange: (e) => setBase64Mime(e.target.value), placeholder: "text/plain" })] }), _jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "fileName" }), _jsx("input", { className: "demo-field__input", value: base64FileName, onChange: (e) => setBase64FileName(e.target.value), placeholder: "hello.txt" })] }), _jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "Base64 or data URL" }), _jsx("textarea", { className: "demo-field__textarea", rows: 4, value: base64Input, onChange: (e) => setBase64Input(e.target.value), placeholder: "aGVsbG8= or data:text/plain;base64,aGVsbG8=" })] }), _jsxs("div", { className: "demo-btn-row", children: [_jsx("button", { type: "button", className: "btn brand", onClick: applyBase64, children: "Preview base64" }), _jsx("button", { type: "button", className: "btn", onClick: () => {
|
|
274
|
+
setBase64Input("data:text/plain;base64,SGVsbG8gRG9jIFByZXZpZXch");
|
|
275
|
+
setBase64FileName("greeting.txt");
|
|
276
|
+
setBase64Mime("text/plain");
|
|
277
|
+
setDocuments([
|
|
278
|
+
createPreviewDocumentFromBase64({
|
|
279
|
+
base64: "data:text/plain;base64,SGVsbG8gRG9jIFByZXZpZXch",
|
|
280
|
+
fileName: "greeting.txt",
|
|
281
|
+
mimeType: "text/plain"
|
|
282
|
+
})
|
|
283
|
+
]);
|
|
284
|
+
}, children: "Sample text" })] })] }))] }), _jsxs("div", { className: "demo-sidebar__section demo-sidebar__section--enterprise", children: [_jsx("h3", { className: "demo-sidebar__heading", children: "Licence" }), _jsx("div", { className: "demo-tier-status", children: isEnterpriseLicensed ? (_jsx("span", { className: "demo-enterprise-badge", children: "Enterprise" })) : (_jsx("span", { className: "demo-community-badge", children: "Community" })) }), _jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "Licence key" }), _jsx("input", { className: "demo-field__input demo-field__input--mono", type: "text", value: licenseKeyInput, onChange: (e) => setLicenseKeyInput(e.target.value), placeholder: "DP-ENT-\u2026", spellCheck: false, autoComplete: "off" })] }), _jsxs("div", { className: "demo-btn-row demo-license-actions", children: [_jsx("button", { type: "button", className: "btn brand", onClick: applyLicenseKey, children: "Use licence key" }), _jsx("button", { type: "button", className: "btn", onClick: clearLicenseKey, children: "Clear key" })] }), _jsx("button", { type: "button", className: "demo-demo-key-link", onClick: fillDemoLicenseKey, children: "Fill demo key" }), isEnterpriseLicensed ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "demo-feature-pills", children: ENTERPRISE_FEATURES.map((feature) => (_jsx("span", { className: "demo-feature-pill", children: feature }, feature))) }), _jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "Watermark text" }), _jsx("input", { className: "demo-field__input", type: "text", value: watermarkText, onChange: (e) => setWatermarkText(e.target.value), placeholder: "e.g. CONFIDENTIAL \u2014 leave empty to hide" })] }), _jsxs("label", { className: "demo-field", children: [_jsx("span", { className: "demo-field__label", children: "PDF password" }), _jsx("input", { className: "demo-field__input", type: "password", value: pdfPassword, onChange: (e) => setPdfPassword(e.target.value), placeholder: "Unlock modal if empty" })] }), _jsxs("label", { className: "demo-toggle", children: [_jsx("input", { type: "checkbox", checked: mockConversion, onChange: (e) => setMockConversion(e.target.checked) }), _jsx("span", { children: "Mock conversion API (.convertme files)" })] })] })) : (_jsx("p", { className: "demo-hint", children: "Community mode \u2014 basic preview only. Apply a licence key above for annotations, watermark, compare, and print." }))] }), _jsxs("div", { className: "demo-sidebar__section", children: [_jsx("h3", { className: "demo-sidebar__heading demo-sidebar__heading--community", children: "Community samples" }), COMMUNITY_SAMPLE_CATEGORIES.map((category) => (_jsxs("div", { children: [_jsx("p", { className: "demo-sample-category", children: category.label }), _jsx("ul", { className: "demo-sample-grid", children: category.samples.map((sample) => (_jsx("li", { children: _jsxs("button", { type: "button", className: `demo-sample-card demo-sample-card--community${isActiveSample(sample) ? " demo-sample-card--active" : ""}`, onClick: () => loadSample(sample), children: [_jsx("span", { className: "demo-sample-card__tier", children: "Community" }), _jsx("span", { className: "demo-sample-card__ext", children: sample.ext }), _jsx("span", { className: "demo-sample-card__name", children: sample.fileName }), _jsx("span", { className: "demo-sample-card__hint", children: sample.hint })] }) }, sample.fileName))) })] }, category.id)))] }), _jsxs("div", { className: "demo-sidebar__section demo-sidebar__section--enterprise", children: [_jsx("h3", { className: "demo-sidebar__heading demo-sidebar__heading--enterprise", children: "Enterprise samples" }), _jsx("p", { className: "demo-hint demo-hint--enterprise", children: "Requires an active licence key. Upload PNG/JPG for image signatures & rotate." }), ENTERPRISE_SAMPLE_CATEGORIES.map((category) => (_jsxs("div", { children: [_jsx("p", { className: "demo-sample-category", children: category.label }), _jsx("ul", { className: "demo-sample-grid", children: category.samples.map((sample) => (_jsx("li", { children: _jsxs("button", { type: "button", className: `demo-sample-card demo-sample-card--enterprise${isActiveSample(sample) ? " demo-sample-card--active" : ""}${!isEnterpriseLicensed ? " demo-sample-card--locked" : ""}`, onClick: () => loadSample(sample), children: [_jsx("span", { className: "demo-sample-card__tier", children: "Enterprise" }), _jsx("span", { className: "demo-sample-card__ext", children: sample.ext }), _jsx("span", { className: "demo-sample-card__name", children: sample.fileName }), _jsx("span", { className: "demo-sample-card__hint", children: sample.hint }), !isEnterpriseLicensed && (_jsx("span", { className: "demo-sample-card__lock", children: "Licence required for full features" }))] }) }, sample.fileName))) })] }, category.id)))] })] }), _jsxs("div", { className: "demo-stage-wrap", children: [_jsxs("header", { className: "demo-stage-header", children: [_jsxs("div", { className: "demo-stage-header__main", children: [_jsx("span", { className: "demo-stage-header__label", children: "Previewing" }), _jsx("strong", { className: "demo-stage-header__title", children: activeDocLabel })] }), _jsxs("div", { className: "demo-stage-header__meta", children: [_jsx("span", { className: phaseClass, children: phase }), isEnterpriseLicensed ? (_jsx("span", { className: "demo-enterprise-badge", children: "Enterprise" })) : (_jsx("span", { className: "demo-community-badge", children: "Community" })), _jsx("span", { className: "demo-source-badge", children: SOURCE_MODES.find((m) => m.id === sourceMode)?.label }), documents.length > 0 && (_jsx("button", { type: "button", className: "demo-stage-header__clear", onClick: clearDocument, children: "Clear" }))] })] }), _jsxs("div", { className: "demo-stage", children: [!documents.length && sourceMode === "upload" && (_jsxs("div", { className: "demo-stage-empty", children: [_jsx("p", { className: "demo-stage-empty__title", children: "Upload to preview" }), _jsx("p", { className: "demo-stage-empty__text", children: "Drag and drop a file below, or use the upload button in the toolbar." })] })), _jsx(DocPreview, { documents: documents, config: viewerConfig, enterpriseLicenseKey: activeLicenseKey, onPhaseChange: onPhase, onFilesSelected: (files) => {
|
|
285
|
+
if (files.length) {
|
|
286
|
+
setDocuments(createPreviewDocumentsFromFiles(files));
|
|
287
|
+
}
|
|
288
|
+
}, onDocumentClear: clearDocument })] })] })] }));
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=DemoReactApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DemoReactApp.js","sourceRoot":"","sources":["../src/DemoReactApp.tsx"],"names":[],"mapp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,EACpB,oBAAoB,EAAE,gBAAgB,EACtC,aAAa,EAAE,OAAO,EACtB,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;oCACzB,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;wCACjB,YAAY,CAAC,+BAA+B,CAAC,KAAK,CAAC,CAAC,CAAC;oCACvD,CAAC;gCACH,CAAC,EACD,eAAe,EAAE,aAAa,GAC9B,IACE,IACF,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
import { type PreviewHostOptions, type PreviewSlots, type PreviewThemeTokens } from "@doc-preview/core";
|
|
3
|
+
export type DocPreviewProps = PreviewHostOptions & {
|
|
4
|
+
dark?: boolean;
|
|
5
|
+
theme?: PreviewThemeTokens;
|
|
6
|
+
slots?: PreviewSlots;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
/** Demo / production key from @doc-preview/enterprise */
|
|
10
|
+
enterpriseLicenseKey?: string;
|
|
11
|
+
onEnterpriseStatusChange?: (licensed: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function DocPreview({ documents, activeIndex, config, requestHeaders, prefetchMethod, onPhaseChange, onDocumentChange, onFilesSelected, onDocumentClear, dark, theme, slots, className, style, enterpriseLicenseKey, onEnterpriseStatusChange }: DocPreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=DocPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocPreview.d.ts","sourceRoot":"","sources":["../src/DocPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAO3B,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yDAAyD;IACzD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wBAAwB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CACxD,CAAC;AA8BF,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,WAAW,EACX,MAAM,EACN,cAAc,EACd,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,IAAI,EACJ,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,oBAAyB,EACzB,wBAAwB,EACzB,EAAE,eAAe,2CA8FjB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { createPreviewApi, mountPreviewTree, renderPreviewTree, NO_PREVIEW_ENTERPRISE_FLAGS } from "@doc-preview/core";
|
|
4
|
+
import { clearEnterpriseLicense, getEnterpriseFeatureFlags, registerEnterpriseLicenseFromPredefinedKey } from "@doc-preview/enterprise";
|
|
5
|
+
function toPreviewEnterpriseFlags() {
|
|
6
|
+
const f = getEnterpriseFeatureFlags();
|
|
7
|
+
return {
|
|
8
|
+
canAnnotations: f.canAnnotations,
|
|
9
|
+
canWatermark: f.canWatermark,
|
|
10
|
+
canSplitView: f.canSplitView,
|
|
11
|
+
canPasswordPdf: f.canPasswordPdf,
|
|
12
|
+
canPrintWithWatermark: f.canPrintWithWatermark,
|
|
13
|
+
canSearchInDocument: f.canSearchInDocument,
|
|
14
|
+
canRedaction: f.canRedaction,
|
|
15
|
+
canDocumentDiff: f.canDocumentDiff
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function documentsKey(documents) {
|
|
19
|
+
return JSON.stringify(documents.map((d) => ({
|
|
20
|
+
uri: d.uri,
|
|
21
|
+
fileName: d.fileName,
|
|
22
|
+
fileType: d.fileType,
|
|
23
|
+
mimeType: d.mimeType,
|
|
24
|
+
base64Len: d.base64?.length,
|
|
25
|
+
fileSize: d.file?.size,
|
|
26
|
+
arrayBufferLen: d.arrayBuffer?.byteLength
|
|
27
|
+
})));
|
|
28
|
+
}
|
|
29
|
+
export function DocPreview({ documents, activeIndex, config, requestHeaders, prefetchMethod, onPhaseChange, onDocumentChange, onFilesSelected, onDocumentClear, dark, theme, slots, className, style, enterpriseLicenseKey = "", onEnterpriseStatusChange }) {
|
|
30
|
+
const mountRef = useRef(null);
|
|
31
|
+
const apiRef = useRef(null);
|
|
32
|
+
const [, tick] = useState(0);
|
|
33
|
+
const refresh = () => tick((n) => n + 1);
|
|
34
|
+
const docsKey = useMemo(() => documentsKey(documents), [documents]);
|
|
35
|
+
const enterpriseFlags = useMemo(() => {
|
|
36
|
+
const key = enterpriseLicenseKey.trim();
|
|
37
|
+
if (key) {
|
|
38
|
+
registerEnterpriseLicenseFromPredefinedKey(key);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
clearEnterpriseLicense();
|
|
42
|
+
}
|
|
43
|
+
const flags = key ? toPreviewEnterpriseFlags() : NO_PREVIEW_ENTERPRISE_FLAGS;
|
|
44
|
+
return flags;
|
|
45
|
+
}, [enterpriseLicenseKey]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
onEnterpriseStatusChange?.(Boolean(enterpriseLicenseKey.trim()));
|
|
48
|
+
}, [enterpriseLicenseKey, onEnterpriseStatusChange]);
|
|
49
|
+
const api = useMemo(() => {
|
|
50
|
+
const next = createPreviewApi({
|
|
51
|
+
documents,
|
|
52
|
+
activeIndex,
|
|
53
|
+
config,
|
|
54
|
+
requestHeaders,
|
|
55
|
+
prefetchMethod,
|
|
56
|
+
onPhaseChange,
|
|
57
|
+
onDocumentChange
|
|
58
|
+
}, refresh);
|
|
59
|
+
return next;
|
|
60
|
+
}, [
|
|
61
|
+
docsKey,
|
|
62
|
+
activeIndex,
|
|
63
|
+
config,
|
|
64
|
+
requestHeaders,
|
|
65
|
+
prefetchMethod,
|
|
66
|
+
onPhaseChange,
|
|
67
|
+
onDocumentChange
|
|
68
|
+
]);
|
|
69
|
+
apiRef.current = api;
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const el = mountRef.current;
|
|
72
|
+
if (!el || !apiRef.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
void mountPreviewTree({
|
|
76
|
+
host: el,
|
|
77
|
+
engine: apiRef.current.engine,
|
|
78
|
+
theme,
|
|
79
|
+
slots,
|
|
80
|
+
dark,
|
|
81
|
+
enterpriseFlags,
|
|
82
|
+
onFilesSelected,
|
|
83
|
+
onDocumentClear,
|
|
84
|
+
requestHeaders,
|
|
85
|
+
prefetchMethod
|
|
86
|
+
});
|
|
87
|
+
}, [api, theme, slots, dark, enterpriseFlags, onFilesSelected, onDocumentClear, requestHeaders, prefetchMethod]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const el = mountRef.current;
|
|
90
|
+
if (!el || !apiRef.current) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
renderPreviewTree({
|
|
94
|
+
host: el,
|
|
95
|
+
engine: apiRef.current.engine,
|
|
96
|
+
theme,
|
|
97
|
+
slots,
|
|
98
|
+
dark,
|
|
99
|
+
enterpriseFlags,
|
|
100
|
+
onFilesSelected,
|
|
101
|
+
onDocumentClear,
|
|
102
|
+
requestHeaders,
|
|
103
|
+
prefetchMethod
|
|
104
|
+
});
|
|
105
|
+
}, [api, theme, slots, dark, enterpriseFlags, onFilesSelected, onDocumentClear, requestHeaders, prefetchMethod]);
|
|
106
|
+
return (_jsx("div", { ref: mountRef, className: className ? `dp-react-host ${className}` : "dp-react-host", style: style }));
|
|
107
|
+
}
|
|
108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eAAe;YACf,eAAe;YACf,eAAe;YACf,cAAc;YACd,cAAc;SACf,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;IAEjH,OAAO,CACL,cACE,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,iBAAiB,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,EACrE,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo-mount.d.ts","sourceRoot":"","sources":["../src/demo-mount.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGzD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAItD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { DemoReactApp } from "./DemoReactApp.js";
|
|
4
|
+
export function mountDemoReact(host) {
|
|
5
|
+
const root = createRoot(host);
|
|
6
|
+
root.render(createElement(DemoReactApp));
|
|
7
|
+
return root;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=demo-mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo-mount.js","sourceRoot":"","sources":["../src/demo-mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,UAAU,cAAc,CAAC,IAAiB;IAC9C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChE,cAAc,mBAAmB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@doc-preview/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React wrapper for Doc Preview.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./demo-mount": {
|
|
14
|
+
"types": "./dist/demo-mount.d.ts",
|
|
15
|
+
"import": "./dist/demo-mount.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/rajkishorsahu89/doc-preview.git",
|
|
22
|
+
"directory": "packages/react"
|
|
23
|
+
},
|
|
24
|
+
"bugs": "https://github.com/rajkishorsahu89/doc-preview/issues",
|
|
25
|
+
"homepage": "https://doc-preview-app.vercel.app/",
|
|
26
|
+
"author": "Rajkishor Sahu (https://github.com/rajkishorsahu89/)",
|
|
27
|
+
"engines": { "node": ">=18" },
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json",
|
|
30
|
+
"prepack": "node ../../scripts/assert-pack-ready.mjs"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": { "@doc-preview/core": "^1.0.0" },
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
35
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
36
|
+
"@doc-preview/enterprise": "^1.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@doc-preview/enterprise": { "optional": true }
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@doc-preview/enterprise": "file:../enterprise",
|
|
43
|
+
"@types/react": "^18.3.0",
|
|
44
|
+
"@types/react-dom": "^18.3.0"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"doc-preview",
|
|
48
|
+
"react",
|
|
49
|
+
"react18",
|
|
50
|
+
"react19",
|
|
51
|
+
"document-viewer",
|
|
52
|
+
"file-preview",
|
|
53
|
+
"pdf",
|
|
54
|
+
"docx",
|
|
55
|
+
"annotations"
|
|
56
|
+
],
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"publishConfig": { "access": "public" }
|
|
59
|
+
}
|