md-editor-v3 4.6.2-beta.2 → 4.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,50 @@
1
- "use strict";var gt=Object.defineProperty;var bt=(e,l,o)=>l in e?gt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o;var q=(e,l,o)=>(bt(e,typeof l!="symbol"?l+"":l,o),o);const t=require("vue"),r=require("./chunks/config.cjs"),le=require("@vavt/util"),z=require("./chunks/index2.cjs"),s=require("./chunks/index3.cjs"),ht=require("./chunks/dom.cjs"),p=require("./chunks/index.cjs"),ee=require("codemirror"),ae=require("@codemirror/view"),vt=require("@codemirror/language-data"),pt=require("@codemirror/lang-markdown"),E=require("@codemirror/state"),se=require("@codemirror/commands"),re=require("@codemirror/language"),c=require("@lezer/highlight"),Ct=require("@codemirror/autocomplete"),P=require("./chunks/index4.cjs"),ft=require("./MdCatalog.cjs"),Je=require("./chunks/vue-tsx.cjs"),kt=require("./NormalToolbar.cjs"),xt=require("./ModalToolbar.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");const Nt=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${r.prefix}-divider`},null)}}),Vt={noPrettier:{type:Boolean},toolbars:{type:Array,default:()=>[]},toolbarsExclude:{type:Array,default:()=>[]},setting:{type:Object,default:()=>({})},screenfull:{type:Object,default:null},screenfullJs:{type:String,default:""},updateSetting:{type:Function,default:()=>{}},tableShape:{type:Array,default:()=>[6,4]},defToolbars:{type:Object},noUploadImg:{type:Boolean},showToolbarName:{type:Boolean}},$t=e=>{var u,m,k,V;const l=t.inject("editorId");let o=(m=(u=r.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:m.instance;const a=(V=(k=r.configOption.editorExtensions)==null?void 0:k.screenfull)==null?void 0:V.js,n=t.ref(!1),i=x=>{if(!o){s.bus.emit(l,s.ERROR_CATCHER,{name:"fullscreen",message:"fullscreen is undefined"});return}o.isEnabled?(n.value=!0,(x===void 0?!o.isFullscreen:x)?o.request():o.exit()):console.error("browser does not support screenfull!")},g=()=>{o&&o.isEnabled&&o.on("change",()=>{(n.value||e.setting.fullscreen)&&(n.value=!1,e.updateSetting("fullscreen"))})},d=()=>{o=window.screenfull,g()};return t.onMounted(()=>{if(g(),!o){const x=document.createElement("script");x.src=a||r.screenfullUrl,x.onload=d,x.id=`${r.prefix}-screenfull`,ht.appendHandler(x,"screenfull")}}),t.onMounted(()=>{s.bus.on(l,{name:s.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},Tt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},yt=t.defineComponent({name:"TableShape",props:Tt,setup(e){const l=t.reactive({x:-1,y:-1});return()=>t.createVNode("div",{class:`${r.prefix}-table-shape`,onMouseleave:()=>{l.x=-1,l.y=-1}},[new Array(e.tableShape[1]).fill("").map((o,a)=>t.createVNode("div",{class:`${r.prefix}-table-shape-row`,key:`table-shape-row-${a}`},[new Array(e.tableShape[0]).fill("").map((n,i)=>t.createVNode("div",{class:`${r.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{l.x=a,l.y=i},onClick:()=>{e.onSelected(l)}},[t.createVNode("div",{class:[`${r.prefix}-table-shape-col-default`,a<=l.x&&i<=l.y&&`${r.prefix}-table-shape-col-include`]},null)]))]))])}}),wt=yt,Et={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},St=t.defineComponent({props:Et,setup(e){const l=t.inject("usedLanguageText"),o=t.inject("editorId"),a=t.computed(()=>{var i,g;switch(e.type){case"link":return(i=l.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(g=l.value.linkModalTips)==null?void 0:g.imageTitle;default:return""}}),n=t.reactive({desc:"",url:""});return t.watch(()=>e.visible,i=>{i||setTimeout(()=>{n.desc="",n.url=""},200)}),()=>t.createVNode(p.MdModal,{title:a.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var i,g,d,u,m;return[t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-desc-${o}`},[(i=l.value.linkModalTips)==null?void 0:i.descLabel]),t.createVNode("input",{placeholder:(g=l.value.linkModalTips)==null?void 0:g.descLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-desc-${o}`,type:"text",value:n.desc,onChange:k=>{n.desc=k.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-url-${o}`},[(d=l.value.linkModalTips)==null?void 0:d.urlLabel]),t.createVNode("input",{placeholder:(u=l.value.linkModalTips)==null?void 0:u.urlLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-url-${o}`,type:"text",value:n.url,onChange:k=>{n.url=k.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:[`${r.prefix}-btn`,`${r.prefix}-btn-row`],type:"button",onClick:()=>{e.onOk(n),n.desc="",n.url=""}},[(m=l.value.linkModalTips)==null?void 0:m.buttonOK])])]}})}}),At={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},It=t.defineComponent({props:At,setup(e){var k,V,x;const l=t.inject("usedLanguageText"),o=t.inject("editorId");let a=(x=(V=(k=r.configOption)==null?void 0:k.editorExtensions)==null?void 0:V.cropper)==null?void 0:x.instance;const n=t.ref(),i=t.ref(),g=t.ref(),d=t.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let u=null;t.watch(()=>e.visible,()=>{e.visible&&!d.cropperInited&&(a=a||window.Cropper,n.value.onchange=()=>{if(!a){s.bus.emit(o,s.ERROR_CATCHER,{name:"Cropper",message:"Cropper is undefined"});return}const f=n.value.files||[];if(d.imgSelected=!0,(f==null?void 0:f.length)>0){const h=new FileReader;h.onload=b=>{d.imgSrc=b.target.result,t.nextTick(()=>{u=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`})})},h.readAsDataURL(f[0])}})}),t.watch(()=>[d.imgSelected],()=>{g.value.style=""}),t.watch(()=>d.isFullscreen,()=>{t.nextTick(()=>{u==null||u.destroy(),g.value.style="",i.value&&(u=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`}))})});const m=()=>{u.clear(),u.destroy(),u=null,n.value.value="",d.imgSelected=!1};return()=>{var f;return t.createVNode(p.MdModal,{class:`${r.prefix}-modal-clip`,title:(f=l.value.clipModalTips)==null?void 0:f.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:d.isFullscreen,onAdjust:h=>{d.isFullscreen=h},width:"668px",height:"421px"},{default:()=>{var h,b;return[t.createVNode("div",{class:`${r.prefix}-form-item ${r.prefix}-clip`},[t.createVNode("div",{class:`${r.prefix}-clip-main`},[d.imgSelected?t.createVNode("div",{class:`${r.prefix}-clip-cropper`},[t.createVNode("img",{src:d.imgSrc,ref:i,style:{display:"none"},alt:""},null),t.createVNode("div",{class:`${r.prefix}-clip-delete`,onClick:m},[t.createVNode(p.Icon,{name:"delete"},null)])]):t.createVNode("div",{class:`${r.prefix}-clip-upload`,onClick:()=>{n.value.click()}},[t.createVNode(p.Icon,{name:"upload"},null)])]),t.createVNode("div",{class:`${r.prefix}-clip-preview`},[t.createVNode("div",{class:`${r.prefix}-clip-preview-target`,ref:g},null)])]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:`${r.prefix}-btn`,type:"button",onClick:()=>{if(u){const v=u.getCroppedCanvas();s.bus.emit(o,s.UPLOAD_IMAGE,[s.base642File(v.toDataURL("image/png"))],e.onOk),m()}}},[((h=l.value.clipModalTips)==null?void 0:h.buttonUpload)||((b=l.value.linkModalTips)==null?void 0:b.buttonOK)])]),t.createVNode("input",{ref:n,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),Lt={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Mt=t.defineComponent({props:Lt,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(St,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(It,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),Rt=t.defineComponent({name:"MDEditorToolbar",props:Vt,setup(e){const l=t.inject("editorId"),o=t.inject("usedLanguageText"),{fullscreenHandler:a}=$t(e),n=`${l}-toolbar-wrapper`,i=t.ref(),g=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),d=(h,b)=>{s.bus.emit(l,s.REPLACE,h,b)},u=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),m=t.ref();t.onMounted(()=>{s.bus.on(l,{name:s.OPEN_MODALS,callback(h){u.type=h,u.linkVisible=!0}})});const k=t.computed(()=>{const h=e.toolbars.filter($=>!e.toolbarsExclude.includes($)),b=h.indexOf("="),v=b===-1?h:h.slice(0,b+1),N=b===-1?[]:h.slice(b,Number.MAX_SAFE_INTEGER);return[v,N]}),V=t.ref(),x=()=>{s.bus.emit(l,s.UPLOAD_IMAGE,Array.from(V.value.files||[])),V.value.value=""};t.onMounted(()=>{V.value.addEventListener("change",x)});const f=h=>{var b,v,N,$,T,M,S,Z,X,y,w,B,F,R,I,L,D,_,j,ne,Y,K,G,J,U,H,O,Q,ie,ge,be,he,ve,pe,Ce,ke,xe,Ne,Ve,$e,Te,ye,we,Ee,Se,Ae,Ie,Le,Me,Re,De,He,Oe,Pe,Fe,Be,qe,_e,je,Ge,Ue,Ke,We,ze,Ze,Xe,Ye;if(r.allToolbar.includes(h))switch(h){case"-":return t.createVNode(Nt,null,null);case"bold":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(b=o.value.toolbarTips)==null?void 0:b.bold,onClick:()=>{d("bold")}},[t.createVNode(p.Icon,{name:"bold"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(v=o.value.toolbarTips)==null?void 0:v.bold])]);case"underline":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(N=o.value.toolbarTips)==null?void 0:N.underline,onClick:()=>{d("underline")}},[t.createVNode(p.Icon,{name:"underline"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[($=o.value.toolbarTips)==null?void 0:$.underline])]);case"italic":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(T=o.value.toolbarTips)==null?void 0:T.italic,onClick:()=>{d("italic")}},[t.createVNode(p.Icon,{name:"italic"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(M=o.value.toolbarTips)==null?void 0:M.italic])]);case"strikeThrough":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(S=o.value.toolbarTips)==null?void 0:S.strikeThrough,onClick:()=>{d("strikeThrough")}},[t.createVNode(p.Icon,{name:"strike-through"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Z=o.value.toolbarTips)==null?void 0:Z.strikeThrough])]);case"title":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.title,onChange:C=>{g.title=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h1")}},[(X=o.value.titleItem)==null?void 0:X.h1]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h2")}},[(y=o.value.titleItem)==null?void 0:y.h2]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h3")}},[(w=o.value.titleItem)==null?void 0:w.h3]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h4")}},[(B=o.value.titleItem)==null?void 0:B.h4]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h5")}},[(F=o.value.titleItem)==null?void 0:F.h5]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h6")}},[(R=o.value.titleItem)==null?void 0:R.h6])])},{default:()=>{var C,A;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.title},[t.createVNode(p.Icon,{name:"title"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(A=o.value.toolbarTips)==null?void 0:A.title])])]}});case"sub":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(I=o.value.toolbarTips)==null?void 0:I.sub,onClick:()=>{d("sub")}},[t.createVNode(p.Icon,{name:"sub"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(L=o.value.toolbarTips)==null?void 0:L.sub])]);case"sup":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(D=o.value.toolbarTips)==null?void 0:D.sup,onClick:()=>{d("sup")}},[t.createVNode(p.Icon,{name:"sup"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(_=o.value.toolbarTips)==null?void 0:_.sup])]);case"quote":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(j=o.value.toolbarTips)==null?void 0:j.quote,onClick:()=>{d("quote")}},[t.createVNode(p.Icon,{name:"quote"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ne=o.value.toolbarTips)==null?void 0:ne.quote])]);case"unorderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Y=o.value.toolbarTips)==null?void 0:Y.unorderedList,onClick:()=>{d("unorderedList")}},[t.createVNode(p.Icon,{name:"unordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(K=o.value.toolbarTips)==null?void 0:K.unorderedList])]);case"orderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(G=o.value.toolbarTips)==null?void 0:G.orderedList,onClick:()=>{d("orderedList")}},[t.createVNode(p.Icon,{name:"ordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(J=o.value.toolbarTips)==null?void 0:J.orderedList])]);case"task":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(U=o.value.toolbarTips)==null?void 0:U.task,onClick:()=>{d("task")}},[t.createVNode(p.Icon,{name:"task"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(H=o.value.toolbarTips)==null?void 0:H.task])]);case"codeRow":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(O=o.value.toolbarTips)==null?void 0:O.codeRow,onClick:()=>{d("codeRow")}},[t.createVNode(p.Icon,{name:"code-row"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Q=o.value.toolbarTips)==null?void 0:Q.codeRow])]);case"code":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ie=o.value.toolbarTips)==null?void 0:ie.code,onClick:()=>{d("code")}},[t.createVNode(p.Icon,{name:"code"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ge=o.value.toolbarTips)==null?void 0:ge.code])]);case"link":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(be=o.value.toolbarTips)==null?void 0:be.link,onClick:()=>{u.type="link",u.linkVisible=!0}},[t.createVNode(p.Icon,{name:"link"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(he=o.value.toolbarTips)==null?void 0:he.link])]);case"image":return e.noUploadImg?t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ve=o.value.toolbarTips)==null?void 0:ve.image,onClick:()=>{u.type="image",u.linkVisible=!0}},[t.createVNode(p.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(pe=o.value.toolbarTips)==null?void 0:pe.image])]):t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.image,onChange:C=>{g.image=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{u.type="image",u.linkVisible=!0}},[(Ce=o.value.imgTitleItem)==null?void 0:Ce.link]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{V.value.click()}},[(ke=o.value.imgTitleItem)==null?void 0:ke.upload]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{u.clipVisible=!0}},[(xe=o.value.imgTitleItem)==null?void 0:xe.clip2upload])])},{default:()=>{var C,A;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.image},[t.createVNode(p.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(A=o.value.toolbarTips)==null?void 0:A.image])])]}});case"table":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.table,onChange:C=>{g.table=C},key:"bar-table",overlay:t.createVNode(wt,{tableShape:e.tableShape,onSelected:C=>{d("table",{selectedShape:C})}},null)},{default:()=>{var C,A;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.table},[t.createVNode(p.Icon,{name:"table"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(A=o.value.toolbarTips)==null?void 0:A.table])])]}});case"revoke":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ne=o.value.toolbarTips)==null?void 0:Ne.revoke,onClick:()=>{s.bus.emit(l,s.CTRL_Z)}},[t.createVNode(p.Icon,{name:"revoke"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ve=o.value.toolbarTips)==null?void 0:Ve.revoke])]);case"next":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:($e=o.value.toolbarTips)==null?void 0:$e.next,onClick:()=>{s.bus.emit(l,s.CTRL_SHIFT_Z)}},[t.createVNode(p.Icon,{name:"next"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Te=o.value.toolbarTips)==null?void 0:Te.next])]);case"save":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ye=o.value.toolbarTips)==null?void 0:ye.save,onClick:()=>{s.bus.emit(l,s.ON_SAVE)}},[t.createVNode(p.Icon,{name:"baocun"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(we=o.value.toolbarTips)==null?void 0:we.save])]);case"prettier":return e.noPrettier?"":t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ee=o.value.toolbarTips)==null?void 0:Ee.prettier,onClick:()=>{d("prettier")}},[t.createVNode(p.Icon,{name:"prettier"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Se=o.value.toolbarTips)==null?void 0:Se.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ae=o.value.toolbarTips)==null?void 0:Ae.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[t.createVNode(p.Icon,{name:e.setting.pageFullscreen?"suoxiao":"fangda"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ie=o.value.toolbarTips)==null?void 0:Ie.pageFullscreen])]);case"fullscreen":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Le=o.value.toolbarTips)==null?void 0:Le.fullscreen,onClick:()=>{a()}},[t.createVNode(p.Icon,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Me=o.value.toolbarTips)==null?void 0:Me.fullscreen])]);case"preview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Re=o.value.toolbarTips)==null?void 0:Re.preview,onClick:()=>{e.updateSetting("preview")}},[t.createVNode(p.Icon,{name:"preview"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(De=o.value.toolbarTips)==null?void 0:De.preview])]);case"htmlPreview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(He=o.value.toolbarTips)==null?void 0:He.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[t.createVNode(p.Icon,{name:"coding"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Oe=o.value.toolbarTips)==null?void 0:Oe.htmlPreview])]);case"catalog":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Pe=o.value.toolbarTips)==null?void 0:Pe.catalog,onClick:()=>{s.bus.emit(l,s.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[t.createVNode(p.Icon,{name:"catalog"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Fe=o.value.toolbarTips)==null?void 0:Fe.catalog])]);case"github":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Be=o.value.toolbarTips)==null?void 0:Be.github,onClick:()=>le.linkTo("https://github.com/imzbf/md-editor-v3")},[t.createVNode(p.Icon,{name:"github"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(qe=o.value.toolbarTips)==null?void 0:qe.github])]);case"mermaid":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.mermaid,onChange:C=>{g.mermaid=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.mermaid=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("flow")}},[(_e=o.value.mermaid)==null?void 0:_e.flow]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("sequence")}},[(je=o.value.mermaid)==null?void 0:je.sequence]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("gantt")}},[(Ge=o.value.mermaid)==null?void 0:Ge.gantt]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("class")}},[(Ue=o.value.mermaid)==null?void 0:Ue.class]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("state")}},[(Ke=o.value.mermaid)==null?void 0:Ke.state]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("pie")}},[(We=o.value.mermaid)==null?void 0:We.pie]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("relationship")}},[(ze=o.value.mermaid)==null?void 0:ze.relationship]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("journey")}},[(Ze=o.value.mermaid)==null?void 0:Ze.journey])]),key:"bar-mermaid"},{default:()=>{var C,A;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.mermaid},[t.createVNode(p.Icon,{name:"mermaid"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(A=o.value.toolbarTips)==null?void 0:A.mermaid])])]}});case"katex":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.katex,onChange:C=>{g.katex=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.katex=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexInline")}},[(Xe=o.value.katex)==null?void 0:Xe.inline]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexBlock")}},[(Ye=o.value.katex)==null?void 0:Ye.block])]),key:"bar-katex"},{default:()=>{var C,A;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.katex},[t.createVNode(p.Icon,{name:"formula"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(A=o.value.toolbarTips)==null?void 0:A.katex])])]}})}else if(e.defToolbars instanceof Array){const C=e.defToolbars[h];return C?t.cloneVNode(C,{insert(ue){s.bus.emit(l,s.REPLACE,"universal",{generate:ue})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const C=e.defToolbars.children[h];return C?t.cloneVNode(C,{insert(ue){s.bus.emit(l,s.REPLACE,"universal",{generate:ue})}}):""}else return""};return t.watch(()=>e.toolbars,()=>{t.nextTick(()=>{i.value&&le.draggingScroll(i.value)})},{immediate:!0}),()=>{const h=k.value[0].map(v=>f(v)),b=k.value[1].map(v=>f(v));return t.createVNode(t.Fragment,null,[e.toolbars.length>0&&t.createVNode("div",{class:`${r.prefix}-toolbar-wrapper`,ref:i,id:n},[t.createVNode("div",{class:[`${r.prefix}-toolbar`,e.showToolbarName&&`${r.prefix}-stn`]},[t.createVNode("div",{class:`${r.prefix}-toolbar-left`,ref:m},[h]),t.createVNode("div",{class:`${r.prefix}-toolbar-right`},[b])])]),t.createVNode("input",{ref:V,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),t.createVNode(Mt,{linkVisible:u.linkVisible,clipVisible:u.clipVisible,type:u.type,onCancel:()=>{u.linkVisible=!1,u.clipVisible=!1},onOk:v=>{v&&d(u.type,{desc:v.desc,url:v.url}),u.linkVisible=!1,u.clipVisible=!1}},null)])}}}),Dt=(e,l)=>{const o=le.debounce(()=>{e.removeEventListener("scroll",a),e.addEventListener("scroll",a),l.removeEventListener("scroll",a),l.addEventListener("scroll",a)},50),a=n=>{const i=e.clientHeight,g=l.clientHeight,d=e.scrollHeight,u=l.scrollHeight,m=(d-i)/(u-g);n.target===e?(l.removeEventListener("scroll",a),l.scrollTo({top:e.scrollTop/m}),o()):(e.removeEventListener("scroll",a),e.scrollTo({top:l.scrollTop*m}),o())};return[()=>{o().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",a),l.removeEventListener("scroll",a)}]},Ht=(e,l,o)=>{const{view:a}=o,n=le.createSmoothScroll(),i=x=>a.lineBlockAt(a.state.doc.line(x).from).top,g=x=>a.lineBlockAt(a.state.doc.line(x).from).height;let d=[];const u=()=>{d=[];const x=Array.from(l.querySelectorAll("[data-line]")).map(v=>Number(v.dataset.line)+1),{lines:f}=a.state.doc;let h=1,b=x.shift()??f;for(let v=1;v<=f;v++)v===b&&(h=v,b=x.shift()||f+1),d.push({start:h,end:b-1})};let m=0,k=0;const V=le.throttle(x=>{var N,$,T,M,S,Z,X;if(!((N=l.firstElementChild)!=null&&N.firstElementChild))return;const f=a.lineBlockAtHeight(a.scrollDOM.scrollTop),{number:h}=a.state.doc.lineAt(f.from);if(h>d.length||a.state.doc.lines<d[d.length-1].end)return;let b=+getComputedStyle(l).paddingTop.replace("px","");const v=+getComputedStyle(l).paddingBottom.replace("px","");if(x.target===e){if(k!==0)return;m++;const y=d[h-1];let w=i(y.end)+g(y.end),B=0;const F=i(y.start),R=l.querySelector(`[data-line="${y.start-1}"]`)||(($=l.firstElementChild)==null?void 0:$.firstElementChild),I=l.querySelector(`[data-line="${y.end}"]`)||((T=l.lastElementChild)==null?void 0:T.lastElementChild);let L=0,D=0;F===0?R===I?(b=0,w=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight,B=a.scrollDOM.scrollTop/w,L=I.offsetTop+I.offsetHeight-l.clientHeight):(B=a.scrollDOM.scrollTop/w,L=I.offsetTop):w>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(B=(a.scrollDOM.scrollTop-F)/(a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight-F),D=R.offsetTop,L=l.scrollHeight-l.clientHeight-D+10):(B=(a.scrollDOM.scrollTop-F)/(w-F),D=R.offsetTop,L=I.offsetTop-D);const _=D-b+L*B;n(l,_,()=>{m--})}else{if(m!==0)return;k++;const y=Array.from(l.querySelectorAll("[data-line]")),w=l.scrollTop,B=l.scrollHeight;let F=y.length===0?1:Math.ceil(Number(y[y.length-1].dataset.line)*(w/B)),R=(M=l.firstElementChild)==null?void 0:M.firstElementChild;for(let H=F;H>=0;H--){const O=l.querySelector(`[data-line="${H}"]`);if(O&&O.offsetTop<=w){R=O,F=H;break}}let I=(S=l.firstElementChild)==null?void 0:S.firstElementChild,L=(Z=l.firstElementChild)==null?void 0:Z.lastElementChild;for(;y.length>0;){const H=y.indexOf(R);if(H+1>=y.length)break;const O=y[H+1];if(H===-1){L=O;break}const Q=R.offsetTop;if(Q>w){if(H===0){I=R,L=O;break}R=y[H-1];continue}const ie=O.offsetTop;if(Q<=w&&ie>w){I=R,L=O;break}R=O}const D=I.offsetTop;let _=L.offsetTop,j=0;const{start:ne,end:Y}=d[Number(I.dataset.line||0)],K=i(ne);let G=i(Y);const J=g(Y);let U=0;I===((X=l.firstElementChild)==null?void 0:X.firstElementChild)?(I===L?(_=L.offsetHeight-l.offsetHeight+b+v,U=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight):U=G+J-K,j=Math.max(w/_,0)):G>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(j=Math.max((w-D)/(l.scrollHeight-D-l.clientHeight),0),G=i(a.state.doc.lines)+g(a.state.doc.lines),U=8+G-K-e.clientHeight):(j=Math.max((w-D)/(_-D),0),U=G+J-K),n(e,K+U*j,()=>{k--})}},10);return[()=>{u(),e.addEventListener("scroll",V),l.addEventListener("scroll",V),e.dispatchEvent(new Event("scroll"))},()=>{d=[],e.removeEventListener("scroll",V),l.removeEventListener("scroll",V)}]},Ot=(e,l,o)=>{const a=t.inject("editorId");let n=()=>{},i=()=>{};const g=()=>{n();const d=document.querySelector(`#${a} .cm-scroller`),u=document.querySelector(`[id="${a}-preview-wrapper"][data-show="true"]`),m=document.querySelector(`[id="${a}-html-wrapper"][data-show="true"]`);(u||m)&&([i,n]=(u?Ht:Dt)(d,u||m,o.value)),e.scrollAuto&&i()};t.watch([l,t.toRef(e.setting,"preview"),t.toRef(e.setting,"htmlPreview"),t.toRef(e.setting,"fullscreen"),t.toRef(e.setting,"pageFullscreen")],()=>{t.nextTick(g)}),t.watch(()=>e.scrollAuto,d=>{d?i():n()}),t.onMounted(g)},Pt=Ot,Ft=(e,l,o)=>{var k,V,x,f,h,b;let a="",n=0,i=0,g=!0,d=!1;const u=l.getSelectedText(),m=(k=r.configOption.editorConfig)==null?void 0:k.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const v=e.replace(/^h(\d)/,(N,$)=>new Array(Number($)).fill("#",0,$).join(""));a=`${v} ${u}`,n=v.length+1}else if(e==="prettier"){const v=window.prettier||((x=(V=r.configOption.editorExtensions)==null?void 0:V.prettier)==null?void 0:x.prettierInstance),N=[((f=window.prettierPlugins)==null?void 0:f.markdown)||((b=(h=r.configOption.editorExtensions)==null?void 0:h.prettier)==null?void 0:b.parserMarkdownInstance)];!v||N[0]===void 0?(s.bus.emit(o.editorId,s.ERROR_CATCHER,{name:"prettier",message:"prettier is undefined"}),a=l.getValue()):a=v.format(l.getValue(),{parser:"markdown",plugins:N}),g=!1,d=!0}else switch(e){case"bold":{a=`**${u}**`,n=2,i=-2;break}case"underline":{a=`<u>${u}</u>`,n=3,i=-4;break}case"italic":{a=`*${u}*`,n=1,i=-1;break}case"strikeThrough":{a=`~~${u}~~`,n=2,i=-2;break}case"sub":{a=`<sub>${u}</sub>`,n=5,i=-6;break}case"sup":{a=`<sup>${u}</sup>`,n=5,i=-6;break}case"codeRow":{a="`"+u+"`",n=1,i=-1;break}case"quote":{a=`> ${u}`,n=2;break}case"orderedList":{a=`1. ${u}`,n=3;break}case"unorderedList":{a=`- ${u}`,n=2;break}case"task":{a=`- [ ] ${u}`,n=6;break}case"code":{const v=o.text||u||"",N=o.mode||"language";a=`\`\`\`${N}
2
- ${v}
1
+ "use strict";var ht=Object.defineProperty;var vt=(e,l,o)=>l in e?ht(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o;var q=(e,l,o)=>(vt(e,typeof l!="symbol"?l+"":l,o),o);const t=require("vue"),r=require("./chunks/config.cjs"),le=require("@vavt/util"),z=require("./chunks/index2.cjs"),s=require("./chunks/index3.cjs"),pt=require("./chunks/dom.cjs"),k=require("./chunks/index.cjs"),ee=require("codemirror"),ae=require("@codemirror/view"),Ct=require("@codemirror/language-data"),kt=require("@codemirror/lang-markdown"),E=require("@codemirror/state"),se=require("@codemirror/commands"),re=require("@codemirror/language"),c=require("@lezer/highlight"),xt=require("@codemirror/autocomplete"),P=require("./chunks/index4.cjs"),bt=require("./MdCatalog.cjs"),et=require("./chunks/vue-tsx.cjs"),Nt=require("./NormalToolbar.cjs"),Vt=require("./ModalToolbar.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");const $t=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${r.prefix}-divider`},null)}}),Tt={noPrettier:{type:Boolean},toolbars:{type:Array,default:()=>[]},toolbarsExclude:{type:Array,default:()=>[]},setting:{type:Object,default:()=>({})},screenfull:{type:Object,default:null},screenfullJs:{type:String,default:""},updateSetting:{type:Function,default:()=>{}},tableShape:{type:Array,default:()=>[6,4]},defToolbars:{type:Object},noUploadImg:{type:Boolean},showToolbarName:{type:Boolean}},yt=e=>{var u,d,v,$;const l=t.inject("editorId");let o=(d=(u=r.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:d.instance;const a=($=(v=r.configOption.editorExtensions)==null?void 0:v.screenfull)==null?void 0:$.js,i=t.ref(!1),n=N=>{if(!o){s.bus.emit(l,s.ERROR_CATCHER,{name:"fullscreen",message:"fullscreen is undefined"});return}o.isEnabled?(i.value=!0,(N===void 0?!o.isFullscreen:N)?o.request():o.exit()):console.error("browser does not support screenfull!")},f=()=>{o&&o.isEnabled&&o.on("change",()=>{(i.value||e.setting.fullscreen)&&(i.value=!1,e.updateSetting("fullscreen"))})},g=()=>{o=window.screenfull,f()};return t.onMounted(()=>{if(f(),!o){const N=document.createElement("script");N.src=a||r.screenfullUrl,N.onload=g,N.id=`${r.prefix}-screenfull`,pt.appendHandler(N,"screenfull")}}),t.onMounted(()=>{s.bus.on(l,{name:s.CHANGE_FULL_SCREEN,callback:n})}),{fullscreenHandler:n}},wt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},Et=t.defineComponent({name:"TableShape",props:wt,setup(e){const l=t.reactive({x:-1,y:-1});return()=>t.createVNode("div",{class:`${r.prefix}-table-shape`,onMouseleave:()=>{l.x=-1,l.y=-1}},[new Array(e.tableShape[1]).fill("").map((o,a)=>t.createVNode("div",{class:`${r.prefix}-table-shape-row`,key:`table-shape-row-${a}`},[new Array(e.tableShape[0]).fill("").map((i,n)=>t.createVNode("div",{class:`${r.prefix}-table-shape-col`,key:`table-shape-col-${n}`,onMouseenter:()=>{l.x=a,l.y=n},onClick:()=>{e.onSelected(l)}},[t.createVNode("div",{class:[`${r.prefix}-table-shape-col-default`,a<=l.x&&n<=l.y&&`${r.prefix}-table-shape-col-include`]},null)]))]))])}}),St=Et,At={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},It=t.defineComponent({props:At,setup(e){const l=t.inject("usedLanguageText"),o=t.inject("editorId"),a=t.computed(()=>{var n,f;switch(e.type){case"link":return(n=l.value.linkModalTips)==null?void 0:n.linkTitle;case"image":return(f=l.value.linkModalTips)==null?void 0:f.imageTitle;default:return""}}),i=t.reactive({desc:"",url:""});return t.watch(()=>e.visible,n=>{n||setTimeout(()=>{i.desc="",i.url=""},200)}),()=>t.createVNode(k.MdModal,{title:a.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var n,f,g,u,d;return[t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-desc-${o}`},[(n=l.value.linkModalTips)==null?void 0:n.descLabel]),t.createVNode("input",{placeholder:(f=l.value.linkModalTips)==null?void 0:f.descLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-desc-${o}`,type:"text",value:i.desc,onChange:v=>{i.desc=v.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-url-${o}`},[(g=l.value.linkModalTips)==null?void 0:g.urlLabel]),t.createVNode("input",{placeholder:(u=l.value.linkModalTips)==null?void 0:u.urlLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-url-${o}`,type:"text",value:i.url,onChange:v=>{i.url=v.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:[`${r.prefix}-btn`,`${r.prefix}-btn-row`],type:"button",onClick:()=>{e.onOk(i),i.desc="",i.url=""}},[(d=l.value.linkModalTips)==null?void 0:d.buttonOK])])]}})}}),Lt={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Mt=t.defineComponent({props:Lt,setup(e){var v,$,N;const l=t.inject("usedLanguageText"),o=t.inject("editorId");let a=(N=($=(v=r.configOption)==null?void 0:v.editorExtensions)==null?void 0:$.cropper)==null?void 0:N.instance;const i=t.ref(),n=t.ref(),f=t.ref(),g=t.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let u=null;t.watch(()=>e.visible,()=>{e.visible&&!g.cropperInited&&(a=a||window.Cropper,i.value.onchange=()=>{if(!a){s.bus.emit(o,s.ERROR_CATCHER,{name:"Cropper",message:"Cropper is undefined"});return}const m=i.value.files||[];if(g.imgSelected=!0,(m==null?void 0:m.length)>0){const p=new FileReader;p.onload=h=>{g.imgSrc=h.target.result,t.nextTick(()=>{u=new a(n.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`})})},p.readAsDataURL(m[0])}})}),t.watch(()=>[g.imgSelected],()=>{f.value.style=""}),t.watch(()=>g.isFullscreen,()=>{t.nextTick(()=>{u==null||u.destroy(),f.value.style="",n.value&&(u=new a(n.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`}))})});const d=()=>{u.clear(),u.destroy(),u=null,i.value.value="",g.imgSelected=!1};return()=>{var m;return t.createVNode(k.MdModal,{class:`${r.prefix}-modal-clip`,title:(m=l.value.clipModalTips)==null?void 0:m.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:g.isFullscreen,onAdjust:p=>{g.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,h;return[t.createVNode("div",{class:`${r.prefix}-form-item ${r.prefix}-clip`},[t.createVNode("div",{class:`${r.prefix}-clip-main`},[g.imgSelected?t.createVNode("div",{class:`${r.prefix}-clip-cropper`},[t.createVNode("img",{src:g.imgSrc,ref:n,style:{display:"none"},alt:""},null),t.createVNode("div",{class:`${r.prefix}-clip-delete`,onClick:d},[t.createVNode(k.Icon,{name:"delete"},null)])]):t.createVNode("div",{class:`${r.prefix}-clip-upload`,onClick:()=>{i.value.click()}},[t.createVNode(k.Icon,{name:"upload"},null)])]),t.createVNode("div",{class:`${r.prefix}-clip-preview`},[t.createVNode("div",{class:`${r.prefix}-clip-preview-target`,ref:f},null)])]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:`${r.prefix}-btn`,type:"button",onClick:()=>{if(u){const b=u.getCroppedCanvas();s.bus.emit(o,s.UPLOAD_IMAGE,[s.base642File(b.toDataURL("image/png"))],e.onOk),d()}}},[((p=l.value.clipModalTips)==null?void 0:p.buttonUpload)||((h=l.value.linkModalTips)==null?void 0:h.buttonOK)])]),t.createVNode("input",{ref:i,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),Rt={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Dt=t.defineComponent({props:Rt,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(It,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(Mt,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),Ht=t.defineComponent({name:"MDEditorToolbar",props:Tt,setup(e){const l=t.inject("editorId"),o=t.inject("usedLanguageText"),a=t.inject("theme"),i=t.inject("language"),{fullscreenHandler:n}=yt(e),f=`${l}-toolbar-wrapper`,g=t.ref(),u=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),d=(b,C)=>{s.bus.emit(l,s.REPLACE,b,C)},v=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),$=t.ref();t.onMounted(()=>{s.bus.on(l,{name:s.OPEN_MODALS,callback(b){v.type=b,v.linkVisible=!0}})});const N=t.computed(()=>{const b=e.toolbars.filter(S=>!e.toolbarsExclude.includes(S)),C=b.indexOf("="),V=C===-1?b:b.slice(0,C+1),T=C===-1?[]:b.slice(C,Number.MAX_SAFE_INTEGER);return[V,T]}),m=t.ref(),p=()=>{s.bus.emit(l,s.UPLOAD_IMAGE,Array.from(m.value.files||[])),m.value.value=""};t.onMounted(()=>{m.value.addEventListener("change",p)});const h=b=>{var C,V,T,S,A,Z,X,y,w,B,F,R,L,M,D,_,j,ne,Y,K,G,J,U,H,O,Q,ie,ge,be,he,ve,pe,Ce,ke,xe,Ne,Ve,$e,Te,ye,we,Ee,Se,Ae,Ie,Le,Me,Re,De,He,Oe,Pe,Fe,Be,qe,_e,je,Ge,Ue,Ke,We,ze,Ze,Xe,Ye,Je,Qe;if(r.allToolbar.includes(b))switch(b){case"-":return t.createVNode($t,null,null);case"bold":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.bold,onClick:()=>{d("bold")}},[t.createVNode(k.Icon,{name:"bold"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(V=o.value.toolbarTips)==null?void 0:V.bold])]);case"underline":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(T=o.value.toolbarTips)==null?void 0:T.underline,onClick:()=>{d("underline")}},[t.createVNode(k.Icon,{name:"underline"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.underline])]);case"italic":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(A=o.value.toolbarTips)==null?void 0:A.italic,onClick:()=>{d("italic")}},[t.createVNode(k.Icon,{name:"italic"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Z=o.value.toolbarTips)==null?void 0:Z.italic])]);case"strikeThrough":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(X=o.value.toolbarTips)==null?void 0:X.strikeThrough,onClick:()=>{d("strikeThrough")}},[t.createVNode(k.Icon,{name:"strike-through"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(y=o.value.toolbarTips)==null?void 0:y.strikeThrough])]);case"title":return t.createVNode(z.Dropdown,{relative:`#${f}`,visible:u.title,onChange:x=>{u.title=x},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h1")}},[(w=o.value.titleItem)==null?void 0:w.h1]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h2")}},[(B=o.value.titleItem)==null?void 0:B.h2]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h3")}},[(F=o.value.titleItem)==null?void 0:F.h3]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h4")}},[(R=o.value.titleItem)==null?void 0:R.h4]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h5")}},[(L=o.value.titleItem)==null?void 0:L.h5]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h6")}},[(M=o.value.titleItem)==null?void 0:M.h6])])},{default:()=>{var x,I;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(x=o.value.toolbarTips)==null?void 0:x.title},[t.createVNode(k.Icon,{name:"title"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.title])])]}});case"sub":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(D=o.value.toolbarTips)==null?void 0:D.sub,onClick:()=>{d("sub")}},[t.createVNode(k.Icon,{name:"sub"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(_=o.value.toolbarTips)==null?void 0:_.sub])]);case"sup":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(j=o.value.toolbarTips)==null?void 0:j.sup,onClick:()=>{d("sup")}},[t.createVNode(k.Icon,{name:"sup"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ne=o.value.toolbarTips)==null?void 0:ne.sup])]);case"quote":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Y=o.value.toolbarTips)==null?void 0:Y.quote,onClick:()=>{d("quote")}},[t.createVNode(k.Icon,{name:"quote"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(K=o.value.toolbarTips)==null?void 0:K.quote])]);case"unorderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(G=o.value.toolbarTips)==null?void 0:G.unorderedList,onClick:()=>{d("unorderedList")}},[t.createVNode(k.Icon,{name:"unordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(J=o.value.toolbarTips)==null?void 0:J.unorderedList])]);case"orderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(U=o.value.toolbarTips)==null?void 0:U.orderedList,onClick:()=>{d("orderedList")}},[t.createVNode(k.Icon,{name:"ordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(H=o.value.toolbarTips)==null?void 0:H.orderedList])]);case"task":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(O=o.value.toolbarTips)==null?void 0:O.task,onClick:()=>{d("task")}},[t.createVNode(k.Icon,{name:"task"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Q=o.value.toolbarTips)==null?void 0:Q.task])]);case"codeRow":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ie=o.value.toolbarTips)==null?void 0:ie.codeRow,onClick:()=>{d("codeRow")}},[t.createVNode(k.Icon,{name:"code-row"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ge=o.value.toolbarTips)==null?void 0:ge.codeRow])]);case"code":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(be=o.value.toolbarTips)==null?void 0:be.code,onClick:()=>{d("code")}},[t.createVNode(k.Icon,{name:"code"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(he=o.value.toolbarTips)==null?void 0:he.code])]);case"link":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ve=o.value.toolbarTips)==null?void 0:ve.link,onClick:()=>{v.type="link",v.linkVisible=!0}},[t.createVNode(k.Icon,{name:"link"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(pe=o.value.toolbarTips)==null?void 0:pe.link])]);case"image":return e.noUploadImg?t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ce=o.value.toolbarTips)==null?void 0:Ce.image,onClick:()=>{v.type="image",v.linkVisible=!0}},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ke=o.value.toolbarTips)==null?void 0:ke.image])]):t.createVNode(z.Dropdown,{relative:`#${f}`,visible:u.image,onChange:x=>{u.image=x},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{v.type="image",v.linkVisible=!0}},[(xe=o.value.imgTitleItem)==null?void 0:xe.link]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{m.value.click()}},[(Ne=o.value.imgTitleItem)==null?void 0:Ne.upload]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{v.clipVisible=!0}},[(Ve=o.value.imgTitleItem)==null?void 0:Ve.clip2upload])])},{default:()=>{var x,I;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(x=o.value.toolbarTips)==null?void 0:x.image},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.image])])]}});case"table":return t.createVNode(z.Dropdown,{relative:`#${f}`,visible:u.table,onChange:x=>{u.table=x},key:"bar-table",overlay:t.createVNode(St,{tableShape:e.tableShape,onSelected:x=>{d("table",{selectedShape:x})}},null)},{default:()=>{var x,I;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(x=o.value.toolbarTips)==null?void 0:x.table},[t.createVNode(k.Icon,{name:"table"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.table])])]}});case"revoke":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:($e=o.value.toolbarTips)==null?void 0:$e.revoke,onClick:()=>{s.bus.emit(l,s.CTRL_Z)}},[t.createVNode(k.Icon,{name:"revoke"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Te=o.value.toolbarTips)==null?void 0:Te.revoke])]);case"next":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ye=o.value.toolbarTips)==null?void 0:ye.next,onClick:()=>{s.bus.emit(l,s.CTRL_SHIFT_Z)}},[t.createVNode(k.Icon,{name:"next"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(we=o.value.toolbarTips)==null?void 0:we.next])]);case"save":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ee=o.value.toolbarTips)==null?void 0:Ee.save,onClick:()=>{s.bus.emit(l,s.ON_SAVE)}},[t.createVNode(k.Icon,{name:"baocun"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Se=o.value.toolbarTips)==null?void 0:Se.save])]);case"prettier":return e.noPrettier?"":t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ae=o.value.toolbarTips)==null?void 0:Ae.prettier,onClick:()=>{d("prettier")}},[t.createVNode(k.Icon,{name:"prettier"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ie=o.value.toolbarTips)==null?void 0:Ie.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Le=o.value.toolbarTips)==null?void 0:Le.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[t.createVNode(k.Icon,{name:e.setting.pageFullscreen?"suoxiao":"fangda"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Me=o.value.toolbarTips)==null?void 0:Me.pageFullscreen])]);case"fullscreen":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Re=o.value.toolbarTips)==null?void 0:Re.fullscreen,onClick:()=>{n()}},[t.createVNode(k.Icon,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(De=o.value.toolbarTips)==null?void 0:De.fullscreen])]);case"preview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(He=o.value.toolbarTips)==null?void 0:He.preview,onClick:()=>{e.updateSetting("preview")}},[t.createVNode(k.Icon,{name:"preview"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Oe=o.value.toolbarTips)==null?void 0:Oe.preview])]);case"htmlPreview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Pe=o.value.toolbarTips)==null?void 0:Pe.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[t.createVNode(k.Icon,{name:"coding"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Fe=o.value.toolbarTips)==null?void 0:Fe.htmlPreview])]);case"catalog":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Be=o.value.toolbarTips)==null?void 0:Be.catalog,onClick:()=>{s.bus.emit(l,s.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[t.createVNode(k.Icon,{name:"catalog"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(qe=o.value.toolbarTips)==null?void 0:qe.catalog])]);case"github":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(_e=o.value.toolbarTips)==null?void 0:_e.github,onClick:()=>le.linkTo("https://github.com/imzbf/md-editor-v3")},[t.createVNode(k.Icon,{name:"github"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(je=o.value.toolbarTips)==null?void 0:je.github])]);case"mermaid":return t.createVNode(z.Dropdown,{relative:`#${f}`,visible:u.mermaid,onChange:x=>{u.mermaid=x},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.mermaid=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("flow")}},[(Ge=o.value.mermaid)==null?void 0:Ge.flow]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("sequence")}},[(Ue=o.value.mermaid)==null?void 0:Ue.sequence]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("gantt")}},[(Ke=o.value.mermaid)==null?void 0:Ke.gantt]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("class")}},[(We=o.value.mermaid)==null?void 0:We.class]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("state")}},[(ze=o.value.mermaid)==null?void 0:ze.state]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("pie")}},[(Ze=o.value.mermaid)==null?void 0:Ze.pie]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("relationship")}},[(Xe=o.value.mermaid)==null?void 0:Xe.relationship]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("journey")}},[(Ye=o.value.mermaid)==null?void 0:Ye.journey])]),key:"bar-mermaid"},{default:()=>{var x,I;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(x=o.value.toolbarTips)==null?void 0:x.mermaid},[t.createVNode(k.Icon,{name:"mermaid"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.mermaid])])]}});case"katex":return t.createVNode(z.Dropdown,{relative:`#${f}`,visible:u.katex,onChange:x=>{u.katex=x},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.katex=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexInline")}},[(Je=o.value.katex)==null?void 0:Je.inline]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexBlock")}},[(Qe=o.value.katex)==null?void 0:Qe.block])]),key:"bar-katex"},{default:()=>{var x,I;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(x=o.value.toolbarTips)==null?void 0:x.katex},[t.createVNode(k.Icon,{name:"formula"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.katex])])]}})}else if(e.defToolbars instanceof Array){const x=e.defToolbars[b];return x?t.cloneVNode(x,{theme:a.value,language:i.value,insert(ue){s.bus.emit(l,s.REPLACE,"universal",{generate:ue})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const x=e.defToolbars.children[b];return x?t.cloneVNode(x,{theme:a.value,language:i.value,insert(ue){s.bus.emit(l,s.REPLACE,"universal",{generate:ue})}}):""}else return""};return t.watch(()=>e.toolbars,()=>{t.nextTick(()=>{g.value&&le.draggingScroll(g.value)})},{immediate:!0}),()=>{const b=N.value[0].map(V=>h(V)),C=N.value[1].map(V=>h(V));return t.createVNode(t.Fragment,null,[e.toolbars.length>0&&t.createVNode("div",{class:`${r.prefix}-toolbar-wrapper`,ref:g,id:f},[t.createVNode("div",{class:[`${r.prefix}-toolbar`,e.showToolbarName&&`${r.prefix}-stn`]},[t.createVNode("div",{class:`${r.prefix}-toolbar-left`,ref:$},[b]),t.createVNode("div",{class:`${r.prefix}-toolbar-right`},[C])])]),t.createVNode("input",{ref:m,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),t.createVNode(Dt,{linkVisible:v.linkVisible,clipVisible:v.clipVisible,type:v.type,onCancel:()=>{v.linkVisible=!1,v.clipVisible=!1},onOk:V=>{V&&d(v.type,{desc:V.desc,url:V.url}),v.linkVisible=!1,v.clipVisible=!1}},null)])}}}),Ot=(e,l)=>{const o=le.debounce(()=>{e.removeEventListener("scroll",a),e.addEventListener("scroll",a),l.removeEventListener("scroll",a),l.addEventListener("scroll",a)},50),a=i=>{const n=e.clientHeight,f=l.clientHeight,g=e.scrollHeight,u=l.scrollHeight,d=(g-n)/(u-f);i.target===e?(l.removeEventListener("scroll",a),l.scrollTo({top:e.scrollTop/d}),o()):(e.removeEventListener("scroll",a),e.scrollTo({top:l.scrollTop*d}),o())};return[()=>{o().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",a),l.removeEventListener("scroll",a)}]},Pt=(e,l,o)=>{const{view:a}=o,i=le.createSmoothScroll(),n=N=>a.lineBlockAt(a.state.doc.line(N).from).top,f=N=>a.lineBlockAt(a.state.doc.line(N).from).height;let g=[];const u=()=>{g=[];const N=Array.from(l.querySelectorAll("[data-line]")).map(b=>Number(b.dataset.line)+1),{lines:m}=a.state.doc;let p=1,h=N.shift()??m;for(let b=1;b<=m;b++)b===h&&(p=b,h=N.shift()||m+1),g.push({start:p,end:h-1})};let d=0,v=0;const $=le.throttle(N=>{var C,V,T,S,A,Z,X;if(!((C=l.firstElementChild)!=null&&C.firstElementChild))return;const m=a.lineBlockAtHeight(a.scrollDOM.scrollTop),{number:p}=a.state.doc.lineAt(m.from);if(p>g.length||a.state.doc.lines<g[g.length-1].end)return;let h=+getComputedStyle(l).paddingTop.replace("px","");const b=+getComputedStyle(l).paddingBottom.replace("px","");if(N.target===e){if(v!==0)return;d++;const y=g[p-1];let w=n(y.end)+f(y.end),B=0;const F=n(y.start),R=l.querySelector(`[data-line="${y.start-1}"]`)||((V=l.firstElementChild)==null?void 0:V.firstElementChild),L=l.querySelector(`[data-line="${y.end}"]`)||((T=l.lastElementChild)==null?void 0:T.lastElementChild);let M=0,D=0;F===0?R===L?(h=0,w=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight,B=a.scrollDOM.scrollTop/w,M=L.offsetTop+L.offsetHeight-l.clientHeight):(B=a.scrollDOM.scrollTop/w,M=L.offsetTop):w>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(B=(a.scrollDOM.scrollTop-F)/(a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight-F),D=R.offsetTop,M=l.scrollHeight-l.clientHeight-D+10):(B=(a.scrollDOM.scrollTop-F)/(w-F),D=R.offsetTop,M=L.offsetTop-D);const _=D-h+M*B;i(l,_,()=>{d--})}else{if(d!==0)return;v++;const y=Array.from(l.querySelectorAll("[data-line]")),w=l.scrollTop,B=l.scrollHeight;let F=y.length===0?1:Math.ceil(Number(y[y.length-1].dataset.line)*(w/B)),R=(S=l.firstElementChild)==null?void 0:S.firstElementChild;for(let H=F;H>=0;H--){const O=l.querySelector(`[data-line="${H}"]`);if(O&&O.offsetTop<=w){R=O,F=H;break}}let L=(A=l.firstElementChild)==null?void 0:A.firstElementChild,M=(Z=l.firstElementChild)==null?void 0:Z.lastElementChild;for(;y.length>0;){const H=y.indexOf(R);if(H+1>=y.length)break;const O=y[H+1];if(H===-1){M=O;break}const Q=R.offsetTop;if(Q>w){if(H===0){L=R,M=O;break}R=y[H-1];continue}const ie=O.offsetTop;if(Q<=w&&ie>w){L=R,M=O;break}R=O}const D=L.offsetTop;let _=M.offsetTop,j=0;const{start:ne,end:Y}=g[Number(L.dataset.line||0)],K=n(ne);let G=n(Y);const J=f(Y);let U=0;L===((X=l.firstElementChild)==null?void 0:X.firstElementChild)?(L===M?(_=M.offsetHeight-l.offsetHeight+h+b,U=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight):U=G+J-K,j=Math.max(w/_,0)):G>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(j=Math.max((w-D)/(l.scrollHeight-D-l.clientHeight),0),G=n(a.state.doc.lines)+f(a.state.doc.lines),U=8+G-K-e.clientHeight):(j=Math.max((w-D)/(_-D),0),U=G+J-K),i(e,K+U*j,()=>{v--})}},10);return[()=>{u(),e.addEventListener("scroll",$),l.addEventListener("scroll",$),e.dispatchEvent(new Event("scroll"))},()=>{g=[],e.removeEventListener("scroll",$),l.removeEventListener("scroll",$)}]},Ft=(e,l,o)=>{const a=t.inject("editorId");let i=()=>{},n=()=>{};const f=()=>{i();const g=document.querySelector(`#${a} .cm-scroller`),u=document.querySelector(`[id="${a}-preview-wrapper"][data-show="true"]`),d=document.querySelector(`[id="${a}-html-wrapper"][data-show="true"]`);(u||d)&&([n,i]=(u?Pt:Ot)(g,u||d,o.value)),e.scrollAuto&&n()};t.watch([l,t.toRef(e.setting,"preview"),t.toRef(e.setting,"htmlPreview"),t.toRef(e.setting,"fullscreen"),t.toRef(e.setting,"pageFullscreen")],()=>{t.nextTick(f)}),t.watch(()=>e.scrollAuto,g=>{g?n():i()}),t.onMounted(f)},Bt=Ft,qt=(e,l,o)=>{var v,$,N,m,p,h;let a="",i=0,n=0,f=!0,g=!1;const u=l.getSelectedText(),d=(v=r.configOption.editorConfig)==null?void 0:v.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const b=e.replace(/^h(\d)/,(C,V)=>new Array(Number(V)).fill("#",0,V).join(""));a=`${b} ${u}`,i=b.length+1}else if(e==="prettier"){const b=window.prettier||((N=($=r.configOption.editorExtensions)==null?void 0:$.prettier)==null?void 0:N.prettierInstance),C=[((m=window.prettierPlugins)==null?void 0:m.markdown)||((h=(p=r.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:h.parserMarkdownInstance)];!b||C[0]===void 0?(s.bus.emit(o.editorId,s.ERROR_CATCHER,{name:"prettier",message:"prettier is undefined"}),a=l.getValue()):a=b.format(l.getValue(),{parser:"markdown",plugins:C}),f=!1,g=!0}else switch(e){case"bold":{a=`**${u}**`,i=2,n=-2;break}case"underline":{a=`<u>${u}</u>`,i=3,n=-4;break}case"italic":{a=`*${u}*`,i=1,n=-1;break}case"strikeThrough":{a=`~~${u}~~`,i=2,n=-2;break}case"sub":{a=`<sub>${u}</sub>`,i=5,n=-6;break}case"sup":{a=`<sup>${u}</sup>`,i=5,n=-6;break}case"codeRow":{a="`"+u+"`",i=1,n=-1;break}case"quote":{a=`> ${u}`,i=2;break}case"orderedList":{a=`1. ${u}`,i=3;break}case"unorderedList":{a=`- ${u}`,i=2;break}case"task":{a=`- [ ] ${u}`,i=6;break}case"code":{const b=o.text||u||"",C=o.mode||"language";a=`\`\`\`${C}
2
+ ${b}
3
3
  \`\`\`
4
- `,n=3,i=3+N.length-a.length;break}case"table":{a="|";const{selectedShape:v={x:1,y:1}}=o,{x:N,y:$}=v;for(let T=0;T<=$;T++)a+=" col |";a+=`
5
- |`;for(let T=0;T<=$;T++)a+=" - |";for(let T=0;T<=N;T++){a+=`
6
- |`;for(let M=0;M<=$;M++)a+=" content |"}n=2,i=5-a.length;break}case"link":{const{desc:v,url:N}=o;a=`[${v}](${N})`,g=!1;break}case"image":{const{desc:v,url:N,urls:$}=o;$ instanceof Array?a=$.reduce((T,M)=>T+`![${v}](${M})
7
- `,""):a=`![${v}](${N})
8
- `,g=!1;break}case"flow":{a=`\`\`\`mermaid
9
- ${(m==null?void 0:m.flow)||`flowchart TD
4
+ `,i=3,n=3+C.length-a.length;break}case"table":{a="|";const{selectedShape:b={x:1,y:1}}=o,{x:C,y:V}=b;for(let T=0;T<=V;T++)a+=" col |";a+=`
5
+ |`;for(let T=0;T<=V;T++)a+=" - |";for(let T=0;T<=C;T++){a+=`
6
+ |`;for(let S=0;S<=V;S++)a+=" content |"}i=2,n=5-a.length;break}case"link":{const{desc:b,url:C}=o;a=`[${b}](${C})`,f=!1;break}case"image":{const{desc:b,url:C,urls:V}=o;V instanceof Array?a=V.reduce((T,S)=>T+`![${b}](${S})
7
+ `,""):a=`![${b}](${C})
8
+ `,f=!1;break}case"flow":{a=`\`\`\`mermaid
9
+ ${(d==null?void 0:d.flow)||`flowchart TD
10
10
  Start --> Stop`}
11
11
  \`\`\`
12
- `,n=3,i=10-a.length;break}case"sequence":{a=`\`\`\`mermaid
13
- ${(m==null?void 0:m.sequence)||`sequenceDiagram
12
+ `,i=3,n=10-a.length;break}case"sequence":{a=`\`\`\`mermaid
13
+ ${(d==null?void 0:d.sequence)||`sequenceDiagram
14
14
  A->>B: hello!
15
15
  B-->>A: hi!
16
16
  A-)B: bye!`}
17
17
  \`\`\`
18
- `,n=3,i=10-a.length;break}case"gantt":{a=`\`\`\`mermaid
19
- ${(m==null?void 0:m.gantt)||`gantt
18
+ `,i=3,n=10-a.length;break}case"gantt":{a=`\`\`\`mermaid
19
+ ${(d==null?void 0:d.gantt)||`gantt
20
20
  title A Gantt Diagram
21
21
  dateFormat YYYY-MM-DD
22
22
  section Section
23
23
  A task :a1, 2014-01-01, 30d
24
24
  Another task :after a1, 20d`}
25
25
  \`\`\`
26
- `,n=3,i=10-a.length;break}case"class":{a=`\`\`\`mermaid
27
- ${(m==null?void 0:m.class)||`classDiagram
26
+ `,i=3,n=10-a.length;break}case"class":{a=`\`\`\`mermaid
27
+ ${(d==null?void 0:d.class)||`classDiagram
28
28
  class Animal
29
29
  Vehicle <|-- Car`}
30
30
  \`\`\`
31
- `,n=3,i=10-a.length;break}case"state":{a=`\`\`\`mermaid
32
- ${(m==null?void 0:m.state)||`stateDiagram-v2
31
+ `,i=3,n=10-a.length;break}case"state":{a=`\`\`\`mermaid
32
+ ${(d==null?void 0:d.state)||`stateDiagram-v2
33
33
  s1 --> s2`}
34
34
  \`\`\`
35
- `,n=3,i=10-a.length;break}case"pie":{a=`\`\`\`mermaid
36
- ${(m==null?void 0:m.pie)||`pie title Pets adopted by volunteers
35
+ `,i=3,n=10-a.length;break}case"pie":{a=`\`\`\`mermaid
36
+ ${(d==null?void 0:d.pie)||`pie title Pets adopted by volunteers
37
37
  "Dogs" : 386
38
38
  "Cats" : 85
39
39
  "Rats" : 15`}
40
40
  \`\`\`
41
- `,n=3,i=10-a.length;break}case"relationship":{a=`\`\`\`mermaid
42
- ${(m==null?void 0:m.relationship)||`erDiagram
41
+ `,i=3,n=10-a.length;break}case"relationship":{a=`\`\`\`mermaid
42
+ ${(d==null?void 0:d.relationship)||`erDiagram
43
43
  CAR ||--o{ NAMED-DRIVER : allows
44
44
  PERSON ||--o{ NAMED-DRIVER : is`}
45
45
  \`\`\`
46
- `,n=3,i=10-a.length;break}case"journey":{a=`\`\`\`mermaid
47
- ${(m==null?void 0:m.journey)||`journey
46
+ `,i=3,n=10-a.length;break}case"journey":{a=`\`\`\`mermaid
47
+ ${(d==null?void 0:d.journey)||`journey
48
48
  title My working day
49
49
  section Go to work
50
50
  Make tea: 5: Me
@@ -54,14 +54,14 @@ ${(m==null?void 0:m.journey)||`journey
54
54
  Go downstairs: 5: Me
55
55
  Sit down: 5: Me`}
56
56
  \`\`\`
57
- `,n=3,i=10-a.length;break}case"katexInline":{a="$$",n=1,i=-1;break}case"katexBlock":{a=`$$
57
+ `,i=3,n=10-a.length;break}case"katexInline":{a="$$",i=1,n=-1;break}case"katexBlock":{a=`$$
58
58
 
59
59
  $$
60
- `,n=3,i=-4;break}case"universal":{const{generate:v}=o,N=v(u);a=N.targetValue,g=N.select,n=N.deviationStart,i=N.deviationEnd}}return{text:a,options:{select:g,deviationStart:n,deviationEnd:i,replaceAll:d}}},Bt="#e5c07b",Qe="var(--md-color)",qt="#56b6c2",_t="#ffffff",te="var(--md-color)",et="#e5c07b",jt="#e5c07b",Gt="var(--md-color)",tt="#d19a66",Ut="#c678dd",Kt="#21252b",Wt="#2c313a",ot="var(--md-bk-color)",me="var(--md-bk-color)",zt="#ceedfa33",lt="#528bff",Zt=ae.EditorView.theme({"&":{color:te,backgroundColor:ot},".cm-content":{caretColor:lt},".cm-cursor, .cm-dropCursor":{borderLeftColor:lt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:zt},".cm-panels":{backgroundColor:Kt,color:te},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:ot,color:te,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Wt},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"1px solid var(--md-border-color)",backgroundColor:me},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:me,borderBottomColor:me},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{color:te}}},{dark:!0}),Xt=re.HighlightStyle.define([{tag:c.tags.keyword,color:Ut},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:Qe},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:jt},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:tt},{tag:[c.tags.definition(c.tags.name),c.tags.separator],color:te},{tag:[c.tags.typeName,c.tags.className,c.tags.number,c.tags.changed,c.tags.annotation,c.tags.modifier,c.tags.self,c.tags.namespace],color:Bt},{tag:[c.tags.operator,c.tags.operatorKeyword,c.tags.url,c.tags.escape,c.tags.regexp,c.tags.link,c.tags.special(c.tags.string)],color:qt},{tag:[c.tags.meta,c.tags.comment],color:et},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:et,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:Qe},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:tt},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:Gt},{tag:c.tags.invalid,color:_t}]),at=[Zt,re.syntaxHighlighting(Xt)],Yt="#e5c07b",rt="#3f4a54",Jt="#56b6c2",Qt="#fff",oe="#3f4a54",nt="#2d8cf0",eo="#2d8cf0",to="#3f4a54",it="#d19a66",oo="#c678dd",lo="#21252b",ao="#ceedfa33",ct="var(--md-bk-color)",fe="var(--md-bk-color)",ro="#bad5fa",st="#3f4a54",no=ae.EditorView.theme({"&":{color:oe,backgroundColor:ct},".cm-content":{caretColor:st},".cm-cursor, .cm-dropCursor":{borderLeftColor:st},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ro},".cm-panels":{backgroundColor:lo,color:oe},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:ct,color:oe,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:ao},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"1px solid var(--md-border-color)",backgroundColor:fe},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fe,borderBottomColor:fe},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{color:oe}}}),io=re.HighlightStyle.define([{tag:c.tags.keyword,color:oo},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:rt},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:eo},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:it},{tag:[c.tags.definition(c.tags.name),c.tags.separator],color:oe},{tag:[c.tags.typeName,c.tags.className,c.tags.number,c.tags.changed,c.tags.annotation,c.tags.modifier,c.tags.self,c.tags.namespace],color:Yt},{tag:[c.tags.operator,c.tags.operatorKeyword,c.tags.url,c.tags.escape,c.tags.regexp,c.tags.link,c.tags.special(c.tags.string)],color:Jt},{tag:[c.tags.meta,c.tags.comment],color:nt},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:nt,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:rt},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:it},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:to},{tag:c.tags.invalid,color:Qt}]),dt=[no,re.syntaxHighlighting(io)],ce=(e,l,o,a,n)=>(i,g,d,u)=>{const m=`${e}${l}`.slice(u-d);i.dispatch(i.state.replaceSelection(`${m}${o}${a}`));const k=d+g.label.length+(n==="title"?o.length:0);i.dispatch({selection:E.EditorSelection.create([E.EditorSelection.range(d+g.label.length+(n==="title"?1:-l.length),k),E.EditorSelection.cursor(k)],1)}),i.focus()},ut=e=>(l,o,a,n)=>{const i=e.slice(n-a);l.dispatch(l.state.replaceSelection(`${i} `))},co=e=>{const l=o=>{const a=o.matchBefore(/^#+|^-\s*\[*\s*\]*|`+|\[|!\[*|^\|\s?\|?|^\$\$?|!+\s*\w*/);return a===null||a.from==a.to&&o.explicit?null:{from:a.from,options:[...["h1","h2","h3","h4","h5","h6"].map((n,i)=>{const g=new Array(i+1).fill("#").join("");return{label:g,type:"text",apply:ut(g)}}),...["unchecked","checked"].map(n=>{const i=n==="checked"?"- [x]":"- [ ]";return{label:i,type:"text",apply:ut(i)}}),...[["`",""],["```","language"],["```mermaid\n",""]].map(n=>({label:`${n[0]}${n[1]}`,type:"text",apply:ce(n[0],n[1],"",n[0]==="`"?"`":"\n```","type")})),{label:"[]()",type:"text"},{label:"![]()",type:"text"},{label:"| |",type:"text",detail:"table",apply:`| col | col | col |
60
+ `,i=3,n=-4;break}case"universal":{const{generate:b}=o,C=b(u);a=C.targetValue,f=C.select,i=C.deviationStart,n=C.deviationEnd}}return{text:a,options:{select:f,deviationStart:i,deviationEnd:n,replaceAll:g}}},_t="#e5c07b",tt="var(--md-color)",jt="#56b6c2",Gt="#ffffff",te="var(--md-color)",ot="#e5c07b",Ut="#e5c07b",Kt="var(--md-color)",lt="#d19a66",Wt="#c678dd",zt="#21252b",Zt="#2c313a",at="var(--md-bk-color)",me="var(--md-bk-color)",Xt="#ceedfa33",rt="#528bff",Yt=ae.EditorView.theme({"&":{color:te,backgroundColor:at},".cm-content":{caretColor:rt},".cm-cursor, .cm-dropCursor":{borderLeftColor:rt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Xt},".cm-panels":{backgroundColor:zt,color:te},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:at,color:te,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Zt},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"1px solid var(--md-border-color)",backgroundColor:me},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:me,borderBottomColor:me},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{color:te}}},{dark:!0}),Jt=re.HighlightStyle.define([{tag:c.tags.keyword,color:Wt},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:tt},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:Ut},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:lt},{tag:[c.tags.definition(c.tags.name),c.tags.separator],color:te},{tag:[c.tags.typeName,c.tags.className,c.tags.number,c.tags.changed,c.tags.annotation,c.tags.modifier,c.tags.self,c.tags.namespace],color:_t},{tag:[c.tags.operator,c.tags.operatorKeyword,c.tags.url,c.tags.escape,c.tags.regexp,c.tags.link,c.tags.special(c.tags.string)],color:jt},{tag:[c.tags.meta,c.tags.comment],color:ot},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:ot,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:tt},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:lt},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:Kt},{tag:c.tags.invalid,color:Gt}]),nt=[Yt,re.syntaxHighlighting(Jt)],Qt="#e5c07b",it="#3f4a54",eo="#56b6c2",to="#fff",oe="#3f4a54",ct="#2d8cf0",oo="#2d8cf0",lo="#3f4a54",st="#d19a66",ao="#c678dd",ro="#21252b",no="#ceedfa33",dt="var(--md-bk-color)",fe="var(--md-bk-color)",io="#bad5fa",ut="#3f4a54",co=ae.EditorView.theme({"&":{color:oe,backgroundColor:dt},".cm-content":{caretColor:ut},".cm-cursor, .cm-dropCursor":{borderLeftColor:ut},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:io},".cm-panels":{backgroundColor:ro,color:oe},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:dt,color:oe,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:no},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"1px solid var(--md-border-color)",backgroundColor:fe},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fe,borderBottomColor:fe},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{color:oe}}}),so=re.HighlightStyle.define([{tag:c.tags.keyword,color:ao},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:it},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:oo},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:st},{tag:[c.tags.definition(c.tags.name),c.tags.separator],color:oe},{tag:[c.tags.typeName,c.tags.className,c.tags.number,c.tags.changed,c.tags.annotation,c.tags.modifier,c.tags.self,c.tags.namespace],color:Qt},{tag:[c.tags.operator,c.tags.operatorKeyword,c.tags.url,c.tags.escape,c.tags.regexp,c.tags.link,c.tags.special(c.tags.string)],color:eo},{tag:[c.tags.meta,c.tags.comment],color:ct},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:ct,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:it},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:st},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:lo},{tag:c.tags.invalid,color:to}]),mt=[co,re.syntaxHighlighting(so)],ce=(e,l,o,a,i)=>(n,f,g,u)=>{const d=`${e}${l}`.slice(u-g);n.dispatch(n.state.replaceSelection(`${d}${o}${a}`));const v=g+f.label.length+(i==="title"?o.length:0);n.dispatch({selection:E.EditorSelection.create([E.EditorSelection.range(g+f.label.length+(i==="title"?1:-l.length),v),E.EditorSelection.cursor(v)],1)}),n.focus()},ft=e=>(l,o,a,i)=>{const n=e.slice(i-a);l.dispatch(l.state.replaceSelection(`${n} `))},uo=e=>{const l=o=>{const a=o.matchBefore(/^#+|^-\s*\[*\s*\]*|`+|\[|!\[*|^\|\s?\|?|^\$\$?|!+\s*\w*/);return a===null||a.from==a.to&&o.explicit?null:{from:a.from,options:[...["h1","h2","h3","h4","h5","h6"].map((i,n)=>{const f=new Array(n+1).fill("#").join("");return{label:f,type:"text",apply:ft(f)}}),...["unchecked","checked"].map(i=>{const n=i==="checked"?"- [x]":"- [ ]";return{label:n,type:"text",apply:ft(n)}}),...[["`",""],["```","language"],["```mermaid\n",""]].map(i=>({label:`${i[0]}${i[1]}`,type:"text",apply:ce(i[0],i[1],"",i[0]==="`"?"`":"\n```","type")})),{label:"[]()",type:"text"},{label:"![]()",type:"text"},{label:"| |",type:"text",detail:"table",apply:`| col | col | col |
61
61
  | - | - | - |
62
62
  | content | content | content |
63
63
  | content | content | content |`},{label:"$",type:"text",apply:ce("$","","","$","type")},{label:"$$",type:"text",apply:ce("$$","",`
64
64
  `,`
65
- $$`,"title")},...["note","abstract","info","tip","success","question","warning","failure","danger","bug","example","quote","hint","caution","error","attention"].map(n=>({label:`!!! ${n}`,type:"text",apply:ce("!!!",` ${n}`," Title",`
65
+ $$`,"title")},...["note","abstract","info","tip","success","question","warning","failure","danger","bug","example","quote","hint","caution","error","attention"].map(i=>({label:`!!! ${i}`,type:"text",apply:ce("!!!",` ${i}`," Title",`
66
66
 
67
- !!!`,"title")}))]}};return Ct.autocompletion({override:e?[l,...e]:[l]})},mt=co,W=e=>{const l=new E.Compartment;return a=>(l.get(e.state)?e.dispatch({effects:l.reconfigure(a)}):e.dispatch({effects:E.StateEffect.appendConfig.of(l.of(a))}),!0)};class so{constructor(l){q(this,"view");q(this,"maxLength",Number.MAX_SAFE_INTEGER);q(this,"toggleTabSize");q(this,"togglePlaceholder");q(this,"setExtensions");q(this,"toggleDisabled");q(this,"toggleReadOnly");q(this,"toggleMaxlength");this.view=l,this.toggleTabSize=W(this.view),this.togglePlaceholder=W(this.view),this.setExtensions=W(this.view),this.toggleDisabled=W(this.view),this.toggleReadOnly=W(this.view),this.toggleMaxlength=W(this.view)}getValue(){return this.view.state.doc.toString()}setValue(l,o=0,a=this.view.state.doc.length){this.view.dispatch({changes:{from:o,to:a,insert:l}})}getSelectedText(){const{from:l,to:o}=this.view.state.selection.main;return this.view.state.sliceDoc(l,o)}replaceSelectedText(l,o={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1},a){try{if(o.replaceAll){if(this.setValue(l),l.length>this.maxLength)throw new Error("The input text is too long");return}if(this.view.state.doc.length-this.getSelectedText().length+l.length>this.maxLength)throw new Error("The input text is too long");const{from:n}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(l)),o.select){const i=n+l.length+o.deviationEnd;this.view.dispatch({selection:E.EditorSelection.create([E.EditorSelection.range(n+o.deviationStart,i),E.EditorSelection.cursor(i)],1)})}this.view.focus()}catch(n){if(n.message==="The input text is too long")s.bus.emit(a,s.ERROR_CATCHER,{name:"overlength",message:n.message,data:l});else throw n}}setTabSize(l){this.toggleTabSize([E.EditorState.tabSize.of(l),re.indentUnit.of(" ".repeat(l))])}setPlaceholder(l){this.togglePlaceholder(ae.placeholder(l))}focus(l){if(this.view.focus(),!l)return;let o=0,a=0,n=0;switch(l){case"start":break;case"end":{o=a=n=this.getValue().length;break}default:o=l.rangeAnchor||l.cursorPos,a=l.rangeHead||l.cursorPos,n=l.cursorPos}this.view.dispatch({scrollIntoView:!0,selection:E.EditorSelection.create([E.EditorSelection.range(o,a),E.EditorSelection.cursor(n)],1)})}setDisabled(l){this.toggleDisabled([ae.EditorView.editable.of(!l)])}setReadOnly(l){this.toggleReadOnly([E.EditorState.readOnly.of(l)])}setMaxLength(l){this.maxLength=l,this.toggleMaxlength([E.EditorState.changeFilter.of(o=>o.newDoc.length<=l)])}}const uo=e=>{const l=t.inject("editorId");return a=>{if(!a.clipboardData)return;if(a.clipboardData.files.length>0){const{files:i}=a.clipboardData;s.bus.emit(l,s.UPLOAD_IMAGE,Array.from(i).filter(g=>/image\/.*/.test(g.type))),a.preventDefault();return}if(e.autoDetectCode&&a.clipboardData.types.includes("vscode-editor-data")){const i=JSON.parse(a.clipboardData.getData("vscode-editor-data"));s.bus.emit(l,s.REPLACE,"code",{mode:i.mode,text:a.clipboardData.getData("text/plain")}),a.preventDefault();return}const n=a.clipboardData.getData("text/plain");e.maxlength&&n.length+e.modelValue.length>e.maxlength&&s.bus.emit(l,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:n})}},mo=uo,fo=e=>{const l=t.inject("editorId");t.onMounted(()=>{s.bus.on(l,{name:s.TEXTAREA_FOCUS,callback(o){var a;(a=e.value)==null||a.focus(o)}})})},go=fo,bo=(e,l)=>{const o={key:"Ctrl-b",mac:"Cmd-b",run:()=>(s.bus.emit(e,s.REPLACE,"bold"),!0)},a={key:"Ctrl-s",mac:"Cmd-s",run:M=>(s.bus.emit(e,s.ON_SAVE,M.state.doc.toString()),!0),shift:()=>(s.bus.emit(e,s.REPLACE,"strikeThrough"),!0)},n={key:"Ctrl-u",mac:"Cmd-u",run:()=>(s.bus.emit(e,s.REPLACE,"underline"),!0),shift:()=>(s.bus.emit(e,s.REPLACE,"unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(s.bus.emit(e,s.REPLACE,"italic"),!0),shift:()=>(s.bus.emit(e,s.OPEN_MODALS,"image"),!0)},g={key:"Ctrl-1",mac:"Cmd-1",run:()=>(s.bus.emit(e,s.REPLACE,"h1"),!0)},d={key:"Ctrl-2",mac:"Cmd-2",run:()=>(s.bus.emit(e,s.REPLACE,"h2"),!0)},u={key:"Ctrl-3",mac:"Cmd-3",run:()=>(s.bus.emit(e,s.REPLACE,"h3"),!0)},m={key:"Ctrl-4",mac:"Cmd-4",run:()=>(s.bus.emit(e,s.REPLACE,"h4"),!0)},k={key:"Ctrl-5",mac:"Cmd-5",run:()=>(s.bus.emit(e,s.REPLACE,"h5"),!0)},V={key:"Ctrl-6",mac:"Cmd-6",run:()=>(s.bus.emit(e,s.REPLACE,"h6"),!0)},x={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(s.bus.emit(e,s.REPLACE,"sup"),!0)},f={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(s.bus.emit(e,s.REPLACE,"sub"),!0)},h={key:"Ctrl-o",mac:"Cmd-o",run:()=>(s.bus.emit(e,s.REPLACE,"orderedList"),!0)},b={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(s.bus.emit(e,s.REPLACE,"code"),!0),any(M,S){return(S.ctrlKey||S.metaKey)&&S.altKey&&S.code==="KeyC"?(s.bus.emit(e,s.REPLACE,"codeRow"),!0):!1}},v={key:"Ctrl-l",mac:"Cmd-l",run:()=>(s.bus.emit(e,s.OPEN_MODALS,"link"),!0)},N={key:"Ctrl-f",mac:"Cmd-f",shift:()=>l.noPrettier?!1:(s.bus.emit(e,s.REPLACE,"prettier"),!0)},$={any:(M,S)=>(S.ctrlKey||S.metaKey)&&S.altKey&&S.shiftKey&&S.code==="KeyT"?(s.bus.emit(e,s.REPLACE,"table"),!0):!1},T={key:"Ctrl-d",mac:"Cmd-d",run:se.deleteLine,preventDefault:!0};return[o,T,a,n,i,g,d,u,m,k,V,x,f,h,b,v,N,$]},ho=bo,vo=e=>{const l=t.inject("tabWidth"),o=t.inject("editorId"),a=t.inject("theme"),n=t.ref(),i=t.shallowRef(),g=new E.Compartment,d=new E.Compartment,u=new E.Compartment,m=ho(o,e),k=mo(e),V=[ae.keymap.of([...m,se.indentWithTab]),ee.minimalSetup,g.of(pt.markdown({codeLanguages:vt.languages})),ee.EditorView.lineWrapping,ee.EditorView.updateListener.of(f=>{f.docChanged&&e.onChange(f.state.doc.toString())}),ee.EditorView.domEventHandlers({paste:k,blur:e.onBlur,focus:e.onFocus,drop:e.onDrop,input:f=>{e.onInput&&e.onInput(f);const{data:h}=f;e.maxlength&&e.modelValue.length+h.length>e.maxlength&&s.bus.emit(o,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:h})}})],x=()=>{const f=[...V,d.of(a.value==="light"?dt:at),u.of(mt(e.completions))];return r.configOption.codeMirrorExtensions(a.value,f,[...m])};return t.onMounted(()=>{const f=new ee.EditorView({doc:e.modelValue,parent:n.value,extensions:[x()]}),h=new so(f);i.value=h,setTimeout(()=>{h.setTabSize(l),h.setDisabled(e.disabled),h.setReadOnly(e.readonly),e.placeholder&&h.setPlaceholder(e.placeholder),typeof e.maxlength=="number"&&h.setMaxLength(e.maxlength),e.autofocus&&f.focus()},0),s.bus.on(o,{name:s.CTRL_Z,callback(){se.undo(f)}}),s.bus.on(o,{name:s.CTRL_SHIFT_Z,callback(){se.redo(f)}}),s.bus.on(o,{name:s.REPLACE,callback(b,v={}){var T;const{text:N,options:$}=Ft(b,i.value,v);(T=i.value)==null||T.replaceSelectedText(N,$,o)}})}),t.watch(a,()=>{var f;(f=i.value)==null||f.view.dispatch({effects:d.reconfigure(a.value==="light"?dt:at)})},{deep:!0}),t.watch(()=>e.completions,()=>{var f;(f=i.value)==null||f.view.dispatch({effects:u.reconfigure(mt(e.completions))})},{deep:!0}),t.watch(()=>e.modelValue,()=>{var f,h;((f=i.value)==null?void 0:f.getValue())!==e.modelValue&&((h=i.value)==null||h.setValue(e.modelValue))}),t.watch(()=>e.placeholder,()=>{var f;(f=i.value)==null||f.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var f;(f=i.value)==null||f.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var f;(f=i.value)==null||f.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var f;e.maxlength&&((f=i.value)==null||f.setMaxLength(e.maxlength))}),go(i),{inputWrapperRef:n,codeMirrorUt:i}},po=vo,Co=t.defineComponent({name:"MDEditorContent",props:P.contentProps,setup(e){const l=t.inject("editorId"),o=t.ref(""),{inputWrapperRef:a,codeMirrorUt:n}=po(e);return Pt(e,o,n),()=>t.createVNode("div",{class:`${r.prefix}-content`},[t.createVNode("div",{class:`${r.prefix}-input-wrapper`,ref:a},null),t.createVNode(P.ContentPreview,{modelValue:e.modelValue,setting:e.setting,onHtmlChanged:i=>{o.value=i,e.onHtmlChanged(i)},onGetCatalog:e.onGetCatalog,mdHeadingId:e.mdHeadingId,noMermaid:e.noMermaid,sanitize:e.sanitize,noKatex:e.noKatex,formatCopiedText:e.formatCopiedText,noHighlight:e.noHighlight,noImgZoomIn:e.noImgZoomIn},null),e.catalogVisible&&t.createVNode(ft,{theme:e.theme,class:`${r.prefix}-catalog-editor`,editorId:l,mdHeadingId:e.mdHeadingId,key:"internal-catalog"},null)])}}),ko=t.defineComponent({props:{modelValue:{type:String,default:""}},setup(e){const l=t.inject("usedLanguageText");return()=>{var o,a;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`},[`${(o=l.value.footer)==null?void 0:o.markdownTotal}:`]),t.createVNode("span",null,[((a=e.modelValue)==null?void 0:a.length)||0])])}}}),xo={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},No=t.defineComponent({props:xo,setup(e){return()=>t.createVNode("div",{class:[`${r.prefix}-checkbox`,e.checked&&`${r.prefix}-checkbox-checked`],onClick:()=>{e.onChange(!e.checked)}},null)}}),Vo={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},$o=t.defineComponent({props:Vo,setup(e){const l=t.inject("usedLanguageText");return()=>{var o;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`,onClick:()=>{e.onScrollAutoChange(!e.scrollAuto)}},[(o=l.value.footer)==null?void 0:o.scrollAuto]),t.createVNode(No,{checked:e.scrollAuto,onChange:e.onScrollAutoChange},null)])}}}),To={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},yo=t.defineComponent({name:"MDEditorFooter",props:To,setup(e){const l=t.computed(()=>{const a=e.footers.indexOf("="),n=a===-1?e.footers:e.footers.slice(0,a),i=a===-1?[]:e.footers.slice(a,Number.MAX_SAFE_INTEGER);return[n,i]}),o=a=>{if(r.allFooter.includes(a))switch(a){case"markdownTotal":return t.createVNode(ko,{modelValue:e.modelValue},null);case"scrollSwitch":return t.createVNode($o,{scrollAuto:e.scrollAuto,onScrollAutoChange:e.onScrollAutoChange},null)}else return e.defFooters instanceof Array?e.defFooters[a]||"":e.defFooters&&e.defFooters.children instanceof Array&&e.defFooters.children[a]||""};return()=>{const a=l.value[0].map(i=>o(i)),n=l.value[1].map(i=>o(i));return t.createVNode("div",{class:`${r.prefix}-footer`},[t.createVNode("div",{class:`${r.prefix}-footer-left`},[a]),t.createVNode("div",{class:`${r.prefix}-footer-right`},[n])])}}}),wo=t.defineComponent({name:"MdEditorV3",props:P.editorProps,emits:P.editorEmits,setup(e,l){const{editorId:o,noKatex:a,noMermaid:n,noPrettier:i,noUploadImg:g,noHighlight:d}=e,u=t.reactive({scrollAuto:e.scrollAuto});P.useOnSave(e,l),P.useProvide(e),P.useExpansion(e),P.useErrorCatcher(e,l);const[m,k]=P.useConfig(e,l),V=P.useCatalog(e);return t.onBeforeUnmount(()=>{s.bus.clear(o)}),P.useExpose(e,l,V,m,k),()=>{var h;const x=Je.getSlot({props:e,ctx:l},"defToolbars"),f=Je.getSlot({props:e,ctx:l},"defFooters");return t.createVNode("div",{id:o,class:[r.prefix,e.class,e.theme==="dark"&&`${r.prefix}-dark`,m.fullscreen||m.pageFullscreen?`${r.prefix}-fullscreen`:""],style:e.style},[t.createVNode(Rt,{noPrettier:i,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:m,updateSetting:k,tableShape:e.tableShape,defToolbars:x,noUploadImg:g,showToolbarName:e.showToolbarName},null),t.createVNode(Co,{modelValue:e.modelValue,setting:m,mdHeadingId:e.mdHeadingId,noMermaid:n,noPrettier:i,sanitize:e.sanitize,placeholder:e.placeholder,noKatex:a,scrollAuto:u.scrollAuto,formatCopiedText:e.formatCopiedText,autofocus:e.autoFocus,disabled:e.disabled,readonly:e.readOnly,maxlength:e.maxLength,autoDetectCode:e.autoDetectCode,noHighlight:d,onChange:b=>{e.onChange?e.onChange(b):(l.emit("update:modelValue",b),l.emit("onChange",b))},onHtmlChanged:b=>{e.onHtmlChanged?e.onHtmlChanged(b):l.emit("onHtmlChanged",b)},onGetCatalog:b=>{e.onGetCatalog?e.onGetCatalog(b):l.emit("onGetCatalog",b)},onBlur:b=>{e.onBlur?e.onBlur(b):l.emit("onBlur",b)},onFocus:b=>{e.onFocus?e.onFocus(b):l.emit("onFocus",b)},onInput:b=>{e.onInput?e.onInput(b):l.emit("onInput",b)},completions:e.completions,catalogVisible:V.value,theme:e.theme,noImgZoomIn:e.noImgZoomIn,onDrop:b=>{e.onDrop?e.onDrop(b):l.emit("onDrop",b)}},null),((h=e.footers)==null?void 0:h.length)>0&&t.createVNode(yo,{modelValue:e.modelValue,footers:e.footers,defFooters:f,scrollAuto:u.scrollAuto,onScrollAutoChange:b=>u.scrollAuto=b},null)])}}}),de=wo;de.install=e=>(e.component(de.name,de),e.use(kt).use(z.DropdownToolbar).use(xt).use(ft).use(P.MdPreview),e);module.exports=de;
67
+ !!!`,"title")}))]}};return xt.autocompletion({override:e?[l,...e]:[l]})},gt=uo,W=e=>{const l=new E.Compartment;return a=>(l.get(e.state)?e.dispatch({effects:l.reconfigure(a)}):e.dispatch({effects:E.StateEffect.appendConfig.of(l.of(a))}),!0)};class mo{constructor(l){q(this,"view");q(this,"maxLength",Number.MAX_SAFE_INTEGER);q(this,"toggleTabSize");q(this,"togglePlaceholder");q(this,"setExtensions");q(this,"toggleDisabled");q(this,"toggleReadOnly");q(this,"toggleMaxlength");this.view=l,this.toggleTabSize=W(this.view),this.togglePlaceholder=W(this.view),this.setExtensions=W(this.view),this.toggleDisabled=W(this.view),this.toggleReadOnly=W(this.view),this.toggleMaxlength=W(this.view)}getValue(){return this.view.state.doc.toString()}setValue(l,o=0,a=this.view.state.doc.length){this.view.dispatch({changes:{from:o,to:a,insert:l}})}getSelectedText(){const{from:l,to:o}=this.view.state.selection.main;return this.view.state.sliceDoc(l,o)}replaceSelectedText(l,o={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1},a){try{if(o.replaceAll){if(this.setValue(l),l.length>this.maxLength)throw new Error("The input text is too long");return}if(this.view.state.doc.length-this.getSelectedText().length+l.length>this.maxLength)throw new Error("The input text is too long");const{from:i}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(l)),o.select){const n=i+l.length+o.deviationEnd;this.view.dispatch({selection:E.EditorSelection.create([E.EditorSelection.range(i+o.deviationStart,n),E.EditorSelection.cursor(n)],1)})}this.view.focus()}catch(i){if(i.message==="The input text is too long")s.bus.emit(a,s.ERROR_CATCHER,{name:"overlength",message:i.message,data:l});else throw i}}setTabSize(l){this.toggleTabSize([E.EditorState.tabSize.of(l),re.indentUnit.of(" ".repeat(l))])}setPlaceholder(l){this.togglePlaceholder(ae.placeholder(l))}focus(l){if(this.view.focus(),!l)return;let o=0,a=0,i=0;switch(l){case"start":break;case"end":{o=a=i=this.getValue().length;break}default:o=l.rangeAnchor||l.cursorPos,a=l.rangeHead||l.cursorPos,i=l.cursorPos}this.view.dispatch({scrollIntoView:!0,selection:E.EditorSelection.create([E.EditorSelection.range(o,a),E.EditorSelection.cursor(i)],1)})}setDisabled(l){this.toggleDisabled([ae.EditorView.editable.of(!l)])}setReadOnly(l){this.toggleReadOnly([E.EditorState.readOnly.of(l)])}setMaxLength(l){this.maxLength=l,this.toggleMaxlength([E.EditorState.changeFilter.of(o=>o.newDoc.length<=l)])}}const fo=e=>{const l=t.inject("editorId");return a=>{if(!a.clipboardData)return;if(a.clipboardData.files.length>0){const{files:n}=a.clipboardData;s.bus.emit(l,s.UPLOAD_IMAGE,Array.from(n).filter(f=>/image\/.*/.test(f.type))),a.preventDefault();return}if(e.autoDetectCode&&a.clipboardData.types.includes("vscode-editor-data")){const n=JSON.parse(a.clipboardData.getData("vscode-editor-data"));s.bus.emit(l,s.REPLACE,"code",{mode:n.mode,text:a.clipboardData.getData("text/plain")}),a.preventDefault();return}const i=a.clipboardData.getData("text/plain");e.maxlength&&i.length+e.modelValue.length>e.maxlength&&s.bus.emit(l,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:i})}},go=fo,bo=e=>{const l=t.inject("editorId");t.onMounted(()=>{s.bus.on(l,{name:s.TEXTAREA_FOCUS,callback(o){var a;(a=e.value)==null||a.focus(o)}})})},ho=bo,vo=(e,l)=>{const o={key:"Ctrl-b",mac:"Cmd-b",run:()=>(s.bus.emit(e,s.REPLACE,"bold"),!0)},a={key:"Ctrl-s",mac:"Cmd-s",run:S=>(s.bus.emit(e,s.ON_SAVE,S.state.doc.toString()),!0),shift:()=>(s.bus.emit(e,s.REPLACE,"strikeThrough"),!0)},i={key:"Ctrl-u",mac:"Cmd-u",run:()=>(s.bus.emit(e,s.REPLACE,"underline"),!0),shift:()=>(s.bus.emit(e,s.REPLACE,"unorderedList"),!0)},n={key:"Ctrl-i",mac:"Cmd-i",run:()=>(s.bus.emit(e,s.REPLACE,"italic"),!0),shift:()=>(s.bus.emit(e,s.OPEN_MODALS,"image"),!0)},f={key:"Ctrl-1",mac:"Cmd-1",run:()=>(s.bus.emit(e,s.REPLACE,"h1"),!0)},g={key:"Ctrl-2",mac:"Cmd-2",run:()=>(s.bus.emit(e,s.REPLACE,"h2"),!0)},u={key:"Ctrl-3",mac:"Cmd-3",run:()=>(s.bus.emit(e,s.REPLACE,"h3"),!0)},d={key:"Ctrl-4",mac:"Cmd-4",run:()=>(s.bus.emit(e,s.REPLACE,"h4"),!0)},v={key:"Ctrl-5",mac:"Cmd-5",run:()=>(s.bus.emit(e,s.REPLACE,"h5"),!0)},$={key:"Ctrl-6",mac:"Cmd-6",run:()=>(s.bus.emit(e,s.REPLACE,"h6"),!0)},N={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(s.bus.emit(e,s.REPLACE,"sup"),!0)},m={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(s.bus.emit(e,s.REPLACE,"sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(s.bus.emit(e,s.REPLACE,"orderedList"),!0)},h={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(s.bus.emit(e,s.REPLACE,"code"),!0),any(S,A){return(A.ctrlKey||A.metaKey)&&A.altKey&&A.code==="KeyC"?(s.bus.emit(e,s.REPLACE,"codeRow"),!0):!1}},b={key:"Ctrl-l",mac:"Cmd-l",run:()=>(s.bus.emit(e,s.OPEN_MODALS,"link"),!0)},C={key:"Ctrl-f",mac:"Cmd-f",shift:()=>l.noPrettier?!1:(s.bus.emit(e,s.REPLACE,"prettier"),!0)},V={any:(S,A)=>(A.ctrlKey||A.metaKey)&&A.altKey&&A.shiftKey&&A.code==="KeyT"?(s.bus.emit(e,s.REPLACE,"table"),!0):!1},T={key:"Ctrl-d",mac:"Cmd-d",run:se.deleteLine,preventDefault:!0};return[o,T,a,i,n,f,g,u,d,v,$,N,m,p,h,b,C,V]},po=vo,Co=e=>{const l=t.inject("tabWidth"),o=t.inject("editorId"),a=t.inject("theme"),i=t.ref(),n=t.shallowRef(),f=new E.Compartment,g=new E.Compartment,u=new E.Compartment,d=po(o,e),v=go(e),$=[ae.keymap.of([...d,se.indentWithTab]),ee.minimalSetup,f.of(kt.markdown({codeLanguages:Ct.languages})),ee.EditorView.lineWrapping,ee.EditorView.updateListener.of(m=>{m.docChanged&&e.onChange(m.state.doc.toString())}),ee.EditorView.domEventHandlers({paste:v,blur:e.onBlur,focus:e.onFocus,drop:e.onDrop,input:m=>{e.onInput&&e.onInput(m);const{data:p}=m;e.maxlength&&e.modelValue.length+p.length>e.maxlength&&s.bus.emit(o,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:p})}})],N=()=>{const m=[...$,g.of(a.value==="light"?mt:nt),u.of(gt(e.completions))];return r.configOption.codeMirrorExtensions(a.value,m,[...d])};return t.onMounted(()=>{const m=new ee.EditorView({doc:e.modelValue,parent:i.value,extensions:[N()]}),p=new mo(m);n.value=p,setTimeout(()=>{p.setTabSize(l),p.setDisabled(e.disabled),p.setReadOnly(e.readonly),e.placeholder&&p.setPlaceholder(e.placeholder),typeof e.maxlength=="number"&&p.setMaxLength(e.maxlength),e.autofocus&&m.focus()},0),s.bus.on(o,{name:s.CTRL_Z,callback(){se.undo(m)}}),s.bus.on(o,{name:s.CTRL_SHIFT_Z,callback(){se.redo(m)}}),s.bus.on(o,{name:s.REPLACE,callback(h,b={}){var T;const{text:C,options:V}=qt(h,n.value,b);(T=n.value)==null||T.replaceSelectedText(C,V,o)}})}),t.watch(a,()=>{var m;(m=n.value)==null||m.view.dispatch({effects:g.reconfigure(a.value==="light"?mt:nt)})},{deep:!0}),t.watch(()=>e.completions,()=>{var m;(m=n.value)==null||m.view.dispatch({effects:u.reconfigure(gt(e.completions))})},{deep:!0}),t.watch(()=>e.modelValue,()=>{var m,p;((m=n.value)==null?void 0:m.getValue())!==e.modelValue&&((p=n.value)==null||p.setValue(e.modelValue))}),t.watch(()=>e.placeholder,()=>{var m;(m=n.value)==null||m.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var m;(m=n.value)==null||m.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var m;(m=n.value)==null||m.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var m;e.maxlength&&((m=n.value)==null||m.setMaxLength(e.maxlength))}),ho(n),{inputWrapperRef:i,codeMirrorUt:n}},ko=Co,xo=t.defineComponent({name:"MDEditorContent",props:P.contentProps,setup(e){const l=t.inject("editorId"),o=t.ref(""),{inputWrapperRef:a,codeMirrorUt:i}=ko(e);return Bt(e,o,i),()=>t.createVNode("div",{class:`${r.prefix}-content`},[t.createVNode("div",{class:`${r.prefix}-input-wrapper`,ref:a},null),t.createVNode(P.ContentPreview,{modelValue:e.modelValue,setting:e.setting,onHtmlChanged:n=>{o.value=n,e.onHtmlChanged(n)},onGetCatalog:e.onGetCatalog,mdHeadingId:e.mdHeadingId,noMermaid:e.noMermaid,sanitize:e.sanitize,noKatex:e.noKatex,formatCopiedText:e.formatCopiedText,noHighlight:e.noHighlight,noImgZoomIn:e.noImgZoomIn},null),e.catalogVisible&&t.createVNode(bt,{theme:e.theme,class:`${r.prefix}-catalog-editor`,editorId:l,mdHeadingId:e.mdHeadingId,key:"internal-catalog"},null)])}}),No=t.defineComponent({props:{modelValue:{type:String,default:""}},setup(e){const l=t.inject("usedLanguageText");return()=>{var o,a;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`},[`${(o=l.value.footer)==null?void 0:o.markdownTotal}:`]),t.createVNode("span",null,[((a=e.modelValue)==null?void 0:a.length)||0])])}}}),Vo={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},$o=t.defineComponent({props:Vo,setup(e){return()=>t.createVNode("div",{class:[`${r.prefix}-checkbox`,e.checked&&`${r.prefix}-checkbox-checked`],onClick:()=>{e.onChange(!e.checked)}},null)}}),To={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},yo=t.defineComponent({props:To,setup(e){const l=t.inject("usedLanguageText");return()=>{var o;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`,onClick:()=>{e.onScrollAutoChange(!e.scrollAuto)}},[(o=l.value.footer)==null?void 0:o.scrollAuto]),t.createVNode($o,{checked:e.scrollAuto,onChange:e.onScrollAutoChange},null)])}}}),wo={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},Eo=t.defineComponent({name:"MDEditorFooter",props:wo,setup(e){const l=t.computed(()=>{const a=e.footers.indexOf("="),i=a===-1?e.footers:e.footers.slice(0,a),n=a===-1?[]:e.footers.slice(a,Number.MAX_SAFE_INTEGER);return[i,n]}),o=a=>{if(r.allFooter.includes(a))switch(a){case"markdownTotal":return t.createVNode(No,{modelValue:e.modelValue},null);case"scrollSwitch":return t.createVNode(yo,{scrollAuto:e.scrollAuto,onScrollAutoChange:e.onScrollAutoChange},null)}else return e.defFooters instanceof Array?e.defFooters[a]||"":e.defFooters&&e.defFooters.children instanceof Array&&e.defFooters.children[a]||""};return()=>{const a=l.value[0].map(n=>o(n)),i=l.value[1].map(n=>o(n));return t.createVNode("div",{class:`${r.prefix}-footer`},[t.createVNode("div",{class:`${r.prefix}-footer-left`},[a]),t.createVNode("div",{class:`${r.prefix}-footer-right`},[i])])}}}),So=t.defineComponent({name:"MdEditorV3",props:P.editorProps,emits:P.editorEmits,setup(e,l){const{editorId:o,noKatex:a,noMermaid:i,noPrettier:n,noUploadImg:f,noHighlight:g}=e,u=t.reactive({scrollAuto:e.scrollAuto});P.useOnSave(e,l),P.useProvide(e),P.useExpansion(e),P.useErrorCatcher(e,l);const[d,v]=P.useConfig(e,l),$=P.useCatalog(e);return t.onBeforeUnmount(()=>{s.bus.clear(o)}),P.useExpose(e,l,$,d,v),()=>{var p;const N=et.getSlot({props:e,ctx:l},"defToolbars"),m=et.getSlot({props:e,ctx:l},"defFooters");return t.createVNode("div",{id:o,class:[r.prefix,e.class,e.theme==="dark"&&`${r.prefix}-dark`,d.fullscreen||d.pageFullscreen?`${r.prefix}-fullscreen`:""],style:e.style},[t.createVNode(Ht,{noPrettier:n,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:d,updateSetting:v,tableShape:e.tableShape,defToolbars:N,noUploadImg:f,showToolbarName:e.showToolbarName},null),t.createVNode(xo,{modelValue:e.modelValue,setting:d,mdHeadingId:e.mdHeadingId,noMermaid:i,noPrettier:n,sanitize:e.sanitize,placeholder:e.placeholder,noKatex:a,scrollAuto:u.scrollAuto,formatCopiedText:e.formatCopiedText,autofocus:e.autoFocus,disabled:e.disabled,readonly:e.readOnly,maxlength:e.maxLength,autoDetectCode:e.autoDetectCode,noHighlight:g,onChange:h=>{e.onChange?e.onChange(h):(l.emit("update:modelValue",h),l.emit("onChange",h))},onHtmlChanged:h=>{e.onHtmlChanged?e.onHtmlChanged(h):l.emit("onHtmlChanged",h)},onGetCatalog:h=>{e.onGetCatalog?e.onGetCatalog(h):l.emit("onGetCatalog",h)},onBlur:h=>{e.onBlur?e.onBlur(h):l.emit("onBlur",h)},onFocus:h=>{e.onFocus?e.onFocus(h):l.emit("onFocus",h)},onInput:h=>{e.onInput?e.onInput(h):l.emit("onInput",h)},completions:e.completions,catalogVisible:$.value,theme:e.theme,noImgZoomIn:e.noImgZoomIn,onDrop:h=>{e.onDrop?e.onDrop(h):l.emit("onDrop",h)}},null),((p=e.footers)==null?void 0:p.length)>0&&t.createVNode(Eo,{modelValue:e.modelValue,footers:e.footers,defFooters:m,scrollAuto:u.scrollAuto,onScrollAutoChange:h=>u.scrollAuto=h},null)])}}}),de=So;de.install=e=>(e.component(de.name,de),e.use(Nt).use(z.DropdownToolbar).use(Vt).use(bt).use(P.MdPreview),e);module.exports=de;
@@ -1 +1 @@
1
- "use strict";const t=require("vue"),c=require("./chunks/config.cjs"),u=require("./chunks/vue-tsx.cjs"),a=require("./chunks/index.cjs");require("./chunks/dom.cjs");require("@vavt/util");function d(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const r={title:{type:String,default:""},modalTitle:{type:String,default:""},visible:{type:Boolean},width:{type:String,default:"auto"},height:{type:String,default:"auto"},trigger:{type:[String,Object]},onClick:{type:Function},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function},insert:{type:Function}},o=t.defineComponent({name:"ModalToolbar",props:r,emits:["onClick","onClose","onAdjust"],setup(e,n){return()=>{const s=u.getSlot({props:e,ctx:n},"trigger"),i=u.getSlot({props:e,ctx:n},"default");return t.createVNode(t.Fragment,null,[t.createVNode("div",{class:`${c.prefix}-toolbar-item`,title:e.title,onClick:()=>{e.onClick instanceof Function?e.onClick():n.emit("onClick")}},[s]),t.createVNode(a.MdModal,{width:e.width,height:e.height,title:e.modalTitle,visible:e.visible,onClose:()=>{e.onClose instanceof Function?e.onClose():n.emit("onClose")},showAdjust:e.showAdjust,isFullscreen:e.isFullscreen,onAdjust:l=>{e.onAdjust instanceof Function?e.onAdjust(l):n.emit("onAdjust",l)}},d(i)?i:{default:()=>[i]})])}}});o.install=e=>(e.component(o.name,o),e);module.exports=o;
1
+ "use strict";const t=require("vue"),a=require("./chunks/config.cjs"),u=require("./chunks/vue-tsx.cjs"),c=require("./chunks/index.cjs");require("./chunks/dom.cjs");require("@vavt/util");function r(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const d={title:{type:String,default:""},modalTitle:{type:String,default:""},visible:{type:Boolean},width:{type:String,default:"auto"},height:{type:String,default:"auto"},trigger:{type:[String,Object]},onClick:{type:Function},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function},insert:{type:Function},language:{type:String},theme:{type:String}},i=t.defineComponent({name:"ModalToolbar",props:d,emits:["onClick","onClose","onAdjust"],setup(e,n){return()=>{const s=u.getSlot({props:e,ctx:n},"trigger"),o=u.getSlot({props:e,ctx:n},"default");return t.createVNode(t.Fragment,null,[t.createVNode("div",{class:`${a.prefix}-toolbar-item`,title:e.title,onClick:()=>{e.onClick instanceof Function?e.onClick():n.emit("onClick")}},[s]),t.createVNode(c.MdModal,{width:e.width,height:e.height,title:e.modalTitle,visible:e.visible,onClose:()=>{e.onClose instanceof Function?e.onClose():n.emit("onClose")},showAdjust:e.showAdjust,isFullscreen:e.isFullscreen,onAdjust:l=>{e.onAdjust instanceof Function?e.onAdjust(l):n.emit("onAdjust",l)}},r(o)?o:{default:()=>[o]})])}}});i.install=e=>(e.component(i.name,i),e);module.exports=i;
@@ -1 +1 @@
1
- "use strict";const o=require("vue"),c=require("./chunks/config.cjs"),l=require("./chunks/vue-tsx.cjs"),s={title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function},insert:{type:Function}},t=o.defineComponent({name:"NormalToolbar",props:s,emits:["onClick"],setup(e,n){return()=>{const r=l.getSlot({props:e,ctx:n},"trigger");return o.createVNode("div",{class:`${c.prefix}-toolbar-item`,title:e.title,onClick:i=>{e.onClick instanceof Function?e.onClick(i):n.emit("onClick",i)}},[r])}}});t.install=e=>(e.component(t.name,t),e);module.exports=t;
1
+ "use strict";const o=require("vue"),c=require("./chunks/config.cjs"),l=require("./chunks/vue-tsx.cjs"),s={title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function},insert:{type:Function},language:{type:String},theme:{type:String}},t=o.defineComponent({name:"NormalToolbar",props:s,emits:["onClick"],setup(e,n){return()=>{const r=l.getSlot({props:e,ctx:n},"trigger");return o.createVNode("div",{class:`${c.prefix}-toolbar-item`,title:e.title,onClick:i=>{e.onClick instanceof Function?e.onClick(i):n.emit("onClick",i)}},[r])}}});t.install=e=>(e.component(t.name,t),e);module.exports=t;
@@ -1 +1 @@
1
- "use strict";const o=require("vue"),d=require("./config.cjs"),c=require("./vue-tsx.cjs"),L={overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}},C=o.defineComponent({props:L,setup(e,i){const s=`${d.prefix}-dropdown-hidden`,t=o.reactive({overlayClass:[s],overlayStyle:{},triggerHover:!1,overlayHover:!1}),n=o.ref(),l=o.ref(),v=()=>{var p;t.triggerHover=!0;const r=n.value,a=l.value;if(!r||!a)return;const u=r.getBoundingClientRect(),y=r.offsetTop,S=r.offsetLeft,b=u.height,w=u.width,H=((p=document.querySelector(e.relative))==null?void 0:p.scrollLeft)||0;t.overlayStyle={...t.overlayStyle,top:y+b+"px",left:S-a.offsetWidth/2+w/2-H+"px"},e.onChange(!0)},m=()=>{t.overlayHover=!0};o.watch(()=>e.visible,r=>{r?t.overlayClass=t.overlayClass.filter(a=>a!==s):t.overlayClass.push(s)});let h=-1;const g=r=>{n.value===r.target?t.triggerHover=!1:t.overlayHover=!1,clearTimeout(h),h=window.setTimeout(()=>{!t.overlayHover&&!t.triggerHover&&e.onChange(!1)},10)};return o.onMounted(()=>{n.value.addEventListener("mouseenter",v),n.value.addEventListener("mouseleave",g),l.value.addEventListener("mouseenter",m),l.value.addEventListener("mouseleave",g)}),o.onBeforeUnmount(()=>{n.value.removeEventListener("mouseenter",v),n.value.removeEventListener("mouseleave",g),l.value.removeEventListener("mouseenter",m),l.value.removeEventListener("mouseleave",g)}),()=>{const r=c.getSlot({ctx:i}),a=c.getSlot({props:e,ctx:i},"overlay"),u=o.cloneVNode(r instanceof Array?r[0]:r,{ref:n}),y=o.createVNode("div",{class:[`${d.prefix}-dropdown`,t.overlayClass],style:t.overlayStyle,ref:l},[o.createVNode("div",{class:`${d.prefix}-dropdown-overlay`},[a instanceof Array?a[0]:a])]);return[u,y]}}}),E={title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]},insert:{type:Function},default:{type:[String,Object]}},f=o.defineComponent({name:"DropdownToolbar",props:E,emits:["onChange"],setup(e,i){const s=o.inject("editorId");return()=>{const t=c.getSlot({props:e,ctx:i},"trigger"),n=c.getSlot({props:e,ctx:i},"overlay"),l=c.getSlot({props:e,ctx:i});return o.createVNode(C,{relative:`#${s}-toolbar-wrapper`,visible:e.visible,onChange:v=>{e.onChange instanceof Function?e.onChange(v):i.emit("onChange",v)},overlay:n},{default:()=>[o.createVNode("div",{class:`${d.prefix}-toolbar-item`,title:e.title||""},[t,l])]})}}});f.install=e=>(e.component(f.name,f),e);exports.Dropdown=C;exports.DropdownToolbar=f;
1
+ "use strict";const o=require("vue"),d=require("./config.cjs"),g=require("./vue-tsx.cjs"),L={overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}},S=o.defineComponent({props:L,setup(e,i){const s=`${d.prefix}-dropdown-hidden`,t=o.reactive({overlayClass:[s],overlayStyle:{},triggerHover:!1,overlayHover:!1}),n=o.ref(),l=o.ref(),v=()=>{var h;t.triggerHover=!0;const r=n.value,a=l.value;if(!r||!a)return;const u=r.getBoundingClientRect(),y=r.offsetTop,C=r.offsetLeft,b=u.height,w=u.width,H=((h=document.querySelector(e.relative))==null?void 0:h.scrollLeft)||0;t.overlayStyle={...t.overlayStyle,top:y+b+"px",left:C-a.offsetWidth/2+w/2-H+"px"},e.onChange(!0)},m=()=>{t.overlayHover=!0};o.watch(()=>e.visible,r=>{r?t.overlayClass=t.overlayClass.filter(a=>a!==s):t.overlayClass.push(s)});let p=-1;const c=r=>{n.value===r.target?t.triggerHover=!1:t.overlayHover=!1,clearTimeout(p),p=window.setTimeout(()=>{!t.overlayHover&&!t.triggerHover&&e.onChange(!1)},10)};return o.onMounted(()=>{n.value.addEventListener("mouseenter",v),n.value.addEventListener("mouseleave",c),l.value.addEventListener("mouseenter",m),l.value.addEventListener("mouseleave",c)}),o.onBeforeUnmount(()=>{n.value.removeEventListener("mouseenter",v),n.value.removeEventListener("mouseleave",c),l.value.removeEventListener("mouseenter",m),l.value.removeEventListener("mouseleave",c)}),()=>{const r=g.getSlot({ctx:i}),a=g.getSlot({props:e,ctx:i},"overlay"),u=o.cloneVNode(r instanceof Array?r[0]:r,{ref:n}),y=o.createVNode("div",{class:[`${d.prefix}-dropdown`,t.overlayClass],style:t.overlayStyle,ref:l},[o.createVNode("div",{class:`${d.prefix}-dropdown-overlay`},[a instanceof Array?a[0]:a])]);return[u,y]}}}),E={title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]},insert:{type:Function},language:{type:String},theme:{type:String},default:{type:[String,Object]}},f=o.defineComponent({name:"DropdownToolbar",props:E,emits:["onChange"],setup(e,i){const s=o.inject("editorId");return()=>{const t=g.getSlot({props:e,ctx:i},"trigger"),n=g.getSlot({props:e,ctx:i},"overlay"),l=g.getSlot({props:e,ctx:i});return o.createVNode(S,{relative:`#${s}-toolbar-wrapper`,visible:e.visible,onChange:v=>{e.onChange instanceof Function?e.onChange(v):i.emit("onChange",v)},overlay:n},{default:()=>[o.createVNode("div",{class:`${d.prefix}-toolbar-item`,title:e.title||""},[t,l])]})}}});f.install=e=>(e.component(f.name,f),e);exports.Dropdown=S;exports.DropdownToolbar=f;
@@ -5,4 +5,4 @@
5
5
  `+l(u,x,f,w,b);return`<div class="code-tabs">
6
6
  <ul>
7
7
  `+$+`</ul>
8
- `+I+"</div>"};e.renderer.rules.fence=m},pe=de,me=e=>{["paragraph_open","table_open","ordered_list_open","bullet_list_open","blockquote_open","hr","html_block","fence"].forEach(i=>{const l=e.renderer.rules[i];l?e.renderer.rules[i]=(t,n,r,a,s)=>{let m;const u=l(t,n,r,a,s);return t[n].map&&t[n].level===0?(m=t[n].map[0],u.replace(/^(<[^>]*)/,`$1 data-line="${m}"`)):u}:e.renderer.rules[i]=(t,n,r,a,s)=>{let m;return t[n].map&&t[n].level===0&&(m=t[n].map[0],t[n].attrSet("data-line",String(m))),s.renderToken(t,n,r)}})},fe=(e,i)=>{const{editorConfig:l,markdownItConfig:t,markdownItPlugins:n}=d.configOption,r=c.inject("editorId"),a=c.inject("showCodeRowNumber"),s=c.inject("theme"),m=c.ref([]),u=J(e),o=ee(e),{reRenderRef:f,replaceMermaid:w}=Q(e),b=G({html:!0,breaks:!0});t(b);const h=[{type:"katex",plugin:le,options:{katexRef:o}},{type:"image",plugin:j,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:ce,options:{}},{type:"taskList",plugin:D,options:{}},{type:"heading",plugin:ue,options:{mdHeadingId:e.mdHeadingId,headsRef:m}},{type:"codeTabs",plugin:pe,options:{editorId:r}}];e.noMermaid||h.push({type:"mermaid",plugin:ne,options:{themeRef:s}}),n(h).forEach(k=>{b.use(k.plugin,k.options)}),b.set({highlight:(k,$)=>{let I;!e.noHighlight&&u.value?u.value.getLanguage($)?I=u.value.highlight(k,{language:$,ignoreIllegals:!0}).value:I=u.value.highlightAuto(k).value:I=b.utils.escapeHtml(k);const x=a?p.generateCodeRowNumber(I.trim()):`<span class="code-block">${I.trim()}</span>`;return`<pre><code class="language-${$}" language=${$}>${x}</code></pre>`}}),me(b);const v=c.ref(e.sanitize(b.render(e.modelValue))),g=()=>{p.bus.emit(r,p.BUILD_FINISHED,v.value),e.onHtmlChanged(v.value),e.onGetCatalog(m.value),p.bus.emit(r,p.CATALOG_CHANGED,m.value),w()};c.onMounted(g);const C=P.debounce(async()=>{m.value=[],v.value=e.sanitize(b.render(e.modelValue)),g()},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:i?0:500),y=c.computed(()=>(e.noKatex||o.value)&&(e.noHighlight||u.value));return c.watch([c.toRef(e,"modelValue"),y,f],C),c.onMounted(()=>{p.bus.on(r,{name:p.PUSH_CATALOG,callback(){p.bus.emit(r,p.CATALOG_CHANGED,m.value)}})}),{html:v}},he=fe,T={modelValue:{type:String,default:""},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:e=>e},noKatex:{type:Boolean,default:!1},formatCopiedText:{type:Function,default:e=>e},noHighlight:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean}},ge={...T,onChange:{type:Function,default:()=>{}},placeholder:{type:String,default:""},scrollAuto:{type:Boolean},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},completions:{type:Array},catalogVisible:{type:Boolean},theme:{type:String,default:"light"},onInput:{type:Function},onDrop:{type:Function,default:()=>{}}},A=c.defineComponent({name:"ContentPreview",props:T,setup(e){const i=c.inject("editorId"),l=c.inject("previewTheme"),t=c.inject("showCodeRowNumber"),{html:n}=he(e,e.previewOnly);return W(e,n),q(e,n),()=>c.createVNode(c.Fragment,null,[c.createVNode("div",{id:`${i}-preview-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.preview,key:"content-preview-wrapper"},[c.createVNode("article",{id:`${i}-preview`,class:[`${d.prefix}-preview`,`${l==null?void 0:l.value}-theme`,t&&`${d.prefix}-scrn`],innerHTML:n.value},null)]),!e.previewOnly&&c.createVNode("div",{id:`${i}-html-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.htmlPreview,key:"html-preview-wrapper"},[c.createVNode("div",{class:`${d.prefix}-html`},[n.value])])])}}),ve=(e,i)=>{const{editorId:l}=e,t=c.reactive({buildFinished:!1,html:""});c.watch(()=>e.modelValue,()=>{t.buildFinished=!1}),c.onMounted(()=>{p.bus.on(l,{name:p.BUILD_FINISHED,callback(n){t.buildFinished=!0,t.html=n}}),p.bus.on(l,{name:p.ON_SAVE,callback(){const n=new Promise(r=>{if(t.buildFinished)r(t.html);else{const a=s=>{r(s),p.bus.remove(l,p.BUILD_FINISHED,a)};p.bus.on(l,{name:p.BUILD_FINISHED,callback:a})}});e.onSave?e.onSave(e.modelValue,n):i.emit("onSave",e.modelValue,n)}})})},M=e=>{var n,r;const{editorId:i}=e,l=(r=(n=d.configOption)==null?void 0:n.editorExtensions)==null?void 0:r.highlight;c.provide("editorId",i),c.provide("theme",c.computed(()=>e.theme)),c.provide("highlight",c.computed(()=>{const a={...d.codeCss,...l==null?void 0:l.css},s=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(l==null?void 0:l.js)||d.highlightUrl,css:a[e.codeTheme]?a[e.codeTheme][s]:d.codeCss.atom[s]}})),c.provide("showCodeRowNumber",e.showCodeRowNumber);const t=c.computed(()=>{var s,m;const a={...d.staticTextDefault,...(m=(s=d.configOption)==null?void 0:s.editorConfig)==null?void 0:m.languageUserDefined};return a[e.language]?a[e.language]:d.staticTextDefault["zh-CN"]});c.provide("usedLanguageText",t),c.provide("previewTheme",c.computed(()=>e.previewTheme)),c.provide("customIcon",c.computed(()=>e.customIcon))},ye=e=>{M(e),c.provide("tabWidth",e.tabWidth)},F=e=>{c.onMounted(()=>{var i,l;if(!e.noIconfont)if(d.configOption.iconfontType==="svg"){const t=document.createElement("script");t.src=((i=d.configOption.editorExtensions)==null?void 0:i.iconfont)||d.iconfontSvgUrl,t.id=`${d.prefix}-icon`,E.appendHandler(t)}else{const t=document.createElement("link");t.rel="stylesheet",t.href=((l=d.configOption.editorExtensions)==null?void 0:l.iconfontClass)||d.iconfontClassUrl,t.id=`${d.prefix}-icon-class`,E.appendHandler(t)}})},be=e=>{var s,m,u,o,f,w;const{noPrettier:i,noUploadImg:l}=e,{editorExtensions:t}=d.configOption,n=i||!!((m=(s=d.configOption.editorExtensions)==null?void 0:s.prettier)!=null&&m.prettierInstance),r=i||!!((o=(u=d.configOption.editorExtensions)==null?void 0:u.prettier)!=null&&o.parserMarkdownInstance),a=l||!!((w=(f=d.configOption.editorExtensions)==null?void 0:f.cropper)!=null&&w.instance);c.onMounted(()=>{var C,y,k,$;const b=document.createElement("script"),h=document.createElement("script");b.src=((C=t==null?void 0:t.prettier)==null?void 0:C.standaloneJs)||d.prettierUrl.main,b.id=`${d.prefix}-prettier`,h.src=((y=t==null?void 0:t.prettier)==null?void 0:y.parserMarkdownJs)||d.prettierUrl.markdown,h.id=`${d.prefix}-prettierMD`;const v=document.createElement("link");v.rel="stylesheet",v.href=((k=t==null?void 0:t.cropper)==null?void 0:k.css)||d.cropperUrl.css,v.id=`${d.prefix}-cropperCss`;const g=document.createElement("script");g.src=(($=t==null?void 0:t.cropper)==null?void 0:$.js)||d.cropperUrl.js,g.id=`${d.prefix}-cropper`,a||(E.appendHandler(v),E.appendHandler(g)),n||E.appendHandler(b),r||E.appendHandler(h)}),F(e)},we=(e,i)=>{const{editorId:l}=e;c.onMounted(()=>{p.bus.on(l,{name:p.ERROR_CATCHER,callback:t=>{e.onError instanceof Function?e.onError(t):i.emit("onError",t)}})})},ke=(e,i)=>{const{editorId:l}=e,t=c.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),n=(s,m)=>{t[s]=m===void 0?!t[s]:m,s==="preview"&&t.preview?t.htmlPreview=!1:s==="htmlPreview"&&t.htmlPreview&&(t.preview=!1)};let r="";const a=()=>{t.pageFullscreen||t.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=r};return c.watch(()=>[t.pageFullscreen,t.fullscreen],a),c.onMounted(()=>{p.bus.on(l,{name:p.UPLOAD_IMAGE,callback(s,m){const u=o=>{p.bus.emit(l,p.REPLACE,"image",{desc:"",urls:o}),m&&m()};e.onUploadImg?e.onUploadImg(s,u):i.emit("onUploadImg",s,u)}}),r=document.body.style.overflow,a()}),[t,n]},Ce=e=>{const{editorId:i}=e,l=c.ref(!1);return c.onMounted(()=>{p.bus.on(i,{name:p.CHANGE_CATALOG_VISIBLE,callback:n=>{n===void 0?l.value=!l.value:l.value=n}})}),c.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog")&&l.value)},$e=(e,i,l,t,n)=>{const{editorId:r}=e;c.watch(()=>t.pageFullscreen,s=>{p.bus.emit(r,p.PAGE_FULL_SCREEN_CHANGED,s)}),c.watch(()=>t.fullscreen,s=>{p.bus.emit(r,p.FULL_SCREEN_CHANGED,s)}),c.watch(()=>t.preview,s=>{p.bus.emit(r,p.PREVIEW_CHANGED,s)}),c.watch(()=>t.htmlPreview,s=>{p.bus.emit(r,p.HTML_PREVIEW_CHANGED,s)}),c.watch(l,s=>{p.bus.emit(r,p.CATALOG_VISIBLE_CHANGED,s)});const a={on(s,m){switch(s){case"pageFullscreen":{p.bus.on(r,{name:p.PAGE_FULL_SCREEN_CHANGED,callback(u){m(u)}});break}case"fullscreen":{p.bus.on(r,{name:p.FULL_SCREEN_CHANGED,callback(u){m(u)}});break}case"preview":{p.bus.on(r,{name:p.PREVIEW_CHANGED,callback(u){m(u)}});break}case"htmlPreview":{p.bus.on(r,{name:p.HTML_PREVIEW_CHANGED,callback(u){m(u)}});break}case"catalog":{p.bus.on(r,{name:p.CATALOG_VISIBLE_CHANGED,callback(u){m(u)}});break}}},togglePageFullscreen(s){n("pageFullscreen",s)},toggleFullscreen(s){p.bus.emit(r,p.CHANGE_FULL_SCREEN,s)},togglePreview(s){n("preview",s)},toggleHtmlPreview(s){n("htmlPreview",s)},toggleCatalog(s){p.bus.emit(r,p.CHANGE_CATALOG_VISIBLE,s)},triggerSave(){p.bus.emit(r,p.ON_SAVE)},insert(s){p.bus.emit(r,p.REPLACE,"universal",{generate:s})},focus(s){p.bus.emit(r,p.TEXTAREA_FOCUS,s)}};i.expose(a)},Ie=e=>e,R={modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},language:{type:String,default:"zh-CN"},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:d.defaultEditorId},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:Ie},sanitize:{type:Function,default:e=>e},noMermaid:{type:Boolean,default:!1},noKatex:{type:Boolean,default:!1},codeTheme:{type:String,default:"atom"},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:e=>e},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},noHighlight:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean,default:!1},customIcon:{type:Object,default:{}}},Ee={...R,onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},toolbars:{type:Array,default:d.allToolbar},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},tabWidth:{type:Number,default:2},tableShape:{type:Array,default:()=>[6,4]},placeholder:{type:String,default:""},defToolbars:{type:[String,Object]},onError:{type:Function},footers:{type:Array,default:d.allFooter},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noUploadImg:{type:Boolean},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function},onFocus:{type:Function},completions:{type:Array},showToolbarName:{type:Boolean,default:!1},onInput:{type:Function},onDrop:{type:Function}},L=["onHtmlChanged","onGetCatalog"],xe=[...L,"onChange","onSave","onUploadImg","onError","update:modelValue","onBlur","onFocus","onInput","onDrop"],Se=c.defineComponent({name:"MdPreview",props:R,emits:L,setup(e,i){const{editorId:l,noKatex:t,noMermaid:n,noHighlight:r}=e;return M(e),F(e),c.onBeforeUnmount(()=>{p.bus.clear(l)}),()=>c.createVNode("div",{id:l,class:[d.prefix,e.class,e.theme==="dark"&&`${d.prefix}-dark`,`${d.prefix}-previewOnly`],style:e.style},[c.createVNode(A,{modelValue:e.modelValue,onHtmlChanged:a=>{e.onHtmlChanged?e.onHtmlChanged(a):i.emit("onHtmlChanged",a)},onGetCatalog:a=>{e.onGetCatalog?e.onGetCatalog(a):i.emit("onGetCatalog",a)},mdHeadingId:e.mdHeadingId,noMermaid:n,sanitize:e.sanitize,noKatex:t,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0},null)])}}),S=Se;S.install=e=>(e.component(S.name,S),e);exports.ContentPreview=A;exports.MdPreview=S;exports.contentProps=ge;exports.editorEmits=xe;exports.editorProps=Ee;exports.useCatalog=Ce;exports.useConfig=ke;exports.useErrorCatcher=we;exports.useExpansion=be;exports.useExpose=$e;exports.useOnSave=ve;exports.useProvide=ye;
8
+ `+I+"</div>"};e.renderer.rules.fence=m},pe=de,me=e=>{["paragraph_open","table_open","ordered_list_open","bullet_list_open","blockquote_open","hr","html_block","fence"].forEach(i=>{const l=e.renderer.rules[i];l?e.renderer.rules[i]=(t,n,r,a,s)=>{let m;const u=l(t,n,r,a,s);return t[n].map&&t[n].level===0?(m=t[n].map[0],u.replace(/^(<[^>]*)/,`$1 data-line="${m}"`)):u}:e.renderer.rules[i]=(t,n,r,a,s)=>{let m;return t[n].map&&t[n].level===0&&(m=t[n].map[0],t[n].attrSet("data-line",String(m))),s.renderToken(t,n,r)}})},fe=(e,i)=>{const{editorConfig:l,markdownItConfig:t,markdownItPlugins:n}=d.configOption,r=c.inject("editorId"),a=c.inject("showCodeRowNumber"),s=c.inject("theme"),m=c.ref([]),u=J(e),o=ee(e),{reRenderRef:f,replaceMermaid:w}=Q(e),b=G({html:!0,breaks:!0});t(b);const h=[{type:"katex",plugin:le,options:{katexRef:o}},{type:"image",plugin:j,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:ce,options:{}},{type:"taskList",plugin:D,options:{}},{type:"heading",plugin:ue,options:{mdHeadingId:e.mdHeadingId,headsRef:m}},{type:"codeTabs",plugin:pe,options:{editorId:r}}];e.noMermaid||h.push({type:"mermaid",plugin:ne,options:{themeRef:s}}),n(h).forEach(k=>{b.use(k.plugin,k.options)}),b.set({highlight:(k,$)=>{let I;!e.noHighlight&&u.value?u.value.getLanguage($)?I=u.value.highlight(k,{language:$,ignoreIllegals:!0}).value:I=u.value.highlightAuto(k).value:I=b.utils.escapeHtml(k);const x=a?p.generateCodeRowNumber(I.trim()):`<span class="code-block">${I.trim()}</span>`;return`<pre><code class="language-${$}" language=${$}>${x}</code></pre>`}}),me(b);const v=c.ref(e.sanitize(b.render(e.modelValue))),g=()=>{p.bus.emit(r,p.BUILD_FINISHED,v.value),e.onHtmlChanged(v.value),e.onGetCatalog(m.value),p.bus.emit(r,p.CATALOG_CHANGED,m.value),w()};c.onMounted(g);const C=P.debounce(async()=>{m.value=[],v.value=e.sanitize(b.render(e.modelValue)),g()},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:i?0:500),y=c.computed(()=>(e.noKatex||o.value)&&(e.noHighlight||u.value));return c.watch([c.toRef(e,"modelValue"),y,f],C),c.onMounted(()=>{p.bus.on(r,{name:p.PUSH_CATALOG,callback(){p.bus.emit(r,p.CATALOG_CHANGED,m.value)}})}),{html:v}},he=fe,T={modelValue:{type:String,default:""},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:e=>e},noKatex:{type:Boolean,default:!1},formatCopiedText:{type:Function,default:e=>e},noHighlight:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean}},ge={...T,onChange:{type:Function,default:()=>{}},placeholder:{type:String,default:""},scrollAuto:{type:Boolean},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},completions:{type:Array},catalogVisible:{type:Boolean},theme:{type:String,default:"light"},onInput:{type:Function},onDrop:{type:Function,default:()=>{}}},A=c.defineComponent({name:"ContentPreview",props:T,setup(e){const i=c.inject("editorId"),l=c.inject("previewTheme"),t=c.inject("showCodeRowNumber"),{html:n}=he(e,e.previewOnly);return W(e,n),q(e,n),()=>c.createVNode(c.Fragment,null,[c.createVNode("div",{id:`${i}-preview-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.preview,key:"content-preview-wrapper"},[c.createVNode("article",{id:`${i}-preview`,class:[`${d.prefix}-preview`,`${l==null?void 0:l.value}-theme`,t&&`${d.prefix}-scrn`],innerHTML:n.value},null)]),!e.previewOnly&&c.createVNode("div",{id:`${i}-html-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.htmlPreview,key:"html-preview-wrapper"},[c.createVNode("div",{class:`${d.prefix}-html`},[n.value])])])}}),ve=(e,i)=>{const{editorId:l}=e,t=c.reactive({buildFinished:!1,html:""});c.watch(()=>e.modelValue,()=>{t.buildFinished=!1}),c.onMounted(()=>{p.bus.on(l,{name:p.BUILD_FINISHED,callback(n){t.buildFinished=!0,t.html=n}}),p.bus.on(l,{name:p.ON_SAVE,callback(){const n=new Promise(r=>{if(t.buildFinished)r(t.html);else{const a=s=>{r(s),p.bus.remove(l,p.BUILD_FINISHED,a)};p.bus.on(l,{name:p.BUILD_FINISHED,callback:a})}});e.onSave?e.onSave(e.modelValue,n):i.emit("onSave",e.modelValue,n)}})})},M=e=>{var n,r;const{editorId:i}=e,l=(r=(n=d.configOption)==null?void 0:n.editorExtensions)==null?void 0:r.highlight;c.provide("editorId",i),c.provide("theme",c.computed(()=>e.theme)),c.provide("language",c.computed(()=>e.language)),c.provide("highlight",c.computed(()=>{const a={...d.codeCss,...l==null?void 0:l.css},s=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(l==null?void 0:l.js)||d.highlightUrl,css:a[e.codeTheme]?a[e.codeTheme][s]:d.codeCss.atom[s]}})),c.provide("showCodeRowNumber",e.showCodeRowNumber);const t=c.computed(()=>{var s,m;const a={...d.staticTextDefault,...(m=(s=d.configOption)==null?void 0:s.editorConfig)==null?void 0:m.languageUserDefined};return a[e.language]?a[e.language]:d.staticTextDefault["zh-CN"]});c.provide("usedLanguageText",t),c.provide("previewTheme",c.computed(()=>e.previewTheme)),c.provide("customIcon",c.computed(()=>e.customIcon))},ye=e=>{M(e),c.provide("tabWidth",e.tabWidth)},F=e=>{c.onMounted(()=>{var i,l;if(!e.noIconfont)if(d.configOption.iconfontType==="svg"){const t=document.createElement("script");t.src=((i=d.configOption.editorExtensions)==null?void 0:i.iconfont)||d.iconfontSvgUrl,t.id=`${d.prefix}-icon`,E.appendHandler(t)}else{const t=document.createElement("link");t.rel="stylesheet",t.href=((l=d.configOption.editorExtensions)==null?void 0:l.iconfontClass)||d.iconfontClassUrl,t.id=`${d.prefix}-icon-class`,E.appendHandler(t)}})},be=e=>{var s,m,u,o,f,w;const{noPrettier:i,noUploadImg:l}=e,{editorExtensions:t}=d.configOption,n=i||!!((m=(s=d.configOption.editorExtensions)==null?void 0:s.prettier)!=null&&m.prettierInstance),r=i||!!((o=(u=d.configOption.editorExtensions)==null?void 0:u.prettier)!=null&&o.parserMarkdownInstance),a=l||!!((w=(f=d.configOption.editorExtensions)==null?void 0:f.cropper)!=null&&w.instance);c.onMounted(()=>{var C,y,k,$;const b=document.createElement("script"),h=document.createElement("script");b.src=((C=t==null?void 0:t.prettier)==null?void 0:C.standaloneJs)||d.prettierUrl.main,b.id=`${d.prefix}-prettier`,h.src=((y=t==null?void 0:t.prettier)==null?void 0:y.parserMarkdownJs)||d.prettierUrl.markdown,h.id=`${d.prefix}-prettierMD`;const v=document.createElement("link");v.rel="stylesheet",v.href=((k=t==null?void 0:t.cropper)==null?void 0:k.css)||d.cropperUrl.css,v.id=`${d.prefix}-cropperCss`;const g=document.createElement("script");g.src=(($=t==null?void 0:t.cropper)==null?void 0:$.js)||d.cropperUrl.js,g.id=`${d.prefix}-cropper`,a||(E.appendHandler(v),E.appendHandler(g)),n||E.appendHandler(b),r||E.appendHandler(h)}),F(e)},we=(e,i)=>{const{editorId:l}=e;c.onMounted(()=>{p.bus.on(l,{name:p.ERROR_CATCHER,callback:t=>{e.onError instanceof Function?e.onError(t):i.emit("onError",t)}})})},ke=(e,i)=>{const{editorId:l}=e,t=c.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),n=(s,m)=>{t[s]=m===void 0?!t[s]:m,s==="preview"&&t.preview?t.htmlPreview=!1:s==="htmlPreview"&&t.htmlPreview&&(t.preview=!1)};let r="";const a=()=>{t.pageFullscreen||t.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=r};return c.watch(()=>[t.pageFullscreen,t.fullscreen],a),c.onMounted(()=>{p.bus.on(l,{name:p.UPLOAD_IMAGE,callback(s,m){const u=o=>{p.bus.emit(l,p.REPLACE,"image",{desc:"",urls:o}),m&&m()};e.onUploadImg?e.onUploadImg(s,u):i.emit("onUploadImg",s,u)}}),r=document.body.style.overflow,a()}),[t,n]},Ce=e=>{const{editorId:i}=e,l=c.ref(!1);return c.onMounted(()=>{p.bus.on(i,{name:p.CHANGE_CATALOG_VISIBLE,callback:n=>{n===void 0?l.value=!l.value:l.value=n}})}),c.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog")&&l.value)},$e=(e,i,l,t,n)=>{const{editorId:r}=e;c.watch(()=>t.pageFullscreen,s=>{p.bus.emit(r,p.PAGE_FULL_SCREEN_CHANGED,s)}),c.watch(()=>t.fullscreen,s=>{p.bus.emit(r,p.FULL_SCREEN_CHANGED,s)}),c.watch(()=>t.preview,s=>{p.bus.emit(r,p.PREVIEW_CHANGED,s)}),c.watch(()=>t.htmlPreview,s=>{p.bus.emit(r,p.HTML_PREVIEW_CHANGED,s)}),c.watch(l,s=>{p.bus.emit(r,p.CATALOG_VISIBLE_CHANGED,s)});const a={on(s,m){switch(s){case"pageFullscreen":{p.bus.on(r,{name:p.PAGE_FULL_SCREEN_CHANGED,callback(u){m(u)}});break}case"fullscreen":{p.bus.on(r,{name:p.FULL_SCREEN_CHANGED,callback(u){m(u)}});break}case"preview":{p.bus.on(r,{name:p.PREVIEW_CHANGED,callback(u){m(u)}});break}case"htmlPreview":{p.bus.on(r,{name:p.HTML_PREVIEW_CHANGED,callback(u){m(u)}});break}case"catalog":{p.bus.on(r,{name:p.CATALOG_VISIBLE_CHANGED,callback(u){m(u)}});break}}},togglePageFullscreen(s){n("pageFullscreen",s)},toggleFullscreen(s){p.bus.emit(r,p.CHANGE_FULL_SCREEN,s)},togglePreview(s){n("preview",s)},toggleHtmlPreview(s){n("htmlPreview",s)},toggleCatalog(s){p.bus.emit(r,p.CHANGE_CATALOG_VISIBLE,s)},triggerSave(){p.bus.emit(r,p.ON_SAVE)},insert(s){p.bus.emit(r,p.REPLACE,"universal",{generate:s})},focus(s){p.bus.emit(r,p.TEXTAREA_FOCUS,s)}};i.expose(a)},Ie=e=>e,R={modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},language:{type:String,default:"zh-CN"},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:d.defaultEditorId},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:Ie},sanitize:{type:Function,default:e=>e},noMermaid:{type:Boolean,default:!1},noKatex:{type:Boolean,default:!1},codeTheme:{type:String,default:"atom"},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:e=>e},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},noHighlight:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean,default:!1},customIcon:{type:Object,default:{}}},Ee={...R,onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},toolbars:{type:Array,default:d.allToolbar},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},tabWidth:{type:Number,default:2},tableShape:{type:Array,default:()=>[6,4]},placeholder:{type:String,default:""},defToolbars:{type:[String,Object]},onError:{type:Function},footers:{type:Array,default:d.allFooter},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noUploadImg:{type:Boolean},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function},onFocus:{type:Function},completions:{type:Array},showToolbarName:{type:Boolean,default:!1},onInput:{type:Function},onDrop:{type:Function}},L=["onHtmlChanged","onGetCatalog"],xe=[...L,"onChange","onSave","onUploadImg","onError","update:modelValue","onBlur","onFocus","onInput","onDrop"],Se=c.defineComponent({name:"MdPreview",props:R,emits:L,setup(e,i){const{editorId:l,noKatex:t,noMermaid:n,noHighlight:r}=e;return M(e),F(e),c.onBeforeUnmount(()=>{p.bus.clear(l)}),()=>c.createVNode("div",{id:l,class:[d.prefix,e.class,e.theme==="dark"&&`${d.prefix}-dark`,`${d.prefix}-previewOnly`],style:e.style},[c.createVNode(A,{modelValue:e.modelValue,onHtmlChanged:a=>{e.onHtmlChanged?e.onHtmlChanged(a):i.emit("onHtmlChanged",a)},onGetCatalog:a=>{e.onGetCatalog?e.onGetCatalog(a):i.emit("onGetCatalog",a)},mdHeadingId:e.mdHeadingId,noMermaid:n,sanitize:e.sanitize,noKatex:t,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0},null)])}}),S=Se;S.install=e=>(e.component(S.name,S),e);exports.ContentPreview=A;exports.MdPreview=S;exports.contentProps=ge;exports.editorEmits=xe;exports.editorProps=Ee;exports.useCatalog=Ce;exports.useConfig=ke;exports.useErrorCatcher=we;exports.useExpansion=be;exports.useExpose=$e;exports.useOnSave=ve;exports.useProvide=ye;