vue-files-preview
Version:
A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.
69 lines (68 loc) • 3.05 kB
JavaScript
import { defineComponent as s, ref as u, watch as m, openBlock as c, createElementBlock as p, createElementVNode as f, unref as d } from "vue";
import h from "../../../../node_modules/.pnpm/markdown-it@14.1.0/node_modules/markdown-it/lib/index.mjs";
import g from "../../../../node_modules/.pnpm/markdown-it-footnote@4.0.0/node_modules/markdown-it-footnote/index.mjs";
import _ from "../../../../node_modules/.pnpm/markdown-it-container@4.0.0/node_modules/markdown-it-container/index.mjs";
import o from "../../../../node_modules/.pnpm/highlight.js@11.10.0/node_modules/highlight.js/lib/index.mjs";
import { getFileRenderByFile as k } from "../../utils/utils.mjs";
const x = { class: "md-preview hljs" }, H = ["innerHTML"], E = /* @__PURE__ */ s({
__name: "index",
props: {
file: { default: () => null },
url: { default: () => null },
name: {}
},
setup(i) {
const a = i, n = u();
return m(
() => a.file,
(t) => {
if (t) {
const r = h({
// Enable HTML tags in source
html: !0,
// Use '/' to close single tags (<br />).
// This is only for full CommonMark compatibility.
xhtmlOut: !1,
// Convert '\n' in paragraphs into <br>
breaks: !1,
// CSS language prefix for fenced blocks. Can be
// useful for external highlighters.
langPrefix: "language-",
// Autoconvert URL-like text to links
linkify: !0,
// Enable some language-neutral replacement + quotes beautification
// For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.mjs
typographer: !0,
// Double + single quotes replacement pairs, when typographer enabled,
// and smartquotes on. Could be either a String or an Array.
//
// For example, you can use '«»„“' for Russian, '„“‚‘' for German,
// and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
quotes: "“”‘’",
// Highlighter function. Should return escaped HTML,
// or '' if the source string is not changed and should be escaped externally.
// If result starts with <pre... internal wrapper is skipped.
highlight(e, l) {
if (l && o.getLanguage(l))
try {
return `<pre><code class="hljs">${o.highlight(e, { language: l, ignoreIllegals: !0 }).value}</code></pre>`;
} catch {
}
return `<pre><code class="hljs">${r.utils.escapeHtml(e)}</code></pre>`;
}
}).use(g).use(_);
k(t).then((e) => {
n.value = r.render(e);
});
}
},
{ immediate: !0 }
), (t, r) => (c(), p("div", x, [
f("div", { innerHTML: d(n) }, null, 8, H)
]));
}
});
export {
E as default
};
//# sourceMappingURL=index.vue2.mjs.map