@eternalheart/vue-file-preview 1.6.13 → 1.7.1
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 +4 -0
- package/README.zh-CN.md +4 -0
- package/lib/FilePreviewContent.vue.d.ts +25 -6
- package/lib/FilePreviewEmbed.vue.d.ts +19 -6
- package/lib/FilePreviewModal.vue.d.ts +19 -6
- package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs → EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs} +1 -1
- package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-Cf00sjt2.mjs} +1 -1
- package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-cn1P7b2x.mjs} +1 -1
- package/lib/chunks/{index-BASg1cr4.mjs → index-0VXtKKev.mjs} +1018 -1018
- package/lib/chunks/index-0fXL30y0.mjs +333 -0
- package/lib/chunks/{index-C9mAajbD.mjs → index-B1AwVHWI.mjs} +191 -191
- package/lib/chunks/{index-BvBqDq3O.mjs → index-B77rFiau.mjs} +2023 -2023
- package/lib/chunks/index-BB10as16.mjs +108 -0
- package/lib/chunks/index-BBIn-k4u.mjs +359 -0
- package/lib/chunks/index-BSzaI9ea.mjs +122 -0
- package/lib/chunks/index-BZvy39tn.mjs +117 -0
- package/lib/chunks/index-BlJEM2Lb.mjs +383 -0
- package/lib/chunks/{index-CxKZKUJj.mjs → index-CZlnxQFA.mjs} +1385 -1385
- package/lib/chunks/index-ClhTPqDI.mjs +137 -0
- package/lib/chunks/{index-8Vpbg2kS.mjs → index-D690gnNu.mjs} +118 -117
- package/lib/chunks/index-D7WykPYL.mjs +51 -0
- package/lib/chunks/{index-DZZN3kYi.mjs → index-DBzyeU0G.mjs} +1609 -1375
- package/lib/chunks/{index-Dkro_8Fy.mjs → index-DKFX5ToE.mjs} +33 -33
- package/lib/chunks/index-DRmKaFXK.mjs +157 -0
- package/lib/chunks/index-DXf3wXT5.mjs +155 -0
- package/lib/chunks/{index-BuqPb5mP.mjs → index-Dp7QQjNH.mjs} +114 -114
- package/lib/chunks/index-FzI__DHC.mjs +104 -0
- package/lib/chunks/index-PWjCziZG.mjs +90 -0
- package/lib/chunks/index-bT6XWKO_.mjs +52 -0
- package/lib/chunks/{index-DN4Ui0Gh.mjs → index-tX9VR6Vo.mjs} +122 -122
- package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-D-OEDL3n.mjs} +1 -1
- package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-CVN06LUc.mjs} +1 -1
- package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-DBqcJPFK.mjs} +5 -5
- package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-8-0icdyL.mjs} +1 -1
- package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-a_GUszuU.mjs} +1 -1
- package/lib/composables/useAudioPlayer.d.ts +1 -1
- package/lib/composables/usePreviewEvents.d.ts +27 -0
- package/lib/composables/useRequest.d.ts +16 -4
- package/lib/composables/useThemeMode.d.ts +1 -1
- package/lib/composables/useTranslator.d.ts +2 -2
- package/lib/core/events.d.ts +69 -0
- package/lib/core/i18n/index.d.ts +29 -0
- package/lib/core/i18n/messages/en-US.d.ts +5 -0
- package/lib/core/i18n/messages/index.d.ts +9 -0
- package/lib/core/i18n/messages/zh-CN.d.ts +5 -0
- package/lib/core/i18n/types.d.ts +23 -0
- package/lib/core/index.d.ts +34 -0
- package/lib/core/loaders/avifLoader.d.ts +22 -0
- package/lib/core/loaders/heicLoader.d.ts +21 -0
- package/lib/core/loaders/jp2Loader.d.ts +16 -0
- package/lib/core/loaders/jp2Worker.d.ts +1 -0
- package/lib/core/loaders/psdLoader.d.ts +14 -0
- package/lib/core/loaders/rawLoader.d.ts +14 -0
- package/lib/core/loaders/registry.d.ts +32 -0
- package/lib/core/loaders/tiffLoader.d.ts +28 -0
- package/lib/core/loaders/types.d.ts +56 -0
- package/lib/core/types.d.ts +89 -0
- package/lib/core/utils/csvParser.d.ts +31 -0
- package/lib/core/utils/emptyState.d.ts +28 -0
- package/lib/core/utils/excelDataConverter.d.ts +61 -0
- package/lib/core/utils/fileNormalizer.d.ts +21 -0
- package/lib/core/utils/fileType.d.ts +21 -0
- package/lib/core/utils/legacy-office/doc.d.ts +25 -0
- package/lib/core/utils/legacy-office/index.d.ts +8 -0
- package/lib/core/utils/legacy-office/ole.d.ts +8 -0
- package/lib/core/utils/legacy-office/ppt.d.ts +79 -0
- package/lib/core/utils/legacy-office/xls.d.ts +28 -0
- package/lib/core/utils/mimeTypes.d.ts +29 -0
- package/lib/core/utils/ooxml/docx.d.ts +17 -0
- package/lib/core/utils/ooxml/index.d.ts +4 -0
- package/lib/core/utils/ooxml/pptx.d.ts +7 -0
- package/lib/core/utils/ooxml/xml.d.ts +15 -0
- package/lib/core/utils/ooxml/zip.d.ts +3 -0
- package/lib/core/utils/pdfWorker.d.ts +61 -0
- package/lib/core/utils/previewMode.d.ts +7 -0
- package/lib/core/utils/request.d.ts +49 -0
- package/lib/core/utils/subtitleParser.d.ts +44 -0
- package/lib/core/utils/textDecoder.d.ts +30 -0
- package/lib/core/utils/uint8ArrayPolyfill.d.ts +18 -0
- package/lib/core/utils/zipReader.d.ts +51 -0
- package/lib/core/workers/imageDecoder.worker.d.ts +31 -0
- package/lib/core/workers/workerClient.d.ts +14 -0
- package/lib/i18n/localeKey.d.ts +1 -1
- package/lib/index.cjs +60 -60
- package/lib/index.css +1 -1
- package/lib/index.d.ts +11 -9
- package/lib/index.mjs +15 -12
- package/lib/renderers/Audio/index.vue.d.ts +1 -1
- package/lib/renderers/Cad/index.vue.d.ts +1 -1
- package/lib/renderers/Cad/toolbar.d.ts +2 -2
- package/lib/renderers/Csv/index.vue.d.ts +1 -1
- package/lib/renderers/Doc/index.vue.d.ts +1 -1
- package/lib/renderers/Docx/index.vue.d.ts +1 -1
- package/lib/renderers/Epub/index.vue.d.ts +1 -1
- package/lib/renderers/Font/index.vue.d.ts +1 -1
- package/lib/renderers/Image/index.vue.d.ts +2 -2
- package/lib/renderers/Json/index.vue.d.ts +2 -2
- package/lib/renderers/Markdown/index.vue.d.ts +1 -1
- package/lib/renderers/Mobi/index.vue.d.ts +1 -1
- package/lib/renderers/Msg/index.vue.d.ts +1 -1
- package/lib/renderers/Pdf/index.vue.d.ts +1 -1
- package/lib/renderers/Ppt/index.vue.d.ts +1 -1
- package/lib/renderers/Pptx/index.vue.d.ts +2 -2
- package/lib/renderers/Subtitle/index.vue.d.ts +1 -1
- package/lib/renderers/Text/index.vue.d.ts +2 -2
- package/lib/renderers/Unsupported/index.vue.d.ts +1 -1
- package/lib/renderers/Video/index.vue.d.ts +1 -1
- package/lib/renderers/Xlsx/index.vue.d.ts +2 -2
- package/lib/renderers/Xml/index.vue.d.ts +1 -1
- package/lib/renderers/Zip/TreeItem.vue.d.ts +1 -1
- package/lib/renderers/Zip/index.vue.d.ts +1 -1
- package/lib/renderers/base.types.d.ts +1 -1
- package/lib/renderers/registry.d.ts +1 -1
- package/lib/types.d.ts +3 -3
- package/package.json +2 -2
- package/lib/chunks/index--612Smof.mjs +0 -383
- package/lib/chunks/index-B21EAyWz.mjs +0 -137
- package/lib/chunks/index-BB0i4QqI.mjs +0 -117
- package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
- package/lib/chunks/index-BlrFFeqc.mjs +0 -330
- package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
- package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
- package/lib/chunks/index-CDg6vIbT.mjs +0 -51
- package/lib/chunks/index-CWE-hKSs.mjs +0 -90
- package/lib/chunks/index-CY3xzGgt.mjs +0 -108
- package/lib/chunks/index-D30L8tm9.mjs +0 -155
- package/lib/chunks/index-VdzIFJJW.mjs +0 -118
- package/lib/chunks/index-aoXgVLBb.mjs +0 -52
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { defineComponent as h, ref as
|
|
1
|
+
import { defineComponent as h, ref as c, onMounted as w, watch as x, onBeforeUnmount as E, openBlock as f, createBlock as C, createElementBlock as _, createElementVNode as a, toDisplayString as B, unref as D, createCommentVNode as P } from "vue";
|
|
2
2
|
import N from "video.js";
|
|
3
|
-
import { u as
|
|
4
|
-
import { _ as
|
|
5
|
-
const
|
|
3
|
+
import { u as R, b as S, B as y } from "./index-DBzyeU0G.mjs";
|
|
4
|
+
import { _ as U } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
+
const V = {
|
|
6
6
|
key: 1,
|
|
7
7
|
class: "vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full"
|
|
8
|
-
},
|
|
8
|
+
}, j = { class: "vfp-w-full vfp-h-full vfp-relative" }, q = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-3 vfp-backdrop-blur-sm vfp-z-10"
|
|
11
|
-
},
|
|
11
|
+
}, L = { class: "vfp-renderer-loading-content" }, G = { class: "vfp-renderer-loading-text" }, X = /* @__PURE__ */ h({
|
|
12
12
|
__name: "index",
|
|
13
13
|
props: {
|
|
14
14
|
url: {},
|
|
15
15
|
fileName: {},
|
|
16
16
|
mimeType: {}
|
|
17
17
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const o =
|
|
18
|
+
setup(g, { expose: k }) {
|
|
19
|
+
const o = g, { t } = R(), u = S(), T = /* @__PURE__ */ new Set(["avi", "wmv", "flv"]), i = c(null), d = c(!0), p = c(null);
|
|
20
20
|
let e = null;
|
|
21
|
-
const
|
|
21
|
+
const b = (s, r) => {
|
|
22
22
|
var n;
|
|
23
23
|
return ((n = (r || s).split(".").pop()) == null ? void 0 : n.toLowerCase().split("?")[0]) || "";
|
|
24
24
|
};
|
|
25
25
|
return w(() => {
|
|
26
|
-
if (!
|
|
27
|
-
const s =
|
|
28
|
-
if (
|
|
26
|
+
if (u.begin(o.url), !p.value || e) return;
|
|
27
|
+
const s = b(o.url, o.fileName);
|
|
28
|
+
if (T.has(s)) {
|
|
29
29
|
i.value = {
|
|
30
30
|
title: t.value("video.unsupported_title"),
|
|
31
31
|
detail: t.value("video.unsupported_detail", { format: s.toUpperCase() })
|
|
32
|
-
},
|
|
32
|
+
}, d.value = !1;
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const r = document.createElement("video-js");
|
|
36
|
-
r.classList.add("vjs-big-play-centered", "rfp-video-player"),
|
|
37
|
-
const
|
|
36
|
+
r.classList.add("vjs-big-play-centered", "rfp-video-player"), p.value.appendChild(r);
|
|
37
|
+
const v = y(o.url, o.mimeType);
|
|
38
38
|
let n;
|
|
39
|
-
|
|
39
|
+
v === "video/quicktime" ? n = [
|
|
40
40
|
{ src: o.url, type: "video/quicktime" },
|
|
41
41
|
{ src: o.url, type: "video/mp4" }
|
|
42
|
-
] : n = [{ src: o.url, type:
|
|
42
|
+
] : n = [{ src: o.url, type: v }], e = N(r, {
|
|
43
43
|
controls: !0,
|
|
44
44
|
fill: !0,
|
|
45
45
|
preload: "auto",
|
|
@@ -67,9 +67,9 @@ const S = {
|
|
|
67
67
|
},
|
|
68
68
|
sources: n
|
|
69
69
|
});
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const m = e.el().querySelector("video");
|
|
71
|
+
m && (m.style.objectFit = "contain"), e.on("loadeddata", () => {
|
|
72
|
+
d.value = !1, u.ready();
|
|
73
73
|
}), e.on("error", () => {
|
|
74
74
|
const l = e == null ? void 0 : e.error();
|
|
75
75
|
console.warn("[VideoRenderer] Video playback error:", (l == null ? void 0 : l.message) || "Unknown error"), (l == null ? void 0 : l.code) === 4 ? i.value = {
|
|
@@ -80,32 +80,32 @@ const S = {
|
|
|
80
80
|
} : i.value = {
|
|
81
81
|
title: t.value("video.load_failed"),
|
|
82
82
|
detail: (l == null ? void 0 : l.message) || t.value("common.unknown_error")
|
|
83
|
-
},
|
|
83
|
+
}, d.value = !1, u.error(l ?? new Error("video load failed"), (l == null ? void 0 : l.code) === 2 ? "request" : "parse");
|
|
84
84
|
});
|
|
85
85
|
}), x(
|
|
86
86
|
[() => o.url, () => o.mimeType],
|
|
87
87
|
() => {
|
|
88
|
-
e && !e.isDisposed() && e.src({ src: o.url, type: y(o.url, o.mimeType) });
|
|
88
|
+
u.begin(o.url), e && !e.isDisposed() && e.src({ src: o.url, type: y(o.url, o.mimeType) });
|
|
89
89
|
}
|
|
90
|
-
),
|
|
90
|
+
), E(() => {
|
|
91
91
|
e && !e.isDisposed() && (e.dispose(), e = null);
|
|
92
|
-
}),
|
|
92
|
+
}), k({
|
|
93
93
|
getToolbarGroups: () => []
|
|
94
|
-
}), (s, r) => i.value ? (
|
|
94
|
+
}), (s, r) => i.value ? (f(), C(U, {
|
|
95
95
|
key: 0,
|
|
96
96
|
message: i.value.title,
|
|
97
97
|
detail: i.value.detail
|
|
98
|
-
}, null, 8, ["message", "detail"])) : (
|
|
99
|
-
a("div",
|
|
100
|
-
|
|
101
|
-
a("div",
|
|
98
|
+
}, null, 8, ["message", "detail"])) : (f(), _("div", V, [
|
|
99
|
+
a("div", j, [
|
|
100
|
+
d.value ? (f(), _("div", q, [
|
|
101
|
+
a("div", L, [
|
|
102
102
|
r[0] || (r[0] = a("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
103
|
-
a("p",
|
|
103
|
+
a("p", G, B(D(t)("video.loading")), 1)
|
|
104
104
|
])
|
|
105
|
-
])) :
|
|
105
|
+
])) : P("", !0),
|
|
106
106
|
a("div", {
|
|
107
107
|
ref_key: "videoContainerRef",
|
|
108
|
-
ref:
|
|
108
|
+
ref: p,
|
|
109
109
|
class: "vfp-overflow-hidden vfp-w-full vfp-h-full",
|
|
110
110
|
style: { "box-shadow": "0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)" }
|
|
111
111
|
}, null, 512)
|
|
@@ -114,5 +114,5 @@ const S = {
|
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
export {
|
|
117
|
-
|
|
117
|
+
X as default
|
|
118
118
|
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { defineComponent as V, ref as v, onMounted as q, watch as A, onBeforeUnmount as I, computed as O, openBlock as p, createElementBlock as h, createElementVNode as k, toDisplayString as S, unref as C, createCommentVNode as b, createVNode as z, normalizeStyle as $ } from "vue";
|
|
2
|
+
import { u as G, a as J, b as U, T as j, J as D, R as K, p as Q } from "./index-DBzyeU0G.mjs";
|
|
3
|
+
import { init as M } from "pptx-preview";
|
|
4
|
+
import { _ as X } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
5
|
+
import { _ as Y } from "./EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs";
|
|
6
|
+
const Z = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, ee = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "vfp-renderer-overlay vfp-renderer-loading"
|
|
9
|
+
}, te = { class: "vfp-renderer-loading-content" }, re = { class: "vfp-renderer-loading-text" }, ie = {
|
|
10
|
+
key: 1,
|
|
11
|
+
class: "vfp-renderer-overlay"
|
|
12
|
+
}, le = {
|
|
13
|
+
key: 2,
|
|
14
|
+
class: "vfp-renderer-overlay"
|
|
15
|
+
}, de = /* @__PURE__ */ V({
|
|
16
|
+
__name: "index",
|
|
17
|
+
props: {
|
|
18
|
+
url: {},
|
|
19
|
+
tiled: { type: Boolean, default: !0 },
|
|
20
|
+
emptyHint: {}
|
|
21
|
+
},
|
|
22
|
+
setup(H, { expose: W }) {
|
|
23
|
+
const o = H, { t: s } = G(), P = J(), m = U(), n = v(!0), u = v(null), w = v(!1), y = v(0), i = v(null);
|
|
24
|
+
let l = null, _ = null, c = null, f = null, g = { width: 0, height: 0 }, R = 9 / 16;
|
|
25
|
+
const x = () => {
|
|
26
|
+
var d;
|
|
27
|
+
if (!i.value) return { width: 960, height: 540 };
|
|
28
|
+
const t = i.value.clientWidth, e = ((d = i.value.parentElement) == null ? void 0 : d.clientWidth) || 0, r = t > 100 ? t : e > 100 ? e : 300, a = Math.floor(r * R);
|
|
29
|
+
return { width: r, height: a };
|
|
30
|
+
}, F = async () => {
|
|
31
|
+
if (!(!i.value || !c || y.value === 0))
|
|
32
|
+
try {
|
|
33
|
+
if (l)
|
|
34
|
+
try {
|
|
35
|
+
l.destroy();
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
i.value.innerHTML = "";
|
|
39
|
+
const t = x();
|
|
40
|
+
l = M(i.value, {
|
|
41
|
+
width: t.width,
|
|
42
|
+
height: o.tiled ? t.height * y.value : t.height,
|
|
43
|
+
mode: o.tiled ? "list" : "slide"
|
|
44
|
+
}), await l.preview(c);
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
}, B = async () => {
|
|
48
|
+
if (m.begin(o.url), !i.value) return;
|
|
49
|
+
n.value = !0, u.value = null, w.value = !1;
|
|
50
|
+
let t = window.setTimeout(() => {
|
|
51
|
+
u.value = s.value("pptx.timeout"), n.value = !1;
|
|
52
|
+
}, 3e4);
|
|
53
|
+
try {
|
|
54
|
+
const e = await P.value(o.url, {
|
|
55
|
+
mode: "cors",
|
|
56
|
+
credentials: "omit",
|
|
57
|
+
redirect: "follow"
|
|
58
|
+
});
|
|
59
|
+
if (!e.ok)
|
|
60
|
+
throw e.status === 404 ? new Error(s.value("pptx.not_found")) : e.status === 403 ? new D("file.forbidden") : e.status >= 500 ? new D("file.server_error") : new D("file.load_failed_status", { status: e.status });
|
|
61
|
+
const r = await e.arrayBuffer();
|
|
62
|
+
if (r.byteLength === 0) {
|
|
63
|
+
t !== null && clearTimeout(t), w.value = !0, n.value = !1, m.ready();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
c = r, R = (await K(r)).ratio;
|
|
67
|
+
const a = document.createElement("div");
|
|
68
|
+
a.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden", document.body.appendChild(a);
|
|
69
|
+
try {
|
|
70
|
+
const d = M(a, {
|
|
71
|
+
width: 100,
|
|
72
|
+
height: 100,
|
|
73
|
+
mode: "slide"
|
|
74
|
+
});
|
|
75
|
+
try {
|
|
76
|
+
await d.preview(r);
|
|
77
|
+
} catch {
|
|
78
|
+
throw new Error(s.value("pptx.invalid_format"));
|
|
79
|
+
}
|
|
80
|
+
const T = d.slideCount;
|
|
81
|
+
if (!T || T === 0) throw new Error(s.value("pptx.no_pages"));
|
|
82
|
+
d.destroy(), y.value = T, i.value && (i.value.innerHTML = "");
|
|
83
|
+
const E = x();
|
|
84
|
+
l = M(i.value, {
|
|
85
|
+
width: E.width,
|
|
86
|
+
height: o.tiled ? E.height * T : E.height,
|
|
87
|
+
mode: o.tiled ? "list" : "slide"
|
|
88
|
+
}), await l.preview(r), t !== null && (clearTimeout(t), t = null), n.value = !1, m.ready();
|
|
89
|
+
} finally {
|
|
90
|
+
document.body.contains(a) && document.body.removeChild(a);
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
t !== null && clearTimeout(t);
|
|
94
|
+
let r = s.value("pptx.parse_failed");
|
|
95
|
+
e instanceof Error ? r = Q(s.value, e) : typeof e == "string" && (r = e), u.value = r, n.value = !1, m.error(e);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
q(() => {
|
|
99
|
+
if (!i.value) return;
|
|
100
|
+
let t = !0;
|
|
101
|
+
_ = new ResizeObserver(() => {
|
|
102
|
+
if (t) {
|
|
103
|
+
t = !1, g = x();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const e = x(), r = Math.abs(g.width - e.width), a = Math.abs(g.height - e.height);
|
|
107
|
+
r < 10 && a < 10 || (g = e, f !== null && clearTimeout(f), f = window.setTimeout(() => {
|
|
108
|
+
l && c && F();
|
|
109
|
+
}, 800));
|
|
110
|
+
}), _.observe(i.value), setTimeout(() => {
|
|
111
|
+
requestAnimationFrame(() => requestAnimationFrame(() => B()));
|
|
112
|
+
}, 150);
|
|
113
|
+
}), A(
|
|
114
|
+
() => o.url,
|
|
115
|
+
(t) => {
|
|
116
|
+
t && B();
|
|
117
|
+
}
|
|
118
|
+
), I(() => {
|
|
119
|
+
if (_ && _.disconnect(), f !== null && clearTimeout(f), c = null, y.value = 0, l)
|
|
120
|
+
try {
|
|
121
|
+
l.destroy();
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
l = null;
|
|
125
|
+
});
|
|
126
|
+
const L = () => [], N = O(() => j(o.emptyHint, "structured"));
|
|
127
|
+
return W({
|
|
128
|
+
getToolbarGroups: L
|
|
129
|
+
}), (t, e) => (p(), h("div", Z, [
|
|
130
|
+
n.value ? (p(), h("div", ee, [
|
|
131
|
+
k("div", te, [
|
|
132
|
+
e[0] || (e[0] = k("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
133
|
+
k("p", re, S(C(s)("pptx.loading")), 1)
|
|
134
|
+
])
|
|
135
|
+
])) : b("", !0),
|
|
136
|
+
w.value && !n.value && N.value ? (p(), h("div", ie, [
|
|
137
|
+
z(Y)
|
|
138
|
+
])) : b("", !0),
|
|
139
|
+
u.value && !n.value ? (p(), h("div", le, [
|
|
140
|
+
z(X, {
|
|
141
|
+
message: C(s)("pptx.load_failed"),
|
|
142
|
+
detail: u.value
|
|
143
|
+
}, null, 8, ["message", "detail"])
|
|
144
|
+
])) : b("", !0),
|
|
145
|
+
u.value ? b("", !0) : (p(), h("div", {
|
|
146
|
+
key: 3,
|
|
147
|
+
ref_key: "containerRef",
|
|
148
|
+
ref: i,
|
|
149
|
+
class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
|
|
150
|
+
style: $({ opacity: n.value || w.value ? 0 : 1 })
|
|
151
|
+
}, null, 4))
|
|
152
|
+
]));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
export {
|
|
156
|
+
de as default
|
|
157
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { defineComponent as K, computed as O, ref as i, watch as k, nextTick as R, openBlock as d, createElementBlock as p, createElementVNode as y, toDisplayString as B, unref as N, createBlock as Y } from "vue";
|
|
2
|
+
import F from "markdown-it";
|
|
3
|
+
import W from "@traptitech/markdown-it-katex";
|
|
4
|
+
import { codeToHtml as L } from "shiki";
|
|
5
|
+
import { Code as z, Eye as J } from "lucide-vue-next";
|
|
6
|
+
import { u as Q, a as U, b as X, e as Z, f as ee, d as te } from "./index-DBzyeU0G.mjs";
|
|
7
|
+
import { _ as oe } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
|
|
8
|
+
import { T as re } from "./base.types-DaftHyg7.mjs";
|
|
9
|
+
const ne = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "vfp-renderer-loading"
|
|
12
|
+
}, se = { class: "vfp-renderer-loading-content" }, ae = { class: "vfp-renderer-loading-text" }, le = {
|
|
13
|
+
key: 2,
|
|
14
|
+
class: "vfp-w-full vfp-h-full vfp-overflow-auto",
|
|
15
|
+
style: { background: "var(--fp-code-bg)" }
|
|
16
|
+
}, ce = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "vfp-p-6 vfp-text-fg-primary vfp-font-mono vfp-text-sm vfp-whitespace-pre-wrap vfp-break-words"
|
|
19
|
+
}, ie = ["innerHTML"], de = {
|
|
20
|
+
key: 3,
|
|
21
|
+
class: "vfp-w-full vfp-h-full vfp-overflow-auto vfp-py-6 vfp-px-4"
|
|
22
|
+
}, ue = ["innerHTML"], q = '<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>', V = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>', pe = '<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>', ve = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>', he = /* @__PURE__ */ K({
|
|
23
|
+
__name: "index",
|
|
24
|
+
props: {
|
|
25
|
+
url: {}
|
|
26
|
+
},
|
|
27
|
+
setup(G, { expose: $ }) {
|
|
28
|
+
const _ = G, T = new re(), { t: l } = Q(), j = U(), b = X(), A = Z(), x = O(() => A.value === "light" ? "github-light" : "github-dark"), c = i("preview"), C = i(""), v = i(""), h = i(""), u = i(!0), f = i(null), m = i(null);
|
|
29
|
+
k([c, u], () => {
|
|
30
|
+
T.notify();
|
|
31
|
+
}), $({
|
|
32
|
+
getToolbarGroups: () => {
|
|
33
|
+
const e = [];
|
|
34
|
+
return e.push({
|
|
35
|
+
items: [
|
|
36
|
+
{
|
|
37
|
+
type: "button",
|
|
38
|
+
icon: c.value === "preview" ? z : J,
|
|
39
|
+
tooltip: c.value === "preview" ? l.value("toolbar.source") : l.value("toolbar.preview"),
|
|
40
|
+
action: () => {
|
|
41
|
+
c.value = c.value === "preview" ? "source" : "preview";
|
|
42
|
+
},
|
|
43
|
+
active: c.value === "source"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}), e;
|
|
47
|
+
},
|
|
48
|
+
onToolbarChange: (e) => T.subscribe(e)
|
|
49
|
+
});
|
|
50
|
+
const s = new F({
|
|
51
|
+
html: !0,
|
|
52
|
+
linkify: !0,
|
|
53
|
+
typographer: !1,
|
|
54
|
+
breaks: !1
|
|
55
|
+
});
|
|
56
|
+
s.use(W), s.renderer.rules.fence = (e, r) => {
|
|
57
|
+
const t = e[r], n = t.info ? t.info.trim() : "", o = t.content;
|
|
58
|
+
return n ? `<div class="code-block-wrapper">
|
|
59
|
+
<div class="code-block-header">
|
|
60
|
+
<span>${n}</span>
|
|
61
|
+
</div>
|
|
62
|
+
<pre data-shiki-pending="1" data-lang="${n}"><code>${s.utils.escapeHtml(o)}</code></pre>
|
|
63
|
+
</div>` : `<div class="code-block-wrapper">
|
|
64
|
+
<pre class="no-lang-pre"><code>${s.utils.escapeHtml(o)}</code></pre>
|
|
65
|
+
</div>`;
|
|
66
|
+
}, s.renderer.rules.code_block = (e, r) => {
|
|
67
|
+
const t = e[r].content;
|
|
68
|
+
return `<div class="code-block-wrapper">
|
|
69
|
+
<pre class="no-lang-pre"><code>${s.utils.escapeHtml(t)}</code></pre>
|
|
70
|
+
</div>`;
|
|
71
|
+
};
|
|
72
|
+
const P = s.renderer.rules.table_open || ((e, r, t, n, o) => o.renderToken(e, r, t));
|
|
73
|
+
s.renderer.rules.table_open = (e, r, t, n, o) => '<div class="table-wrapper">' + P(e, r, t, n, o);
|
|
74
|
+
const I = s.renderer.rules.table_close || ((e, r, t, n, o) => o.renderToken(e, r, t));
|
|
75
|
+
s.renderer.rules.table_close = (e, r, t, n, o) => I(e, r, t, n, o) + "</div>";
|
|
76
|
+
const M = async () => {
|
|
77
|
+
b.begin(_.url), u.value = !0, f.value = null;
|
|
78
|
+
try {
|
|
79
|
+
const e = await ee(_.url, { fetcher: j.value });
|
|
80
|
+
C.value = e, v.value = s.render(e), u.value = !1, b.ready();
|
|
81
|
+
try {
|
|
82
|
+
h.value = await L(e, { lang: "markdown", theme: x.value });
|
|
83
|
+
} catch {
|
|
84
|
+
h.value = "";
|
|
85
|
+
}
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error(e), f.value = l.value("markdown.load_failed"), u.value = !1, b.error(e);
|
|
88
|
+
}
|
|
89
|
+
}, S = (e, r) => {
|
|
90
|
+
const t = document.createElement("button");
|
|
91
|
+
return t.type = "button", t.className = r ? "code-copy-btn" : "code-copy-btn code-copy-float", t.title = l.value("markdown.copy_code"), t.innerHTML = r ? q : V, t.addEventListener("click", async (n) => {
|
|
92
|
+
n.stopPropagation();
|
|
93
|
+
try {
|
|
94
|
+
await navigator.clipboard.writeText(e);
|
|
95
|
+
} catch {
|
|
96
|
+
const o = document.createElement("textarea");
|
|
97
|
+
o.value = e, document.body.appendChild(o), o.select(), document.execCommand("copy"), document.body.removeChild(o);
|
|
98
|
+
}
|
|
99
|
+
t.innerHTML = r ? pe : ve, t.title = l.value("markdown.copied"), setTimeout(() => {
|
|
100
|
+
t.innerHTML = r ? q : V, t.title = l.value("markdown.copy_code");
|
|
101
|
+
}, 2e3);
|
|
102
|
+
}), t;
|
|
103
|
+
}, D = async () => {
|
|
104
|
+
var t, n;
|
|
105
|
+
if (!m.value) return;
|
|
106
|
+
const e = m.value.querySelectorAll('pre[data-shiki-pending="1"]');
|
|
107
|
+
for (const o of e) {
|
|
108
|
+
const w = o.getAttribute("data-lang") || "text", a = ((t = o.querySelector("code")) == null ? void 0 : t.textContent) || "";
|
|
109
|
+
try {
|
|
110
|
+
const g = await L(a, { lang: w, theme: x.value }), H = document.createElement("div");
|
|
111
|
+
H.innerHTML = g;
|
|
112
|
+
const E = H.firstElementChild;
|
|
113
|
+
E && o.replaceWith(E);
|
|
114
|
+
} catch {
|
|
115
|
+
o.style.backgroundColor = "var(--fp-code-bg)", o.removeAttribute("data-shiki-pending");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const r = m.value.querySelectorAll(".code-block-wrapper");
|
|
119
|
+
for (const o of r) {
|
|
120
|
+
if (o.querySelector(".code-copy-btn")) continue;
|
|
121
|
+
const w = o.querySelector(".code-block-header"), a = o.querySelector("pre"), g = ((n = a == null ? void 0 : a.querySelector("code")) == null ? void 0 : n.textContent) ?? (a == null ? void 0 : a.textContent) ?? "";
|
|
122
|
+
w ? w.appendChild(S(g, !0)) : o.appendChild(S(g, !1));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return k(() => _.url, M, { immediate: !0 }), k(v, async () => {
|
|
126
|
+
v.value && (await R(), D());
|
|
127
|
+
}), k(x, () => {
|
|
128
|
+
C.value && M();
|
|
129
|
+
}), (e, r) => u.value ? (d(), p("div", ne, [
|
|
130
|
+
y("div", se, [
|
|
131
|
+
r[0] || (r[0] = y("div", { class: "vfp-renderer-spinner" }, null, -1)),
|
|
132
|
+
y("span", ae, B(N(l)("common.loading")), 1)
|
|
133
|
+
])
|
|
134
|
+
])) : f.value ? (d(), Y(oe, {
|
|
135
|
+
key: 1,
|
|
136
|
+
message: f.value
|
|
137
|
+
}, null, 8, ["message"])) : c.value === "source" ? (d(), p("div", le, [
|
|
138
|
+
h.value ? (d(), p("div", {
|
|
139
|
+
key: 1,
|
|
140
|
+
class: "shiki-wrapper",
|
|
141
|
+
innerHTML: h.value
|
|
142
|
+
}, null, 8, ie)) : (d(), p("pre", ce, B(C.value), 1))
|
|
143
|
+
])) : (d(), p("div", de, [
|
|
144
|
+
y("div", {
|
|
145
|
+
ref_key: "containerRef",
|
|
146
|
+
ref: m,
|
|
147
|
+
class: "markdown-body",
|
|
148
|
+
innerHTML: v.value
|
|
149
|
+
}, null, 8, ue)
|
|
150
|
+
]));
|
|
151
|
+
}
|
|
152
|
+
}), Ce = /* @__PURE__ */ te(he, [["__scopeId", "data-v-67620d24"]]);
|
|
153
|
+
export {
|
|
154
|
+
Ce as default
|
|
155
|
+
};
|