UNPKG

dm-vue3-ui

Version:

This Components Library will help get you started developing in Vue 3.

61 lines (60 loc) 2.11 kB
import { defineComponent, computed, onMounted, openBlock, createElementBlock, normalizeClass, createTextVNode, createElementVNode } from "vue"; import Prism from "prismjs"; const prismTomorrow_min = ""; const _hoisted_1 = ["data-prismjs-copy", "data-prismjs-copy-success", "data-prismjs-copy-error", "data-language"]; const _hoisted_2 = ["innerHTML"]; const _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "dm-preview-code" }, __name: "index", props: { code: { default: "" }, type: { default: "markup" }, isShowlineNumbers: { type: Boolean, default: false }, copyText: { default: "Copy" }, copySuccessText: { default: "Copied!" }, copyErrorText: { default: "User to press Ctrl+C" } }, setup(__props) { const props = __props; const lineNumbers = computed(() => { return props.isShowlineNumbers ? "line-numbers" : "no-line-numbers"; }); const codeContent = computed(() => { try { return Prism.highlight(props.code, Prism.languages[props.type], props.type); } catch (error) { console.log(error); } return ""; }); onMounted(() => { Prism.highlightAll(); }); return (_ctx, _cache) => { return openBlock(), createElementBlock("pre", { lang: "zh-Hans-CN", "data-previewers": "color time", "data-prismjs-copy": props.copyText, "data-prismjs-copy-success": _ctx.copySuccessText, "data-prismjs-copy-error": _ctx.copyErrorText, class: normalizeClass( "hx-scroll dm-preview-code normalize-whitespace " + lineNumbers.value + " language-" + props.type ), "data-language": props.type }, [ _cache[0] || (_cache[0] = createTextVNode(" ")), createElementVNode("code", { class: normalizeClass("language-" + props.type), innerHTML: codeContent.value }, null, 10, _hoisted_2), _cache[1] || (_cache[1] = createTextVNode("\n ")) ], 10, _hoisted_1); }; } }); const index_vue_vue_type_style_index_0_lang = ""; export { _sfc_main as default };