@eternalheart/vue-file-preview 1.6.12 → 1.6.13
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 -0
- package/README.zh-CN.md +2 -0
- package/lib/FilePreviewContent.vue.d.ts +9 -1
- package/lib/FilePreviewEmbed.vue.d.ts +4 -1
- package/lib/FilePreviewModal.vue.d.ts +4 -1
- package/lib/chunks/EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs +20 -0
- package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs +32 -0
- package/lib/chunks/{avifLoader-CAUzjn-d-CTy7cevh.mjs → avifLoader-CAUzjn-d-C0KRpetN.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-DdDu94xL.mjs → heicLoader-D_9PukkA-Czof_5FJ.mjs} +1 -1
- package/lib/chunks/{index-CLM9sOKN.mjs → index--612Smof.mjs} +112 -112
- package/lib/chunks/{index-De-oaCgN.mjs → index-8Vpbg2kS.mjs} +2 -2
- package/lib/chunks/{index-2VQLB2Mi.mjs → index-B21EAyWz.mjs} +53 -49
- package/lib/chunks/{index-DmEMePjL.mjs → index-BASg1cr4.mjs} +2 -2
- package/lib/chunks/index-BB0i4QqI.mjs +117 -0
- package/lib/chunks/{index-Bmqn45d_.mjs → index-BVdrGK3Q.mjs} +72 -72
- package/lib/chunks/index-BlrFFeqc.mjs +330 -0
- package/lib/chunks/index-Bp9CuvMZ.mjs +157 -0
- package/lib/chunks/{index-i-KacQvS.mjs → index-BuqPb5mP.mjs} +3 -3
- package/lib/chunks/{index-DVG1fZAv.mjs → index-BvBqDq3O.mjs} +2 -2
- package/lib/chunks/{index-D6te_qaB.mjs → index-Bxpf9v5j.mjs} +26 -26
- package/lib/chunks/{index-D9z6lQat.mjs → index-C9mAajbD.mjs} +225 -220
- package/lib/chunks/{index-CM11hSQu.mjs → index-CDg6vIbT.mjs} +11 -11
- package/lib/chunks/{index-BxmX005K.mjs → index-CWE-hKSs.mjs} +11 -11
- package/lib/chunks/{index-BPmyF7Wr.mjs → index-CY3xzGgt.mjs} +18 -18
- package/lib/chunks/{index-t9kSzzMg.mjs → index-CxKZKUJj.mjs} +521 -523
- package/lib/chunks/{index-CuiEjR23.mjs → index-D30L8tm9.mjs} +15 -15
- package/lib/chunks/{index-DOAOk6m5.mjs → index-DN4Ui0Gh.mjs} +11 -11
- package/lib/chunks/{index-CEk6FKm3.mjs → index-DZZN3kYi.mjs} +551 -531
- package/lib/chunks/{index-D6Pjjxi0.mjs → index-Dkro_8Fy.mjs} +20 -20
- package/lib/chunks/{index-CiGUKdlt.mjs → index-VdzIFJJW.mjs} +23 -23
- package/lib/chunks/{index-WcAnJA2t.mjs → index-aoXgVLBb.mjs} +14 -14
- package/lib/chunks/{jp2Loader-Dig19xyo-BBR3tcPW.mjs → jp2Loader-Dig19xyo-CKUaGhPl.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-DGOmJwkQ.mjs → psdLoader-C0tKUXXl-CYWoQis5.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-CrCtXMup.mjs → rawLoader-C-tPeFAB-C35zC8nZ.mjs} +1 -1
- package/lib/chunks/{tiffLoader-BlhByX8w-jsxHlbyu.mjs → tiffLoader-BlhByX8w-BOxg_Du5.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-BdhPCj48.mjs → useShikiHighlight-BPmcxA-h.mjs} +1 -1
- package/lib/index.cjs +59 -59
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.mjs +4 -4
- package/lib/renderers/EmptyState.vue.d.ts +2 -0
- package/lib/renderers/Json/index.vue.d.ts +5 -0
- package/lib/renderers/Pptx/index.vue.d.ts +3 -0
- package/lib/renderers/Text/index.vue.d.ts +3 -0
- package/lib/renderers/Xlsx/index.vue.d.ts +3 -0
- package/lib/renderers/registry.d.ts +3 -1
- package/package.json +1 -1
- package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs +0 -30
- package/lib/chunks/index-Bfg5zM8l.mjs +0 -141
- package/lib/chunks/index-Cud9j9Xy.mjs +0 -322
- package/lib/chunks/index-D4jhvs5m.mjs +0 -113
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { u as A,
|
|
3
|
-
import
|
|
4
|
-
import { S as
|
|
5
|
-
import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { defineComponent as S, ref as w, onMounted as E, watch as B, onBeforeUnmount as H, openBlock as d, createElementBlock as h, createElementVNode as x, toDisplayString as z, unref as k, createCommentVNode as g, createVNode as L, normalizeStyle as R } from "vue";
|
|
2
|
+
import { u as A, c as C, k as v, e as G, o as J, J as N, h as V, f as F, Z as O, W as Z } from "./index-DZZN3kYi.mjs";
|
|
3
|
+
import q from "exceljs";
|
|
4
|
+
import { S as I } from "./index-CyBXARuf.mjs";
|
|
5
|
+
import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
6
6
|
const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, $ = {
|
|
7
7
|
key: 0,
|
|
8
|
-
class: "vfp-
|
|
9
|
-
}, j = { class: "vfp-renderer-loading-content" }, K = { class: "vfp-renderer-loading-text
|
|
8
|
+
class: "vfp-renderer-overlay vfp-renderer-loading"
|
|
9
|
+
}, j = { class: "vfp-renderer-loading-content" }, K = { class: "vfp-renderer-loading-text" }, P = {
|
|
10
|
+
key: 1,
|
|
11
|
+
class: "vfp-renderer-overlay"
|
|
12
|
+
}, se = /* @__PURE__ */ S({
|
|
10
13
|
__name: "index",
|
|
11
14
|
props: {
|
|
12
|
-
url: {}
|
|
15
|
+
url: {},
|
|
16
|
+
emptyHint: {}
|
|
13
17
|
},
|
|
14
18
|
setup(T, { expose: W }) {
|
|
15
19
|
async function D(e) {
|
|
16
20
|
try {
|
|
17
|
-
return await new
|
|
21
|
+
return await new q.Workbook().xlsx.load(e.slice().buffer);
|
|
18
22
|
} catch (t) {
|
|
19
|
-
throw t instanceof TypeError && /sheets/i.test(t.message) ? new
|
|
23
|
+
throw t instanceof TypeError && /sheets/i.test(t.message) ? new v("xlsx.invalid_format") : t;
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
|
-
const
|
|
23
|
-
let i = null,
|
|
26
|
+
const _ = T, { t: o } = A(), M = C(), a = w(!0), n = w(null), l = w(null);
|
|
27
|
+
let i = null, m = 100, f = null, u = null, c = { width: 0, height: 0 };
|
|
24
28
|
const p = () => {
|
|
25
29
|
if (!l.value) return { width: 800, height: 600 };
|
|
26
30
|
const e = l.value.clientWidth, t = l.value.clientHeight, r = e > 100 ? e : 800, s = t > 100 ? t : 600;
|
|
27
31
|
return { width: r, height: s };
|
|
28
|
-
},
|
|
32
|
+
}, y = () => {
|
|
29
33
|
if (!l.value || !i) return;
|
|
30
34
|
l.value.innerHTML = "";
|
|
31
35
|
const { width: e, height: t } = p(), r = e < 640;
|
|
32
|
-
new
|
|
36
|
+
new I(l.value, {
|
|
33
37
|
mode: "read",
|
|
34
38
|
showToolbar: !1,
|
|
35
39
|
showContextmenu: !1,
|
|
36
40
|
showGrid: !0,
|
|
37
41
|
row: {
|
|
38
|
-
len:
|
|
42
|
+
len: m,
|
|
39
43
|
height: 25
|
|
40
44
|
},
|
|
41
45
|
col: {
|
|
@@ -49,76 +53,76 @@ const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
49
53
|
width: () => e
|
|
50
54
|
}
|
|
51
55
|
}).loadData(i);
|
|
52
|
-
},
|
|
56
|
+
}, b = async () => {
|
|
53
57
|
if (l.value) {
|
|
54
58
|
a.value = !0, n.value = null;
|
|
55
59
|
try {
|
|
56
|
-
const e = await M.value(
|
|
60
|
+
const e = await M.value(_.url, {
|
|
57
61
|
mode: "cors",
|
|
58
62
|
credentials: "omit",
|
|
59
63
|
redirect: "follow"
|
|
60
64
|
});
|
|
61
65
|
if (!e.ok)
|
|
62
|
-
throw e.status === 404 ? new Error(o.value("xlsx.not_found")) : e.status === 403 ? new
|
|
66
|
+
throw e.status === 404 ? new Error(o.value("xlsx.not_found")) : e.status === 403 ? new v("file.forbidden") : new v("file.load_failed_status", { status: e.status });
|
|
63
67
|
const t = G(await e.arrayBuffer());
|
|
64
|
-
if (t.byteLength === 0)
|
|
65
|
-
throw new u("file.empty");
|
|
66
68
|
let r;
|
|
67
|
-
if (
|
|
69
|
+
if (t.byteLength === 0)
|
|
70
|
+
r = [{ name: "Sheet1" }];
|
|
71
|
+
else if (J(t)) {
|
|
68
72
|
const s = N(t);
|
|
69
73
|
if (!s || !Array.isArray(s.sheets))
|
|
70
|
-
throw new
|
|
71
|
-
r =
|
|
74
|
+
throw new v("xlsx.invalid_legacy_data");
|
|
75
|
+
r = V(s);
|
|
72
76
|
} else
|
|
73
|
-
r =
|
|
77
|
+
r = F(
|
|
74
78
|
await D(t)
|
|
75
79
|
);
|
|
76
|
-
i = r,
|
|
80
|
+
i = r.length ? r : [{ name: "Sheet1" }], m = O(r), y(), a.value = !1;
|
|
77
81
|
} catch (e) {
|
|
78
82
|
console.error(o.value("xlsx.parse_failed") + ":", e);
|
|
79
83
|
let t = o.value("xlsx.parse_failed");
|
|
80
|
-
e instanceof Error && (t =
|
|
84
|
+
e instanceof Error && (t = Z(o.value, e)), n.value = t, a.value = !1;
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
};
|
|
84
|
-
return
|
|
88
|
+
return E(() => {
|
|
85
89
|
if (!l.value) return;
|
|
86
90
|
let e = !0;
|
|
87
|
-
|
|
91
|
+
f = new ResizeObserver(() => {
|
|
88
92
|
if (e) {
|
|
89
|
-
e = !1,
|
|
93
|
+
e = !1, c = p();
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
92
|
-
const t = p(), r = Math.abs(
|
|
93
|
-
r < 10 && s < 10 || (
|
|
94
|
-
i &&
|
|
96
|
+
const t = p(), r = Math.abs(c.width - t.width), s = Math.abs(c.height - t.height);
|
|
97
|
+
r < 10 && s < 10 || (c = t, u !== null && clearTimeout(u), u = window.setTimeout(() => {
|
|
98
|
+
i && y();
|
|
95
99
|
}, 500));
|
|
96
|
-
}),
|
|
97
|
-
requestAnimationFrame(() =>
|
|
100
|
+
}), f.observe(l.value), setTimeout(() => {
|
|
101
|
+
requestAnimationFrame(() => b());
|
|
98
102
|
}, 100);
|
|
99
103
|
}), B(
|
|
100
|
-
() =>
|
|
104
|
+
() => _.url,
|
|
101
105
|
(e) => {
|
|
102
|
-
e &&
|
|
106
|
+
e && b();
|
|
103
107
|
}
|
|
104
|
-
),
|
|
105
|
-
|
|
108
|
+
), H(() => {
|
|
109
|
+
f && f.disconnect(), u !== null && clearTimeout(u), i = null, m = 100, l.value && (l.value.innerHTML = "");
|
|
106
110
|
}), W({
|
|
107
111
|
getToolbarGroups: () => []
|
|
108
|
-
}), (e, t) => (
|
|
109
|
-
a.value ? (
|
|
112
|
+
}), (e, t) => (d(), h("div", X, [
|
|
113
|
+
a.value ? (d(), h("div", $, [
|
|
110
114
|
x("div", j, [
|
|
111
115
|
t[0] || (t[0] = x("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
112
|
-
x("p", K,
|
|
116
|
+
x("p", K, z(k(o)("xlsx.loading")), 1)
|
|
113
117
|
])
|
|
114
118
|
])) : g("", !0),
|
|
115
|
-
n.value && !a.value ? (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
n.value ? g("", !0) : (
|
|
119
|
+
n.value && !a.value ? (d(), h("div", P, [
|
|
120
|
+
L(U, {
|
|
121
|
+
message: k(o)("xlsx.load_failed"),
|
|
122
|
+
detail: n.value
|
|
123
|
+
}, null, 8, ["message", "detail"])
|
|
124
|
+
])) : g("", !0),
|
|
125
|
+
n.value ? g("", !0) : (d(), h("div", {
|
|
122
126
|
key: 2,
|
|
123
127
|
ref_key: "containerRef",
|
|
124
128
|
ref: l,
|
|
@@ -129,5 +133,5 @@ const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-fu
|
|
|
129
133
|
}
|
|
130
134
|
});
|
|
131
135
|
export {
|
|
132
|
-
|
|
136
|
+
se as default
|
|
133
137
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as er, ref as qe, watch as tr, computed as te, openBlock as J, createElementBlock as Q, createElementVNode as D, toDisplayString as ne, unref as ae, createBlock as rr, createVNode as he, createCommentVNode as oe, normalizeStyle as ir, Fragment as nr, renderList as ar, createTextVNode as sr, normalizeClass as or } from "vue";
|
|
2
|
-
import { u as cr,
|
|
2
|
+
import { u as cr, c as fr, k as ur, _ as hr } from "./index-DZZN3kYi.mjs";
|
|
3
3
|
import { User as lr, Users as Ve, Calendar as mt, Clock as Et, Tag as gt, Mail as dr, Paperclip as pr, Hash as yr } from "lucide-vue-next";
|
|
4
|
-
import { _ as br } from "./RendererError.vue_vue_type_script_setup_true_lang-
|
|
4
|
+
import { _ as br } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
5
|
var fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
6
6
|
function vr(e) {
|
|
7
7
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { defineComponent as F, ref as c, computed as f, watch as k, unref as m, openBlock as t, createElementBlock as i, createElementVNode as l, toDisplayString as h, createBlock as T, normalizeClass as H, normalizeStyle as $, Fragment as C, renderList as z } from "vue";
|
|
2
|
+
import { WrapText as G, Code as M, Eye as W } from "lucide-vue-next";
|
|
3
|
+
import { u as X, c as D, C as P, w as R, l as V, X as j } from "./index-DZZN3kYi.mjs";
|
|
4
|
+
import { u as q } from "./useShikiHighlight-BPmcxA-h.mjs";
|
|
5
|
+
import { _ as A } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
6
|
+
import { _ as I } from "./EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs";
|
|
7
|
+
import { T as J } from "./base.types-DaftHyg7.mjs";
|
|
8
|
+
const K = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "vfp-renderer-loading"
|
|
11
|
+
}, O = { class: "vfp-renderer-loading-content" }, Q = { class: "vfp-renderer-loading-text" }, U = {
|
|
12
|
+
key: 3,
|
|
13
|
+
class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
|
|
14
|
+
}, Y = ["srcdoc", "title"], Z = {
|
|
15
|
+
key: 4,
|
|
16
|
+
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
17
|
+
style: { background: "var(--fp-code-bg)" }
|
|
18
|
+
}, ee = {
|
|
19
|
+
key: 5,
|
|
20
|
+
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
21
|
+
style: { background: "var(--fp-code-bg)" }
|
|
22
|
+
}, le = { class: "vfp-code-gutter" }, te = ["innerHTML"], fe = /* @__PURE__ */ F({
|
|
23
|
+
__name: "index",
|
|
24
|
+
props: {
|
|
25
|
+
url: {},
|
|
26
|
+
fileName: {},
|
|
27
|
+
emptyHint: {}
|
|
28
|
+
},
|
|
29
|
+
setup(w, { expose: E }) {
|
|
30
|
+
const d = w, _ = new J(), { t: s } = X(), L = D(), o = c(!0), a = c(!1), r = c(""), v = c(!0), p = c(null), n = f(() => P(d.fileName)), N = f(() => n.value !== "text" ? r.value : ""), { lineHtmls: y, loading: S } = q(N, n), b = f(() => n.value === "html"), B = f(
|
|
31
|
+
() => !v.value && !p.value && R(r.value) && V(d.emptyHint, "textual")
|
|
32
|
+
);
|
|
33
|
+
k([o, a, v, b], () => {
|
|
34
|
+
_.notify();
|
|
35
|
+
}), k(() => d.url, async () => {
|
|
36
|
+
v.value = !0, p.value = null;
|
|
37
|
+
try {
|
|
38
|
+
const e = await j(d.url, { fetcher: L.value });
|
|
39
|
+
r.value = e;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error(e), p.value = s.value("text.load_failed");
|
|
42
|
+
} finally {
|
|
43
|
+
v.value = !1;
|
|
44
|
+
}
|
|
45
|
+
}, { immediate: !0 });
|
|
46
|
+
const x = f(() => r.value.split(`
|
|
47
|
+
`));
|
|
48
|
+
return E({
|
|
49
|
+
getToolbarGroups: () => {
|
|
50
|
+
const e = [];
|
|
51
|
+
return e.push({
|
|
52
|
+
items: [
|
|
53
|
+
{
|
|
54
|
+
type: "button",
|
|
55
|
+
icon: G,
|
|
56
|
+
tooltip: o.value ? s.value("toolbar.wrap_off") : s.value("toolbar.wrap_on"),
|
|
57
|
+
action: () => {
|
|
58
|
+
o.value = !o.value;
|
|
59
|
+
},
|
|
60
|
+
active: o.value
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}), b.value && e.push({
|
|
64
|
+
items: [
|
|
65
|
+
{
|
|
66
|
+
type: "button",
|
|
67
|
+
icon: a.value ? M : W,
|
|
68
|
+
tooltip: a.value ? s.value("toolbar.source") : s.value("toolbar.preview"),
|
|
69
|
+
action: () => {
|
|
70
|
+
a.value = !a.value;
|
|
71
|
+
},
|
|
72
|
+
active: a.value
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}), e;
|
|
76
|
+
},
|
|
77
|
+
onToolbarChange: (e) => _.subscribe(e)
|
|
78
|
+
}), (e, u) => v.value || n.value !== "text" && m(S) ? (t(), i("div", K, [
|
|
79
|
+
l("div", O, [
|
|
80
|
+
u[0] || (u[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
81
|
+
l("span", Q, h(m(s)("common.loading")), 1)
|
|
82
|
+
])
|
|
83
|
+
])) : p.value ? (t(), T(A, {
|
|
84
|
+
key: 1,
|
|
85
|
+
message: p.value
|
|
86
|
+
}, null, 8, ["message"])) : B.value ? (t(), T(I, { key: 2 })) : a.value && n.value === "html" ? (t(), i("div", U, [
|
|
87
|
+
l("iframe", {
|
|
88
|
+
srcdoc: r.value,
|
|
89
|
+
sandbox: "allow-same-origin",
|
|
90
|
+
class: "vfp-w-full vfp-h-full vfp-border-0",
|
|
91
|
+
title: w.fileName
|
|
92
|
+
}, null, 8, Y)
|
|
93
|
+
])) : n.value === "text" || m(y).length === 0 ? (t(), i("div", Z, [
|
|
94
|
+
l("pre", {
|
|
95
|
+
class: H(["vfp-py-6 vfp-px-4 vfp-text-fg-primary vfp-font-mono vfp-text-sm", o.value ? "vfp-whitespace-pre-wrap vfp-break-words" : "vfp-whitespace-pre"])
|
|
96
|
+
}, h(r.value), 3)
|
|
97
|
+
])) : (t(), i("div", ee, [
|
|
98
|
+
l("div", {
|
|
99
|
+
class: H(["vfp-code-block with-line-numbers vfp-w-full", { "no-wrap": !o.value }]),
|
|
100
|
+
style: $({ gridTemplateRows: `repeat(${x.value.length}, auto) minmax(1.5rem, 1fr)` })
|
|
101
|
+
}, [
|
|
102
|
+
(t(!0), i(C, null, z(x.value, (se, g) => (t(), i(C, { key: g }, [
|
|
103
|
+
l("span", le, h(g + 1), 1),
|
|
104
|
+
l("span", {
|
|
105
|
+
class: "vfp-code-line",
|
|
106
|
+
innerHTML: m(y)[g] ?? ""
|
|
107
|
+
}, null, 8, te)
|
|
108
|
+
], 64))), 128)),
|
|
109
|
+
u[1] || (u[1] = l("span", { class: "vfp-code-gutter-filler" }, null, -1)),
|
|
110
|
+
u[2] || (u[2] = l("span", { class: "vfp-code-line-filler" }, null, -1))
|
|
111
|
+
], 6)
|
|
112
|
+
]));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
export {
|
|
116
|
+
fe as default
|
|
117
|
+
};
|