import{d as c}from"./marked.esm.CbTws8Ir.js";import h from"./purify.es.aGzT-_H7.js";import{a as M,r as p,f as C,w as v,q as x,aj as s,c as T,o as B,b as i,S as n,K as u}from"./vue.D1BjjNmv.js";import{_ as N}from"./_plugin-vue_export-helper.DlAUqK2U.js";const E={class:"markdown-editor"},H={class:"editor-tabs"},I={class:"editor-container"},g=["innerHTML"],L=M({__name:"MarkdownEditor",props:{modelValue:{type:String,default:""},readonly:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(d,{emit:f}){const o=d,_=f,t=p("edit"),a=p("");c.setOptions({breaks:!0,gfm:!0});const b=C(()=>{if(!a.value)return"";try{const e=c.parse(a.value);return h.sanitize(e)}catch(e){return console.error("Markdown解析错误:",e),a.value}}),w=()=>{_("update:modelValue",a.value)},k=e=>{o.readonly&&e.paneName==="edit"||(t.value=e.paneName)};return v(()=>o.modelValue,e=>{e!==a.value&&(a.value=e||"")},{immediate:!0}),v(()=>o.readonly,e=>{e?t.value="preview":t.value="edit"},{immediate:!0}),x(()=>{a.value=o.modelValue||"",o.readonly&&(t.value="preview")}),(e,l)=>{const V=s("el-input"),m=s("el-tab-pane"),y=s("el-tabs");return B(),T("div",E,[i("div",H,[n(y,{modelValue:t.value,"onUpdate:modelValue":l[1]||(l[1]=r=>t.value=r),onTabClick:k},{default:u(()=>[n(m,{label:"编辑",name:"edit",disabled:d.readonly},{default:u(()=>[i("div",I,[n(V,{modelValue:a.value,"onUpdate:modelValue":l[0]||(l[0]=r=>a.value=r),type:"textarea",rows:20,placeholder:"请输入Markdown格式的内容...",onInput:w,class:"markdown-input",disabled:d.readonly},null,8,["modelValue","disabled"])])]),_:1},8,["disabled"]),n(m,{label:"预览",name:"preview"},{default:u(()=>[i("div",{class:"preview-container",innerHTML:b.value},null,8,g)]),_:1})]),_:1},8,["modelValue"])])])}}}),z=N(L,[["__scopeId","data-v-65a9f5db"]]);export{z as default};
