UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

70 lines (69 loc) 2.04 kB
import { defineComponent as d, ref as f, watch as a, openBlock as p, createElementBlock as h, createElementVNode as g } from "vue"; import _ from "../../../../node_modules/markdown-it/lib/index.mjs"; import k from "../../../../node_modules/markdown-it-footnote/index.mjs"; import v from "../../../../node_modules/markdown-it-container/index.mjs"; import c from "../../../../node_modules/highlight.js/lib/index.mjs"; import { getFileRenderByFile as w, getFileRenderByUrl as x } from "../../utils/utils.mjs"; const y = { class: "md-preview hljs" }, H = ["innerHTML"], I = /* @__PURE__ */ d({ __name: "index", props: { file: { default: () => null }, url: { default: () => null }, name: {} }, emits: ["rendered", "error"], setup(u, { emit: m }) { const t = u, n = m, i = f(); function s() { const r = _({ html: !0, xhtmlOut: !1, breaks: !1, langPrefix: "language-", linkify: !0, typographer: !0, quotes: "“”‘’", highlight(e, o) { if (o && c.getLanguage(o)) try { return `<pre><code class="hljs">${c.highlight(e, { language: o, ignoreIllegals: !0 }).value}</code></pre>`; } catch { } return `<pre><code class="hljs">${r.utils.escapeHtml(e)}</code></pre>`; } }); return r.use(k).use(v); } function l(r) { const e = s(); i.value = e.render(r), n("rendered"); } return a( () => t.file, (r) => { r && w(r).then((e) => { l(e); }).catch((e) => { n("error", e); }); }, { immediate: !0 } ), a( () => t.url, (r) => { r && !t.file && x(r).then((e) => { l(e); }).catch((e) => { n("error", e); }); }, { immediate: !0 } ), (r, e) => (p(), h("div", y, [ g("div", { innerHTML: i.value }, null, 8, H) ])); } }); export { I as default }; //# sourceMappingURL=index.vue2.mjs.map