basic-file-preview 1.0.1 → 1.0.2
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/dist/lib/DocxPreview.js +19 -1
- package/dist/lib/ExcelPreview.js +20 -1
- package/dist/lib/ImagePreview.js +670 -1
- package/dist/lib/JsonPreview.js +42 -1
- package/dist/lib/MarkdownPreview.js +50 -1
- package/dist/lib/PdfPreview.js +42 -1
- package/dist/lib/PptPreview.js +203 -1
- package/dist/lib/TxtPreview.js +39 -2
- package/dist/lib/_plugin-vue_export-helper.js +9 -1
- package/dist/lib/index.js +3142 -5
- package/dist/types/components/FilePreview/index.d.ts +11 -4
- package/package.json +3 -4
- package/dist/index.cjs.js +0 -2
package/dist/lib/JsonPreview.js
CHANGED
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineComponent as s, ref as p, onMounted as c, openBlock as l, createBlock as i, unref as t } from "vue";
|
|
2
|
+
import u from "axios";
|
|
3
|
+
import d from "vue-json-viewer";
|
|
4
|
+
import { _ as f } from "./_plugin-vue_export-helper.js";
|
|
5
|
+
const m = /* @__PURE__ */ s({
|
|
6
|
+
name: "JsonPreview",
|
|
7
|
+
__name: "JsonPreview",
|
|
8
|
+
props: {
|
|
9
|
+
url: {}
|
|
10
|
+
},
|
|
11
|
+
setup(r) {
|
|
12
|
+
const e = r, o = p({}), n = async () => {
|
|
13
|
+
if (!e.url) return;
|
|
14
|
+
const a = await u.get(e.url, {
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": "application/json"
|
|
17
|
+
},
|
|
18
|
+
params: { _t: Date.now() }
|
|
19
|
+
});
|
|
20
|
+
o.value = a.data;
|
|
21
|
+
};
|
|
22
|
+
return c(() => {
|
|
23
|
+
n();
|
|
24
|
+
}), (a, _) => (l(), i(t(d), {
|
|
25
|
+
value: t(o),
|
|
26
|
+
"expand-depth": 1,
|
|
27
|
+
expanded: !1,
|
|
28
|
+
copyable: {
|
|
29
|
+
copyText: "复制",
|
|
30
|
+
copiedText: "已复制"
|
|
31
|
+
},
|
|
32
|
+
sort: !1,
|
|
33
|
+
boxed: !1,
|
|
34
|
+
"preview-mode": "",
|
|
35
|
+
"show-array-index": !1,
|
|
36
|
+
showDoubleQuotes: !1
|
|
37
|
+
}, null, 8, ["value"]));
|
|
38
|
+
}
|
|
39
|
+
}), y = /* @__PURE__ */ f(m, [["__scopeId", "data-v-71d7c898"]]);
|
|
40
|
+
export {
|
|
41
|
+
y as default
|
|
42
|
+
};
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineComponent as a, ref as i, onMounted as p, openBlock as s, createBlock as l, unref as f } from "vue";
|
|
2
|
+
import c from "axios";
|
|
3
|
+
import { Viewer as u } from "@bytemd/vue-next";
|
|
4
|
+
import d from "@bytemd/plugin-breaks";
|
|
5
|
+
import g from "@bytemd/plugin-frontmatter";
|
|
6
|
+
import w from "@bytemd/plugin-gemoji";
|
|
7
|
+
import v from "@bytemd/plugin-gfm";
|
|
8
|
+
import _ from "@bytemd/plugin-highlight";
|
|
9
|
+
import h from "@bytemd/plugin-math";
|
|
10
|
+
import k from "@bytemd/plugin-medium-zoom";
|
|
11
|
+
import x from "@bytemd/plugin-mermaid";
|
|
12
|
+
const z = /* @__PURE__ */ a({
|
|
13
|
+
name: "MarkdownPreview",
|
|
14
|
+
__name: "MarkdownPreview",
|
|
15
|
+
props: {
|
|
16
|
+
url: {}
|
|
17
|
+
},
|
|
18
|
+
setup(t) {
|
|
19
|
+
console.log("MarkdownPreview");
|
|
20
|
+
const r = t, m = [
|
|
21
|
+
d(),
|
|
22
|
+
g(),
|
|
23
|
+
w(),
|
|
24
|
+
v(),
|
|
25
|
+
_(),
|
|
26
|
+
h(),
|
|
27
|
+
k(),
|
|
28
|
+
x()
|
|
29
|
+
], e = i(), n = async () => {
|
|
30
|
+
if (!r.url) return;
|
|
31
|
+
const o = await c.get(r.url, {
|
|
32
|
+
headers: {
|
|
33
|
+
"Content-Type": "application/json"
|
|
34
|
+
},
|
|
35
|
+
params: { _t: Date.now() }
|
|
36
|
+
});
|
|
37
|
+
console.log("md", o.data), e.value = o.data;
|
|
38
|
+
};
|
|
39
|
+
return p(() => {
|
|
40
|
+
n();
|
|
41
|
+
}), (o, M) => (s(), l(f(u), {
|
|
42
|
+
style: { padding: "10px 15px" },
|
|
43
|
+
value: e.value,
|
|
44
|
+
plugins: m
|
|
45
|
+
}, null, 8, ["value"]));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export {
|
|
49
|
+
z as default
|
|
50
|
+
};
|
package/dist/lib/PdfPreview.js
CHANGED
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineComponent as f, openBlock as n, createElementBlock as a, createElementVNode as l, createVNode as p, unref as i } from "vue";
|
|
2
|
+
import s from "vue3-pdf-app";
|
|
3
|
+
import { _ as d } from "./_plugin-vue_export-helper.js";
|
|
4
|
+
const c = { class: "h-full" }, m = /* @__PURE__ */ f({
|
|
5
|
+
name: "PdfPreview",
|
|
6
|
+
__name: "PdfPreview",
|
|
7
|
+
props: {
|
|
8
|
+
url: {}
|
|
9
|
+
},
|
|
10
|
+
setup(o) {
|
|
11
|
+
const r = {
|
|
12
|
+
toolbar: {
|
|
13
|
+
toolbarViewerRight: {
|
|
14
|
+
presentationMode: !1,
|
|
15
|
+
openFile: !1,
|
|
16
|
+
print: !1,
|
|
17
|
+
download: !1,
|
|
18
|
+
viewBookmark: !1
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function t() {
|
|
23
|
+
localStorage.removeItem("pdfjs.history");
|
|
24
|
+
}
|
|
25
|
+
return (u, e) => (n(), a("div", c, [
|
|
26
|
+
e[0] || (e[0] = l("link", {
|
|
27
|
+
rel: "resource",
|
|
28
|
+
type: "application/l10n",
|
|
29
|
+
href: "/pdf/viewer.properties"
|
|
30
|
+
}, null, -1)),
|
|
31
|
+
p(i(s), {
|
|
32
|
+
ref: "pdfRef",
|
|
33
|
+
pdf: o.url,
|
|
34
|
+
config: r,
|
|
35
|
+
onAfterCreated: t
|
|
36
|
+
}, null, 8, ["pdf"])
|
|
37
|
+
]));
|
|
38
|
+
}
|
|
39
|
+
}), P = /* @__PURE__ */ d(m, [["__scopeId", "data-v-23ac8401"]]);
|
|
40
|
+
export {
|
|
41
|
+
P as default
|
|
42
|
+
};
|
package/dist/lib/PptPreview.js
CHANGED
|
@@ -1 +1,203 @@
|
|
|
1
|
-
|
|
1
|
+
import { u as R, r as y, i as j, a as I, g as v, b as A, c as N, h as z } from "./index.js";
|
|
2
|
+
import { ref as k, reactive as q, createApp as D, defineComponent as S, h as m, Transition as F, withCtx as G, withDirectives as V, createVNode as H, vShow as K, toRefs as M, nextTick as $, isRef as Y, openBlock as Z, createBlock as J, unref as L, createCommentVNode as Q } from "vue";
|
|
3
|
+
import U from "@vue-office/pptx";
|
|
4
|
+
import { _ as W } from "./_plugin-vue_export-helper.js";
|
|
5
|
+
function X(e, n) {
|
|
6
|
+
let t;
|
|
7
|
+
const s = k(!1), o = q({
|
|
8
|
+
...e,
|
|
9
|
+
originalPosition: "",
|
|
10
|
+
originalOverflow: "",
|
|
11
|
+
visible: !1
|
|
12
|
+
});
|
|
13
|
+
function r(a) {
|
|
14
|
+
o.text = a;
|
|
15
|
+
}
|
|
16
|
+
function i() {
|
|
17
|
+
const a = o.parent, p = f.ns;
|
|
18
|
+
if (!a.vLoadingAddClassList) {
|
|
19
|
+
let c = a.getAttribute("loading-number");
|
|
20
|
+
c = Number.parseInt(c) - 1, c ? a.setAttribute("loading-number", c.toString()) : (y(a, p.bm("parent", "relative")), a.removeAttribute("loading-number")), y(a, p.bm("parent", "hidden"));
|
|
21
|
+
}
|
|
22
|
+
d(), C.unmount();
|
|
23
|
+
}
|
|
24
|
+
function d() {
|
|
25
|
+
f.$el?.parentNode?.removeChild(f.$el);
|
|
26
|
+
}
|
|
27
|
+
function b() {
|
|
28
|
+
e.beforeClose && !e.beforeClose() || (s.value = !0, clearTimeout(t), t = setTimeout(l, 400), o.visible = !1, e.closed?.());
|
|
29
|
+
}
|
|
30
|
+
function l() {
|
|
31
|
+
if (!s.value) return;
|
|
32
|
+
const a = o.parent;
|
|
33
|
+
s.value = !1, a.vLoadingAddClassList = void 0, i();
|
|
34
|
+
}
|
|
35
|
+
const C = D(S({
|
|
36
|
+
name: "ElLoading",
|
|
37
|
+
setup(a, { expose: p }) {
|
|
38
|
+
const { ns: c, zIndex: T } = R("loading");
|
|
39
|
+
return p({
|
|
40
|
+
ns: c,
|
|
41
|
+
zIndex: T
|
|
42
|
+
}), () => {
|
|
43
|
+
const w = o.spinner || o.svg, E = m("svg", {
|
|
44
|
+
class: "circular",
|
|
45
|
+
viewBox: o.svgViewBox ? o.svgViewBox : "0 0 50 50",
|
|
46
|
+
...w ? { innerHTML: w } : {}
|
|
47
|
+
}, [m("circle", {
|
|
48
|
+
class: "path",
|
|
49
|
+
cx: "25",
|
|
50
|
+
cy: "25",
|
|
51
|
+
r: "20",
|
|
52
|
+
fill: "none"
|
|
53
|
+
})]), O = o.text ? m("p", { class: c.b("text") }, [o.text]) : void 0;
|
|
54
|
+
return m(F, {
|
|
55
|
+
name: c.b("fade"),
|
|
56
|
+
onAfterLeave: l
|
|
57
|
+
}, { default: G(() => [V(H("div", {
|
|
58
|
+
style: { backgroundColor: o.background || "" },
|
|
59
|
+
class: [
|
|
60
|
+
c.b("mask"),
|
|
61
|
+
o.customClass,
|
|
62
|
+
c.is("fullscreen", o.fullscreen)
|
|
63
|
+
]
|
|
64
|
+
}, [m("div", { class: c.b("spinner") }, [E, O])]), [[K, o.visible]])]) });
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
Object.assign(C._context, n ?? {});
|
|
69
|
+
const f = C.mount(document.createElement("div"));
|
|
70
|
+
return {
|
|
71
|
+
...M(o),
|
|
72
|
+
setText: r,
|
|
73
|
+
removeElLoadingChild: d,
|
|
74
|
+
close: b,
|
|
75
|
+
handleAfterLeave: l,
|
|
76
|
+
vm: f,
|
|
77
|
+
get $el() {
|
|
78
|
+
return f.$el;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
let x;
|
|
83
|
+
const _ = function(e = {}, n) {
|
|
84
|
+
if (!j) return;
|
|
85
|
+
const t = ee(e);
|
|
86
|
+
if (t.fullscreen && x) return x;
|
|
87
|
+
const s = X({
|
|
88
|
+
...t,
|
|
89
|
+
closed: () => {
|
|
90
|
+
t.closed?.(), t.fullscreen && (x = void 0);
|
|
91
|
+
}
|
|
92
|
+
}, n ?? _._context);
|
|
93
|
+
te(t, t.parent, s), B(t, t.parent, s), t.parent.vLoadingAddClassList = () => B(t, t.parent, s);
|
|
94
|
+
let o = t.parent.getAttribute("loading-number");
|
|
95
|
+
return o ? o = `${Number.parseInt(o) + 1}` : o = "1", t.parent.setAttribute("loading-number", o), t.parent.appendChild(s.$el), $(() => s.visible.value = t.visible), t.fullscreen && (x = s), s;
|
|
96
|
+
}, ee = (e) => {
|
|
97
|
+
let n;
|
|
98
|
+
return I(e.target) ? n = document.querySelector(e.target) ?? document.body : n = e.target || document.body, {
|
|
99
|
+
parent: n === document.body || e.body ? document.body : n,
|
|
100
|
+
background: e.background || "",
|
|
101
|
+
svg: e.svg || "",
|
|
102
|
+
svgViewBox: e.svgViewBox || "",
|
|
103
|
+
spinner: e.spinner || !1,
|
|
104
|
+
text: e.text || "",
|
|
105
|
+
fullscreen: n === document.body && (e.fullscreen ?? !0),
|
|
106
|
+
lock: e.lock ?? !1,
|
|
107
|
+
customClass: e.customClass || "",
|
|
108
|
+
visible: e.visible ?? !0,
|
|
109
|
+
beforeClose: e.beforeClose,
|
|
110
|
+
closed: e.closed,
|
|
111
|
+
target: n
|
|
112
|
+
};
|
|
113
|
+
}, te = async (e, n, t) => {
|
|
114
|
+
const { nextZIndex: s } = t.vm.zIndex || t.vm._.exposed.zIndex, o = {};
|
|
115
|
+
if (e.fullscreen)
|
|
116
|
+
t.originalPosition.value = v(document.body, "position"), t.originalOverflow.value = v(document.body, "overflow"), o.zIndex = s();
|
|
117
|
+
else if (e.parent === document.body) {
|
|
118
|
+
t.originalPosition.value = v(document.body, "position"), await $();
|
|
119
|
+
for (const r of ["top", "left"]) {
|
|
120
|
+
const i = r === "top" ? "scrollTop" : "scrollLeft";
|
|
121
|
+
o[r] = `${e.target.getBoundingClientRect()[r] + document.body[i] + document.documentElement[i] - Number.parseInt(v(document.body, `margin-${r}`), 10)}px`;
|
|
122
|
+
}
|
|
123
|
+
for (const r of ["height", "width"]) o[r] = `${e.target.getBoundingClientRect()[r]}px`;
|
|
124
|
+
} else t.originalPosition.value = v(n, "position");
|
|
125
|
+
for (const [r, i] of Object.entries(o)) t.$el.style[r] = i;
|
|
126
|
+
}, B = (e, n, t) => {
|
|
127
|
+
const s = t.vm.ns || t.vm._.exposed.ns;
|
|
128
|
+
[
|
|
129
|
+
"absolute",
|
|
130
|
+
"fixed",
|
|
131
|
+
"sticky"
|
|
132
|
+
].includes(t.originalPosition.value) ? y(n, s.bm("parent", "relative")) : A(n, s.bm("parent", "relative")), e.fullscreen && e.lock ? A(n, s.bm("parent", "hidden")) : y(n, s.bm("parent", "hidden"));
|
|
133
|
+
};
|
|
134
|
+
_._context = null;
|
|
135
|
+
const g = /* @__PURE__ */ Symbol("ElLoading"), u = (e) => `element-loading-${z(e)}`, P = (e, n) => {
|
|
136
|
+
const t = n.instance, s = (l) => N(n.value) ? n.value[l] : void 0, o = (l) => k(I(l) && t?.[l] || l), r = (l) => o(s(l) || e.getAttribute(u(l))), i = s("fullscreen") ?? n.modifiers.fullscreen, d = {
|
|
137
|
+
text: r("text"),
|
|
138
|
+
svg: r("svg"),
|
|
139
|
+
svgViewBox: r("svgViewBox"),
|
|
140
|
+
spinner: r("spinner"),
|
|
141
|
+
background: r("background"),
|
|
142
|
+
customClass: r("customClass"),
|
|
143
|
+
fullscreen: i,
|
|
144
|
+
target: s("target") ?? (i ? void 0 : e),
|
|
145
|
+
body: s("body") ?? n.modifiers.body,
|
|
146
|
+
lock: s("lock") ?? n.modifiers.lock
|
|
147
|
+
}, b = _(d);
|
|
148
|
+
b._context = h._context, e[g] = {
|
|
149
|
+
options: d,
|
|
150
|
+
instance: b
|
|
151
|
+
};
|
|
152
|
+
}, ne = (e, n) => {
|
|
153
|
+
for (const t of Object.keys(e)) Y(e[t]) && (e[t].value = n[t]);
|
|
154
|
+
}, h = {
|
|
155
|
+
mounted(e, n) {
|
|
156
|
+
n.value && P(e, n);
|
|
157
|
+
},
|
|
158
|
+
updated(e, n) {
|
|
159
|
+
const t = e[g];
|
|
160
|
+
if (!n.value) {
|
|
161
|
+
t?.instance.close(), e[g] = null;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
t ? ne(t.options, N(n.value) ? n.value : {
|
|
165
|
+
text: e.getAttribute(u("text")),
|
|
166
|
+
svg: e.getAttribute(u("svg")),
|
|
167
|
+
svgViewBox: e.getAttribute(u("svgViewBox")),
|
|
168
|
+
spinner: e.getAttribute(u("spinner")),
|
|
169
|
+
background: e.getAttribute(u("background")),
|
|
170
|
+
customClass: e.getAttribute(u("customClass"))
|
|
171
|
+
}) : P(e, n);
|
|
172
|
+
},
|
|
173
|
+
unmounted(e) {
|
|
174
|
+
e[g]?.instance.close(), e[g] = null;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
h._context = null;
|
|
178
|
+
const oe = /* @__PURE__ */ S({
|
|
179
|
+
name: "PptPreview",
|
|
180
|
+
__name: "PptPreview",
|
|
181
|
+
props: {
|
|
182
|
+
url: {}
|
|
183
|
+
},
|
|
184
|
+
setup(e) {
|
|
185
|
+
const n = k(!0), t = () => {
|
|
186
|
+
n.value = !1;
|
|
187
|
+
};
|
|
188
|
+
return (s, o) => {
|
|
189
|
+
const r = h;
|
|
190
|
+
return e.url ? V((Z(), J(L(U), {
|
|
191
|
+
key: 0,
|
|
192
|
+
src: e.url,
|
|
193
|
+
class: "vue-office-pptx",
|
|
194
|
+
onRendered: t
|
|
195
|
+
}, null, 8, ["src"])), [
|
|
196
|
+
[r, L(n)]
|
|
197
|
+
]) : Q("", !0);
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}), ce = /* @__PURE__ */ W(oe, [["__scopeId", "data-v-ad74f2de"]]);
|
|
201
|
+
export {
|
|
202
|
+
ce as default
|
|
203
|
+
};
|
package/dist/lib/TxtPreview.js
CHANGED
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { defineComponent as p, ref as c, onMounted as d, openBlock as i, createElementBlock as F, createElementVNode as g, toDisplayString as m, unref as b } from "vue";
|
|
2
|
+
import h from "axios";
|
|
3
|
+
const x = { class: "flex justify-center min-h-full h-full bg-gray! lh-loose box-border overflow-auto p-20px" }, D = /* @__PURE__ */ p({
|
|
4
|
+
__name: "TxtPreview",
|
|
5
|
+
props: {
|
|
6
|
+
url: {}
|
|
7
|
+
},
|
|
8
|
+
setup(s) {
|
|
9
|
+
const t = s, a = c(null), o = c("");
|
|
10
|
+
return d(() => {
|
|
11
|
+
t.url && h.get(t.url, { responseType: "arraybuffer" }).then(async (n) => {
|
|
12
|
+
const r = ["UTF-8", "GBK", "GB18030"];
|
|
13
|
+
let e = "";
|
|
14
|
+
for (const l of r)
|
|
15
|
+
try {
|
|
16
|
+
if (e = new TextDecoder(l).decode(n.data), ![
|
|
17
|
+
/�/,
|
|
18
|
+
/[\uD800-\uDBFF][\uDC00-\uDFFF]/,
|
|
19
|
+
/[\uFFFD\uFFFE\uFFFF]/
|
|
20
|
+
].some((f) => f.test(e)))
|
|
21
|
+
break;
|
|
22
|
+
} catch {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
o.value = e;
|
|
26
|
+
});
|
|
27
|
+
}), (n, r) => (i(), F("div", x, [
|
|
28
|
+
g("pre", {
|
|
29
|
+
ref_key: "contentRef",
|
|
30
|
+
ref: a,
|
|
31
|
+
class: "w-[70%] h-fit mt-30px mb-0 bg-white! p-10px whitespace-pre-wrap break-words"
|
|
32
|
+
}, " " + m(b(o)) + `
|
|
33
|
+
`, 513)
|
|
34
|
+
]));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export {
|
|
38
|
+
D as default
|
|
39
|
+
};
|