md-editor-v3 4.6.0 → 4.6.2-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,4 +1,4 @@
1
- "use strict";var ut=Object.defineProperty;var mt=(e,l,o)=>l in e?ut(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o;var q=(e,l,o)=>(mt(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/index4.cjs"),ft=require("./chunks/dom.cjs"),k=require("./chunks/index3.cjs"),ee=require("codemirror"),ae=require("@codemirror/view"),gt=require("@codemirror/language-data"),bt=require("@codemirror/lang-markdown"),se=require("@codemirror/commands"),re=require("@codemirror/language"),c=require("@lezer/highlight"),R=require("@codemirror/state"),ht=require("@codemirror/autocomplete"),P=require("./chunks/index.cjs"),dt=require("./MdCatalog.cjs"),Je=require("./chunks/vue-tsx.cjs"),vt=require("./NormalToolbar.cjs"),pt=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 kt=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${r.prefix}-divider`},null)}}),Ct={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}},xt=e=>{var u,f,m,v;const l=t.inject("editorId");let o=(f=(u=r.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:f.instance;const a=(v=(m=r.configOption.editorExtensions)==null?void 0:m.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`,ft.appendHandler(x,"screenfull")}}),t.onMounted(()=>{s.bus.on(l,{name:s.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},Nt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},Vt=t.defineComponent({name:"TableShape",props:Nt,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)]))]))])}}),$t=Vt,Tt={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},yt=t.defineComponent({props:Tt,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(k.MdModal,{title:a.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var i,g,d,u,f;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:m=>{n.desc=m.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:m=>{n.url=m.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=""}},[(f=l.value.linkModalTips)==null?void 0:f.buttonOK])])]}})}}),wt={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Et=t.defineComponent({props:wt,setup(e){var m,v,x;const l=t.inject("usedLanguageText"),o=t.inject("editorId");let a=(x=(v=(m=r.configOption)==null?void 0:m.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 V=n.value.files||[];if(d.imgSelected=!0,(V==null?void 0:V.length)>0){const p=new FileReader;p.onload=b=>{d.imgSrc=b.target.result,t.nextTick(()=>{u=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`})})},p.readAsDataURL(V[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 f=()=>{u.clear(),u.destroy(),u=null,n.value.value="",d.imgSelected=!1};return()=>{var V;return t.createVNode(k.MdModal,{class:`${r.prefix}-modal-clip`,title:(V=l.value.clipModalTips)==null?void 0:V.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:d.isFullscreen,onAdjust:p=>{d.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,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:f},[t.createVNode(k.Icon,{name:"delete"},null)])]):t.createVNode("div",{class:`${r.prefix}-clip-upload`,onClick:()=>{n.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:g},null)])]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:`${r.prefix}-btn`,type:"button",onClick:()=>{if(u){const h=u.getCroppedCanvas();s.bus.emit(o,s.UPLOAD_IMAGE,[s.base642File(h.toDataURL("image/png"))],e.onOk),f()}}},[((p=l.value.clipModalTips)==null?void 0:p.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)]}})}}}),St={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},At=t.defineComponent({props:St,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(yt,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(Et,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),It=t.defineComponent({name:"MDEditorToolbar",props:Ct,setup(e){const l=t.inject("editorId"),o=t.inject("usedLanguageText"),{fullscreenHandler:a}=xt(e),n=`${l}-toolbar-wrapper`,i=t.ref(),g=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),d=(p,b)=>{s.bus.emit(l,s.REPLACE,p,b)},u=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),f=t.ref();t.onMounted(()=>{s.bus.on(l,{name:s.OPEN_MODALS,callback(p){u.type=p,u.linkVisible=!0}})});const m=t.computed(()=>{const p=e.toolbars.filter($=>!e.toolbarsExclude.includes($)),b=p.indexOf("="),h=b===-1?p:p.slice(0,b+1),N=b===-1?[]:p.slice(b,Number.MAX_SAFE_INTEGER);return[h,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 V=p=>{var b,h,N,$,T,L,E,Z,X,y,w,B,F,M,A,I,D,_,j,ne,Y,K,G,J,U,H,O,Q,ie,ge,be,he,ve,pe,ke,Ce,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(p))switch(p){case"-":return t.createVNode(kt,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(k.Icon,{name:"bold"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(h=o.value.toolbarTips)==null?void 0:h.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(k.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(k.Icon,{name:"italic"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(L=o.value.toolbarTips)==null?void 0:L.italic])]);case"strikeThrough":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(E=o.value.toolbarTips)==null?void 0:E.strikeThrough,onClick:()=>{d("strikeThrough")}},[t.createVNode(k.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")}},[(M=o.value.titleItem)==null?void 0:M.h6])])},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.title},[t.createVNode(k.Icon,{name:"title"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.title])])]}});case"sub":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(A=o.value.toolbarTips)==null?void 0:A.sub,onClick:()=>{d("sub")}},[t.createVNode(k.Icon,{name:"sub"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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}},[(ke=o.value.imgTitleItem)==null?void 0:ke.link]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{v.value.click()}},[(Ce=o.value.imgTitleItem)==null?void 0:Ce.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,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.image},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.image])])]}});case"table":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.table,onChange:C=>{g.table=C},key:"bar-table",overlay:t.createVNode($t,{tableShape:e.tableShape,onSelected:C=>{d("table",{selectedShape:C})}},null)},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.table},[t.createVNode(k.Icon,{name:"table"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.mermaid},[t.createVNode(k.Icon,{name:"mermaid"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.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,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.katex},[t.createVNode(k.Icon,{name:"formula"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.katex])])]}})}else if(e.defToolbars instanceof Array){const C=e.defToolbars[p];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[p];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 p=m.value[0].map(h=>V(h)),b=m.value[1].map(h=>V(h));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:f},[p]),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(At,{linkVisible:u.linkVisible,clipVisible:u.clipVisible,type:u.type,onCancel:()=>{u.linkVisible=!1,u.clipVisible=!1},onOk:h=>{h&&d(u.type,{desc:h.desc,url:h.url}),u.linkVisible=!1,u.clipVisible=!1}},null)])}}}),Lt=(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,f=(d-i)/(u-g);n.target===e?(l.removeEventListener("scroll",a),l.scrollTo({top:e.scrollTop/f}),o()):(e.removeEventListener("scroll",a),e.scrollTo({top:l.scrollTop*f}),o())};return[()=>{o().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",a),l.removeEventListener("scroll",a)}]},Mt=(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(h=>Number(h.dataset.line)+1),{lines:V}=a.state.doc;let p=1,b=x.shift()??V;for(let h=1;h<=V;h++)h===b&&(p=h,b=x.shift()||V+1),d.push({start:p,end:b-1})};let f=0,m=0;const v=le.throttle(x=>{var N,$,T,L,E,Z,X;if(!((N=l.firstElementChild)!=null&&N.firstElementChild))return;const V=a.lineBlockAtHeight(a.scrollDOM.scrollTop),{number:p}=a.state.doc.lineAt(V.from);if(p>d.length||a.state.doc.lines<d[d.length-1].end)return;let b=+getComputedStyle(l).paddingTop.replace("px","");const h=+getComputedStyle(l).paddingBottom.replace("px","");if(x.target===e){if(m!==0)return;f++;const y=d[p-1];let w=i(y.end)+g(y.end),B=0;const F=i(y.start),M=l.querySelector(`[data-line="${y.start-1}"]`)||(($=l.firstElementChild)==null?void 0:$.firstElementChild),A=l.querySelector(`[data-line="${y.end}"]`)||((T=l.lastElementChild)==null?void 0:T.lastElementChild);let I=0,D=0;F===0?M===A?(b=0,w=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight,B=a.scrollDOM.scrollTop/w,I=A.offsetTop+A.offsetHeight-l.clientHeight):(B=a.scrollDOM.scrollTop/w,I=A.offsetTop):w>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(B=(a.scrollDOM.scrollTop-F)/(a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight-F),D=M.offsetTop,I=l.scrollHeight-l.clientHeight-D+10):(B=(a.scrollDOM.scrollTop-F)/(w-F),D=M.offsetTop,I=A.offsetTop-D);const _=D-b+I*B;n(l,_,()=>{f--})}else{if(f!==0)return;m++;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)),M=(L=l.firstElementChild)==null?void 0:L.firstElementChild;for(let H=F;H>=0;H--){const O=l.querySelector(`[data-line="${H}"]`);if(O&&O.offsetTop<=w){M=O,F=H;break}}let A=(E=l.firstElementChild)==null?void 0:E.firstElementChild,I=(Z=l.firstElementChild)==null?void 0:Z.lastElementChild;for(;y.length>0;){const H=y.indexOf(M);if(H+1>=y.length)break;const O=y[H+1];if(H===-1){I=O;break}const Q=M.offsetTop;if(Q>w){if(H===0){A=M,I=O;break}M=y[H-1];continue}const ie=O.offsetTop;if(Q<=w&&ie>w){A=M,I=O;break}M=O}const D=A.offsetTop;let _=I.offsetTop,j=0;const{start:ne,end:Y}=d[Number(A.dataset.line||0)],K=i(ne);let G=i(Y);const J=g(Y);let U=0;A===((X=l.firstElementChild)==null?void 0:X.firstElementChild)?(A===I?(_=I.offsetHeight-l.offsetHeight+b+h,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,()=>{m--})}},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)}]},Rt=(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"]`),f=document.querySelector(`[id="${a}-html-wrapper"][data-show="true"]`);(u||f)&&([i,n]=(u?Mt:Lt)(d,u||f,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)},Dt=Rt,Ht=(e,l,o)=>{var m,v,x,V,p,b;let a="",n=0,i=0,g=!0,d=!1;const u=l.getSelectedText(),f=(m=r.configOption.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const h=e.replace(/^h(\d)/,(N,$)=>new Array(Number($)).fill("#",0,$).join(""));a=`${h} ${u}`,n=h.length+1}else if(e==="prettier"){const h=window.prettier||((x=(v=r.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:x.prettierInstance),N=[((V=window.prettierPlugins)==null?void 0:V.markdown)||((b=(p=r.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:b.parserMarkdownInstance)];!h||N[0]===void 0?(s.bus.emit(o.editorId,s.ERROR_CATCHER,{name:"prettier",message:"prettier is undefined"}),a=l.getValue()):a=h.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 h=o.text||u||"",N=o.mode||"language";a=`\`\`\`${N}
1
+ "use strict";var mt=Object.defineProperty;var ft=(e,l,o)=>l in e?mt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o;var q=(e,l,o)=>(ft(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/index4.cjs"),gt=require("./chunks/dom.cjs"),k=require("./chunks/index3.cjs"),ee=require("codemirror"),ae=require("@codemirror/view"),bt=require("@codemirror/language-data"),ht=require("@codemirror/lang-markdown"),dt=require("@codemirror/lang-html"),se=require("@codemirror/commands"),re=require("@codemirror/language"),c=require("@lezer/highlight"),R=require("@codemirror/state"),vt=require("@codemirror/autocomplete"),P=require("./chunks/index.cjs"),ut=require("./MdCatalog.cjs"),Je=require("./chunks/vue-tsx.cjs"),pt=require("./NormalToolbar.cjs"),kt=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 Ct=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${r.prefix}-divider`},null)}}),xt={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}},Nt=e=>{var u,f,m,v;const l=t.inject("editorId");let o=(f=(u=r.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:f.instance;const a=(v=(m=r.configOption.editorExtensions)==null?void 0:m.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`,gt.appendHandler(x,"screenfull")}}),t.onMounted(()=>{s.bus.on(l,{name:s.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},Vt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},$t=t.defineComponent({name:"TableShape",props:Vt,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)]))]))])}}),Tt=$t,yt={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},wt=t.defineComponent({props:yt,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(k.MdModal,{title:a.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var i,g,d,u,f;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:m=>{n.desc=m.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:m=>{n.url=m.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=""}},[(f=l.value.linkModalTips)==null?void 0:f.buttonOK])])]}})}}),Et={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},St=t.defineComponent({props:Et,setup(e){var m,v,x;const l=t.inject("usedLanguageText"),o=t.inject("editorId");let a=(x=(v=(m=r.configOption)==null?void 0:m.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 V=n.value.files||[];if(d.imgSelected=!0,(V==null?void 0:V.length)>0){const p=new FileReader;p.onload=b=>{d.imgSrc=b.target.result,t.nextTick(()=>{u=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`})})},p.readAsDataURL(V[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 f=()=>{u.clear(),u.destroy(),u=null,n.value.value="",d.imgSelected=!1};return()=>{var V;return t.createVNode(k.MdModal,{class:`${r.prefix}-modal-clip`,title:(V=l.value.clipModalTips)==null?void 0:V.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:d.isFullscreen,onAdjust:p=>{d.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,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:f},[t.createVNode(k.Icon,{name:"delete"},null)])]):t.createVNode("div",{class:`${r.prefix}-clip-upload`,onClick:()=>{n.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:g},null)])]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:`${r.prefix}-btn`,type:"button",onClick:()=>{if(u){const h=u.getCroppedCanvas();s.bus.emit(o,s.UPLOAD_IMAGE,[s.base642File(h.toDataURL("image/png"))],e.onOk),f()}}},[((p=l.value.clipModalTips)==null?void 0:p.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)]}})}}}),At={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},It=t.defineComponent({props:At,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(wt,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(St,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),Lt=t.defineComponent({name:"MDEditorToolbar",props:xt,setup(e){const l=t.inject("editorId"),o=t.inject("usedLanguageText"),{fullscreenHandler:a}=Nt(e),n=`${l}-toolbar-wrapper`,i=t.ref(),g=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),d=(p,b)=>{s.bus.emit(l,s.REPLACE,p,b)},u=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),f=t.ref();t.onMounted(()=>{s.bus.on(l,{name:s.OPEN_MODALS,callback(p){u.type=p,u.linkVisible=!0}})});const m=t.computed(()=>{const p=e.toolbars.filter($=>!e.toolbarsExclude.includes($)),b=p.indexOf("="),h=b===-1?p:p.slice(0,b+1),N=b===-1?[]:p.slice(b,Number.MAX_SAFE_INTEGER);return[h,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 V=p=>{var b,h,N,$,T,L,E,Z,X,y,w,B,F,M,A,I,D,_,j,ne,Y,K,G,J,U,H,O,Q,ie,ge,be,he,ve,pe,ke,Ce,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(p))switch(p){case"-":return t.createVNode(Ct,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(k.Icon,{name:"bold"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(h=o.value.toolbarTips)==null?void 0:h.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(k.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(k.Icon,{name:"italic"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(L=o.value.toolbarTips)==null?void 0:L.italic])]);case"strikeThrough":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(E=o.value.toolbarTips)==null?void 0:E.strikeThrough,onClick:()=>{d("strikeThrough")}},[t.createVNode(k.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")}},[(M=o.value.titleItem)==null?void 0:M.h6])])},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.title},[t.createVNode(k.Icon,{name:"title"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.title])])]}});case"sub":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(A=o.value.toolbarTips)==null?void 0:A.sub,onClick:()=>{d("sub")}},[t.createVNode(k.Icon,{name:"sub"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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}},[(ke=o.value.imgTitleItem)==null?void 0:ke.link]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{v.value.click()}},[(Ce=o.value.imgTitleItem)==null?void 0:Ce.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,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.image},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.image])])]}});case"table":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.table,onChange:C=>{g.table=C},key:"bar-table",overlay:t.createVNode(Tt,{tableShape:e.tableShape,onSelected:C=>{d("table",{selectedShape:C})}},null)},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.table},[t.createVNode(k.Icon,{name:"table"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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(k.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,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.mermaid},[t.createVNode(k.Icon,{name:"mermaid"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.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,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.katex},[t.createVNode(k.Icon,{name:"formula"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.katex])])]}})}else if(e.defToolbars instanceof Array){const C=e.defToolbars[p];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[p];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 p=m.value[0].map(h=>V(h)),b=m.value[1].map(h=>V(h));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:f},[p]),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(It,{linkVisible:u.linkVisible,clipVisible:u.clipVisible,type:u.type,onCancel:()=>{u.linkVisible=!1,u.clipVisible=!1},onOk:h=>{h&&d(u.type,{desc:h.desc,url:h.url}),u.linkVisible=!1,u.clipVisible=!1}},null)])}}}),Mt=(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,f=(d-i)/(u-g);n.target===e?(l.removeEventListener("scroll",a),l.scrollTo({top:e.scrollTop/f}),o()):(e.removeEventListener("scroll",a),e.scrollTo({top:l.scrollTop*f}),o())};return[()=>{o().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",a),l.removeEventListener("scroll",a)}]},Rt=(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(h=>Number(h.dataset.line)+1),{lines:V}=a.state.doc;let p=1,b=x.shift()??V;for(let h=1;h<=V;h++)h===b&&(p=h,b=x.shift()||V+1),d.push({start:p,end:b-1})};let f=0,m=0;const v=le.throttle(x=>{var N,$,T,L,E,Z,X;if(!((N=l.firstElementChild)!=null&&N.firstElementChild))return;const V=a.lineBlockAtHeight(a.scrollDOM.scrollTop),{number:p}=a.state.doc.lineAt(V.from);if(p>d.length||a.state.doc.lines<d[d.length-1].end)return;let b=+getComputedStyle(l).paddingTop.replace("px","");const h=+getComputedStyle(l).paddingBottom.replace("px","");if(x.target===e){if(m!==0)return;f++;const y=d[p-1];let w=i(y.end)+g(y.end),B=0;const F=i(y.start),M=l.querySelector(`[data-line="${y.start-1}"]`)||(($=l.firstElementChild)==null?void 0:$.firstElementChild),A=l.querySelector(`[data-line="${y.end}"]`)||((T=l.lastElementChild)==null?void 0:T.lastElementChild);let I=0,D=0;F===0?M===A?(b=0,w=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight,B=a.scrollDOM.scrollTop/w,I=A.offsetTop+A.offsetHeight-l.clientHeight):(B=a.scrollDOM.scrollTop/w,I=A.offsetTop):w>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(B=(a.scrollDOM.scrollTop-F)/(a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight-F),D=M.offsetTop,I=l.scrollHeight-l.clientHeight-D+10):(B=(a.scrollDOM.scrollTop-F)/(w-F),D=M.offsetTop,I=A.offsetTop-D);const _=D-b+I*B;n(l,_,()=>{f--})}else{if(f!==0)return;m++;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)),M=(L=l.firstElementChild)==null?void 0:L.firstElementChild;for(let H=F;H>=0;H--){const O=l.querySelector(`[data-line="${H}"]`);if(O&&O.offsetTop<=w){M=O,F=H;break}}let A=(E=l.firstElementChild)==null?void 0:E.firstElementChild,I=(Z=l.firstElementChild)==null?void 0:Z.lastElementChild;for(;y.length>0;){const H=y.indexOf(M);if(H+1>=y.length)break;const O=y[H+1];if(H===-1){I=O;break}const Q=M.offsetTop;if(Q>w){if(H===0){A=M,I=O;break}M=y[H-1];continue}const ie=O.offsetTop;if(Q<=w&&ie>w){A=M,I=O;break}M=O}const D=A.offsetTop;let _=I.offsetTop,j=0;const{start:ne,end:Y}=d[Number(A.dataset.line||0)],K=i(ne);let G=i(Y);const J=g(Y);let U=0;A===((X=l.firstElementChild)==null?void 0:X.firstElementChild)?(A===I?(_=I.offsetHeight-l.offsetHeight+b+h,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,()=>{m--})}},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)}]},Dt=(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"]`),f=document.querySelector(`[id="${a}-html-wrapper"][data-show="true"]`);(u||f)&&([i,n]=(u?Rt:Mt)(d,u||f,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)},Ht=Dt,Ot=(e,l,o)=>{var m,v,x,V,p,b;let a="",n=0,i=0,g=!0,d=!1;const u=l.getSelectedText(),f=(m=r.configOption.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const h=e.replace(/^h(\d)/,(N,$)=>new Array(Number($)).fill("#",0,$).join(""));a=`${h} ${u}`,n=h.length+1}else if(e==="prettier"){const h=window.prettier||((x=(v=r.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:x.prettierInstance),N=[((V=window.prettierPlugins)==null?void 0:V.markdown)||((b=(p=r.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:b.parserMarkdownInstance)];!h||N[0]===void 0?(s.bus.emit(o.editorId,s.ERROR_CATCHER,{name:"prettier",message:"prettier is undefined"}),a=l.getValue()):a=h.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 h=o.text||u||"",N=o.mode||"language";a=`\`\`\`${N}
2
2
  ${h}
3
3
  \`\`\`
4
4
  `,n=3,i=3+N.length-a.length;break}case"table":{a="|";const{selectedShape:h={x:1,y:1}}=o,{x:N,y:$}=h;for(let T=0;T<=$;T++)a+=" col |";a+=`
@@ -57,11 +57,11 @@ ${(f==null?void 0:f.journey)||`journey
57
57
  `,n=3,i=10-a.length;break}case"katexInline":{a="$$",n=1,i=-1;break}case"katexBlock":{a=`$$
58
58
 
59
59
  $$
60
- `,n=3,i=-4;break}case"universal":{const{generate:h}=o,N=h(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}}},Ot="#e5c07b",Qe="var(--md-color)",Pt="#56b6c2",Ft="#ffffff",te="var(--md-color)",et="#e5c07b",Bt="#e5c07b",qt="var(--md-color)",tt="#d19a66",_t="#c678dd",jt="#21252b",Gt="#2c313a",ot="var(--md-bk-color)",me="var(--md-bk-color)",Ut="#ceedfa33",lt="#528bff",Kt=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:Ut},".cm-panels":{backgroundColor:jt,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:Gt},".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}),Wt=re.HighlightStyle.define([{tag:c.tags.keyword,color:_t},{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:Bt},{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:Ot},{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:Pt},{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:qt},{tag:c.tags.invalid,color:Ft}]),zt=[Kt,re.syntaxHighlighting(Wt)],Zt="#e5c07b",at="#3f4a54",Xt="#56b6c2",Yt="#fff",oe="#3f4a54",rt="#2d8cf0",Jt="#2d8cf0",Qt="#3f4a54",nt="#d19a66",eo="#c678dd",to="#21252b",oo="#ceedfa33",it="var(--md-bk-color)",fe="var(--md-bk-color)",lo="#bad5fa",ct="#3f4a54",ao=ae.EditorView.theme({"&":{color:oe,backgroundColor:it},".cm-content":{caretColor:ct},".cm-cursor, .cm-dropCursor":{borderLeftColor:ct},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:lo},".cm-panels":{backgroundColor:to,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:it,color:oe,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:oo},".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}}}),ro=re.HighlightStyle.define([{tag:c.tags.keyword,color:eo},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:at},{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:nt},{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:Zt},{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:Xt},{tag:[c.tags.meta,c.tags.comment],color:rt},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:rt,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:at},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:nt},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:Qt},{tag:c.tags.invalid,color:Yt}]),no=[ao,re.syntaxHighlighting(ro)],ce=(e,l,o,a,n)=>(i,g,d,u)=>{const f=`${e}${l}`.slice(u-d);i.dispatch(i.state.replaceSelection(`${f}${o}${a}`));const m=d+g.label.length+(n==="title"?o.length:0);i.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(d+g.label.length+(n==="title"?1:-l.length),m),R.EditorSelection.cursor(m)],1)}),i.focus()},st=e=>(l,o,a,n)=>{const i=e.slice(n-a);l.dispatch(l.state.replaceSelection(`${i} `))},io=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:st(g)}}),...["unchecked","checked"].map(n=>{const i=n==="checked"?"- [x]":"- [ ]";return{label:i,type:"text",apply:st(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
+ `,n=3,i=-4;break}case"universal":{const{generate:h}=o,N=h(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}}},Pt="#e5c07b",Qe="var(--md-color)",Ft="#56b6c2",Bt="#ffffff",te="var(--md-color)",et="#e5c07b",qt="#e5c07b",_t="var(--md-color)",tt="#d19a66",jt="#c678dd",Gt="#21252b",Ut="#2c313a",ot="var(--md-bk-color)",me="var(--md-bk-color)",Kt="#ceedfa33",lt="#528bff",Wt=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:Kt},".cm-panels":{backgroundColor:Gt,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:Ut},".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}),zt=re.HighlightStyle.define([{tag:c.tags.keyword,color:jt},{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:qt},{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:Pt},{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:Ft},{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:_t},{tag:c.tags.invalid,color:Bt}]),Zt=[Wt,re.syntaxHighlighting(zt)],Xt="#e5c07b",at="#3f4a54",Yt="#56b6c2",Jt="#fff",oe="#3f4a54",rt="#2d8cf0",Qt="#2d8cf0",eo="#3f4a54",nt="#d19a66",to="#c678dd",oo="#21252b",lo="#ceedfa33",it="var(--md-bk-color)",fe="var(--md-bk-color)",ao="#bad5fa",ct="#3f4a54",ro=ae.EditorView.theme({"&":{color:oe,backgroundColor:it},".cm-content":{caretColor:ct},".cm-cursor, .cm-dropCursor":{borderLeftColor:ct},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ao},".cm-panels":{backgroundColor:oo,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:it,color:oe,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:lo},".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}}}),no=re.HighlightStyle.define([{tag:c.tags.keyword,color:to},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:at},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:Qt},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:nt},{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:Xt},{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:Yt},{tag:[c.tags.meta,c.tags.comment],color:rt},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:rt,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:at},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:nt},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:eo},{tag:c.tags.invalid,color:Jt}]),io=[ro,re.syntaxHighlighting(no)],ce=(e,l,o,a,n)=>(i,g,d,u)=>{const f=`${e}${l}`.slice(u-d);i.dispatch(i.state.replaceSelection(`${f}${o}${a}`));const m=d+g.label.length+(n==="title"?o.length:0);i.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(d+g.label.length+(n==="title"?1:-l.length),m),R.EditorSelection.cursor(m)],1)}),i.focus()},st=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:st(g)}}),...["unchecked","checked"].map(n=>{const i=n==="checked"?"- [x]":"- [ ]";return{label:i,type:"text",apply:st(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 |
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
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",`
66
66
 
67
- !!!`,"title")}))]}};return ht.autocompletion({override:e?[l,...e]:[l]})},co=io,W=e=>{const l=new R.Compartment;return a=>(l.get(e.state)?e.dispatch({effects:l.reconfigure(a)}):e.dispatch({effects:R.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:R.EditorSelection.create([R.EditorSelection.range(n+o.deviationStart,i),R.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([R.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:R.EditorSelection.create([R.EditorSelection.range(o,a),R.EditorSelection.cursor(n)],1)})}setDisabled(l){this.toggleDisabled([ae.EditorView.editable.of(!l)])}setReadOnly(l){this.toggleReadOnly([R.EditorState.readOnly.of(l)])}setMaxLength(l){this.maxLength=l,this.toggleMaxlength([R.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:L=>(s.bus.emit(e,s.ON_SAVE,L.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)},f={key:"Ctrl-4",mac:"Cmd-4",run:()=>(s.bus.emit(e,s.REPLACE,"h4"),!0)},m={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)},V={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)},b={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(s.bus.emit(e,s.REPLACE,"code"),!0),any(L,E){return(E.ctrlKey||E.metaKey)&&E.altKey&&E.code==="KeyC"?(s.bus.emit(e,s.REPLACE,"codeRow"),!0):!1}},h={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:(L,E)=>(E.ctrlKey||E.metaKey)&&E.altKey&&E.shiftKey&&E.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,f,m,v,x,V,p,b,h,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=ho(o,e),d=mo(e),u=[ae.keymap.of([...g,se.indentWithTab]),ee.minimalSetup,bt.markdown({codeLanguages:gt.languages}),ee.EditorView.lineWrapping,ee.EditorView.updateListener.of(m=>{m.docChanged&&e.onChange(m.state.doc.toString())}),ee.EditorView.domEventHandlers({paste:d,blur:e.onBlur,focus:e.onFocus,drop:e.onDrop,input:m=>{e.onInput&&e.onInput(m);const{data:v}=m;e.maxlength&&e.modelValue.length+v.length>e.maxlength&&s.bus.emit(o,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:v})}})],f=()=>{const m=[...u,a.value==="light"?no:zt,co(e.completions)];return r.configOption.codeMirrorExtensions(a.value,m,[...g])};return t.onMounted(()=>{const m=new ee.EditorView({doc:e.modelValue,parent:n.value}),v=new so(m);i.value=v,setTimeout(()=>{v.setTabSize(l),v.setDisabled(e.disabled),v.setReadOnly(e.readonly),v.setExtensions(f()),e.placeholder&&v.setPlaceholder(e.placeholder),typeof e.maxlength=="number"&&v.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(x,V={}){var h;const{text:p,options:b}=Ht(x,i.value,V);(h=i.value)==null||h.replaceSelectedText(p,b,o)}})}),t.watch([a,t.toRef(e,"completions")],()=>{var m;(m=i.value)==null||m.setExtensions(f())},{deep:!0}),t.watch(()=>e.modelValue,()=>{var m,v;((m=i.value)==null?void 0:m.getValue())!==e.modelValue&&((v=i.value)==null||v.setValue(e.modelValue))}),t.watch(()=>e.placeholder,()=>{var m;(m=i.value)==null||m.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var m;(m=i.value)==null||m.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var m;(m=i.value)==null||m.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var m;e.maxlength&&((m=i.value)==null||m.setMaxLength(e.maxlength))}),go(i),{inputWrapperRef:n,codeMirrorUt:i}},po=vo,ko=t.defineComponent({name:"MDEditorContent",props:P.contentProps,setup(e){const l=t.inject("editorId"),o=t.ref(""),{inputWrapperRef:a,codeMirrorUt:n}=po(e);return Dt(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(dt,{theme:e.theme,class:`${r.prefix}-catalog-editor`,editorId:l,mdHeadingId:e.mdHeadingId,key:"internal-catalog"},null)])}}),Co=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(Co,{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[f,m]=P.useConfig(e,l),v=P.useCatalog(e);return t.onBeforeUnmount(()=>{s.bus.clear(o)}),P.useExpose(e,l,v,f,m),()=>{var p;const x=Je.getSlot({props:e,ctx:l},"defToolbars"),V=Je.getSlot({props:e,ctx:l},"defFooters");return t.createVNode("div",{id:o,class:[r.prefix,e.class,e.theme==="dark"&&`${r.prefix}-dark`,f.fullscreen||f.pageFullscreen?`${r.prefix}-fullscreen`:""],style:e.style},[t.createVNode(It,{noPrettier:i,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:f,updateSetting:m,tableShape:e.tableShape,defToolbars:x,noUploadImg:g,showToolbarName:e.showToolbarName},null),t.createVNode(ko,{modelValue:e.modelValue,setting:f,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),((p=e.footers)==null?void 0:p.length)>0&&t.createVNode(yo,{modelValue:e.modelValue,footers:e.footers,defFooters:V,scrollAuto:u.scrollAuto,onScrollAutoChange:b=>u.scrollAuto=b},null)])}}}),de=wo;de.install=e=>(e.component(de.name,de),e.use(vt).use(z.DropdownToolbar).use(pt).use(dt).use(P.MdPreview),e);module.exports=de;
67
+ !!!`,"title")}))]}};return vt.autocompletion({override:e?[l,dt.htmlCompletionSource,...e]:[l]})},so=co,W=e=>{const l=new R.Compartment;return a=>(l.get(e.state)?e.dispatch({effects:l.reconfigure(a)}):e.dispatch({effects:R.StateEffect.appendConfig.of(l.of(a))}),!0)};class uo{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:R.EditorSelection.create([R.EditorSelection.range(n+o.deviationStart,i),R.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([R.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:R.EditorSelection.create([R.EditorSelection.range(o,a),R.EditorSelection.cursor(n)],1)})}setDisabled(l){this.toggleDisabled([ae.EditorView.editable.of(!l)])}setReadOnly(l){this.toggleReadOnly([R.EditorState.readOnly.of(l)])}setMaxLength(l){this.maxLength=l,this.toggleMaxlength([R.EditorState.changeFilter.of(o=>o.newDoc.length<=l)])}}const mo=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})}},fo=mo,go=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)}})})},bo=go,ho=(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:L=>(s.bus.emit(e,s.ON_SAVE,L.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)},f={key:"Ctrl-4",mac:"Cmd-4",run:()=>(s.bus.emit(e,s.REPLACE,"h4"),!0)},m={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)},V={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)},b={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(s.bus.emit(e,s.REPLACE,"code"),!0),any(L,E){return(E.ctrlKey||E.metaKey)&&E.altKey&&E.code==="KeyC"?(s.bus.emit(e,s.REPLACE,"codeRow"),!0):!1}},h={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:(L,E)=>(E.ctrlKey||E.metaKey)&&E.altKey&&E.shiftKey&&E.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,f,m,v,x,V,p,b,h,N,$]},vo=ho,po=e=>{const l=t.inject("tabWidth"),o=t.inject("editorId"),a=t.inject("theme"),n=t.ref(),i=t.shallowRef(),g=vo(o,e),d=fo(e),u=[ae.keymap.of([...g,se.indentWithTab]),ee.minimalSetup,dt.html(),ht.markdown({codeLanguages:bt.languages}),ee.EditorView.lineWrapping,ee.EditorView.updateListener.of(m=>{m.docChanged&&e.onChange(m.state.doc.toString())}),ee.EditorView.domEventHandlers({paste:d,blur:e.onBlur,focus:e.onFocus,drop:e.onDrop,input:m=>{e.onInput&&e.onInput(m);const{data:v}=m;e.maxlength&&e.modelValue.length+v.length>e.maxlength&&s.bus.emit(o,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:v})}})],f=()=>{const m=[...u,a.value==="light"?io:Zt,so(e.completions)];return r.configOption.codeMirrorExtensions(a.value,m,[...g])};return t.onMounted(()=>{const m=new ee.EditorView({doc:e.modelValue,parent:n.value}),v=new uo(m);i.value=v,setTimeout(()=>{v.setTabSize(l),v.setDisabled(e.disabled),v.setReadOnly(e.readonly),v.setExtensions(f()),e.placeholder&&v.setPlaceholder(e.placeholder),typeof e.maxlength=="number"&&v.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(x,V={}){var h;const{text:p,options:b}=Ot(x,i.value,V);(h=i.value)==null||h.replaceSelectedText(p,b,o)}})}),t.watch([a,t.toRef(e,"completions")],()=>{var m;(m=i.value)==null||m.setExtensions(f())},{deep:!0}),t.watch(()=>e.modelValue,()=>{var m,v;((m=i.value)==null?void 0:m.getValue())!==e.modelValue&&((v=i.value)==null||v.setValue(e.modelValue))}),t.watch(()=>e.placeholder,()=>{var m;(m=i.value)==null||m.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var m;(m=i.value)==null||m.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var m;(m=i.value)==null||m.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var m;e.maxlength&&((m=i.value)==null||m.setMaxLength(e.maxlength))}),bo(i),{inputWrapperRef:n,codeMirrorUt:i}},ko=po,Co=t.defineComponent({name:"MDEditorContent",props:P.contentProps,setup(e){const l=t.inject("editorId"),o=t.ref(""),{inputWrapperRef:a,codeMirrorUt:n}=ko(e);return Ht(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(ut,{theme:e.theme,class:`${r.prefix}-catalog-editor`,editorId:l,mdHeadingId:e.mdHeadingId,key:"internal-catalog"},null)])}}),xo=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])])}}}),No={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Vo=t.defineComponent({props:No,setup(e){return()=>t.createVNode("div",{class:[`${r.prefix}-checkbox`,e.checked&&`${r.prefix}-checkbox-checked`],onClick:()=>{e.onChange(!e.checked)}},null)}}),$o={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},To=t.defineComponent({props:$o,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(Vo,{checked:e.scrollAuto,onChange:e.onScrollAutoChange},null)])}}}),yo={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},wo=t.defineComponent({name:"MDEditorFooter",props:yo,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(xo,{modelValue:e.modelValue},null);case"scrollSwitch":return t.createVNode(To,{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])])}}}),Eo=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[f,m]=P.useConfig(e,l),v=P.useCatalog(e);return t.onBeforeUnmount(()=>{s.bus.clear(o)}),P.useExpose(e,l,v,f,m),()=>{var p;const x=Je.getSlot({props:e,ctx:l},"defToolbars"),V=Je.getSlot({props:e,ctx:l},"defFooters");return t.createVNode("div",{id:o,class:[r.prefix,e.class,e.theme==="dark"&&`${r.prefix}-dark`,f.fullscreen||f.pageFullscreen?`${r.prefix}-fullscreen`:""],style:e.style},[t.createVNode(Lt,{noPrettier:i,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:f,updateSetting:m,tableShape:e.tableShape,defToolbars:x,noUploadImg:g,showToolbarName:e.showToolbarName},null),t.createVNode(Co,{modelValue:e.modelValue,setting:f,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),((p=e.footers)==null?void 0:p.length)>0&&t.createVNode(wo,{modelValue:e.modelValue,footers:e.footers,defFooters:V,scrollAuto:u.scrollAuto,onScrollAutoChange:b=>u.scrollAuto=b},null)])}}}),de=Eo;de.install=e=>(e.component(de.name,de),e.use(pt).use(z.DropdownToolbar).use(kt).use(ut).use(P.MdPreview),e);module.exports=de;
@@ -1,6 +1,6 @@
1
1
  "use strict";const c=require("vue"),d=require("./config.cjs"),p=require("./index4.cjs"),E=require("./dom.cjs"),O=require("medium-zoom"),P=require("@vavt/util"),B=require("copy-to-clipboard"),G=require("markdown-it"),j=require("markdown-it-image-figures"),D=require("markdown-it-task-lists"),U=require("lru-cache"),V=(e,i)=>{const l=c.inject("editorId"),{noImgZoomIn:t}=e,n=P.debounce(()=>{const r=document.querySelectorAll(`#${l}-preview img`);r.length!==0&&O(r,{background:"#00000073"})});c.onMounted(()=>{!t&&n()}),c.watch([i,c.toRef(e.setting,"preview")],()=>{!t&&n()})},q=V,z=(e,i)=>{if(typeof i[e]=="string")return i[e];const l=`<i class="${d.prefix}-iconfont ${d.prefix}-icon-${e}"></i>`;switch(d.configOption.iconfontType){case"svg":return`<svg class="${d.prefix}-icon" aria-hidden="true"><use xlink:href="#${d.prefix}-icon-${e}"></use></svg>`;default:return l}},K=(e,i)=>{const l=c.inject("editorId"),t=c.inject("usedLanguageText"),n=c.inject("customIcon"),r=()=>{document.querySelectorAll(`#${l}-preview pre`).forEach(m=>{var w,b;let u=-1;(w=m.querySelector(".copy-button"))==null||w.remove();const o=((b=t.value.copyCode)==null?void 0:b.text)||"复制代码",f=document.createElement("span");f.setAttribute("class","copy-button"),f.dataset.tips=o,f.innerHTML=z("copy",n.value),f.addEventListener("click",()=>{var y,k;clearTimeout(u);const h=m.querySelector("code").innerText,v=B(e.formatCopiedText(h)),g=((y=t.value.copyCode)==null?void 0:y.successTips)||"已复制!",C=((k=t.value.copyCode)==null?void 0:k.failTips)||"已复制!";f.dataset.tips=v?g:C,u=window.setTimeout(()=>{f.dataset.tips=o},1500)}),m.appendChild(f)})},a=()=>{c.nextTick(r)},s=m=>{m&&c.nextTick(r)};c.watch(()=>i.value,a),c.watch(()=>e.setting.preview,s),c.watch(()=>e.setting.htmlPreview,s),c.watch(()=>t.value,r),c.onMounted(r)},W=K,Z=e=>{var r;const i=(r=d.configOption.editorExtensions)==null?void 0:r.highlight,l=i==null?void 0:i.instance,t=c.inject("highlight"),n=c.shallowRef(l);return c.onMounted(()=>{if(!e.noHighlight&&!n.value){const a=document.createElement("script");a.src=t.value.js,a.onload=()=>{n.value=window.hljs},a.id=`${d.prefix}-hljs`,E.appendHandler(a,"hljs");const s=document.createElement("link");s.rel="stylesheet",s.href=t.value.css,s.id=`${d.prefix}-hlCss`,E.appendHandler(s)}}),c.watch(()=>t.value.css,a=>{E.updateHandler(`${d.prefix}-hlCss`,"href",a)}),n},J=Z,X=e=>{const i=c.inject("theme"),{editorExtensions:l}=d.configOption,t=l==null?void 0:l.mermaid,n=c.shallowRef(t==null?void 0:t.instance),r=c.shallowRef(-1),a=new U({max:1e3,ttl:6e5}),s=()=>{const u=n.value;!e.noMermaid&&u&&(u.initialize({startOnLoad:!1,theme:i.value==="dark"?"dark":"default"}),r.value=r.value+1)};return c.watch(()=>i.value,()=>{a.clear(),s()}),c.onMounted(()=>{if(!e.noMermaid&&!(t!=null&&t.instance)){const u=(t==null?void 0:t.js)||d.mermaidUrl;if(/\.mjs/.test(u))import(u).then(o=>{n.value=o.default,s()});else{const o=document.createElement("script");o.id=`${d.prefix}-mermaid`,o.src=u,o.onload=()=>{n.value=window.mermaid,s()},E.appendHandler(o,"mermaid")}}}),{mermaidRef:n,reRenderRef:r,replaceMermaid:()=>{c.nextTick(()=>{if(!e.noMermaid&&n.value){const u=document.querySelectorAll(`div.${d.prefix}-mermaid`),o=document.createElement("div");o.style.width=document.body.offsetWidth+"px",o.style.height=document.body.offsetHeight+"px",o.style.position="fixed",o.style.zIndex="-10000",o.style.top="-10000";let f=u.length;f>0&&document.body.appendChild(o),u.forEach(async w=>{let b=a.get(w.innerText);if(!b){const v=p.uuid(),g=n.value.renderAsync||n.value.render;let C="";try{C=await g(v,w.innerText,o)}catch{}b=typeof C=="string"?C:C.svg,a.set(w.innerText,b)}const h=document.createElement("p");h.className=`${d.prefix}-mermaid`,h.setAttribute("data-processed",""),h.innerHTML=b,w.dataset.line!==void 0&&(h.dataset.line=w.dataset.line),w.replaceWith(h),--f===0&&o.remove()})}})}}},Q=X,Y=e=>{var n;const i=(n=d.configOption.editorExtensions)==null?void 0:n.katex,l=i==null?void 0:i.instance,t=c.shallowRef(l);return c.onMounted(()=>{if(!e.noKatex&&!t.value){const r=document.createElement("script");r.src=(i==null?void 0:i.js)||d.katexUrl.js,r.onload=()=>{t.value=window.katex},r.id=`${d.prefix}-katex`;const a=document.createElement("link");a.rel="stylesheet",a.href=(i==null?void 0:i.css)||d.katexUrl.css,a.id=`${d.prefix}-katexCss`,E.appendHandler(r,"katex"),E.appendHandler(a)}}),t},ee=Y,te=(e,i)=>{const l=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(t,n,r,a,s)=>{const m=t[n],u=m.content.trim();if(m.info==="mermaid"){let o;return t[n].map&&t[n].level===0&&(o=t[n].map[0],t[n].attrSet("data-line",String(o))),`<div class="${d.prefix}-mermaid" ${o!==void 0?"data-line="+o:""} data-mermaid-theme=${i.themeRef.value}>${u}</div>`}return l(t,n,r,a,s)}},ne=te,H=(e,i)=>{let l=!0,t=!0;const n=e.posMax,r=i>0?e.src.charCodeAt(i-1):-1,a=i+1<=n?e.src.charCodeAt(i+1):-1;return(r===32||r===9||a>=48&&a<=57)&&(t=!1),(a===32||a===9)&&(l=!1),{can_open:l,can_close:t}},oe=(e,i)=>{let l,t,n,r;if(e.src[e.pos]!=="$")return!1;if(n=H(e,e.pos),!n.can_open)return i||(e.pending+="$"),e.pos+=1,!0;const a=e.pos+1;for(l=a;(l=e.src.indexOf("$",l))!==-1;){for(r=l-1;e.src[r]==="\\";)r-=1;if((l-r)%2==1)break;l+=1}return l===-1?(i||(e.pending+="$"),e.pos=a,!0):l-a===0?(i||(e.pending+="$$"),e.pos=a+1,!0):(n=H(e,l),n.can_close?(i||(t=e.push("math_inline","math",0),t.markup="$",t.content=e.src.slice(a,l)),e.pos=l+1,!0):(i||(e.pending+="$"),e.pos=a,!0))},re=(e,i,l,t)=>{let n,r,a,s,m=!1,u=e.bMarks[i]+e.tShift[i],o=e.eMarks[i];if(u+2>o||e.src.slice(u,u+2)!=="$$")return!1;if(u+=2,n=e.src.slice(u,o),t)return!0;for(n.trim().slice(-2)==="$$"&&(n=n.trim().slice(0,-2),m=!0),a=i;!m&&(a++,!(a>=l||(u=e.bMarks[a]+e.tShift[a],o=e.eMarks[a],u<o&&e.tShift[a]<e.blkIndent)));)e.src.slice(u,o).trim().slice(-2)==="$$"&&(s=e.src.slice(0,o).lastIndexOf("$$"),r=e.src.slice(u,s),m=!0);e.line=a+1;const f=e.push("math_block","math",0);return f.block=!0,f.content=(n&&n.trim()?n+`
2
2
  `:"")+e.getLines(i+1,a,e.tShift[i],!0)+(r&&r.trim()?r:""),f.map=[i,e.line],f.markup="$$",!0},ie=(e,i)=>{const l=n=>{if(i.katexRef.value){const r=i.katexRef.value.renderToString(n,{throwOnError:!1});return`<span class="${d.prefix}-katex-inline" data-processed>${r}</span>`}else return`<span class="${d.prefix}-katex-inline">${n}</span>`},t=(n,r)=>{if(i.katexRef.value){const a=i.katexRef.value.renderToString(n,{throwOnError:!1,displayMode:!0});return`<p class="${d.prefix}-katex-block" data-line=${r} data-processed>${a}</p>`}else return`<p class="${d.prefix}-katex-block" data-line=${r}>${n}</p>`};e.inline.ruler.after("escape","math_inline",oe),e.block.ruler.after("blockquote","math_block",re,{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=(n,r)=>l(n[r].content),e.renderer.rules.math_block=(n,r)=>t(n[r].content,n[r].map[0])+`
3
- `},le=ie,ae=(e,i)=>{i=i||{};const l=3,t=i.marker||"!",n=t.charCodeAt(0),r=t.length;let a="",s="";const m=(o,f,w,b,h)=>{const v=o[f];return v.type==="admonition_open"?(o[f].attrPush(["class",`${d.prefix}-admonition ${d.prefix}-admonition-${v.info}`]),o[f].attrSet("data-line",String(o[f].map[0]))):v.type==="admonition_title_open"&&o[f].attrPush(["class",`${d.prefix}-admonition-title`]),h.renderToken(o,f,w)},u=o=>{const f=o.trim().split(" ",2);s="",a=f[0],f.length>1&&(s=o.substring(a.length+2)),(s===""||!s)&&(s=a)};e.block.ruler.before("code","admonition",(o,f,w,b)=>{let h,v,g,C=!1,y=o.bMarks[f]+o.tShift[f],k=o.eMarks[f];if(n!==o.src.charCodeAt(y))return!1;for(h=y+1;h<=k&&t[(h-y)%r]===o.src[h];h++);const $=Math.floor((h-y)/r);if($!==l)return!1;h-=(h-y)%r;const I=o.src.slice(y,h),x=o.src.slice(h,k);if(u(x),b)return!0;for(v=f;v++,!(v>=w||(y=o.bMarks[v]+o.tShift[v],k=o.eMarks[v],y<k&&o.sCount[v]<o.blkIndent));)if(n===o.src.charCodeAt(y)&&!(o.sCount[v]-o.blkIndent>=4)){for(h=y+1;h<=k&&t[(h-y)%r]===o.src[h];h++);if(!(Math.floor((h-y)/r)<$)&&(h-=(h-y)%r,h=o.skipSpaces(h),!(h<k))){C=!0;break}}const _=o.parentType,N=o.lineMax;return o.parentType="root",o.lineMax=v,g=o.push("admonition_open","div",1),g.markup=I,g.block=!0,g.info=a,g.map=[f,v],g=o.push("admonition_title_open","p",1),g.markup=I+" "+a,g.map=[f,v],g=o.push("inline","",0),g.content=s,g.map=[f,o.line-1],g.children=[],g=o.push("admonition_title_close","p",-1),g.markup=I+" "+a,o.md.block.tokenize(o,f+1,v),g=o.push("admonition_close","div",-1),g.markup=o.src.slice(y,h),g.block=!0,o.parentType=_,o.lineMax=N,o.line=v+(C?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=m,e.renderer.rules.admonition_title_open=m,e.renderer.rules.admonition_title_close=m,e.renderer.rules.admonition_close=m},ce=ae,se=(e,i)=>{e.renderer.rules.heading_open=(l,t)=>{const n=l[t],r=l[t+1].content,a=n.markup.length;return i.headsRef.value.push({text:r,level:a}),n.map&&n.level===0&&(n.attrSet("data-line",String(n.map[0])),n.attrSet("id",i.mdHeadingId(r,a,i.headsRef.value.length))),e.renderer.renderToken(l,t,i)},e.renderer.rules.heading_close=(l,t,n,r,a)=>a.renderToken(l,t,n)},ue=se,de=(e,i)=>{const l=e.renderer.rules.fence,t=e.utils.unescapeAll,n=/\[(\w*)(?::([\w ]*))?\]/;function r(u){return u.info?t(u.info).trim():""}function a(u){const o=r(u),[f=null,w=""]=(n.exec(o)||[]).slice(1);return[f,w]}function s(u){const o=r(u);return o?o.split(/(\s+)/g)[0]:""}const m=(u,o,f,w,b)=>{if(u[o].hidden)return"";const[h,v]=a(u[o]);if(h===null)return l(u,o,f,w,b);let g,C,y,k,$="",I="";for(let x=o;x<u.length&&(g=u[x],[C,y]=a(g),C===h);x++)g.info=g.info.replace(n,""),g.hidden=!0,k=x-o>0?"":" checked",$+=`<li><input type="radio" name="label-group-${i.editorId}-${o}"${k}><label for="group-${i.editorId}-${o}-tab-${x-o}" onclick="this.previousElementSibling.click()">${y||s(g)}</label></li>
3
+ `},le=ie,ae=(e,i)=>{i=i||{};const l=3,t=i.marker||"!",n=t.charCodeAt(0),r=t.length;let a="",s="";const m=(o,f,w,b,h)=>{const v=o[f];return v.type==="admonition_open"?(o[f].attrPush(["class",`${d.prefix}-admonition ${d.prefix}-admonition-${v.info}`]),o[f].attrSet("data-line",String(o[f].map[0]))):v.type==="admonition_title_open"&&o[f].attrPush(["class",`${d.prefix}-admonition-title`]),h.renderToken(o,f,w)},u=o=>{const f=o.trim().split(" ",2);s="",a=f[0],f.length>1&&(s=o.substring(a.length+2)),(s===""||!s)&&(s=a)};e.block.ruler.before("code","admonition",(o,f,w,b)=>{let h,v,g,C=!1,y=o.bMarks[f]+o.tShift[f],k=o.eMarks[f];if(n!==o.src.charCodeAt(y))return!1;for(h=y+1;h<=k&&t[(h-y)%r]===o.src[h];h++);const $=Math.floor((h-y)/r);if($!==l)return!1;h-=(h-y)%r;const I=o.src.slice(y,h),x=o.src.slice(h,k);if(u(x),b)return!0;for(v=f;v++,!(v>=w||(y=o.bMarks[v]+o.tShift[v],k=o.eMarks[v],y<k&&o.sCount[v]<o.blkIndent));)if(n===o.src.charCodeAt(y)&&!(o.sCount[v]-o.blkIndent>=4)){for(h=y+1;h<=k&&t[(h-y)%r]===o.src[h];h++);if(!(Math.floor((h-y)/r)<$)&&(h-=(h-y)%r,h=o.skipSpaces(h),!(h<k))){C=!0;break}}const _=o.parentType,N=o.lineMax;return o.parentType="root",o.lineMax=v,g=o.push("admonition_open","div",1),g.markup=I,g.block=!0,g.info=a,g.map=[f,v],g=o.push("admonition_title_open","p",1),g.markup=I+" "+a,g.map=[f,v],g=o.push("inline","",0),g.content=s,g.map=[f,o.line-1],g.children=[],g=o.push("admonition_title_close","p",-1),g.markup=I+" "+a,o.md.block.tokenize(o,f+1,v),g=o.push("admonition_close","div",-1),g.markup=o.src.slice(y,h),g.block=!0,o.parentType=_,o.lineMax=N,o.line=v+(C?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=m,e.renderer.rules.admonition_title_open=m,e.renderer.rules.admonition_title_close=m,e.renderer.rules.admonition_close=m},ce=ae,se=(e,i)=>{e.renderer.rules.heading_open=(l,t)=>{var s;const n=l[t],r=((s=l[t+1].children)==null?void 0:s.reduce((m,u)=>m+(u.content||""),""))||"",a=n.markup.length;return i.headsRef.value.push({text:r,level:a}),n.map&&n.level===0&&(n.attrSet("data-line",String(n.map[0])),n.attrSet("id",i.mdHeadingId(r,a,i.headsRef.value.length))),e.renderer.renderToken(l,t,i)},e.renderer.rules.heading_close=(l,t,n,r,a)=>a.renderToken(l,t,n)},ue=se,de=(e,i)=>{const l=e.renderer.rules.fence,t=e.utils.unescapeAll,n=/\[(\w*)(?::([\w ]*))?\]/;function r(u){return u.info?t(u.info).trim():""}function a(u){const o=r(u),[f=null,w=""]=(n.exec(o)||[]).slice(1);return[f,w]}function s(u){const o=r(u);return o?o.split(/(\s+)/g)[0]:""}const m=(u,o,f,w,b)=>{if(u[o].hidden)return"";const[h,v]=a(u[o]);if(h===null)return l(u,o,f,w,b);let g,C,y,k,$="",I="";for(let x=o;x<u.length&&(g=u[x],[C,y]=a(g),C===h);x++)g.info=g.info.replace(n,""),g.hidden=!0,k=x-o>0?"":" checked",$+=`<li><input type="radio" name="label-group-${i.editorId}-${o}"${k}><label for="group-${i.editorId}-${o}-tab-${x-o}" onclick="this.previousElementSibling.click()">${y||s(g)}</label></li>
4
4
  `,I+=`<input type="radio" id="group-${i.editorId}-${o}-tab-${x-o}" name="group-${i.editorId}-${o}"${k}>
5
5
  `+l(u,x,f,w,b);return`<div class="code-tabs">
6
6
  <ul>
package/lib/cjs/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./MdEditor.cjs"),e=require("./chunks/index.cjs"),o=require("./NormalToolbar.cjs"),i=require("./chunks/index2.cjs"),u=require("./ModalToolbar.cjs"),q=require("./MdCatalog.cjs"),d=require("./chunks/config.cjs"),a=require("./chunks/index3.cjs");require("vue");require("@vavt/util");require("./chunks/index4.cjs");require("./chunks/dom.cjs");require("codemirror");require("@codemirror/view");require("@codemirror/language-data");require("@codemirror/lang-markdown");require("@codemirror/commands");require("@codemirror/language");require("@lezer/highlight");require("@codemirror/state");require("@codemirror/autocomplete");require("./chunks/vue-tsx.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");exports.MdEditor=r;exports.MdPreview=e.MdPreview;exports.NormalToolbar=o;exports.DropdownToolbar=i.DropdownToolbar;exports.ModalToolbar=u;exports.MdCatalog=q;exports.config=d.config;exports.MdModal=a.MdModal;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./MdEditor.cjs"),e=require("./chunks/index.cjs"),o=require("./NormalToolbar.cjs"),i=require("./chunks/index2.cjs"),u=require("./ModalToolbar.cjs"),q=require("./MdCatalog.cjs"),d=require("./chunks/config.cjs"),a=require("./chunks/index3.cjs");require("vue");require("@vavt/util");require("./chunks/index4.cjs");require("./chunks/dom.cjs");require("codemirror");require("@codemirror/view");require("@codemirror/language-data");require("@codemirror/lang-markdown");require("@codemirror/lang-html");require("@codemirror/commands");require("@codemirror/language");require("@lezer/highlight");require("@codemirror/state");require("@codemirror/autocomplete");require("./chunks/vue-tsx.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");exports.MdEditor=r;exports.MdPreview=e.MdPreview;exports.NormalToolbar=o;exports.DropdownToolbar=i.DropdownToolbar;exports.ModalToolbar=u;exports.MdCatalog=q;exports.config=d.config;exports.MdModal=a.MdModal;