@work-zhanguo/light-file-preview 0.0.7 → 0.0.9
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 +25 -1
- package/dist/SheetRenderer-CXOjo3C1.js +551 -0
- package/dist/{UnsupportedRenderer-8vWx7yB8.js → UnsupportedRenderer-DA6ZSyt7.js} +1 -1
- package/dist/{index-BNN8UXSN.js → index-CZ37tDnP.js} +1 -1
- package/dist/light-file-preview.js +1 -1
- package/dist/light-file-preview.umd.cjs +69 -69
- package/dist/standalone/light-file-preview.iife.js +91 -91
- package/dist/standalone/style.css +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/FilePreview.vue.d.ts +1 -1
- package/dist/vue2/{DocxRenderer-B9neMid7.js → DocxRenderer-pUvnG-5n.js} +1 -1
- package/dist/vue2/{PdfRenderer-iEictZ1C.js → PdfRenderer-BDChtpiV.js} +1 -1
- package/dist/vue2/SheetRenderer-BATFlzFf.js +551 -0
- package/dist/vue2/{TextRenderer-B8_BjhwJ.js → TextRenderer-Bg2LfLu7.js} +1 -1
- package/dist/vue2/{UnsupportedRenderer-WZYKdRc9.js → UnsupportedRenderer-CljMmiGZ.js} +1 -1
- package/dist/vue2/light-file-preview-vue2.js +1 -1
- package/dist/vue2/light-file-preview-vue2.umd.cjs +108 -108
- package/dist/vue2/{vue2-C2dNeAAJ.js → vue2-CNyOC3tL.js} +5 -3
- package/package.json +1 -1
- package/dist/SheetRenderer-D4Y1dYZX.js +0 -77
- package/dist/vue2/SheetRenderer-KITfWM9E.js +0 -77
package/README.md
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
用于业务系统里的附件预览,支持传入文件路径、远程地址和本地文件,接入方式尽量保持简单。
|
|
10
10
|
|
|
11
|
-
当前版本:`0.0.
|
|
11
|
+
当前版本:`0.0.9`
|
|
12
12
|
|
|
13
13
|
最近更新:
|
|
14
14
|
|
|
15
|
+
- `0.0.9`:优化 `xlsx` 图片锚点尺寸和裁切边界,补充更接近 Excel 的公式栏名字框与编辑条样式
|
|
16
|
+
- `0.0.8`:优化 `xlsx` 预览,补充工作表页签、首行首列编号区、冻结观感、单元格 hover / 选中高亮,并补充组件属性说明
|
|
15
17
|
- `0.0.7`:修复 Vue2 `vue-cli / webpack4` 项目引入 PDF 预览时报 `import.meta.url`、`process.getBuiltinModule` 解析错误
|
|
16
18
|
- `0.0.6`:修复 Vue2 `vue-cli / webpack4` 项目解析产物时报 `Unexpected token`,降低构建目标到 `es2018`
|
|
17
19
|
- `0.0.5`:修复 Vue2 `vue-cli / webpack4` 项目子路径入口解析失败,补充 `vue2.js` 和 `style.css` 兼容入口
|
|
@@ -81,6 +83,28 @@ import LightFilePreview from '@work-zhanguo/light-file-preview/vue2';
|
|
|
81
83
|
import '@work-zhanguo/light-file-preview/style.css';
|
|
82
84
|
```
|
|
83
85
|
|
|
86
|
+
## 组件属性
|
|
87
|
+
|
|
88
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
89
|
+
| --- | --- | --- | --- |
|
|
90
|
+
| `source` | `string \| File \| Blob` | - | 必填。支持远程 URL、本地 `File`、`Blob`。 |
|
|
91
|
+
| `fileName` | `string` | - | 自定义文件名,远程地址没有扩展名时建议传。 |
|
|
92
|
+
| `mode` | `'inline' \| 'dialog'` | `'inline'` | 直接预览或弹窗预览。 |
|
|
93
|
+
| `visible` | `boolean` | `true` | 弹窗模式下控制显示状态,可配合 `v-model:visible`。 |
|
|
94
|
+
| `loadingText` | `string` | `'文件加载中...'` | 加载提示文案。 |
|
|
95
|
+
| `textEncoding` | `string` | `'utf-8'` | 文本类文件读取编码。 |
|
|
96
|
+
| `maxTextBytes` | `number` | `2097152` | 文本预览最大读取字节数,默认 2MB。 |
|
|
97
|
+
| `maxSheetRows` | `number` | `200` | 表格预览最大展示行数。 |
|
|
98
|
+
| `maxSheetCols` | `number` | `50` | 表格预览最大展示列数。 |
|
|
99
|
+
| `pdfScale` | `number` | `1.35` | PDF 渲染缩放比例。 |
|
|
100
|
+
| `showToolbar` | `boolean` | `true` | 是否显示顶部工具栏。 |
|
|
101
|
+
| `dialogTitle` | `string` | `'文件预览'` | 预览标题兜底文案。 |
|
|
102
|
+
|
|
103
|
+
组件事件:
|
|
104
|
+
|
|
105
|
+
- `update:visible`:弹窗关闭时回传状态
|
|
106
|
+
- `error`:解析失败时返回错误对象
|
|
107
|
+
|
|
84
108
|
## 远程地址预览
|
|
85
109
|
|
|
86
110
|
通过 `window.open` 传入网络地址,直接打开新页面预览。建议同时传 `name`,这样扩展名识别更稳定。
|
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { defineComponent as kt, ref as L, computed as ke, onMounted as Nt, onBeforeUnmount as At, openBlock as d, createElementBlock as m, createElementVNode as u, Fragment as U, renderList as H, normalizeClass as pe, toDisplayString as b, createCommentVNode as Ne, createTextVNode as tt, normalizeStyle as M } from "vue";
|
|
2
|
+
import { r as Dt } from "./text-Bqxn_tMI.js";
|
|
3
|
+
const Et = { class: "lfp-document lfp-sheet" }, It = { class: "lfp-sheet__toolbar" }, Tt = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "lfp-sheet__tabs",
|
|
6
|
+
role: "tablist",
|
|
7
|
+
"aria-label": "工作表切换"
|
|
8
|
+
}, Ot = ["onClick"], Bt = { class: "lfp-sheet__tab-label" }, Ft = { class: "lfp-sheet__tab-meta" }, Vt = {
|
|
9
|
+
key: 1,
|
|
10
|
+
class: "lfp-sheet__summary"
|
|
11
|
+
}, Lt = { class: "lfp-sheet__summary-item" }, Ut = { class: "lfp-sheet__summary-item" }, Ht = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "lfp-sheet__formula-bar"
|
|
14
|
+
}, Mt = { class: "lfp-sheet__name-box" }, Wt = { class: "lfp-sheet__name-box-text" }, jt = { class: "lfp-sheet__formula-input" }, zt = { class: "lfp-sheet__formula-text" }, Pt = {
|
|
15
|
+
key: 1,
|
|
16
|
+
class: "lfp-hint"
|
|
17
|
+
}, Kt = {
|
|
18
|
+
key: 2,
|
|
19
|
+
class: "lfp-sheet__table-wrap"
|
|
20
|
+
}, Gt = { class: "lfp-sheet__grid" }, qt = { class: "lfp-sheet__table" }, Zt = { class: "lfp-sheet__header-row" }, Jt = ["rowspan", "colspan", "title", "onMouseenter", "onFocus", "onClick"], Qt = { class: "lfp-sheet__cell-text" }, Yt = {
|
|
21
|
+
class: "lfp-sheet__images",
|
|
22
|
+
"aria-hidden": "true"
|
|
23
|
+
}, Xt = ["src", "alt"], eo = {
|
|
24
|
+
key: 3,
|
|
25
|
+
class: "lfp-sheet__empty"
|
|
26
|
+
}, to = 32, oo = 20, W = 52, he = 40, He = 28, ot = 96, ro = /* @__PURE__ */ kt({
|
|
27
|
+
__name: "SheetRenderer",
|
|
28
|
+
props: {
|
|
29
|
+
source: {},
|
|
30
|
+
maxRows: {},
|
|
31
|
+
maxCols: {}
|
|
32
|
+
},
|
|
33
|
+
emits: ["loading", "error"],
|
|
34
|
+
setup(nt, { emit: st }) {
|
|
35
|
+
const Ae = nt, De = st, Me = new AbortController(), Ee = L(0), j = L([]), C = L(""), Ie = L(null), Te = L(null), Oe = L([]), c = ke(() => j.value[Ee.value]), We = ke(() => {
|
|
36
|
+
var t;
|
|
37
|
+
const e = c.value;
|
|
38
|
+
return !e || !C.value ? null : (t = e.cellMap[C.value]) != null ? t : null;
|
|
39
|
+
}), rt = ke(() => {
|
|
40
|
+
var e, t;
|
|
41
|
+
return (t = (e = We.value) == null ? void 0 : e.address) != null ? t : "A1";
|
|
42
|
+
}), lt = ke(() => {
|
|
43
|
+
const e = We.value;
|
|
44
|
+
return e ? e.formula ? `=${e.formula}` : e.value : "";
|
|
45
|
+
});
|
|
46
|
+
function je() {
|
|
47
|
+
for (const e of Oe.value)
|
|
48
|
+
URL.revokeObjectURL(e);
|
|
49
|
+
Oe.value = [];
|
|
50
|
+
}
|
|
51
|
+
function it(e) {
|
|
52
|
+
let t = e + 1, o = "";
|
|
53
|
+
for (; t > 0; ) {
|
|
54
|
+
const n = (t - 1) % 26;
|
|
55
|
+
o = String.fromCharCode(65 + n) + o, t = Math.floor((t - 1) / 26);
|
|
56
|
+
}
|
|
57
|
+
return o;
|
|
58
|
+
}
|
|
59
|
+
function z(e, t) {
|
|
60
|
+
Ie.value = e, Te.value = t;
|
|
61
|
+
}
|
|
62
|
+
function at(e) {
|
|
63
|
+
C.value = e;
|
|
64
|
+
}
|
|
65
|
+
function ze(e) {
|
|
66
|
+
Ee.value = e;
|
|
67
|
+
const t = j.value[e];
|
|
68
|
+
C.value = t ? `${t.firstVisibleRow}:${t.firstVisibleCol}` : "", z(null, null);
|
|
69
|
+
}
|
|
70
|
+
function Pe(e, t) {
|
|
71
|
+
return e != null && (e === Ie.value || e === Ke()) || t != null && (t === Te.value || t === Ge());
|
|
72
|
+
}
|
|
73
|
+
function Ke() {
|
|
74
|
+
if (!C.value)
|
|
75
|
+
return null;
|
|
76
|
+
const [e] = C.value.split(":");
|
|
77
|
+
return Number.isFinite(Number(e)) ? Number(e) : null;
|
|
78
|
+
}
|
|
79
|
+
function Ge() {
|
|
80
|
+
if (!C.value)
|
|
81
|
+
return null;
|
|
82
|
+
const [, e] = C.value.split(":");
|
|
83
|
+
return Number.isFinite(Number(e)) ? Number(e) : null;
|
|
84
|
+
}
|
|
85
|
+
function ct(e) {
|
|
86
|
+
if (e) {
|
|
87
|
+
if (["thin", "hair"].includes(e) || ["medium", "dashed", "dotted", "dashDot", "dashDotDot"].includes(e))
|
|
88
|
+
return "1px solid";
|
|
89
|
+
if (["thick", "double", "mediumDashed", "mediumDashDot", "mediumDashDotDot"].includes(e))
|
|
90
|
+
return "2px solid";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function ge(e) {
|
|
94
|
+
if (!e || typeof e != "object")
|
|
95
|
+
return;
|
|
96
|
+
const t = "rgb" in e && typeof e.rgb == "string" ? e.rgb : "argb" in e && typeof e.argb == "string" ? e.argb : void 0;
|
|
97
|
+
if (!t)
|
|
98
|
+
return;
|
|
99
|
+
const o = t.replace(/^#/, "");
|
|
100
|
+
if (/^[0-9a-fA-F]{8}$/.test(o))
|
|
101
|
+
return `#${o.slice(2)}`;
|
|
102
|
+
if (/^[0-9a-fA-F]{6}$/.test(o))
|
|
103
|
+
return `#${o}`;
|
|
104
|
+
}
|
|
105
|
+
function be(e, t, o) {
|
|
106
|
+
var s;
|
|
107
|
+
if (!o)
|
|
108
|
+
return;
|
|
109
|
+
const n = ct(o.style), r = (s = ge(o.color)) != null ? s : "rgba(31, 44, 61, 0.12)";
|
|
110
|
+
n && (t === "left" ? e.borderLeft = `${n} ${r}` : t === "right" ? e.borderRight = `${n} ${r}` : t === "top" ? e.borderTop = `${n} ${r}` : t === "bottom" && (e.borderBottom = `${n} ${r}`));
|
|
111
|
+
}
|
|
112
|
+
function qe(e) {
|
|
113
|
+
const t = typeof (e == null ? void 0 : e.hpx) == "number" ? e.hpx : typeof (e == null ? void 0 : e.hpt) == "number" ? e.hpt * 1.3334 : void 0;
|
|
114
|
+
return Math.max(t != null ? t : He, He);
|
|
115
|
+
}
|
|
116
|
+
function ut(e) {
|
|
117
|
+
return { height: `${qe(e)}px` };
|
|
118
|
+
}
|
|
119
|
+
function Ze(e) {
|
|
120
|
+
return typeof (e == null ? void 0 : e.wpx) == "number" ? Math.max(e.wpx, 72) : typeof (e == null ? void 0 : e.width) == "number" ? Math.max(e.width * 8, 72) : ot;
|
|
121
|
+
}
|
|
122
|
+
function Je(e) {
|
|
123
|
+
return `${Ze(e)}px`;
|
|
124
|
+
}
|
|
125
|
+
function ft(e) {
|
|
126
|
+
if (!e)
|
|
127
|
+
return {};
|
|
128
|
+
const t = {};
|
|
129
|
+
return e.horizontal && (t.textAlign = e.horizontal), e.vertical && (t.verticalAlign = e.vertical === "center" ? "middle" : e.vertical), e.wrapText && (t.whiteSpace = "pre-wrap", t.wordBreak = "break-word"), t;
|
|
130
|
+
}
|
|
131
|
+
function dt(e, t, o) {
|
|
132
|
+
var f;
|
|
133
|
+
const n = {};
|
|
134
|
+
if (o ? (n.minWidth = o, n.width = o) : t && (n.minWidth = t, n.width = t), !(e != null && e.s) || typeof e.s != "object")
|
|
135
|
+
return n;
|
|
136
|
+
const r = e.s.fill, s = e.s.font, l = e.s.border, a = (f = ge(r == null ? void 0 : r.fgColor)) != null ? f : ge(r == null ? void 0 : r.bgColor), h = ge(s == null ? void 0 : s.color);
|
|
137
|
+
return a && (r == null ? void 0 : r.patternType) !== "none" && (n.backgroundColor = a), h && (n.color = h), s != null && s.bold && (n.fontWeight = "700"), s != null && s.italic && (n.fontStyle = "italic"), s != null && s.underline && (n.textDecoration = "underline"), typeof (s == null ? void 0 : s.sz) == "number" && (n.fontSize = `${s.sz}px`), typeof (s == null ? void 0 : s.name) == "string" && s.name.trim() && (n.fontFamily = s.name), Object.assign(n, ft(e.s.alignment)), be(n, "left", l == null ? void 0 : l.left), be(n, "right", l == null ? void 0 : l.right), be(n, "top", l == null ? void 0 : l.top), be(n, "bottom", l == null ? void 0 : l.bottom), n;
|
|
138
|
+
}
|
|
139
|
+
function mt(e, t) {
|
|
140
|
+
var o, n;
|
|
141
|
+
return t ? typeof t.w == "string" ? t.w : (o = e.utils) != null && o.format_cell ? String(e.utils.format_cell(t, (n = t.v) != null ? n : "")) : t.v != null ? String(t.v) : typeof t.f == "string" && t.f.trim() ? `=${t.f}` : "" : "";
|
|
142
|
+
}
|
|
143
|
+
function pt(e, t, o) {
|
|
144
|
+
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
|
|
145
|
+
for (const s of e) {
|
|
146
|
+
const l = t.filter((f) => f >= s.s.r && f <= s.e.r), a = o.filter((f) => f >= s.s.c && f <= s.e.c);
|
|
147
|
+
if (!l.length || !a.length)
|
|
148
|
+
continue;
|
|
149
|
+
const h = `${s.s.r}:${s.s.c}`;
|
|
150
|
+
r.set(h, {
|
|
151
|
+
rowSpan: l.length,
|
|
152
|
+
colSpan: a.length,
|
|
153
|
+
colsInRange: a
|
|
154
|
+
});
|
|
155
|
+
for (const f of l)
|
|
156
|
+
for (const _ of a)
|
|
157
|
+
f === s.s.r && _ === s.s.c || n.add(`${f}:${_}`);
|
|
158
|
+
}
|
|
159
|
+
return { coveredCells: n, mergeStarts: r };
|
|
160
|
+
}
|
|
161
|
+
function Qe(e) {
|
|
162
|
+
return e ? e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : typeof e == "string" ? new TextEncoder().encode(e) : null : null;
|
|
163
|
+
}
|
|
164
|
+
function ve(e) {
|
|
165
|
+
if (!e)
|
|
166
|
+
return "";
|
|
167
|
+
if (typeof e == "string")
|
|
168
|
+
return e;
|
|
169
|
+
const t = Qe(e);
|
|
170
|
+
return t ? new TextDecoder("utf-8").decode(t) : "";
|
|
171
|
+
}
|
|
172
|
+
function _e(e) {
|
|
173
|
+
if (!e.trim())
|
|
174
|
+
return null;
|
|
175
|
+
const t = new DOMParser().parseFromString(e, "application/xml");
|
|
176
|
+
return t.querySelector("parsererror") ? null : t;
|
|
177
|
+
}
|
|
178
|
+
function ye(e, t) {
|
|
179
|
+
var o;
|
|
180
|
+
return e && (o = Array.from(e.children).find((n) => n.localName === t)) != null ? o : null;
|
|
181
|
+
}
|
|
182
|
+
function Be(e, t) {
|
|
183
|
+
var o;
|
|
184
|
+
return e && (o = Array.from(e.getElementsByTagName("*")).find((n) => n.localName === t)) != null ? o : null;
|
|
185
|
+
}
|
|
186
|
+
function S(e, t) {
|
|
187
|
+
var r, s;
|
|
188
|
+
const o = (s = (r = ye(e, t)) == null ? void 0 : r.textContent) != null ? s : "", n = Number.parseInt(o, 10);
|
|
189
|
+
return Number.isFinite(n) ? n : 0;
|
|
190
|
+
}
|
|
191
|
+
function Ye(e) {
|
|
192
|
+
const t = e.lastIndexOf("/"), o = t >= 0 ? e.slice(0, t) : "", n = t >= 0 ? e.slice(t + 1) : e;
|
|
193
|
+
return `${o}/_rels/${n}.rels`;
|
|
194
|
+
}
|
|
195
|
+
function Fe(e, t) {
|
|
196
|
+
if (!t)
|
|
197
|
+
return e;
|
|
198
|
+
const o = e.split("/");
|
|
199
|
+
o.pop();
|
|
200
|
+
const n = t.split("/");
|
|
201
|
+
for (const r of n)
|
|
202
|
+
!r || r === "." || (r === ".." ? o.pop() : o.push(r));
|
|
203
|
+
return o.join("/");
|
|
204
|
+
}
|
|
205
|
+
function Ve(e, t) {
|
|
206
|
+
var s;
|
|
207
|
+
const o = ve((s = e[t]) == null ? void 0 : s.content), n = _e(o);
|
|
208
|
+
if (!n)
|
|
209
|
+
return {};
|
|
210
|
+
const r = {};
|
|
211
|
+
for (const l of Array.from(n.getElementsByTagName("*"))) {
|
|
212
|
+
if (l.localName !== "Relationship")
|
|
213
|
+
continue;
|
|
214
|
+
const a = l.getAttribute("Id"), h = l.getAttribute("Target");
|
|
215
|
+
a && h && (r[a] = h);
|
|
216
|
+
}
|
|
217
|
+
return r;
|
|
218
|
+
}
|
|
219
|
+
function ht(e) {
|
|
220
|
+
var r;
|
|
221
|
+
const t = "xl/workbook.xml", o = _e(ve((r = e[t]) == null ? void 0 : r.content));
|
|
222
|
+
if (!o)
|
|
223
|
+
return [];
|
|
224
|
+
const n = Ve(e, "xl/_rels/workbook.xml.rels");
|
|
225
|
+
return Array.from(o.getElementsByTagName("*")).filter((s) => s.localName === "sheet").map((s) => {
|
|
226
|
+
var a, h, f, _;
|
|
227
|
+
const l = (h = (a = s.getAttribute("r:id")) != null ? a : s.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id")) != null ? h : "";
|
|
228
|
+
return {
|
|
229
|
+
name: (f = s.getAttribute("name")) != null ? f : "",
|
|
230
|
+
path: Fe(t, (_ = n[l]) != null ? _ : "")
|
|
231
|
+
};
|
|
232
|
+
}).filter((s) => s.name && s.path);
|
|
233
|
+
}
|
|
234
|
+
function gt(e) {
|
|
235
|
+
var o;
|
|
236
|
+
const t = (o = e.split(".").pop()) == null ? void 0 : o.toLowerCase();
|
|
237
|
+
return t === "png" ? "image/png" : t === "jpg" || t === "jpeg" ? "image/jpeg" : t === "gif" ? "image/gif" : t === "webp" ? "image/webp" : t === "svg" ? "image/svg+xml" : "application/octet-stream";
|
|
238
|
+
}
|
|
239
|
+
function O(e) {
|
|
240
|
+
return e / 9525;
|
|
241
|
+
}
|
|
242
|
+
function we(e, t, o, n) {
|
|
243
|
+
var s;
|
|
244
|
+
let r = n;
|
|
245
|
+
for (let l = 0; l < e.length; l += 1) {
|
|
246
|
+
if (e[l] === o)
|
|
247
|
+
return r;
|
|
248
|
+
r += (s = t[l]) != null ? s : 0;
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
function xe(e, t, o) {
|
|
253
|
+
return Math.min(Math.max(e, t), o);
|
|
254
|
+
}
|
|
255
|
+
function bt(e, t, o, n, r, s) {
|
|
256
|
+
var Re, J, Q, Y, X, ee, te, oe, ne, se, re, le, ie;
|
|
257
|
+
const l = _e(ve((Re = e[t]) == null ? void 0 : Re.content));
|
|
258
|
+
if (!l)
|
|
259
|
+
return [];
|
|
260
|
+
const a = Array.from(l.getElementsByTagName("*")).find((p) => p.localName === "drawing");
|
|
261
|
+
if (!a)
|
|
262
|
+
return [];
|
|
263
|
+
const h = (Q = (J = a.getAttribute("r:id")) != null ? J : a.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id")) != null ? Q : "";
|
|
264
|
+
if (!h)
|
|
265
|
+
return [];
|
|
266
|
+
const f = Ve(e, Ye(t)), _ = Fe(t, (Y = f[h]) != null ? Y : ""), x = _e(ve((X = e[_]) == null ? void 0 : X.content));
|
|
267
|
+
if (!x)
|
|
268
|
+
return [];
|
|
269
|
+
const $ = Ve(e, Ye(_)), P = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map();
|
|
270
|
+
let G = W, q = he;
|
|
271
|
+
n.forEach((p, R) => {
|
|
272
|
+
var g;
|
|
273
|
+
P.set(p, G), G += (g = s[R]) != null ? g : ot;
|
|
274
|
+
}), o.forEach((p, R) => {
|
|
275
|
+
var g;
|
|
276
|
+
K.set(p, q), q += (g = r[R]) != null ? g : He;
|
|
277
|
+
});
|
|
278
|
+
const Z = G, B = q, Ce = [], $e = Array.from(x.getElementsByTagName("*")).filter(
|
|
279
|
+
(p) => ["oneCellAnchor", "twoCellAnchor"].includes(p.localName)
|
|
280
|
+
);
|
|
281
|
+
for (const p of $e) {
|
|
282
|
+
const R = Be(p, "pic"), g = Be(R, "blip"), i = (te = (ee = g == null ? void 0 : g.getAttribute("r:embed")) != null ? ee : g == null ? void 0 : g.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed")) != null ? te : "";
|
|
283
|
+
if (!i)
|
|
284
|
+
continue;
|
|
285
|
+
const ae = Fe(_, (oe = $[i]) != null ? oe : ""), A = Qe((ne = e[ae]) == null ? void 0 : ne.content);
|
|
286
|
+
if (!A)
|
|
287
|
+
continue;
|
|
288
|
+
const D = ye(p, "from"), ce = S(D, "col"), ue = S(D, "row"), fe = we(n, s, ce, W), de = we(o, r, ue, he);
|
|
289
|
+
if (fe == null || de == null)
|
|
290
|
+
continue;
|
|
291
|
+
const Se = O(S(D, "colOff")), E = O(S(D, "rowOff")), k = fe + Se, I = de + E;
|
|
292
|
+
let y = 160, v = 120;
|
|
293
|
+
if (p.localName === "twoCellAnchor") {
|
|
294
|
+
const w = ye(p, "to"), wt = S(w, "col"), xt = S(w, "row"), Ct = O(S(w, "colOff")), $t = O(S(w, "rowOff")), Le = we(n, s, wt, W), Ue = we(o, r, xt, he), Rt = (Le != null ? Le : Z) + Ct, St = (Ue != null ? Ue : B) + $t;
|
|
295
|
+
y = Math.max(Rt - k, 32), v = Math.max(St - I, 32);
|
|
296
|
+
} else {
|
|
297
|
+
const w = ye(p, "ext");
|
|
298
|
+
y = Math.max(O(Number.parseInt((se = w == null ? void 0 : w.getAttribute("cx")) != null ? se : "0", 10)), 32), v = Math.max(O(Number.parseInt((re = w == null ? void 0 : w.getAttribute("cy")) != null ? re : "0", 10)), 32);
|
|
299
|
+
}
|
|
300
|
+
const F = xe(k, W, Z), T = xe(I, he, B), N = xe(k + y, W, Z), V = xe(I + v, he, B), me = N - F, Xe = V - T;
|
|
301
|
+
if (me <= 6 || Xe <= 6)
|
|
302
|
+
continue;
|
|
303
|
+
const yt = A.buffer.slice(
|
|
304
|
+
A.byteOffset,
|
|
305
|
+
A.byteOffset + A.byteLength
|
|
306
|
+
), et = URL.createObjectURL(new Blob([yt], { type: gt(ae) }));
|
|
307
|
+
Oe.value.push(et), Ce.push({
|
|
308
|
+
key: `${t}-${ue}-${ce}-${ae}`,
|
|
309
|
+
src: et,
|
|
310
|
+
alt: (ie = (le = Be(R, "cNvPr")) == null ? void 0 : le.getAttribute("name")) != null ? ie : "embedded image",
|
|
311
|
+
left: F,
|
|
312
|
+
top: T,
|
|
313
|
+
width: me,
|
|
314
|
+
height: Xe,
|
|
315
|
+
frameStyle: {
|
|
316
|
+
transform: `translate(${F - k}px, ${T - I}px)`,
|
|
317
|
+
width: `${y}px`,
|
|
318
|
+
height: `${v}px`
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return Ce;
|
|
323
|
+
}
|
|
324
|
+
function vt(e, t, o, n, r) {
|
|
325
|
+
var J, Q, Y, X, ee, te, oe, ne, se, re, le, ie, p, R, g;
|
|
326
|
+
const s = (J = o["!ref"]) != null ? J : "A1", l = e.utils.decode_range(s), a = Math.max(Math.min(Ae.maxRows, Math.max(l.e.r + 1, to)), 1), h = Math.max(Math.min(Ae.maxCols, Math.max(l.e.c + 1, oo)), 1), f = [], _ = [], x = [], $ = [], P = [], K = [];
|
|
327
|
+
for (let i = 0; i <= l.e.r; i += 1)
|
|
328
|
+
(Y = (Q = o["!rows"]) == null ? void 0 : Q[i]) != null && Y.hidden || f.push(i);
|
|
329
|
+
for (let i = 0; i <= l.e.c; i += 1)
|
|
330
|
+
(ee = (X = o["!cols"]) == null ? void 0 : X[i]) != null && ee.hidden || _.push(i);
|
|
331
|
+
for (let i = 0; i < a; i += 1)
|
|
332
|
+
(oe = (te = o["!rows"]) == null ? void 0 : te[i]) != null && oe.hidden || (x.push(i), P.push(qe((ne = o["!rows"]) == null ? void 0 : ne[i])));
|
|
333
|
+
for (let i = 0; i < h; i += 1)
|
|
334
|
+
(re = (se = o["!cols"]) == null ? void 0 : se[i]) != null && re.hidden || ($.push(i), K.push(Ze((le = o["!cols"]) == null ? void 0 : le[i])));
|
|
335
|
+
const G = (ie = o["!merges"]) != null ? ie : [], { coveredCells: q, mergeStarts: Z } = pt(G, x, $), B = {}, Ce = x.map((i) => {
|
|
336
|
+
var ce, ue, fe, de, Se;
|
|
337
|
+
const ae = (ce = o["!rows"]) == null ? void 0 : ce[i], A = ut(ae), D = [];
|
|
338
|
+
for (const E of $) {
|
|
339
|
+
const k = `${i}:${E}`;
|
|
340
|
+
if (q.has(k))
|
|
341
|
+
continue;
|
|
342
|
+
const I = e.utils.encode_cell({ r: i, c: E }), y = o[I], v = Z.get(k), F = ((ue = v == null ? void 0 : v.colsInRange) != null ? ue : [E]).map((N) => {
|
|
343
|
+
var V;
|
|
344
|
+
return Je((V = o["!cols"]) == null ? void 0 : V[N]);
|
|
345
|
+
}).filter(Boolean).reduce((N, V) => {
|
|
346
|
+
const me = Number.parseFloat(V);
|
|
347
|
+
return Number.isFinite(me) ? (N != null ? N : 0) + me : N;
|
|
348
|
+
}, null), T = {
|
|
349
|
+
key: k,
|
|
350
|
+
address: I,
|
|
351
|
+
value: mt(e, y),
|
|
352
|
+
formula: typeof (y == null ? void 0 : y.f) == "string" ? y.f : "",
|
|
353
|
+
rowIndex: i,
|
|
354
|
+
colIndex: E,
|
|
355
|
+
rowSpan: (fe = v == null ? void 0 : v.rowSpan) != null ? fe : 1,
|
|
356
|
+
colSpan: (de = v == null ? void 0 : v.colSpan) != null ? de : 1,
|
|
357
|
+
style: dt(
|
|
358
|
+
y,
|
|
359
|
+
Je((Se = o["!cols"]) == null ? void 0 : Se[E]),
|
|
360
|
+
F ? `${F}px` : void 0
|
|
361
|
+
)
|
|
362
|
+
};
|
|
363
|
+
D.push(T), B[T.key] = T;
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
key: `${t}-${i}`,
|
|
367
|
+
rowIndex: i,
|
|
368
|
+
cells: D,
|
|
369
|
+
style: A
|
|
370
|
+
};
|
|
371
|
+
}), $e = (p = r[t]) != null ? p : "", Re = $e ? bt(n, $e, x, $, P, K) : [];
|
|
372
|
+
return {
|
|
373
|
+
name: t,
|
|
374
|
+
rows: Ce,
|
|
375
|
+
totalRows: f.length,
|
|
376
|
+
totalCols: _.length,
|
|
377
|
+
visibleRows: x.length,
|
|
378
|
+
visibleCols: $.length,
|
|
379
|
+
visibleRowIndexes: x,
|
|
380
|
+
visibleColIndexes: $,
|
|
381
|
+
firstVisibleRow: (R = x[0]) != null ? R : 0,
|
|
382
|
+
firstVisibleCol: (g = $[0]) != null ? g : 0,
|
|
383
|
+
rowHeights: P,
|
|
384
|
+
colWidths: K,
|
|
385
|
+
images: Re,
|
|
386
|
+
cellMap: B
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
async function _t() {
|
|
390
|
+
var e;
|
|
391
|
+
De("loading", !0), je();
|
|
392
|
+
try {
|
|
393
|
+
const t = await Dt(Ae.source, Me.signal), o = await import("./xlsx-j9Zzywas.js"), n = o.read(t, {
|
|
394
|
+
type: "array",
|
|
395
|
+
cellStyles: !0,
|
|
396
|
+
cellNF: !0,
|
|
397
|
+
cellText: !0,
|
|
398
|
+
cellFormula: !0,
|
|
399
|
+
bookFiles: !0
|
|
400
|
+
}), r = (e = n.files) != null ? e : {}, s = ht(r), l = Object.fromEntries(s.map((a) => [a.name, a.path]));
|
|
401
|
+
j.value = n.SheetNames.map(
|
|
402
|
+
(a) => vt(
|
|
403
|
+
o,
|
|
404
|
+
a,
|
|
405
|
+
n.Sheets[a],
|
|
406
|
+
r,
|
|
407
|
+
l
|
|
408
|
+
)
|
|
409
|
+
), ze(0);
|
|
410
|
+
} catch (t) {
|
|
411
|
+
De("error", t instanceof Error ? t : new Error("表格预览失败"));
|
|
412
|
+
} finally {
|
|
413
|
+
De("loading", !1);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return Nt(() => {
|
|
417
|
+
_t();
|
|
418
|
+
}), At(() => {
|
|
419
|
+
Me.abort(), je();
|
|
420
|
+
}), (e, t) => (d(), m("div", Et, [
|
|
421
|
+
u("div", It, [
|
|
422
|
+
j.value.length > 1 ? (d(), m("div", Tt, [
|
|
423
|
+
(d(!0), m(U, null, H(j.value, (o, n) => (d(), m("button", {
|
|
424
|
+
key: o.name,
|
|
425
|
+
class: pe(["lfp-sheet__tab", { "is-active": n === Ee.value }]),
|
|
426
|
+
type: "button",
|
|
427
|
+
onClick: (r) => ze(n)
|
|
428
|
+
}, [
|
|
429
|
+
u("span", Bt, b(o.name), 1),
|
|
430
|
+
u("span", Ft, b(o.totalRows) + " × " + b(o.totalCols), 1)
|
|
431
|
+
], 10, Ot))), 128))
|
|
432
|
+
])) : Ne("", !0),
|
|
433
|
+
c.value ? (d(), m("div", Vt, [
|
|
434
|
+
u("span", Lt, [
|
|
435
|
+
t[2] || (t[2] = tt(" 当前工作表 ", -1)),
|
|
436
|
+
u("strong", null, b(c.value.name), 1)
|
|
437
|
+
]),
|
|
438
|
+
u("span", Ut, [
|
|
439
|
+
t[3] || (t[3] = tt(" 总览 ", -1)),
|
|
440
|
+
u("strong", null, b(c.value.totalRows) + " 行 / " + b(c.value.totalCols) + " 列", 1)
|
|
441
|
+
])
|
|
442
|
+
])) : Ne("", !0)
|
|
443
|
+
]),
|
|
444
|
+
c.value ? (d(), m("div", Ht, [
|
|
445
|
+
u("span", Mt, [
|
|
446
|
+
u("span", Wt, b(rt.value), 1),
|
|
447
|
+
t[4] || (t[4] = u("span", {
|
|
448
|
+
class: "lfp-sheet__name-box-caret",
|
|
449
|
+
"aria-hidden": "true"
|
|
450
|
+
}, null, -1))
|
|
451
|
+
]),
|
|
452
|
+
u("div", jt, [
|
|
453
|
+
t[5] || (t[5] = u("span", { class: "lfp-sheet__formula-label" }, "fx", -1)),
|
|
454
|
+
u("span", zt, b(lt.value), 1)
|
|
455
|
+
])
|
|
456
|
+
])) : Ne("", !0),
|
|
457
|
+
c.value ? (d(), m("p", Pt, " 共 " + b(c.value.totalRows) + " 行," + b(c.value.totalCols) + " 列。当前展示 " + b(c.value.visibleRows) + " 行、" + b(c.value.visibleCols) + " 列。 ", 1)) : Ne("", !0),
|
|
458
|
+
c.value ? (d(), m("div", Kt, [
|
|
459
|
+
u("div", Gt, [
|
|
460
|
+
u("table", qt, [
|
|
461
|
+
u("colgroup", null, [
|
|
462
|
+
u("col", {
|
|
463
|
+
style: M({ width: `${W}px` })
|
|
464
|
+
}, null, 4),
|
|
465
|
+
(d(!0), m(U, null, H(c.value.colWidths, (o, n) => (d(), m("col", {
|
|
466
|
+
key: `col-width-${c.value.visibleColIndexes[n]}`,
|
|
467
|
+
style: M({ width: `${o}px` })
|
|
468
|
+
}, null, 4))), 128))
|
|
469
|
+
]),
|
|
470
|
+
u("tbody", null, [
|
|
471
|
+
u("tr", Zt, [
|
|
472
|
+
t[6] || (t[6] = u("th", {
|
|
473
|
+
class: "lfp-sheet__corner-header",
|
|
474
|
+
scope: "col",
|
|
475
|
+
"aria-label": "表格左上角"
|
|
476
|
+
}, null, -1)),
|
|
477
|
+
(d(!0), m(U, null, H(c.value.visibleColIndexes, (o) => (d(), m("th", {
|
|
478
|
+
key: `col-header-${o}`,
|
|
479
|
+
class: pe(["lfp-sheet__col-header", {
|
|
480
|
+
"is-first-data-col": o === c.value.firstVisibleCol,
|
|
481
|
+
"is-related": Pe(null, o)
|
|
482
|
+
}]),
|
|
483
|
+
scope: "col"
|
|
484
|
+
}, b(it(o)), 3))), 128))
|
|
485
|
+
]),
|
|
486
|
+
(d(!0), m(U, null, H(c.value.rows, (o) => (d(), m("tr", {
|
|
487
|
+
key: o.key,
|
|
488
|
+
class: pe(["lfp-sheet__row", { "is-first-row": o.rowIndex === c.value.firstVisibleRow }]),
|
|
489
|
+
style: M(o.style)
|
|
490
|
+
}, [
|
|
491
|
+
u("th", {
|
|
492
|
+
class: pe(["lfp-sheet__row-header", {
|
|
493
|
+
"is-first-data-row": o.rowIndex === c.value.firstVisibleRow,
|
|
494
|
+
"is-related": Pe(o.rowIndex, null)
|
|
495
|
+
}]),
|
|
496
|
+
scope: "row"
|
|
497
|
+
}, b(o.rowIndex + 1), 3),
|
|
498
|
+
(d(!0), m(U, null, H(o.cells, (n) => (d(), m("td", {
|
|
499
|
+
key: n.key,
|
|
500
|
+
class: pe({
|
|
501
|
+
"is-first-row": n.rowIndex === c.value.firstVisibleRow,
|
|
502
|
+
"is-first-col": n.colIndex === c.value.firstVisibleCol,
|
|
503
|
+
"is-corner-cell": n.rowIndex === c.value.firstVisibleRow && n.colIndex === c.value.firstVisibleCol,
|
|
504
|
+
"is-selected": C.value === n.key,
|
|
505
|
+
"is-row-active": Ie.value === n.rowIndex || Ke() === n.rowIndex,
|
|
506
|
+
"is-col-active": Te.value === n.colIndex || Ge() === n.colIndex,
|
|
507
|
+
"is-formula-cell": !!n.formula
|
|
508
|
+
}),
|
|
509
|
+
rowspan: n.rowSpan,
|
|
510
|
+
colspan: n.colSpan,
|
|
511
|
+
style: M(n.style),
|
|
512
|
+
title: n.formula ? `=${n.formula}` : n.value,
|
|
513
|
+
tabindex: "0",
|
|
514
|
+
onMouseenter: (r) => z(n.rowIndex, n.colIndex),
|
|
515
|
+
onMouseleave: t[0] || (t[0] = (r) => z(null, null)),
|
|
516
|
+
onFocus: (r) => z(n.rowIndex, n.colIndex),
|
|
517
|
+
onBlur: t[1] || (t[1] = (r) => z(null, null)),
|
|
518
|
+
onClick: (r) => at(n.key)
|
|
519
|
+
}, [
|
|
520
|
+
u("span", Qt, b(n.value), 1)
|
|
521
|
+
], 46, Jt))), 128))
|
|
522
|
+
], 6))), 128))
|
|
523
|
+
])
|
|
524
|
+
]),
|
|
525
|
+
u("div", Yt, [
|
|
526
|
+
(d(!0), m(U, null, H(c.value.images, (o) => (d(), m("div", {
|
|
527
|
+
key: o.key,
|
|
528
|
+
style: M({
|
|
529
|
+
left: `${o.left}px`,
|
|
530
|
+
top: `${o.top}px`,
|
|
531
|
+
width: `${o.width}px`,
|
|
532
|
+
height: `${o.height}px`
|
|
533
|
+
}),
|
|
534
|
+
class: "lfp-sheet__image-frame"
|
|
535
|
+
}, [
|
|
536
|
+
u("img", {
|
|
537
|
+
class: "lfp-sheet__floating-image",
|
|
538
|
+
src: o.src,
|
|
539
|
+
alt: o.alt,
|
|
540
|
+
style: M(o.frameStyle)
|
|
541
|
+
}, null, 12, Xt)
|
|
542
|
+
], 4))), 128))
|
|
543
|
+
])
|
|
544
|
+
])
|
|
545
|
+
])) : (d(), m("p", eo, "当前工作表没有可展示的数据。"))
|
|
546
|
+
]));
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
export {
|
|
550
|
+
ro as default
|
|
551
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as o, openBlock as l, createElementBlock as a, createElementVNode as t, toDisplayString as i, unref as r } from "vue";
|
|
2
|
-
import { d as s } from "./index-
|
|
2
|
+
import { d as s } from "./index-CZ37tDnP.js";
|
|
3
3
|
const d = { class: "lfp-empty" }, p = { class: "lfp-hint" }, c = /* @__PURE__ */ o({
|
|
4
4
|
__name: "UnsupportedRenderer",
|
|
5
5
|
props: {
|
|
@@ -77,7 +77,7 @@ const ee = ["aria-modal"], te = {
|
|
|
77
77
|
},
|
|
78
78
|
emits: ["update:visible", "error"],
|
|
79
79
|
setup(e, { emit: t }) {
|
|
80
|
-
const o = h(() => import("./PdfRenderer-Due2M5cA.js")), c = h(() => import("./TextRenderer-KUhpnf63.js")), i = h(() => import("./DocxRenderer-DogNhBLd.js")), p = h(() => import("./SheetRenderer-
|
|
80
|
+
const o = h(() => import("./PdfRenderer-Due2M5cA.js")), c = h(() => import("./TextRenderer-KUhpnf63.js")), i = h(() => import("./DocxRenderer-DogNhBLd.js")), p = h(() => import("./SheetRenderer-CXOjo3C1.js")), d = h(() => import("./UnsupportedRenderer-DA6ZSyt7.js")), l = e, D = t, f = U(null), j = U(!1), L = U(""), n = U(I(l.source, l.fileName)), m = w(() => Q(n.value.name)), N = w(() => l.fileName || n.value.name || l.dialogTitle), b = w(() => l.mode === "dialog"), O = w(() => b.value ? l.visible : !0), T = w(() => m.value === "image" ? "img" : m.value === "video" ? "video" : m.value === "audio" ? "audio" : null);
|
|
81
81
|
Z(
|
|
82
82
|
() => [l.source, l.fileName],
|
|
83
83
|
() => {
|