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