UNPKG

vue-markdown-wasm

Version:
13 lines (11 loc) 2.53 kB
/** * vue-markdown-wasm * * @description markdown-wasm for vue 2 & 3 * @author Logue <logue@hotmail.co.jp> * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved. * @license MIT * @version 1.0.1 * @see {@link https://github.com/logue/vue-markdown-wasm} */ (function(a,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@logue/markdown-wasm"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@logue/markdown-wasm","vue-demi"],l):(a=typeof globalThis<"u"?globalThis:a||self,l(a.VueMarkdown={},a.markdown,a.VueDemi))})(this,(function(a,l,o){"use strict";const f={name:"vue-markdown-wasm",version:"1.0.1",author:{name:"Logue",email:"logue@hotmail.co.jp",url:"https://logue.dev/"},date:"2025-10-23T01:25:22.768Z"},m=e=>e?Object.entries(e).reduce((r,[n,d])=>(n=n.charAt(0).toUpperCase()+n.slice(1),n=`on${n}`,{...r,[n]:d}),{}):{};function h(e,r={},n){if(o.isVue2)return o.h(e,r,n);const{props:d,domProps:s,on:t,...u}=r,i=t!=null?m(t):{};return o.h(e,{...u,...d,...s,...i},n)}const c=o.defineComponent({name:"VueMarkdown",model:{prop:"modelValue"},props:{modelValue:{type:String,default:""},tag:{type:String,default:"article"},parseFlags:{type:Number,default:l.ParseFlags.DEFAULT},format:{type:String,default:"xhtml"},bytes:{type:Boolean,default:!1},allowJsUri:{type:Boolean,default:!1},onCodeBlock:{type:Function},debug:{type:Boolean,default:!1},verbatimEntities:{type:Boolean,default:!0},disableHeadlineAnchors:{type:Boolean,default:!1}},emits:{render:e=>!0},setup(e,r){const n=o.ref(),d=o.ref("");o.watch(()=>e,async t=>{d.value=s(t.modelValue,{parseFlags:t.parseFlags,xhtml:t.format==="xhtml",bytes:e.bytes,allowJSURIs:t.allowJsUri,onCodeBlock:t.onCodeBlock,debug:t.debug,verbatimEntities:t.verbatimEntities,disableHeadlineAnchors:t.disableHeadlineAnchors}),await o.nextTick()},{deep:!0}),o.onMounted(async()=>{globalThis.window!==void 0&&(await l.ready(),d.value=s(e.modelValue,{parseFlags:e.parseFlags,xhtml:e.format=="xhtml",bytes:e.bytes,allowJSURIs:e.allowJsUri,onCodeBlock:e.onCodeBlock,debug:e.debug,verbatimEntities:e.verbatimEntities,disableHeadlineAnchors:e.disableHeadlineAnchors}))});const s=(t,u)=>{if(globalThis.window===void 0)return"";const i=l.parse(t,u);return r.emit("render",i),i};return r.expose({render:s}),{placeholder:n,html:d}},render(){return h(this.$props.tag,{ref:"placeholder",class:"vue-markdown",innerHTML:this.html})}}),b=e=>e.component("VueMarkdown",c);a.Meta=f,a.default=c,a.install=b,Object.defineProperty(a,"__esModule",{value:!0})}));