UNPKG

2.34 kBSource Map (JSON)View Raw
1{"version":3,"file":"vue-prism-component.min.js","sources":["../src/index.js"],"sourcesContent":["import { h, defineComponent } from 'vue'\nimport Prism from 'prismjs'\n\nexport default defineComponent({\n props: {\n code: {\n type: String\n },\n inline: {\n type: Boolean,\n default: false\n },\n language: {\n type: String,\n default: 'markup'\n }\n },\n setup(props, { slots, attrs }) {\n const defaultSlot = (slots && slots.default && slots.default()) || []\n const code =\n props.code || (defaultSlot && defaultSlot.length)\n ? defaultSlot[0].children\n : ''\n const inline = props.inline\n const language = props.language\n const prismLanguage = Prism.languages[language]\n const className = `language-${language}`\n\n if (process.env.NODE_ENV === 'development' && !prismLanguage) {\n throw new Error(\n `Prism component for language \"${language}\" was not found, did you forget to register it? See all available ones: https://cdn.jsdelivr.net/npm/prismjs/components/`\n )\n }\n return () => {\n if (inline) {\n return h('code', {\n class: [className],\n innerHTML: Prism.highlight(code, prismLanguage)\n })\n }\n\n return h(\n 'pre',\n {\n ...attrs,\n class: [attrs.class, className]\n },\n [\n h('code', {\n ...attrs,\n class: [attrs.class, className],\n innerHTML: Prism.highlight(code, prismLanguage)\n })\n ]\n )\n }\n }\n})\n"],"names":["defineComponent","props","code","type","String","inline","Boolean","language","setup","slots","attrs","defaultSlot","length","children","prismLanguage","Prism","languages","className","h","innerHTML","highlight"],"mappings":"iVAGeA,kBAAgB,CAC7BC,MAAO,CACLC,KAAM,CACJC,KAAMC,QAERC,OAAQ,CACNF,KAAMG,iBACG,GAEXC,SAAU,CACRJ,KAAMC,eACG,WAGbI,eAAMP,SAASQ,IAAAA,MAAOC,IAAAA,MACdC,EAAeF,GAASA,WAAiBA,aAAoB,GAC7DP,EACJD,EAAMC,MAASS,GAAeA,EAAYC,OACtCD,EAAY,GAAGE,SACf,GACAR,EAASJ,EAAMI,OACfE,EAAWN,EAAMM,SACjBO,EAAgBC,EAAMC,UAAUT,GAChCU,qBAAwBV,UAOvB,kBACDF,EACKa,IAAE,OAAQ,OACR,CAACD,GACRE,UAAWJ,EAAMK,UAAUlB,EAAMY,KAI9BI,IACL,uBAEKR,SACI,CAACA,QAAaO,KAEvB,CACEC,IAAE,wBACGR,SACI,CAACA,QAAaO,GACrBE,UAAWJ,EAAMK,UAAUlB,EAAMY"}
\No newline at end of file