@ghyassd/office-preview 0.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 +55 -0
- package/dist/assets/xlsxParser.worker-CUZcso8W.js +38 -0
- package/dist/index.es.js +392 -0
- package/dist/index.umd.js +105 -0
- package/dist/style.css +1 -0
- package/dist/xlsx-BopDBbWb.js +24176 -0
- package/package.json +40 -0
- package/src/index.d.ts +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @ghyassd/office-preview
|
|
2
|
+
|
|
3
|
+
Vue components for Office preview, focused on:
|
|
4
|
+
- Word (`doc/docx`) image or PDF preview
|
|
5
|
+
- Excel (`xls/xlsx`) sheet rendering with merged cell support
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @ghyassd/office-preview
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<template>
|
|
17
|
+
<OfficePreview :file="file" :adapter="adapter" />
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup>
|
|
21
|
+
import { OfficePreview } from '@ghyassd/office-preview';
|
|
22
|
+
import '@ghyassd/office-preview/style.css';
|
|
23
|
+
|
|
24
|
+
const file = {
|
|
25
|
+
name: 'report.xlsx',
|
|
26
|
+
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
27
|
+
url: '/api/file/preview/xxx'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const adapter = {
|
|
31
|
+
// Required for Excel
|
|
32
|
+
async getArrayBuffer(file) {
|
|
33
|
+
const res = await fetch(file.url);
|
|
34
|
+
return await res.arrayBuffer();
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// Required for Word
|
|
38
|
+
async getPageImages(file) {
|
|
39
|
+
const res = await fetch(`/api/file/convert-preview-images/${file.hash}`);
|
|
40
|
+
return await res.json();
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// Optional fallback
|
|
44
|
+
getPdfUrl(file) {
|
|
45
|
+
return `/api/file/convert-preview/${file.hash}`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Components
|
|
52
|
+
|
|
53
|
+
- `OfficePreview`: wrapper by file type
|
|
54
|
+
- `WordPreview`: word-only preview
|
|
55
|
+
- `ExcelPreview`: excel-only preview
|