@work-zhanguo/light-file-preview 0.0.18 → 0.0.19
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 +26 -10
- package/dist/{UnsupportedRenderer-B016ePP5.js → UnsupportedRenderer-CbQ7S46f.js} +1 -1
- package/dist/index-DB5StklO.js +363 -0
- package/dist/light-file-preview.js +1 -1
- package/dist/light-file-preview.umd.cjs +158 -196
- package/dist/standalone/light-file-preview.iife.js +178 -217
- package/dist/standalone/style.css +1 -1
- package/dist/style.css +1 -1
- package/dist/types/components/FilePreview.vue.d.ts +3 -3
- package/dist/types/constants/file.d.ts +0 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/vue2/light-file-preview-vue2.js +55300 -3
- package/dist/vue2/light-file-preview-vue2.umd.cjs +178 -217
- package/package.json +1 -3
- package/dist/PptxRenderer-B4sDptn0.js +0 -14773
- package/dist/index-DX4yvG8n.js +0 -353
- package/dist/types/components/renderers/PptxRenderer.vue.d.ts +0 -13
- package/dist/vue2/DocxRenderer-BYzWAtSx.js +0 -110
- package/dist/vue2/PdfRenderer-2f-SRj0_.js +0 -123
- package/dist/vue2/PptxRenderer-B1TlLH2y.js +0 -14773
- package/dist/vue2/SheetRenderer-DF9A6Tqq.js +0 -940
- package/dist/vue2/TextRenderer-Be7RzYjF.js +0 -59
- package/dist/vue2/UnsupportedRenderer-CIeHYr5T.js +0 -31
- package/dist/vue2/_commonjs-dynamic-modules-C74YT1gS.js +0 -32
- package/dist/vue2/docx-preview-BV-bQyiM.js +0 -5533
- package/dist/vue2/marked.esm-CRmQbSOC.js +0 -1577
- package/dist/vue2/pdf-BiKi76Et.js +0 -15320
- package/dist/vue2/purify.es-CCmmh-Lt.js +0 -553
- package/dist/vue2/style.css +0 -1
- package/dist/vue2/text-Bqxn_tMI.js +0 -24
- package/dist/vue2/vue2-DryhXOWQ.js +0 -6296
- package/dist/vue2/xlsx-j9Zzywas.js +0 -24774
- package/public/screenshots/effect-pptx.png +0 -0
package/dist/index-DX4yvG8n.js
DELETED
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import { defineComponent as z, defineAsyncComponent as R, ref as T, computed as f, watch as U, onBeforeUnmount as W, openBlock as l, createBlock as w, Teleport as G, createElementBlock as v, normalizeClass as J, createCommentVNode as P, createElementVNode as s, toDisplayString as D, createVNode as Q, Transition as Y, withCtx as ee, Fragment as te, unref as E, reactive as O, createApp as V, h as Z } from "vue";
|
|
2
|
-
const g = {
|
|
3
|
-
image: ["png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"],
|
|
4
|
-
pdf: ["pdf"],
|
|
5
|
-
text: ["txt", "json", "js", "ts", "jsx", "tsx", "html", "css", "md", "csv"],
|
|
6
|
-
docx: ["docx"],
|
|
7
|
-
pptx: ["pptx"],
|
|
8
|
-
sheet: ["xls", "xlsx", "csv"],
|
|
9
|
-
video: ["mp4", "webm"],
|
|
10
|
-
audio: ["mp3", "wav"]
|
|
11
|
-
}, oe = ["doc", "ppt"];
|
|
12
|
-
function I(e = "") {
|
|
13
|
-
const n = e.split("#")[0].split("?")[0].split(".");
|
|
14
|
-
return n.length > 1 ? n[n.length - 1].toLowerCase() : "";
|
|
15
|
-
}
|
|
16
|
-
function ne(e) {
|
|
17
|
-
const t = I(e);
|
|
18
|
-
return g.image.includes(t) ? "image" : g.pdf.includes(t) ? "pdf" : g.docx.includes(t) ? "docx" : g.pptx.includes(t) ? "pptx" : g.sheet.includes(t) ? "sheet" : g.video.includes(t) ? "video" : g.audio.includes(t) ? "audio" : g.text.includes(t) ? t === "csv" ? "sheet" : "text" : (oe.includes(t), "unsupported");
|
|
19
|
-
}
|
|
20
|
-
function ae(e) {
|
|
21
|
-
if (/^(blob:|data:|https?:\/\/|file:\/\/)/i.test(e))
|
|
22
|
-
return e;
|
|
23
|
-
try {
|
|
24
|
-
const t = new URL(e, window.location.href);
|
|
25
|
-
return t.pathname = t.pathname.split("/").map((n) => encodeURIComponent(decodeURIComponent(n))).join("/"), t.toString();
|
|
26
|
-
} catch (t) {
|
|
27
|
-
return e.split("/").map((n) => encodeURIComponent(decodeURIComponent(n))).join("/");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function N(e, t) {
|
|
31
|
-
var r;
|
|
32
|
-
if (typeof e == "string") {
|
|
33
|
-
const m = ae(e), d = e.split("/"), C = (r = t != null ? t : d[d.length - 1]) != null ? r : "unknown";
|
|
34
|
-
return {
|
|
35
|
-
source: e,
|
|
36
|
-
src: m,
|
|
37
|
-
name: decodeURIComponent(C.split("?")[0].split("#")[0]),
|
|
38
|
-
extension: I(C)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const n = URL.createObjectURL(e), c = t != null ? t : "name" in e && typeof e.name == "string" ? e.name : "blob";
|
|
42
|
-
return {
|
|
43
|
-
source: e,
|
|
44
|
-
src: n,
|
|
45
|
-
name: c,
|
|
46
|
-
extension: I(c),
|
|
47
|
-
cleanup: () => URL.revokeObjectURL(n)
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function le(e, t) {
|
|
51
|
-
const n = document.createElement("a");
|
|
52
|
-
n.href = e, n.download = t, n.target = "_blank", n.rel = "noopener", document.body.append(n), n.click(), n.remove();
|
|
53
|
-
}
|
|
54
|
-
const se = ["aria-modal"], ie = {
|
|
55
|
-
key: 0,
|
|
56
|
-
class: "lfp-toolbar"
|
|
57
|
-
}, ue = { class: "lfp-toolbar__meta" }, re = { class: "lfp-title" }, ce = { class: "lfp-badge" }, de = { class: "lfp-toolbar__actions" }, ve = { class: "lfp-content" }, pe = {
|
|
58
|
-
key: 0,
|
|
59
|
-
class: "lfp-loading"
|
|
60
|
-
}, me = {
|
|
61
|
-
key: 0,
|
|
62
|
-
class: "lfp-error"
|
|
63
|
-
}, fe = ["src", "alt"], ge = ["src"], xe = ["src"], A = /* @__PURE__ */ z({
|
|
64
|
-
__name: "FilePreview",
|
|
65
|
-
props: {
|
|
66
|
-
source: {},
|
|
67
|
-
fileName: {},
|
|
68
|
-
mode: { default: "inline" },
|
|
69
|
-
visible: { type: Boolean, default: !0 },
|
|
70
|
-
loadingText: { default: "文件加载中..." },
|
|
71
|
-
textEncoding: { default: "utf-8" },
|
|
72
|
-
maxTextBytes: { default: 1024 * 1024 * 2 },
|
|
73
|
-
maxSheetRows: { default: 200 },
|
|
74
|
-
maxSheetCols: { default: 50 },
|
|
75
|
-
pdfScale: { default: 1.35 },
|
|
76
|
-
showToolbar: { type: Boolean, default: !0 },
|
|
77
|
-
dialogTitle: { default: "文件预览" }
|
|
78
|
-
},
|
|
79
|
-
emits: ["update:visible", "error"],
|
|
80
|
-
setup(e, { emit: t }) {
|
|
81
|
-
const n = R(() => import("./PdfRenderer-DweDxjLS.js")), c = R(() => import("./TextRenderer-KUhpnf63.js")), r = R(() => import("./DocxRenderer-Cck1uOjU.js")), m = R(() => import("./PptxRenderer-B4sDptn0.js")), d = R(() => import("./SheetRenderer-CMDoDBXR.js")), C = R(() => import("./UnsupportedRenderer-B016ePP5.js")), o = e, F = t, x = T(null), b = T(!1), h = T(""), k = T(0), a = T(N(o.source, o.fileName)), H = {
|
|
82
|
-
image: "图片",
|
|
83
|
-
pdf: "PDF",
|
|
84
|
-
text: "文本",
|
|
85
|
-
docx: "DOCX",
|
|
86
|
-
pptx: "PPTX",
|
|
87
|
-
sheet: "表格",
|
|
88
|
-
video: "视频",
|
|
89
|
-
audio: "音频",
|
|
90
|
-
unsupported: "下载"
|
|
91
|
-
}, p = f(() => ne(a.value.name)), X = f(() => H[p.value]), $ = f(() => o.fileName || a.value.name || o.dialogTitle), y = f(() => o.mode === "dialog"), q = f(() => y.value ? o.visible : !0), B = f(() => `${a.value.src}::${k.value}`), L = f(
|
|
92
|
-
() => [
|
|
93
|
-
a.value.src,
|
|
94
|
-
a.value.extension,
|
|
95
|
-
o.textEncoding,
|
|
96
|
-
o.maxTextBytes,
|
|
97
|
-
o.maxSheetRows,
|
|
98
|
-
o.maxSheetCols,
|
|
99
|
-
o.pdfScale,
|
|
100
|
-
k.value
|
|
101
|
-
].join("::")
|
|
102
|
-
), j = f(() => p.value === "image" ? "img" : p.value === "video" ? "video" : p.value === "audio" ? "audio" : null);
|
|
103
|
-
U(
|
|
104
|
-
() => [o.source, o.fileName],
|
|
105
|
-
() => {
|
|
106
|
-
var i, u;
|
|
107
|
-
(i = x.value) == null || i.call(x), a.value = N(o.source, o.fileName), x.value = (u = a.value.cleanup) != null ? u : null, h.value = "", b.value = !1, k.value += 1;
|
|
108
|
-
},
|
|
109
|
-
{ immediate: !0 }
|
|
110
|
-
), U(
|
|
111
|
-
() => [o.textEncoding, o.maxTextBytes, o.maxSheetRows, o.maxSheetCols, o.pdfScale],
|
|
112
|
-
() => {
|
|
113
|
-
h.value = "", b.value = !1, k.value += 1;
|
|
114
|
-
}
|
|
115
|
-
), U(
|
|
116
|
-
() => o.visible,
|
|
117
|
-
(i, u) => {
|
|
118
|
-
if (y.value) {
|
|
119
|
-
if (!i) {
|
|
120
|
-
b.value = !1;
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
u || (h.value = "", b.value = !1, k.value += 1);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
), U(
|
|
127
|
-
() => o.mode,
|
|
128
|
-
(i, u) => {
|
|
129
|
-
i === "dialog" && u !== "dialog" && o.visible && (h.value = "", b.value = !1, k.value += 1);
|
|
130
|
-
}
|
|
131
|
-
), W(() => {
|
|
132
|
-
var i;
|
|
133
|
-
(i = x.value) == null || i.call(x);
|
|
134
|
-
});
|
|
135
|
-
function M() {
|
|
136
|
-
F("update:visible", !1);
|
|
137
|
-
}
|
|
138
|
-
function K() {
|
|
139
|
-
le(a.value.src, a.value.name);
|
|
140
|
-
}
|
|
141
|
-
function S(i) {
|
|
142
|
-
h.value = i.message, F("error", i);
|
|
143
|
-
}
|
|
144
|
-
function _(i) {
|
|
145
|
-
b.value = i;
|
|
146
|
-
}
|
|
147
|
-
return (i, u) => (l(), w(G, {
|
|
148
|
-
to: "body",
|
|
149
|
-
disabled: !y.value
|
|
150
|
-
}, [
|
|
151
|
-
q.value ? (l(), v("div", {
|
|
152
|
-
key: 0,
|
|
153
|
-
class: J(["lfp-wrapper", { "is-dialog": y.value }])
|
|
154
|
-
}, [
|
|
155
|
-
y.value ? (l(), v("div", {
|
|
156
|
-
key: 0,
|
|
157
|
-
class: "lfp-backdrop",
|
|
158
|
-
onClick: M
|
|
159
|
-
})) : P("", !0),
|
|
160
|
-
s("section", {
|
|
161
|
-
class: "lfp-panel",
|
|
162
|
-
role: "dialog",
|
|
163
|
-
"aria-modal": y.value ? "true" : "false"
|
|
164
|
-
}, [
|
|
165
|
-
e.showToolbar ? (l(), v("header", ie, [
|
|
166
|
-
s("div", ue, [
|
|
167
|
-
s("strong", re, D($.value), 1),
|
|
168
|
-
s("span", ce, D(X.value), 1)
|
|
169
|
-
]),
|
|
170
|
-
s("div", de, [
|
|
171
|
-
s("button", {
|
|
172
|
-
class: "lfp-button lfp-icon-button",
|
|
173
|
-
type: "button",
|
|
174
|
-
"aria-label": "Download",
|
|
175
|
-
title: "Download",
|
|
176
|
-
onClick: K
|
|
177
|
-
}, [...u[0] || (u[0] = [
|
|
178
|
-
s("svg", {
|
|
179
|
-
viewBox: "0 0 24 24",
|
|
180
|
-
"aria-hidden": "true"
|
|
181
|
-
}, [
|
|
182
|
-
s("path", { d: "M12 3.5a1 1 0 0 1 1 1V12l2.8-2.8a1 1 0 1 1 1.4 1.42l-4.5 4.48a1 1 0 0 1-1.4 0l-4.5-4.48a1 1 0 0 1 1.4-1.42L11 12V4.5a1 1 0 0 1 1-1Zm-7 13a1 1 0 0 1 1 1v.75c0 .41.34.75.75.75h10.5a.75.75 0 0 0 .75-.75v-.75a1 1 0 1 1 2 0v.75A2.75 2.75 0 0 1 17.25 21H6.75A2.75 2.75 0 0 1 4 18.25v-.75a1 1 0 0 1 1-1Z" })
|
|
183
|
-
], -1)
|
|
184
|
-
])]),
|
|
185
|
-
y.value ? (l(), v("button", {
|
|
186
|
-
key: 0,
|
|
187
|
-
class: "lfp-button lfp-button is-ghost lfp-icon-button",
|
|
188
|
-
type: "button",
|
|
189
|
-
"aria-label": "Close",
|
|
190
|
-
title: "Close",
|
|
191
|
-
onClick: M
|
|
192
|
-
}, [...u[1] || (u[1] = [
|
|
193
|
-
s("svg", {
|
|
194
|
-
viewBox: "0 0 24 24",
|
|
195
|
-
"aria-hidden": "true"
|
|
196
|
-
}, [
|
|
197
|
-
s("path", { d: "M6.7 5.3a1 1 0 0 1 1.4 0L12 9.17l3.9-3.88a1 1 0 1 1 1.4 1.42L13.4 10.6l3.9 3.89a1 1 0 0 1-1.4 1.42L12 12.03l-3.9 3.88a1 1 0 0 1-1.4-1.42l3.9-3.89-3.9-3.89a1 1 0 0 1 0-1.42Z" })
|
|
198
|
-
], -1)
|
|
199
|
-
])])) : P("", !0)
|
|
200
|
-
])
|
|
201
|
-
])) : P("", !0),
|
|
202
|
-
s("div", ve, [
|
|
203
|
-
Q(Y, { name: "lfp-fade" }, {
|
|
204
|
-
default: ee(() => [
|
|
205
|
-
b.value ? (l(), v("div", pe, [
|
|
206
|
-
u[2] || (u[2] = s("span", { class: "lfp-spinner" }, null, -1)),
|
|
207
|
-
s("span", null, D(e.loadingText), 1)
|
|
208
|
-
])) : P("", !0)
|
|
209
|
-
]),
|
|
210
|
-
_: 1
|
|
211
|
-
}),
|
|
212
|
-
h.value ? (l(), v("div", me, [
|
|
213
|
-
s("p", null, D(h.value), 1),
|
|
214
|
-
s("button", {
|
|
215
|
-
class: "lfp-button lfp-icon-button",
|
|
216
|
-
type: "button",
|
|
217
|
-
"aria-label": "Download",
|
|
218
|
-
title: "Download",
|
|
219
|
-
onClick: K
|
|
220
|
-
}, [...u[3] || (u[3] = [
|
|
221
|
-
s("svg", {
|
|
222
|
-
viewBox: "0 0 24 24",
|
|
223
|
-
"aria-hidden": "true"
|
|
224
|
-
}, [
|
|
225
|
-
s("path", { d: "M12 3.5a1 1 0 0 1 1 1V12l2.8-2.8a1 1 0 1 1 1.4 1.42l-4.5 4.48a1 1 0 0 1-1.4 0l-4.5-4.48a1 1 0 0 1 1.4-1.42L11 12V4.5a1 1 0 0 1 1-1Zm-7 13a1 1 0 0 1 1 1v.75c0 .41.34.75.75.75h10.5a.75.75 0 0 0 .75-.75v-.75a1 1 0 1 1 2 0v.75A2.75 2.75 0 0 1 17.25 21H6.75A2.75 2.75 0 0 1 4 18.25v-.75a1 1 0 0 1 1-1Z" })
|
|
226
|
-
], -1)
|
|
227
|
-
])])
|
|
228
|
-
])) : (l(), v(te, { key: 1 }, [
|
|
229
|
-
j.value === "img" ? (l(), v("img", {
|
|
230
|
-
key: B.value,
|
|
231
|
-
class: "lfp-image",
|
|
232
|
-
src: a.value.src,
|
|
233
|
-
alt: a.value.name,
|
|
234
|
-
loading: "lazy"
|
|
235
|
-
}, null, 8, fe)) : j.value === "video" ? (l(), v("video", {
|
|
236
|
-
key: B.value,
|
|
237
|
-
class: "lfp-media",
|
|
238
|
-
src: a.value.src,
|
|
239
|
-
controls: "",
|
|
240
|
-
preload: "metadata"
|
|
241
|
-
}, null, 8, ge)) : j.value === "audio" ? (l(), v("audio", {
|
|
242
|
-
key: B.value,
|
|
243
|
-
class: "lfp-audio",
|
|
244
|
-
src: a.value.src,
|
|
245
|
-
controls: "",
|
|
246
|
-
preload: "metadata"
|
|
247
|
-
}, null, 8, xe)) : p.value === "pdf" ? (l(), w(E(n), {
|
|
248
|
-
key: L.value,
|
|
249
|
-
source: typeof o.source == "string" ? a.value.src : o.source,
|
|
250
|
-
scale: e.pdfScale,
|
|
251
|
-
onLoading: _,
|
|
252
|
-
onError: S
|
|
253
|
-
}, null, 8, ["source", "scale"])) : p.value === "docx" ? (l(), w(E(r), {
|
|
254
|
-
key: L.value,
|
|
255
|
-
source: typeof o.source == "string" ? a.value.src : o.source,
|
|
256
|
-
onLoading: _,
|
|
257
|
-
onError: S
|
|
258
|
-
}, null, 8, ["source"])) : p.value === "pptx" ? (l(), w(E(m), {
|
|
259
|
-
key: L.value,
|
|
260
|
-
source: typeof o.source == "string" ? a.value.src : o.source,
|
|
261
|
-
onLoading: _,
|
|
262
|
-
onError: S
|
|
263
|
-
}, null, 8, ["source"])) : p.value === "sheet" ? (l(), w(E(d), {
|
|
264
|
-
key: L.value,
|
|
265
|
-
source: typeof o.source == "string" ? a.value.src : o.source,
|
|
266
|
-
"max-cols": e.maxSheetCols,
|
|
267
|
-
"max-rows": e.maxSheetRows,
|
|
268
|
-
onLoading: _,
|
|
269
|
-
onError: S
|
|
270
|
-
}, null, 8, ["source", "max-cols", "max-rows"])) : p.value === "text" ? (l(), w(E(c), {
|
|
271
|
-
key: L.value,
|
|
272
|
-
source: typeof o.source == "string" ? a.value.src : o.source,
|
|
273
|
-
encoding: e.textEncoding,
|
|
274
|
-
extension: a.value.extension,
|
|
275
|
-
"max-bytes": e.maxTextBytes,
|
|
276
|
-
onLoading: _,
|
|
277
|
-
onError: S
|
|
278
|
-
}, null, 8, ["source", "encoding", "extension", "max-bytes"])) : (l(), w(E(C), {
|
|
279
|
-
key: 8,
|
|
280
|
-
"file-name": a.value.name,
|
|
281
|
-
src: a.value.src
|
|
282
|
-
}, null, 8, ["file-name", "src"]))
|
|
283
|
-
], 64))
|
|
284
|
-
])
|
|
285
|
-
], 8, se)
|
|
286
|
-
], 2)) : P("", !0)
|
|
287
|
-
], 8, ["disabled"]));
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
function be(e) {
|
|
291
|
-
if (typeof e == "string") {
|
|
292
|
-
const t = document.querySelector(e);
|
|
293
|
-
if (!t)
|
|
294
|
-
throw new Error(`未找到挂载节点:${e}`);
|
|
295
|
-
return t;
|
|
296
|
-
}
|
|
297
|
-
return e;
|
|
298
|
-
}
|
|
299
|
-
function he(e, t) {
|
|
300
|
-
const n = O({ ...t }), c = be(e), r = V({
|
|
301
|
-
render: () => Z(A, n)
|
|
302
|
-
});
|
|
303
|
-
return r.mount(c), {
|
|
304
|
-
update(m) {
|
|
305
|
-
Object.assign(n, m);
|
|
306
|
-
},
|
|
307
|
-
unmount() {
|
|
308
|
-
r.unmount();
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
function ye(e) {
|
|
313
|
-
const t = document.createElement("div");
|
|
314
|
-
document.body.append(t);
|
|
315
|
-
let n;
|
|
316
|
-
const c = e["onUpdate:visible"], r = O({
|
|
317
|
-
visible: !0,
|
|
318
|
-
mode: "dialog",
|
|
319
|
-
...e,
|
|
320
|
-
"onUpdate:visible"(d) {
|
|
321
|
-
c == null || c(d), r.visible = d, d || queueMicrotask(() => n.unmount());
|
|
322
|
-
}
|
|
323
|
-
}), m = V({
|
|
324
|
-
render: () => Z(A, r)
|
|
325
|
-
});
|
|
326
|
-
return m.mount(t), n = {
|
|
327
|
-
update(d) {
|
|
328
|
-
Object.assign(r, d);
|
|
329
|
-
},
|
|
330
|
-
unmount() {
|
|
331
|
-
m.unmount(), t.remove();
|
|
332
|
-
}
|
|
333
|
-
}, n;
|
|
334
|
-
}
|
|
335
|
-
function ke() {
|
|
336
|
-
const e = {
|
|
337
|
-
mount: he,
|
|
338
|
-
openDialog: ye
|
|
339
|
-
};
|
|
340
|
-
return typeof window != "undefined" && (window.LightFilePreview = e), e;
|
|
341
|
-
}
|
|
342
|
-
const Re = {
|
|
343
|
-
install(e) {
|
|
344
|
-
e.component("LightFilePreview", A);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
export {
|
|
348
|
-
A as _,
|
|
349
|
-
le as d,
|
|
350
|
-
Re as i,
|
|
351
|
-
ye as o,
|
|
352
|
-
ke as r
|
|
353
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import '@work-zhanguo/pptx-preview/style.css';
|
|
2
|
-
import type { PreviewSource } from '../../types';
|
|
3
|
-
type __VLS_Props = {
|
|
4
|
-
source: PreviewSource;
|
|
5
|
-
};
|
|
6
|
-
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
7
|
-
error: (error: Error) => any;
|
|
8
|
-
loading: (value: boolean) => any;
|
|
9
|
-
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
10
|
-
onError?: ((error: Error) => any) | undefined;
|
|
11
|
-
onLoading?: ((value: boolean) => any) | undefined;
|
|
12
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
-
export default _default;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { d as B, c as E, w as _, o as L, a as N, b as d, e as p, f as n, t as f, n as b, F as T, g as m, r as i } from "./vue2-DryhXOWQ.js";
|
|
2
|
-
import { r as D } from "./text-Bqxn_tMI.js";
|
|
3
|
-
const R = { class: "lfp-document" }, $ = {
|
|
4
|
-
key: 0,
|
|
5
|
-
class: "lfp-page-toolbar"
|
|
6
|
-
}, H = { class: "lfp-page-toolbar__meta" }, S = { class: "lfp-page-toolbar__status" }, V = { class: "lfp-page-toolbar__actions" }, A = ["disabled"], F = { class: "lfp-page-toolbar__pager" }, O = ["disabled"], q = /* @__PURE__ */ B({
|
|
7
|
-
__name: "DocxRenderer",
|
|
8
|
-
props: {
|
|
9
|
-
source: {}
|
|
10
|
-
},
|
|
11
|
-
emits: ["loading", "error"],
|
|
12
|
-
setup(h, { emit: y }) {
|
|
13
|
-
const w = h, u = y, s = i(null), o = i(0), a = i(1), l = i("paged"), v = new AbortController(), x = E(() => o.value ? l.value === "paged" ? `第 ${a.value} / ${o.value} 页` : `共 ${o.value} 页` : "");
|
|
14
|
-
function C() {
|
|
15
|
-
if (!s.value)
|
|
16
|
-
return [];
|
|
17
|
-
const t = s.value.querySelector(".docx-wrapper");
|
|
18
|
-
if (!t)
|
|
19
|
-
return [];
|
|
20
|
-
const e = Array.from(t.children).filter(
|
|
21
|
-
(r) => r instanceof HTMLElement && (r.tagName === "SECTION" || r.classList.contains("docx"))
|
|
22
|
-
);
|
|
23
|
-
return e.length ? e : [t];
|
|
24
|
-
}
|
|
25
|
-
function c() {
|
|
26
|
-
const t = C();
|
|
27
|
-
o.value = t.length || 1, a.value = Math.min(Math.max(a.value, 1), o.value), t.forEach((e, r) => {
|
|
28
|
-
e.classList.add("lfp-docx-page"), e.dataset.page = String(r + 1), e.hidden = l.value === "paged" && r !== a.value - 1;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function g(t) {
|
|
32
|
-
l.value = t;
|
|
33
|
-
}
|
|
34
|
-
function M() {
|
|
35
|
-
a.value = Math.max(a.value - 1, 1);
|
|
36
|
-
}
|
|
37
|
-
function k() {
|
|
38
|
-
a.value = Math.min(a.value + 1, o.value);
|
|
39
|
-
}
|
|
40
|
-
async function P() {
|
|
41
|
-
u("loading", !0);
|
|
42
|
-
try {
|
|
43
|
-
const t = await D(w.source, v.signal), { renderAsync: e } = await import("./docx-preview-BV-bQyiM.js");
|
|
44
|
-
if (!s.value)
|
|
45
|
-
return;
|
|
46
|
-
s.value.innerHTML = "", await e(t, s.value, void 0, {
|
|
47
|
-
className: "lfp-docx-content",
|
|
48
|
-
ignoreWidth: !1,
|
|
49
|
-
ignoreHeight: !1,
|
|
50
|
-
useBase64URL: !0
|
|
51
|
-
}), c();
|
|
52
|
-
} catch (t) {
|
|
53
|
-
u("error", t instanceof Error ? t : new Error("DOCX 预览失败"));
|
|
54
|
-
} finally {
|
|
55
|
-
u("loading", !1);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return _(l, () => {
|
|
59
|
-
c();
|
|
60
|
-
}), _(a, () => {
|
|
61
|
-
l.value === "paged" && c();
|
|
62
|
-
}), L(() => {
|
|
63
|
-
P();
|
|
64
|
-
}), N(() => {
|
|
65
|
-
v.abort(), s.value && (s.value.innerHTML = "");
|
|
66
|
-
}), (t, e) => (d(), p("div", R, [
|
|
67
|
-
o.value ? (d(), p("div", $, [
|
|
68
|
-
n("div", H, [
|
|
69
|
-
e[2] || (e[2] = n("span", { class: "lfp-page-toolbar__title" }, "Word 视图", -1)),
|
|
70
|
-
n("span", S, f(x.value), 1)
|
|
71
|
-
]),
|
|
72
|
-
n("div", V, [
|
|
73
|
-
n("button", {
|
|
74
|
-
class: b(["lfp-button is-ghost lfp-page-toolbar__toggle", { "is-active": l.value === "paged" }]),
|
|
75
|
-
type: "button",
|
|
76
|
-
onClick: e[0] || (e[0] = (r) => g("paged"))
|
|
77
|
-
}, " 分页 ", 2),
|
|
78
|
-
n("button", {
|
|
79
|
-
class: b(["lfp-button is-ghost lfp-page-toolbar__toggle", { "is-active": l.value === "all" }]),
|
|
80
|
-
type: "button",
|
|
81
|
-
onClick: e[1] || (e[1] = (r) => g("all"))
|
|
82
|
-
}, " 全部 ", 2),
|
|
83
|
-
l.value === "paged" && o.value > 1 ? (d(), p(T, { key: 0 }, [
|
|
84
|
-
n("button", {
|
|
85
|
-
class: "lfp-button is-ghost lfp-page-toolbar__nav",
|
|
86
|
-
type: "button",
|
|
87
|
-
disabled: a.value <= 1,
|
|
88
|
-
onClick: M
|
|
89
|
-
}, " 上一页 ", 8, A),
|
|
90
|
-
n("span", F, f(a.value) + " / " + f(o.value), 1),
|
|
91
|
-
n("button", {
|
|
92
|
-
class: "lfp-button is-ghost lfp-page-toolbar__nav",
|
|
93
|
-
type: "button",
|
|
94
|
-
disabled: a.value >= o.value,
|
|
95
|
-
onClick: k
|
|
96
|
-
}, " 下一页 ", 8, O)
|
|
97
|
-
], 64)) : m("", !0)
|
|
98
|
-
])
|
|
99
|
-
])) : m("", !0),
|
|
100
|
-
n("div", {
|
|
101
|
-
ref_key: "containerRef",
|
|
102
|
-
ref: s,
|
|
103
|
-
class: "lfp-docx"
|
|
104
|
-
}, null, 512)
|
|
105
|
-
]));
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
export {
|
|
109
|
-
q as default
|
|
110
|
-
};
|