vue-files-preview-inno
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
59 lines (58 loc) • 1.99 kB
JavaScript
import { defineComponent as c, ref as f, shallowRef as p, watch as i, openBlock as h, createElementBlock as v, createVNode as w, unref as _ } from "vue";
import { Codemirror as x } from "../../../../node_modules/vue-codemirror/dist/vue-codemirror.esm.mjs";
import { javascript as R } from "../../../../node_modules/@codemirror/lang-javascript/dist/index.mjs";
import { json as V } from "../../../../node_modules/@codemirror/lang-json/dist/index.mjs";
import { html as y } from "../../../../node_modules/@codemirror/lang-html/dist/index.mjs";
import { xml as B } from "../../../../node_modules/@codemirror/lang-xml/dist/index.mjs";
import { oneDark as k } from "../../../../node_modules/@codemirror/theme-one-dark/dist/index.mjs";
import { getFileRenderByFile as F, getFileRenderByUrl as b } from "../../utils/utils.mjs";
const g = { class: "code-preview" }, q = /* @__PURE__ */ c({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {}
},
emits: ["rendered", "error"],
setup(l, { emit: a }) {
const o = l, n = a, t = f(), m = [R(), V(), y(), B(), k], d = p();
function u(r) {
d.value = r.view, n("rendered");
}
return i(
() => o.file,
(r) => {
r && F(r).then((e) => {
t.value = e;
}).catch((e) => {
n("error", e);
});
},
{ immediate: !0 }
), i(
() => o.url,
(r) => {
r && !o.file && b(r).then((e) => {
t.value = e;
}).catch((e) => {
n("error", e);
});
},
{ immediate: !0 }
), (r, e) => (h(), v("div", g, [
w(_(x), {
modelValue: t.value,
"onUpdate:modelValue": e[0] || (e[0] = (s) => t.value = s),
autofocus: !0,
"indent-with-tab": !0,
"tab-size": 2,
extensions: m,
onReady: u
}, null, 8, ["modelValue"])
]));
}
});
export {
q as default
};
//# sourceMappingURL=index.vue2.mjs.map