"use strict"; const common_vendor = require("../../common/vendor.js"); const components_uaMarkdown_lib_markdownIt_min = require("./lib/markdown-it.min.js"); const components_uaMarkdown_lib_highlight_uniHighlight_min = require("./lib/highlight/uni-highlight.min.js"); require("./lib/html-parser.js"); const _sfc_main = { __name: "ua-markdown", props: { // 解析内容 source: String, showLine: { type: [Boolean, String], default: true } }, setup(__props) { const props = __props; let copyCodeData = []; const markdown = components_uaMarkdown_lib_markdownIt_min.mt({ html: true, highlight: function(str, lang) { let preCode = ""; try { preCode = components_uaMarkdown_lib_highlight_uniHighlight_min.$e.highlightAuto(str).value; } catch (err) { preCode = markdown.utils.escapeHtml(str); } const lines = preCode.split(/\n/).slice(0, -1); let html = lines.map((item, index) => { if (item == "") { return ""; } return '
${html}`;
htmlCode += "| `); htmlString = htmlString.replace(/ | | | /g, ` `); return htmlString; }; const handleItemClick = (e) => { let { attrs } = e.detail.node; let { "code-data-index": codeDataIndex, "class": className } = attrs; if (className == "copy-btn") { common_vendor.index.setClipboardData({ data: copyCodeData[codeDataIndex], showToast: false, success() { common_vendor.index.showToast({ title: "复制成功", icon: "none" }); } }); } }; return (_ctx, _cache) => { return { a: parseNodes(__props.source), b: common_vendor.o(handleItemClick) }; }; } }; const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-64f4d077"]]); wx.createComponent(Component); //# sourceMappingURL=../../../.sourcemap/mp-weixin/components/ua-markdown/ua-markdown.js.map |
|---|