md-editor-v3 4.0.4-beta.0 → 4.0.4

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,9 +1,9 @@
1
- "use strict";var Oe=Object.defineProperty;var Re=(t,a,r)=>a in t?Oe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r;var R=(t,a,r)=>(Re(t,typeof a!="symbol"?a+"":a,r),r);const e=require("vue"),o=require("./chunks/config.cjs"),K=require("./chunks/index2.cjs"),h=require("./chunks/index4.cjs"),X=require("@vavt/util"),w=require("./chunks/index.cjs"),qe=require("./chunks/dom.cjs"),ne=require("./chunks/index3.cjs"),Y=require("codemirror"),Q=require("@codemirror/view"),Pe=require("@codemirror/language-data"),je=require("@codemirror/lang-markdown"),le=require("@codemirror/commands"),ee=require("@codemirror/language"),n=require("@lezer/highlight"),q=require("@codemirror/state"),$e=require("./chunks/vue-tsx.cjs"),Be=require("./MdCatalog.cjs"),Ge=require("./NormalToolbar.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 Ue=e.defineComponent({setup(){return()=>e.createVNode("div",{class:`${o.prefix}-divider`},null)}}),Ke={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}},_e=t=>{var g,d,u,v;const a=e.inject("editorId");let r=(d=(g=o.configOption.editorExtensions)==null?void 0:g.screenfull)==null?void 0:d.instance;const l=(v=(u=o.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:v.js,c=e.ref(!1),i=k=>{if(!r){h.bus.emit(a,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}r.isEnabled?(c.value=!0,(k===void 0?!r.isFullscreen:k)?r.request():r.exit()):console.error("browser does not support screenfull!")},s=()=>{r&&r.isEnabled&&r.on("change",()=>{(c.value||t.setting.fullscreen)&&(c.value=!1,t.updateSetting("fullscreen"))})},m=()=>{r=window.screenfull,s()};return e.onMounted(()=>{if(s(),!r){const k=document.createElement("script");k.src=l||o.screenfullUrl,k.onload=m,k.id=`${o.prefix}-screenfull`,qe.appendHandler(k,"screenfull")}}),e.onMounted(()=>{h.bus.on(a,{name:w.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},We={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},ze=e.defineComponent({name:"TableShape",props:We,setup(t){const a=e.reactive({x:-1,y:-1});return()=>e.createVNode("div",{class:`${o.prefix}-table-shape`,onMouseleave:()=>{a.x=-1,a.y=-1}},[new Array(t.tableShape[1]).fill("").map((r,l)=>e.createVNode("div",{class:`${o.prefix}-table-shape-row`,key:`table-shape-row-${l}`},[new Array(t.tableShape[0]).fill("").map((c,i)=>e.createVNode("div",{class:`${o.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{a.x=l,a.y=i},onClick:()=>{t.onSelected(a)}},[e.createVNode("div",{class:[`${o.prefix}-table-shape-col-default`,l<=a.x&&i<=a.y&&`${o.prefix}-table-shape-col-include`]},null)]))]))])}}),Ye=ze,Ze={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Je=e.defineComponent({props:Ze,setup(t){const a=e.inject("usedLanguageText"),r=e.inject("editorId"),l=e.computed(()=>{var i,s;switch(t.type){case"link":return(i=a.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(s=a.value.linkModalTips)==null?void 0:s.imageTitle;default:return""}}),c=e.reactive({desc:"",url:""});return e.watch(()=>t.visible,i=>{i||setTimeout(()=>{c.desc="",c.url=""},200)}),()=>e.createVNode(ne.Modal,{title:l.value,visible:t.visible,onClose:t.onCancel},{default:()=>{var i,s,m,g,d;return[e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("label",{class:`${o.prefix}-label`,for:`link-desc-${r}`},[(i=a.value.linkModalTips)==null?void 0:i.descLabel]),e.createVNode("input",{placeholder:(s=a.value.linkModalTips)==null?void 0:s.descLabelPlaceHolder,class:`${o.prefix}-input`,id:`link-desc-${r}`,type:"text",value:c.desc,onChange:u=>{c.desc=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("label",{class:`${o.prefix}-label`,for:`link-url-${r}`},[(m=a.value.linkModalTips)==null?void 0:m.urlLabel]),e.createVNode("input",{placeholder:(g=a.value.linkModalTips)==null?void 0:g.urlLabelPlaceHolder,class:`${o.prefix}-input`,id:`link-url-${r}`,type:"text",value:c.url,onChange:u=>{c.url=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("button",{class:[`${o.prefix}-btn`,`${o.prefix}-btn-row`],type:"button",onClick:()=>{t.onOk(c),c.desc="",c.url=""}},[(d=a.value.linkModalTips)==null?void 0:d.buttonOK])])]}})}}),Xe={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Qe=e.defineComponent({props:Xe,setup(t){var u,v,k;const a=e.inject("usedLanguageText"),r=e.inject("editorId");let l=(k=(v=(u=o.configOption)==null?void 0:u.editorExtensions)==null?void 0:v.cropper)==null?void 0:k.instance;const c=e.ref(),i=e.ref(),s=e.ref(),m=e.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let g=null;e.watch(()=>t.visible,()=>{t.visible&&!m.cropperInited&&(l=l||window.Cropper,c.value.onchange=()=>{if(!l){h.bus.emit(r,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const b=c.value.files||[];if(m.imgSelected=!0,(b==null?void 0:b.length)>0){const p=new FileReader;p.onload=f=>{m.imgSrc=f.target.result,e.nextTick(()=>{g=new l(i.value,{viewMode:2,preview:`.${o.prefix}-clip-preview-target`})})},p.readAsDataURL(b[0])}})}),e.watch(()=>[m.imgSelected],()=>{s.value.style=""}),e.watch(()=>m.isFullscreen,()=>{e.nextTick(()=>{g==null||g.destroy(),s.value.style="",i.value&&(g=new l(i.value,{viewMode:2,preview:`.${o.prefix}-clip-preview-target`}))})});const d=()=>{g.clear(),g.destroy(),g=null,c.value.value="",m.imgSelected=!1};return()=>{var b;return e.createVNode(ne.Modal,{class:`${o.prefix}-modal-clip`,title:(b=a.value.clipModalTips)==null?void 0:b.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:m.isFullscreen,onAdjust:p=>{m.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,f;return[e.createVNode("div",{class:`${o.prefix}-form-item ${o.prefix}-clip`},[e.createVNode("div",{class:`${o.prefix}-clip-main`},[m.imgSelected?e.createVNode("div",{class:`${o.prefix}-clip-cropper`},[e.createVNode("img",{src:m.imgSrc,ref:i,style:{display:"none"},alt:""},null),e.createVNode("div",{class:`${o.prefix}-clip-delete`,onClick:d},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):e.createVNode("div",{class:`${o.prefix}-clip-upload`,onClick:()=>{c.value.click()}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),e.createVNode("div",{class:`${o.prefix}-clip-preview`},[e.createVNode("div",{class:`${o.prefix}-clip-preview-target`,ref:s},null)])]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("button",{class:`${o.prefix}-btn`,type:"button",onClick:()=>{if(g){const x=g.getCroppedCanvas();h.bus.emit(r,"uploadImage",[h.base642File(x.toDataURL("image/png"))],t.onOk),d()}}},[((p=a.value.clipModalTips)==null?void 0:p.buttonUpload)||((f=a.value.linkModalTips)==null?void 0:f.buttonOK)])]),e.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),et={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},tt=e.defineComponent({props:et,setup(t){return()=>e.createVNode(e.Fragment,null,[e.createVNode(Je,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),e.createVNode(Qe,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),ot=e.defineComponent({name:"MDEditorToolbar",props:Ke,setup(t){const a=e.inject("editorId"),r=e.inject("usedLanguageText"),{fullscreenHandler:l}=_e(t),c=`${a}-toolbar-wrapper`,i=e.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),s=(b,p)=>{h.bus.emit(a,"replace",b,p)},m=e.reactive({type:"link",linkVisible:!1,clipVisible:!1}),g=e.ref();e.onMounted(()=>{h.bus.on(a,{name:"openModals",callback(b){m.type=b,m.linkVisible=!0}})});const d=e.computed(()=>{const b=t.toolbars.filter(N=>!t.toolbarsExclude.includes(N)),p=b.indexOf("="),f=p===-1?b:b.slice(0,p+1),x=p===-1?[]:b.slice(p,Number.MAX_SAFE_INTEGER);return[f,x]}),u=e.ref(),v=()=>{h.bus.emit(a,"uploadImage",Array.from(u.value.files||[])),u.value.value=""};e.onMounted(()=>{u.value.addEventListener("change",v)});const k=b=>{var p,f,x,N,y,$,T,C,S,I,M,A,H,L,E,P,B,te,_,j,O,W,G,D,F,z,oe,ce,se,de,ue,fe,ge,me,he,be,pe,ve,ke,xe,Ce,Ve,Ne;if(o.allToolbar.includes(b))switch(b){case"-":return e.createVNode(Ue,null,null);case"bold":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(p=r.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{s("bold")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(f=r.value.toolbarTips)==null?void 0:f.underline,onClick:()=>{s("underline")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(x=r.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{s("italic")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(N=r.value.toolbarTips)==null?void 0:N.strikeThrough,onClick:()=>{s("strikeThrough")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.title,onChange:V=>{i.title=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h1")}},[(y=r.value.titleItem)==null?void 0:y.h1]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h2")}},[($=r.value.titleItem)==null?void 0:$.h2]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h3")}},[(T=r.value.titleItem)==null?void 0:T.h3]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h4")}},[(C=r.value.titleItem)==null?void 0:C.h4]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h5")}},[(S=r.value.titleItem)==null?void 0:S.h5]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h6")}},[(I=r.value.titleItem)==null?void 0:I.h6])])},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.title},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(M=r.value.toolbarTips)==null?void 0:M.sub,onClick:()=>{s("sub")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(A=r.value.toolbarTips)==null?void 0:A.sup,onClick:()=>{s("sup")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(H=r.value.toolbarTips)==null?void 0:H.quote,onClick:()=>{s("quote")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(L=r.value.toolbarTips)==null?void 0:L.unorderedList,onClick:()=>{s("unorderedList")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(E=r.value.toolbarTips)==null?void 0:E.orderedList,onClick:()=>{s("orderedList")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(P=r.value.toolbarTips)==null?void 0:P.task,onClick:()=>{s("task")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(B=r.value.toolbarTips)==null?void 0:B.codeRow,onClick:()=>{s("codeRow")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(te=r.value.toolbarTips)==null?void 0:te.code,onClick:()=>{s("code")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(_=r.value.toolbarTips)==null?void 0:_.link,onClick:()=>{m.type="link",m.linkVisible=!0}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(j=r.value.toolbarTips)==null?void 0:j.image,onClick:()=>{m.type="image",m.linkVisible=!0}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.image,onChange:V=>{i.image=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{m.type="image",m.linkVisible=!0}},[(O=r.value.imgTitleItem)==null?void 0:O.link]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{u.value.click()}},[(W=r.value.imgTitleItem)==null?void 0:W.upload]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{m.clipVisible=!0}},[(G=r.value.imgTitleItem)==null?void 0:G.clip2upload])])},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.image},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.table,onChange:V=>{i.table=V},key:"bar-table",overlay:e.createVNode(Ye,{tableShape:t.tableShape,onSelected:V=>{s("table",{selectedShape:V})}},null)},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.table},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(D=r.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{h.bus.emit(a,"ctrlZ")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(F=r.value.toolbarTips)==null?void 0:F.next,onClick:()=>{h.bus.emit(a,"ctrlShiftZ")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(z=r.value.toolbarTips)==null?void 0:z.save,onClick:()=>{h.bus.emit(a,w.ON_SAVE)}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(oe=r.value.toolbarTips)==null?void 0:oe.prettier,onClick:()=>{s("prettier")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ce=r.value.toolbarTips)==null?void 0:ce.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(se=r.value.toolbarTips)==null?void 0:se.fullscreen,onClick:()=>{l()}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(de=r.value.toolbarTips)==null?void 0:de.preview,onClick:()=>{t.updateSetting("preview")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ue=r.value.toolbarTips)==null?void 0:ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(fe=r.value.toolbarTips)==null?void 0:fe.catalog,onClick:()=>{h.bus.emit(a,w.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ge=r.value.toolbarTips)==null?void 0:ge.github,onClick:()=>X.linkTo("https://github.com/imzbf/md-editor-v3")},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.mermaid,onChange:V=>{i.mermaid=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.mermaid=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("flow")}},[(me=r.value.mermaid)==null?void 0:me.flow]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("sequence")}},[(he=r.value.mermaid)==null?void 0:he.sequence]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("gantt")}},[(be=r.value.mermaid)==null?void 0:be.gantt]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("class")}},[(pe=r.value.mermaid)==null?void 0:pe.class]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("state")}},[(ve=r.value.mermaid)==null?void 0:ve.state]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("pie")}},[(ke=r.value.mermaid)==null?void 0:ke.pie]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("relationship")}},[(xe=r.value.mermaid)==null?void 0:xe.relationship]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("journey")}},[(Ce=r.value.mermaid)==null?void 0:Ce.journey])]),key:"bar-mermaid"},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.mermaid},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.katex,onChange:V=>{i.katex=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.katex=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("katexInline")}},[(Ve=r.value.katex)==null?void 0:Ve.inline]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("katexBlock")}},[(Ne=r.value.katex)==null?void 0:Ne.block])]),key:"bar-katex"},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.katex},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[b]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[b]||""};return()=>{const b=d.value[0].map(f=>k(f)),p=d.value[1].map(f=>k(f));return e.createVNode(e.Fragment,null,[t.toolbars.length>0&&e.createVNode("div",{class:`${o.prefix}-toolbar-wrapper`,id:c},[e.createVNode("div",{class:`${o.prefix}-toolbar`},[e.createVNode("div",{class:`${o.prefix}-toolbar-left`,ref:g},[b]),e.createVNode("div",{class:`${o.prefix}-toolbar-right`},[p])])]),e.createVNode("input",{ref:u,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),e.createVNode(tt,{linkVisible:m.linkVisible,clipVisible:m.clipVisible,type:m.type,onCancel:()=>{m.linkVisible=!1,m.clipVisible=!1},onOk:f=>{f&&s(m.type,{desc:f.desc,url:f.url}),m.linkVisible=!1,m.clipVisible=!1}},null)])}}}),lt=(t,a)=>{const r=X.debounce(()=>{t.removeEventListener("scroll",l),t.addEventListener("scroll",l),a.removeEventListener("scroll",l),a.addEventListener("scroll",l)},50),l=c=>{const i=t.clientHeight,s=a.clientHeight,m=t.scrollHeight,g=a.scrollHeight,d=(m-i)/(g-s);c.target===t?(a.removeEventListener("scroll",l),a.scrollTo({top:t.scrollTop/d}),r()):(t.removeEventListener("scroll",l),t.scrollTo({top:a.scrollTop*d}),r())};return[()=>{r().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",l),a.removeEventListener("scroll",l)}]},at=(t,a,r)=>{const{view:l}=r,c=v=>l.lineBlockAt(l.state.doc.line(v).from).top,i=v=>l.lineBlockAt(l.state.doc.line(v).from).height;let s=[];const m=()=>{s=[];const v=Array.from(a.querySelectorAll("[data-line]")).map(f=>Number(f.dataset.line)+1),{lines:k}=l.state.doc;let b=1,p=v.shift()??k;for(let f=1;f<=k;f++)f===p&&(b=f,p=v.shift()||k+1),s.push({start:b,end:p-1})};let g=0,d=0;const u=X.throttle(v=>{var p,f,x,N,y,$,T;if(!((p=a.firstElementChild)!=null&&p.firstElementChild))return;const k=l.lineBlockAtHeight(l.scrollDOM.scrollTop),{number:b}=l.state.doc.lineAt(k.from);if(!(b>s.length)&&!(l.state.doc.lines<s[s.length-1].end))if(v.target===t){if(d!==0)return;g++;const C=s[b-1],S=c(C.end)+i(C.end);let I=0;const M=c(C.start),A=a.querySelector(`[data-line="${C.start-1}"]`)||((f=a.firstElementChild)==null?void 0:f.firstElementChild),H=a.querySelector(`[data-line="${C.end}"]`)||((x=a.lastElementChild)==null?void 0:x.lastElementChild);let L=0,E=0;M===0?(I=(l.scrollDOM.scrollTop-M)/(S-M),L=H.offsetTop):S>l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight?(I=(l.scrollDOM.scrollTop-M)/(l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight-M),E=A.offsetTop,L=a.scrollHeight-a.clientHeight-E+10):(I=(l.scrollDOM.scrollTop-M)/(S-M),E=A.offsetTop,L=H.offsetTop-E);const P=E-10+L*I;X.smoothScroll(a,P,()=>{g--})}else{if(g!==0)return;d++;const C=Array.from(a.querySelectorAll("[data-line]")),S=a.scrollTop,I=a.scrollHeight;let M=C.length===0?1:Math.ceil(Number(C[C.length-1].dataset.line)*(S/I)),A=(N=a.firstElementChild)==null?void 0:N.firstElementChild;for(let D=M;D>=0;D--){const F=a.querySelector(`[data-line="${D}"]`);if(F){A=F,M=D;break}}let H=(y=a.firstElementChild)==null?void 0:y.firstElementChild,L=($=a.firstElementChild)==null?void 0:$.lastElementChild;for(;C.length>0;){const D=C.indexOf(A);if(D+1>=C.length)break;const F=C[D+1];if(D===-1){L=F;break}const z=A.offsetTop;if(z>S){if(D===0){H=A,L=F;break}A=C[D-1];continue}const oe=F.offsetTop;if(z<=S&&oe>S){H=A,L=F;break}A=F}const E=H.offsetTop,P=L.offsetTop;let B=0;const{start:te,end:_}=s[Number(H.dataset.line||0)],j=c(te);let O=c(_);const W=i(_);let G=0;H===((T=a.firstElementChild)==null?void 0:T.firstElementChild)?(B=Math.max(S/P,0),G=O+W-j):O>l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight?(B=Math.max((S-E)/(a.scrollHeight-E-a.clientHeight),0),O=c(l.state.doc.lines)+i(l.state.doc.lines),G=8+O-j-t.clientHeight):(B=Math.max((S-E)/(P-E),0),G=O+W-j),X.smoothScroll(t,j+G*B,()=>{d--})}},10);return[()=>{m(),t.addEventListener("scroll",u),a.addEventListener("scroll",u),t.dispatchEvent(new Event("scroll"))},()=>{s=[],t.removeEventListener("scroll",u),a.removeEventListener("scroll",u)}]},rt=(t,a,r)=>{const l=e.inject("editorId");let c=()=>{},i=()=>{};const s=()=>{c();const m=document.querySelector(".cm-scroller"),g=document.querySelector(`[id="${l}-preview-wrapper"][data-show="true"]`),d=document.querySelector(`[id="${l}-html-wrapper"][data-show="true"]`);(g||d)&&([i,c]=(g?at:lt)(m,g||d,r.value)),t.scrollAuto&&i()};e.watch([a,e.toRef(t.setting,"preview"),e.toRef(t.setting,"htmlPreview"),e.toRef(t.setting,"fullscreen"),e.toRef(t.setting,"pageFullscreen")],()=>{e.nextTick(s)}),e.watch(()=>t.scrollAuto,m=>{m?i():c()}),e.onMounted(s)},it=rt,nt=(t,a,r)=>{var u,v,k,b,p,f;let l="",c=0,i=0,s=!0,m=!1;const g=a.getSelectedText(),d=(u=o.configOption.editorConfig)==null?void 0:u.mermaidTemplate;if(/^h[1-6]{1}$/.test(t)){const x=t.replace(/^h(\d)/,(N,y)=>new Array(Number(y)).fill("#",0,y).join(""));l=`${x} ${g}`,c=x.length+1}else if(t==="prettier"){const x=window.prettier||((k=(v=o.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:k.prettierInstance),N=[((b=window.prettierPlugins)==null?void 0:b.markdown)||((f=(p=o.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.parserMarkdownInstance)];!x||N[0]===void 0?(h.bus.emit(r.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),l=a.getValue()):l=x.format(a.getValue(),{parser:"markdown",plugins:N}),s=!1,m=!0}else switch(t){case"bold":{l=`**${g}**`,c=2,i=-2;break}case"underline":{l=`<u>${g}</u>`,c=3,i=-4;break}case"italic":{l=`*${g}*`,c=1,i=-1;break}case"strikeThrough":{l=`~~${g}~~`,c=2,i=-2;break}case"sub":{l=`<sub>${g}</sub>`,c=5,i=-6;break}case"sup":{l=`<sup>${g}</sup>`,c=5,i=-6;break}case"codeRow":{l="`"+g+"`",c=1,i=-1;break}case"quote":{l=`> ${g}`,c=2;break}case"orderedList":{l=`1. ${g}`,c=3;break}case"unorderedList":{l=`- ${g}`,c=2;break}case"task":{l=`- [ ] ${g}`,c=6;break}case"code":{const x=r.text||g||"",N=r.mode||"language";l=`\`\`\`${N}
1
+ "use strict";var Oe=Object.defineProperty;var Re=(t,a,r)=>a in t?Oe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r;var R=(t,a,r)=>(Re(t,typeof a!="symbol"?a+"":a,r),r);const e=require("vue"),o=require("./chunks/config.cjs"),K=require("./chunks/index2.cjs"),h=require("./chunks/index4.cjs"),X=require("@vavt/util"),T=require("./chunks/index.cjs"),qe=require("./chunks/dom.cjs"),ne=require("./chunks/index3.cjs"),Y=require("codemirror"),Q=require("@codemirror/view"),Pe=require("@codemirror/language-data"),je=require("@codemirror/lang-markdown"),le=require("@codemirror/commands"),ee=require("@codemirror/language"),n=require("@lezer/highlight"),q=require("@codemirror/state"),$e=require("./chunks/vue-tsx.cjs"),Be=require("./MdCatalog.cjs"),Ge=require("./NormalToolbar.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 Ue=e.defineComponent({setup(){return()=>e.createVNode("div",{class:`${o.prefix}-divider`},null)}}),Ke={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}},_e=t=>{var g,d,u,v;const a=e.inject("editorId");let r=(d=(g=o.configOption.editorExtensions)==null?void 0:g.screenfull)==null?void 0:d.instance;const l=(v=(u=o.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:v.js,c=e.ref(!1),i=k=>{if(!r){h.bus.emit(a,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}r.isEnabled?(c.value=!0,(k===void 0?!r.isFullscreen:k)?r.request():r.exit()):console.error("browser does not support screenfull!")},s=()=>{r&&r.isEnabled&&r.on("change",()=>{(c.value||t.setting.fullscreen)&&(c.value=!1,t.updateSetting("fullscreen"))})},m=()=>{r=window.screenfull,s()};return e.onMounted(()=>{if(s(),!r){const k=document.createElement("script");k.src=l||o.screenfullUrl,k.onload=m,k.id=`${o.prefix}-screenfull`,qe.appendHandler(k,"screenfull")}}),e.onMounted(()=>{h.bus.on(a,{name:T.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},We={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},ze=e.defineComponent({name:"TableShape",props:We,setup(t){const a=e.reactive({x:-1,y:-1});return()=>e.createVNode("div",{class:`${o.prefix}-table-shape`,onMouseleave:()=>{a.x=-1,a.y=-1}},[new Array(t.tableShape[1]).fill("").map((r,l)=>e.createVNode("div",{class:`${o.prefix}-table-shape-row`,key:`table-shape-row-${l}`},[new Array(t.tableShape[0]).fill("").map((c,i)=>e.createVNode("div",{class:`${o.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{a.x=l,a.y=i},onClick:()=>{t.onSelected(a)}},[e.createVNode("div",{class:[`${o.prefix}-table-shape-col-default`,l<=a.x&&i<=a.y&&`${o.prefix}-table-shape-col-include`]},null)]))]))])}}),Ye=ze,Ze={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Je=e.defineComponent({props:Ze,setup(t){const a=e.inject("usedLanguageText"),r=e.inject("editorId"),l=e.computed(()=>{var i,s;switch(t.type){case"link":return(i=a.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(s=a.value.linkModalTips)==null?void 0:s.imageTitle;default:return""}}),c=e.reactive({desc:"",url:""});return e.watch(()=>t.visible,i=>{i||setTimeout(()=>{c.desc="",c.url=""},200)}),()=>e.createVNode(ne.Modal,{title:l.value,visible:t.visible,onClose:t.onCancel},{default:()=>{var i,s,m,g,d;return[e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("label",{class:`${o.prefix}-label`,for:`link-desc-${r}`},[(i=a.value.linkModalTips)==null?void 0:i.descLabel]),e.createVNode("input",{placeholder:(s=a.value.linkModalTips)==null?void 0:s.descLabelPlaceHolder,class:`${o.prefix}-input`,id:`link-desc-${r}`,type:"text",value:c.desc,onChange:u=>{c.desc=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("label",{class:`${o.prefix}-label`,for:`link-url-${r}`},[(m=a.value.linkModalTips)==null?void 0:m.urlLabel]),e.createVNode("input",{placeholder:(g=a.value.linkModalTips)==null?void 0:g.urlLabelPlaceHolder,class:`${o.prefix}-input`,id:`link-url-${r}`,type:"text",value:c.url,onChange:u=>{c.url=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("button",{class:[`${o.prefix}-btn`,`${o.prefix}-btn-row`],type:"button",onClick:()=>{t.onOk(c),c.desc="",c.url=""}},[(d=a.value.linkModalTips)==null?void 0:d.buttonOK])])]}})}}),Xe={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Qe=e.defineComponent({props:Xe,setup(t){var u,v,k;const a=e.inject("usedLanguageText"),r=e.inject("editorId");let l=(k=(v=(u=o.configOption)==null?void 0:u.editorExtensions)==null?void 0:v.cropper)==null?void 0:k.instance;const c=e.ref(),i=e.ref(),s=e.ref(),m=e.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let g=null;e.watch(()=>t.visible,()=>{t.visible&&!m.cropperInited&&(l=l||window.Cropper,c.value.onchange=()=>{if(!l){h.bus.emit(r,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const b=c.value.files||[];if(m.imgSelected=!0,(b==null?void 0:b.length)>0){const p=new FileReader;p.onload=f=>{m.imgSrc=f.target.result,e.nextTick(()=>{g=new l(i.value,{viewMode:2,preview:`.${o.prefix}-clip-preview-target`})})},p.readAsDataURL(b[0])}})}),e.watch(()=>[m.imgSelected],()=>{s.value.style=""}),e.watch(()=>m.isFullscreen,()=>{e.nextTick(()=>{g==null||g.destroy(),s.value.style="",i.value&&(g=new l(i.value,{viewMode:2,preview:`.${o.prefix}-clip-preview-target`}))})});const d=()=>{g.clear(),g.destroy(),g=null,c.value.value="",m.imgSelected=!1};return()=>{var b;return e.createVNode(ne.Modal,{class:`${o.prefix}-modal-clip`,title:(b=a.value.clipModalTips)==null?void 0:b.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:m.isFullscreen,onAdjust:p=>{m.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,f;return[e.createVNode("div",{class:`${o.prefix}-form-item ${o.prefix}-clip`},[e.createVNode("div",{class:`${o.prefix}-clip-main`},[m.imgSelected?e.createVNode("div",{class:`${o.prefix}-clip-cropper`},[e.createVNode("img",{src:m.imgSrc,ref:i,style:{display:"none"},alt:""},null),e.createVNode("div",{class:`${o.prefix}-clip-delete`,onClick:d},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):e.createVNode("div",{class:`${o.prefix}-clip-upload`,onClick:()=>{c.value.click()}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),e.createVNode("div",{class:`${o.prefix}-clip-preview`},[e.createVNode("div",{class:`${o.prefix}-clip-preview-target`,ref:s},null)])]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("button",{class:`${o.prefix}-btn`,type:"button",onClick:()=>{if(g){const x=g.getCroppedCanvas();h.bus.emit(r,"uploadImage",[h.base642File(x.toDataURL("image/png"))],t.onOk),d()}}},[((p=a.value.clipModalTips)==null?void 0:p.buttonUpload)||((f=a.value.linkModalTips)==null?void 0:f.buttonOK)])]),e.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),et={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},tt=e.defineComponent({props:et,setup(t){return()=>e.createVNode(e.Fragment,null,[e.createVNode(Je,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),e.createVNode(Qe,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),ot=e.defineComponent({name:"MDEditorToolbar",props:Ke,setup(t){const a=e.inject("editorId"),r=e.inject("usedLanguageText"),{fullscreenHandler:l}=_e(t),c=`${a}-toolbar-wrapper`,i=e.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),s=(b,p)=>{h.bus.emit(a,"replace",b,p)},m=e.reactive({type:"link",linkVisible:!1,clipVisible:!1}),g=e.ref();e.onMounted(()=>{h.bus.on(a,{name:"openModals",callback(b){m.type=b,m.linkVisible=!0}})});const d=e.computed(()=>{const b=t.toolbars.filter(N=>!t.toolbarsExclude.includes(N)),p=b.indexOf("="),f=p===-1?b:b.slice(0,p+1),x=p===-1?[]:b.slice(p,Number.MAX_SAFE_INTEGER);return[f,x]}),u=e.ref(),v=()=>{h.bus.emit(a,"uploadImage",Array.from(u.value.files||[])),u.value.value=""};e.onMounted(()=>{u.value.addEventListener("change",v)});const k=b=>{var p,f,x,N,y,$,S,C,w,I,M,A,F,L,E,P,B,te,_,j,O,W,G,D,H,z,oe,ce,se,de,ue,fe,ge,me,he,be,pe,ve,ke,xe,Ce,Ve,Ne;if(o.allToolbar.includes(b))switch(b){case"-":return e.createVNode(Ue,null,null);case"bold":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(p=r.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{s("bold")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(f=r.value.toolbarTips)==null?void 0:f.underline,onClick:()=>{s("underline")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(x=r.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{s("italic")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(N=r.value.toolbarTips)==null?void 0:N.strikeThrough,onClick:()=>{s("strikeThrough")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.title,onChange:V=>{i.title=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h1")}},[(y=r.value.titleItem)==null?void 0:y.h1]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h2")}},[($=r.value.titleItem)==null?void 0:$.h2]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h3")}},[(S=r.value.titleItem)==null?void 0:S.h3]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h4")}},[(C=r.value.titleItem)==null?void 0:C.h4]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h5")}},[(w=r.value.titleItem)==null?void 0:w.h5]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h6")}},[(I=r.value.titleItem)==null?void 0:I.h6])])},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.title},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(M=r.value.toolbarTips)==null?void 0:M.sub,onClick:()=>{s("sub")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(A=r.value.toolbarTips)==null?void 0:A.sup,onClick:()=>{s("sup")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(F=r.value.toolbarTips)==null?void 0:F.quote,onClick:()=>{s("quote")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(L=r.value.toolbarTips)==null?void 0:L.unorderedList,onClick:()=>{s("unorderedList")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(E=r.value.toolbarTips)==null?void 0:E.orderedList,onClick:()=>{s("orderedList")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(P=r.value.toolbarTips)==null?void 0:P.task,onClick:()=>{s("task")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(B=r.value.toolbarTips)==null?void 0:B.codeRow,onClick:()=>{s("codeRow")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(te=r.value.toolbarTips)==null?void 0:te.code,onClick:()=>{s("code")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(_=r.value.toolbarTips)==null?void 0:_.link,onClick:()=>{m.type="link",m.linkVisible=!0}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(j=r.value.toolbarTips)==null?void 0:j.image,onClick:()=>{m.type="image",m.linkVisible=!0}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.image,onChange:V=>{i.image=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{m.type="image",m.linkVisible=!0}},[(O=r.value.imgTitleItem)==null?void 0:O.link]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{u.value.click()}},[(W=r.value.imgTitleItem)==null?void 0:W.upload]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{m.clipVisible=!0}},[(G=r.value.imgTitleItem)==null?void 0:G.clip2upload])])},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.image},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.table,onChange:V=>{i.table=V},key:"bar-table",overlay:e.createVNode(Ye,{tableShape:t.tableShape,onSelected:V=>{s("table",{selectedShape:V})}},null)},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.table},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(D=r.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{h.bus.emit(a,"ctrlZ")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(H=r.value.toolbarTips)==null?void 0:H.next,onClick:()=>{h.bus.emit(a,"ctrlShiftZ")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(z=r.value.toolbarTips)==null?void 0:z.save,onClick:()=>{h.bus.emit(a,T.ON_SAVE)}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(oe=r.value.toolbarTips)==null?void 0:oe.prettier,onClick:()=>{s("prettier")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ce=r.value.toolbarTips)==null?void 0:ce.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(se=r.value.toolbarTips)==null?void 0:se.fullscreen,onClick:()=>{l()}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(de=r.value.toolbarTips)==null?void 0:de.preview,onClick:()=>{t.updateSetting("preview")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ue=r.value.toolbarTips)==null?void 0:ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(fe=r.value.toolbarTips)==null?void 0:fe.catalog,onClick:()=>{h.bus.emit(a,T.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ge=r.value.toolbarTips)==null?void 0:ge.github,onClick:()=>X.linkTo("https://github.com/imzbf/md-editor-v3")},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.mermaid,onChange:V=>{i.mermaid=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.mermaid=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("flow")}},[(me=r.value.mermaid)==null?void 0:me.flow]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("sequence")}},[(he=r.value.mermaid)==null?void 0:he.sequence]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("gantt")}},[(be=r.value.mermaid)==null?void 0:be.gantt]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("class")}},[(pe=r.value.mermaid)==null?void 0:pe.class]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("state")}},[(ve=r.value.mermaid)==null?void 0:ve.state]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("pie")}},[(ke=r.value.mermaid)==null?void 0:ke.pie]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("relationship")}},[(xe=r.value.mermaid)==null?void 0:xe.relationship]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("journey")}},[(Ce=r.value.mermaid)==null?void 0:Ce.journey])]),key:"bar-mermaid"},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.mermaid},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.katex,onChange:V=>{i.katex=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.katex=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("katexInline")}},[(Ve=r.value.katex)==null?void 0:Ve.inline]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("katexBlock")}},[(Ne=r.value.katex)==null?void 0:Ne.block])]),key:"bar-katex"},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.katex},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[b]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[b]||""};return()=>{const b=d.value[0].map(f=>k(f)),p=d.value[1].map(f=>k(f));return e.createVNode(e.Fragment,null,[t.toolbars.length>0&&e.createVNode("div",{class:`${o.prefix}-toolbar-wrapper`,id:c},[e.createVNode("div",{class:`${o.prefix}-toolbar`},[e.createVNode("div",{class:`${o.prefix}-toolbar-left`,ref:g},[b]),e.createVNode("div",{class:`${o.prefix}-toolbar-right`},[p])])]),e.createVNode("input",{ref:u,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),e.createVNode(tt,{linkVisible:m.linkVisible,clipVisible:m.clipVisible,type:m.type,onCancel:()=>{m.linkVisible=!1,m.clipVisible=!1},onOk:f=>{f&&s(m.type,{desc:f.desc,url:f.url}),m.linkVisible=!1,m.clipVisible=!1}},null)])}}}),lt=(t,a)=>{const r=X.debounce(()=>{t.removeEventListener("scroll",l),t.addEventListener("scroll",l),a.removeEventListener("scroll",l),a.addEventListener("scroll",l)},50),l=c=>{const i=t.clientHeight,s=a.clientHeight,m=t.scrollHeight,g=a.scrollHeight,d=(m-i)/(g-s);c.target===t?(a.removeEventListener("scroll",l),a.scrollTo({top:t.scrollTop/d}),r()):(t.removeEventListener("scroll",l),t.scrollTo({top:a.scrollTop*d}),r())};return[()=>{r().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",l),a.removeEventListener("scroll",l)}]},at=(t,a,r)=>{const{view:l}=r,c=v=>l.lineBlockAt(l.state.doc.line(v).from).top,i=v=>l.lineBlockAt(l.state.doc.line(v).from).height;let s=[];const m=()=>{s=[];const v=Array.from(a.querySelectorAll("[data-line]")).map(f=>Number(f.dataset.line)+1),{lines:k}=l.state.doc;let b=1,p=v.shift()??k;for(let f=1;f<=k;f++)f===p&&(b=f,p=v.shift()||k+1),s.push({start:b,end:p-1})};let g=0,d=0;const u=X.throttle(v=>{var p,f,x,N,y,$,S;if(!((p=a.firstElementChild)!=null&&p.firstElementChild))return;const k=l.lineBlockAtHeight(l.scrollDOM.scrollTop),{number:b}=l.state.doc.lineAt(k.from);if(!(b>s.length)&&!(l.state.doc.lines<s[s.length-1].end))if(v.target===t){if(d!==0)return;g++;const C=s[b-1],w=c(C.end)+i(C.end);let I=0;const M=c(C.start),A=a.querySelector(`[data-line="${C.start-1}"]`)||((f=a.firstElementChild)==null?void 0:f.firstElementChild),F=a.querySelector(`[data-line="${C.end}"]`)||((x=a.lastElementChild)==null?void 0:x.lastElementChild);let L=0,E=0;M===0?(I=(l.scrollDOM.scrollTop-M)/(w-M),L=F.offsetTop):w>l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight?(I=(l.scrollDOM.scrollTop-M)/(l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight-M),E=A.offsetTop,L=a.scrollHeight-a.clientHeight-E+10):(I=(l.scrollDOM.scrollTop-M)/(w-M),E=A.offsetTop,L=F.offsetTop-E);const P=E-10+L*I;X.smoothScroll(a,P,()=>{g--})}else{if(g!==0)return;d++;const C=Array.from(a.querySelectorAll("[data-line]")),w=a.scrollTop,I=a.scrollHeight;let M=C.length===0?1:Math.ceil(Number(C[C.length-1].dataset.line)*(w/I)),A=(N=a.firstElementChild)==null?void 0:N.firstElementChild;for(let D=M;D>=0;D--){const H=a.querySelector(`[data-line="${D}"]`);if(H&&H.offsetTop<=w){A=H,M=D;break}}let F=(y=a.firstElementChild)==null?void 0:y.firstElementChild,L=($=a.firstElementChild)==null?void 0:$.lastElementChild;for(;C.length>0;){const D=C.indexOf(A);if(D+1>=C.length)break;const H=C[D+1];if(D===-1){L=H;break}const z=A.offsetTop;if(z>w){if(D===0){F=A,L=H;break}A=C[D-1];continue}const oe=H.offsetTop;if(z<=w&&oe>w){F=A,L=H;break}A=H}const E=F.offsetTop,P=L.offsetTop;let B=0;const{start:te,end:_}=s[Number(F.dataset.line||0)],j=c(te);let O=c(_);const W=i(_);let G=0;F===((S=a.firstElementChild)==null?void 0:S.firstElementChild)?(B=Math.max(w/P,0),G=O+W-j):O>l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight?(B=Math.max((w-E)/(a.scrollHeight-E-a.clientHeight),0),O=c(l.state.doc.lines)+i(l.state.doc.lines),G=8+O-j-t.clientHeight):(B=Math.max((w-E)/(P-E),0),G=O+W-j),X.smoothScroll(t,j+G*B,()=>{d--})}},10);return[()=>{m(),t.addEventListener("scroll",u),a.addEventListener("scroll",u),t.dispatchEvent(new Event("scroll"))},()=>{s=[],t.removeEventListener("scroll",u),a.removeEventListener("scroll",u)}]},rt=(t,a,r)=>{const l=e.inject("editorId");let c=()=>{},i=()=>{};const s=()=>{c();const m=document.querySelector(".cm-scroller"),g=document.querySelector(`[id="${l}-preview-wrapper"][data-show="true"]`),d=document.querySelector(`[id="${l}-html-wrapper"][data-show="true"]`);(g||d)&&([i,c]=(g?at:lt)(m,g||d,r.value)),t.scrollAuto&&i()};e.watch([a,e.toRef(t.setting,"preview"),e.toRef(t.setting,"htmlPreview"),e.toRef(t.setting,"fullscreen"),e.toRef(t.setting,"pageFullscreen")],()=>{e.nextTick(s)}),e.watch(()=>t.scrollAuto,m=>{m?i():c()}),e.onMounted(s)},it=rt,nt=(t,a,r)=>{var u,v,k,b,p,f;let l="",c=0,i=0,s=!0,m=!1;const g=a.getSelectedText(),d=(u=o.configOption.editorConfig)==null?void 0:u.mermaidTemplate;if(/^h[1-6]{1}$/.test(t)){const x=t.replace(/^h(\d)/,(N,y)=>new Array(Number(y)).fill("#",0,y).join(""));l=`${x} ${g}`,c=x.length+1}else if(t==="prettier"){const x=window.prettier||((k=(v=o.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:k.prettierInstance),N=[((b=window.prettierPlugins)==null?void 0:b.markdown)||((f=(p=o.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.parserMarkdownInstance)];!x||N[0]===void 0?(h.bus.emit(r.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),l=a.getValue()):l=x.format(a.getValue(),{parser:"markdown",plugins:N}),s=!1,m=!0}else switch(t){case"bold":{l=`**${g}**`,c=2,i=-2;break}case"underline":{l=`<u>${g}</u>`,c=3,i=-4;break}case"italic":{l=`*${g}*`,c=1,i=-1;break}case"strikeThrough":{l=`~~${g}~~`,c=2,i=-2;break}case"sub":{l=`<sub>${g}</sub>`,c=5,i=-6;break}case"sup":{l=`<sup>${g}</sup>`,c=5,i=-6;break}case"codeRow":{l="`"+g+"`",c=1,i=-1;break}case"quote":{l=`> ${g}`,c=2;break}case"orderedList":{l=`1. ${g}`,c=3;break}case"unorderedList":{l=`- ${g}`,c=2;break}case"task":{l=`- [ ] ${g}`,c=6;break}case"code":{const x=r.text||g||"",N=r.mode||"language";l=`\`\`\`${N}
2
2
  ${x}
3
3
  \`\`\`
4
4
  `,c=3,i=3+N.length-l.length;break}case"table":{l="|";const{selectedShape:x={x:1,y:1}}=r,{x:N,y}=x;for(let $=0;$<=y;$++)l+=" col |";l+=`
5
5
  |`;for(let $=0;$<=y;$++)l+=" - |";for(let $=0;$<=N;$++){l+=`
6
- |`;for(let T=0;T<=y;T++)l+=" content |"}c=2,i=5-l.length;break}case"link":{const{desc:x,url:N}=r;l=`[${x}](${N})`,s=!1;break}case"image":{const{desc:x,url:N,urls:y}=r;y instanceof Array?l=y.reduce(($,T)=>$+`![${x}](${T})
6
+ |`;for(let S=0;S<=y;S++)l+=" content |"}c=2,i=5-l.length;break}case"link":{const{desc:x,url:N}=r;l=`[${x}](${N})`,s=!1;break}case"image":{const{desc:x,url:N,urls:y}=r;y instanceof Array?l=y.reduce(($,S)=>$+`![${x}](${S})
7
7
  `,""):l=`![${x}](${N})
8
8
  `,s=!1;break}case"flow":{l=`\`\`\`mermaid
9
9
  ${(d==null?void 0:d.flow)||`flowchart TD
@@ -57,4 +57,4 @@ ${(d==null?void 0:d.journey)||`journey
57
57
  `,c=3,i=10-l.length;break}case"katexInline":{l="$$",c=1,i=-1;break}case"katexBlock":{l=`$$
58
58
 
59
59
  $$
60
- `,c=3,i=-4;break}case"universal":{const{generate:x}=r,N=x(g);l=N.targetValue,s=N.select,c=N.deviationStart,i=N.deviationEnd}}return{text:l,options:{select:s,deviationStart:c,deviationEnd:i,replaceAll:m}}},ct="#e5c07b",ye="var(--md-color)",st="#56b6c2",dt="#ffffff",Z="var(--md-color)",we="#e5c07b",ut="#e5c07b",ft="var(--md-color)",Te="#d19a66",gt="#c678dd",mt="#21252b",Se="#2c313a",Me="var(--md-bk-color)",re="#353a42",ht="#ceedfa33",Ae="#528bff",bt=Q.EditorView.theme({"&":{color:Z,backgroundColor:Me},".cm-content":{caretColor:Ae},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ae},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ht},".cm-panels":{backgroundColor:mt,color:Z},".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:Me,color:Z,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Se},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:re},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:re,borderBottomColor:re},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Se,color:Z}}},{dark:!0}),pt=ee.HighlightStyle.define([{tag:n.tags.keyword,color:gt},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:ye},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:ut},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Te},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:Z},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:ct},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:st},{tag:[n.tags.meta,n.tags.comment],color:we},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:we,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:ye},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Te},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:ft},{tag:n.tags.invalid,color:dt}]),vt=[bt,ee.syntaxHighlighting(pt)],kt="#e5c07b",Ee="#3f4a54",xt="#56b6c2",Ct="#fff",J="#3f4a54",De="#2d8cf0",Vt="#2d8cf0",Nt="#3f4a54",Le="#d19a66",$t="#c678dd",yt="#21252b",He="#ceedfa33",Fe="var(--md-bk-color)",ie="#353a42",wt="#bad5fa",Ie="#3f4a54",Tt=Q.EditorView.theme({"&":{color:J,backgroundColor:Fe},".cm-content":{caretColor:Ie},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ie},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:wt},".cm-panels":{backgroundColor:yt,color:J},".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:Fe,color:J,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:He},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ie},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ie,borderBottomColor:ie},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:He,color:J}}},{dark:!0}),St=ee.HighlightStyle.define([{tag:n.tags.keyword,color:$t},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:Ee},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:Vt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Le},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:J},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:kt},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:xt},{tag:[n.tags.meta,n.tags.comment],color:De},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:De,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:Ee},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Le},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:Nt},{tag:n.tags.invalid,color:Ct}]),Mt=[Tt,ee.syntaxHighlighting(St)],U=t=>{const a=new q.Compartment;return l=>(a.get(t.state)?t.dispatch({effects:a.reconfigure(l)}):t.dispatch({effects:q.StateEffect.appendConfig.of(a.of(l))}),!0)};class At{constructor(a){R(this,"view");R(this,"toggleTabSize");R(this,"togglePlaceholder");R(this,"setExtensions");R(this,"toggleDisabled");R(this,"toggleReadOnly");R(this,"toggleMaxlength");this.view=a,this.toggleTabSize=U(this.view),this.togglePlaceholder=U(this.view),this.setExtensions=U(this.view),this.toggleDisabled=U(this.view),this.toggleReadOnly=U(this.view),this.toggleMaxlength=U(this.view)}getValue(){return this.view.state.doc.toString()}setValue(a,r=0,l=this.view.state.doc.length){this.view.dispatch({changes:{from:r,to:l,insert:a}})}getSelectedText(){const{from:a,to:r}=this.view.state.selection.main;return this.view.state.sliceDoc(a,r)}replaceSelectedText(a,r={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1}){if(r.replaceAll){this.setValue(a);return}const{from:l}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(a)),r.select){const c=l+a.length+r.deviationEnd;this.view.dispatch({selection:q.EditorSelection.create([q.EditorSelection.range(l+r.deviationStart,c),q.EditorSelection.cursor(c)],1)}),this.view.focus()}}setTabSize(a){this.toggleTabSize([q.EditorState.tabSize.of(a),ee.indentUnit.of(" ".repeat(a))])}setPlaceholder(a){this.togglePlaceholder(Q.placeholder(a))}focus(){this.view.focus()}setDisabled(a){this.toggleDisabled([Q.EditorView.editable.of(!a)])}setReadOnly(a){this.toggleReadOnly([q.EditorState.readOnly.of(a)])}setMaxLength(a){this.toggleMaxlength([q.EditorState.changeFilter.of(r=>r.newDoc.length<=a)])}}const Et=t=>{const a=e.inject("editorId");return l=>{if(l.clipboardData){if(l.clipboardData.files.length>0){const{files:c}=l.clipboardData;h.bus.emit(a,"uploadImage",Array.from(c).filter(i=>/image\/.*/.test(i.type))),l.preventDefault()}if(t.autoDetectCode&&l.clipboardData.types.includes("vscode-editor-data")){const c=JSON.parse(l.clipboardData.getData("vscode-editor-data"));h.bus.emit(a,"replace","code",{mode:c.mode,text:l.clipboardData.getData("text/plain")}),l.preventDefault()}}}},Dt=Et,Lt=t=>{const a=e.inject("editorId");e.onMounted(()=>{h.bus.on(a,{name:w.TEXTAREA_FOCUS,callback(){var r;(r=t.value)==null||r.focus()}})})},Ht=Lt,Ft=(t,a)=>{const r={key:"Ctrl-b",mac:"Cmd-b",run:()=>(h.bus.emit(t,"replace","bold"),!0)},l={key:"Ctrl-s",mac:"Cmd-s",run:T=>(h.bus.emit(t,w.ON_SAVE,T.state.doc.toString()),!0),shift:()=>(h.bus.emit(t,"replace","strikeThrough"),!0)},c={key:"Ctrl-u",mac:"Cmd-u",run:()=>(h.bus.emit(t,"replace","underline"),!0),shift:()=>(h.bus.emit(t,"replace","unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(h.bus.emit(t,"replace","italic"),!0),shift:()=>(h.bus.emit(t,"openModals","image"),!0)},s={key:"Ctrl-1",mac:"Cmd-1",run:()=>(h.bus.emit(t,"replace","h1"),!0)},m={key:"Ctrl-2",mac:"Cmd-2",run:()=>(h.bus.emit(t,"replace","h2"),!0)},g={key:"Ctrl-3",mac:"Cmd-3",run:()=>(h.bus.emit(t,"replace","h3"),!0)},d={key:"Ctrl-4",mac:"Cmd-4",run:()=>(h.bus.emit(t,"replace","h4"),!0)},u={key:"Ctrl-5",mac:"Cmd-5",run:()=>(h.bus.emit(t,"replace","h5"),!0)},v={key:"Ctrl-6",mac:"Cmd-6",run:()=>(h.bus.emit(t,"replace","h6"),!0)},k={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(h.bus.emit(t,"replace","sup"),!0)},b={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(h.bus.emit(t,"replace","sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(h.bus.emit(t,"replace","orderedList"),!0)},f={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(h.bus.emit(t,"replace","code"),!0),any(T,C){return(C.ctrlKey||C.metaKey)&&C.altKey&&C.code==="KeyC"?(h.bus.emit(t,"replace","codeRow"),!0):!1}},x={key:"Ctrl-l",mac:"Cmd-l",run:()=>(h.bus.emit(t,"openModals","link"),!0)},N={key:"Ctrl-f",mac:"Cmd-f",shift:()=>a.noPrettier?!1:(h.bus.emit(t,"replace","prettier"),!0)},y={any:(T,C)=>(C.ctrlKey||C.metaKey)&&C.altKey&&C.shiftKey&&C.code==="KeyT"?(h.bus.emit(t,"replace","table"),!0):!1},$={key:"Ctrl-d",mac:"Cmd-d",run:le.deleteLine,preventDefault:!0};return[r,$,l,c,i,s,m,g,d,u,v,k,b,p,f,x,N,y]},It=Ft,Bt=t=>{const a=e.inject("tabWidth"),r=e.inject("editorId"),l=e.inject("theme"),c=e.ref(),i=e.shallowRef(),s=It(r,t),m=Dt(t),g=[Q.keymap.of([...s,le.indentWithTab]),Y.minimalSetup,je.markdown({codeLanguages:Pe.languages}),Y.EditorView.lineWrapping,Y.EditorView.updateListener.of(u=>{u.docChanged&&t.onChange(u.state.doc.toString())}),Y.EditorView.domEventHandlers({paste:m,blur:t.onBlur,focus:t.onFocus})],d=()=>l.value==="light"?o.configOption.codeMirrorExtensions(l.value,[...g,Mt],[...s]):o.configOption.codeMirrorExtensions(l.value,[...g,vt],[...s]);return e.onMounted(()=>{const u=new Y.EditorView({doc:t.value,parent:c.value});i.value=new At(u),i.value.setTabSize(a),i.value.setExtensions(d()),i.value.setDisabled(t.disabled),i.value.setReadOnly(t.readonly),t.placeholder&&i.value.setPlaceholder(t.placeholder),t.autofocus&&u.focus(),t.maxlength&&i.value.setMaxLength(t.maxlength),h.bus.on(r,{name:"ctrlZ",callback(){le.undo(u)}}),h.bus.on(r,{name:"ctrlShiftZ",callback(){le.redo(u)}}),h.bus.on(r,{name:"replace",callback(v,k={}){var f;const{text:b,options:p}=nt(v,i.value,k);(f=i.value)==null||f.replaceSelectedText(b,p)}})}),e.watch(()=>l.value,()=>{var u,v;l.value==="dark"?(u=i.value)==null||u.setExtensions(d()):(v=i.value)==null||v.setExtensions(d())}),e.watch(()=>t.value,()=>{var u,v;((u=i.value)==null?void 0:u.getValue())!==t.value&&((v=i.value)==null||v.setValue(t.value))}),e.watch(()=>t.placeholder,()=>{var u;(u=i.value)==null||u.setPlaceholder(t.placeholder)}),e.watch(()=>t.disabled,()=>{var u;(u=i.value)==null||u.setDisabled(t.disabled)}),e.watch(()=>t.readonly,()=>{var u;(u=i.value)==null||u.setDisabled(t.readonly)}),e.watch(()=>t.maxlength,()=>{var u;t.maxlength&&((u=i.value)==null||u.setMaxLength(t.maxlength))}),Ht(i),{inputWrapperRef:c,codeMirrorUt:i}},Ot=Bt,Rt={value:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:t=>t},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:t=>t},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},noHighlight:{type:Boolean,default:!1}},qt=e.defineComponent({name:"MDEditorContent",props:Rt,setup(t){const a=e.ref(""),{inputWrapperRef:r,codeMirrorUt:l}=Ot(t);return it(t,a,l),()=>e.createVNode("div",{class:`${o.prefix}-content`},[e.createVNode("div",{class:`${o.prefix}-input-wrapper`,ref:r},null),e.createVNode(w.ContentPreview,{modelValue:t.value,setting:t.setting,onHtmlChanged:c=>{a.value=c,t.onHtmlChanged(c)},onGetCatalog:t.onGetCatalog,mdHeadingId:t.mdHeadingId,noMermaid:t.noMermaid,sanitize:t.sanitize,noKatex:t.noKatex,formatCopiedText:t.formatCopiedText,noHighlight:t.noHighlight},null)])}}),Pt=e.defineComponent({props:{modelValue:{type:String,default:""}},setup(t){const a=e.inject("usedLanguageText");return()=>{var r,l;return e.createVNode("div",{class:`${o.prefix}-footer-item`},[e.createVNode("label",{class:`${o.prefix}-footer-label`},[`${(r=a.value.footer)==null?void 0:r.markdownTotal}:`]),e.createVNode("span",null,[((l=t.modelValue)==null?void 0:l.length)||0])])}}}),jt={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Gt=e.defineComponent({props:jt,setup(t){return()=>e.createVNode("div",{class:[`${o.prefix}-checkbox`,t.checked&&`${o.prefix}-checkbox-checked`],onClick:()=>{t.onChange(!t.checked)}},null)}}),Ut={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},Kt=e.defineComponent({props:Ut,setup(t){const a=e.inject("usedLanguageText");return()=>{var r;return e.createVNode("div",{class:`${o.prefix}-footer-item`},[e.createVNode("label",{class:`${o.prefix}-footer-label`,onClick:()=>{t.onScrollAutoChange(!t.scrollAuto)}},[(r=a.value.footer)==null?void 0:r.scrollAuto]),e.createVNode(Gt,{checked:t.scrollAuto,onChange:t.onScrollAutoChange},null)])}}}),_t={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},Wt=e.defineComponent({name:"MDEditorFooter",props:_t,setup(t){const a=e.computed(()=>{const l=t.footers.indexOf("="),c=l===-1?t.footers:t.footers.slice(0,l),i=l===-1?[]:t.footers.slice(l,Number.MAX_SAFE_INTEGER);return[c,i]}),r=l=>{if(o.allFooter.includes(l))switch(l){case"markdownTotal":return e.createVNode(Pt,{modelValue:t.modelValue},null);case"scrollSwitch":return e.createVNode(Kt,{scrollAuto:t.scrollAuto,onScrollAutoChange:t.onScrollAutoChange},null)}else return t.defFooters instanceof Array?t.defFooters[l]||"":t.defFooters&&t.defFooters.children instanceof Array&&t.defFooters.children[l]||""};return()=>{const l=a.value[0].map(i=>r(i)),c=a.value[1].map(i=>r(i));return e.createVNode("div",{class:`${o.prefix}-footer`},[e.createVNode("div",{class:`${o.prefix}-footer-left`},[l]),e.createVNode("div",{class:`${o.prefix}-footer-right`},[c])])}}}),zt=e.defineComponent({name:"MdEditorV3",props:w.editorProps,emits:w.editorEmits,setup(t,a){const{editorId:r,noKatex:l,noMermaid:c,noPrettier:i,noUploadImg:s,noHighlight:m}=t,g=e.reactive({scrollAuto:t.scrollAuto});w.useOnSave(t,a),w.useProvide(t),w.useExpansion(t);const[d,u]=w.useConfig(t,a),v=w.useCatalog(t);return e.onBeforeUnmount(()=>{h.bus.clear(r)}),w.useExpose(t,a,v,d,u),()=>{var p;const k=$e.getSlot({props:t,ctx:a},"defToolbars"),b=$e.getSlot({props:t,ctx:a},"defFooters");return e.createVNode("div",{id:r,class:[o.prefix,t.class,t.theme==="dark"&&`${o.prefix}-dark`,d.fullscreen||d.pageFullscreen?`${o.prefix}-fullscreen`:""],style:t.style},[e.createVNode(ot,{noPrettier:i,toolbars:t.toolbars,toolbarsExclude:t.toolbarsExclude,setting:d,updateSetting:u,tableShape:t.tableShape,defToolbars:k,noUploadImg:s},null),e.createVNode(qt,{value:t.modelValue,setting:d,mdHeadingId:t.mdHeadingId,noMermaid:c,noPrettier:i,sanitize:t.sanitize,placeholder:t.placeholder,noKatex:l,scrollAuto:g.scrollAuto,formatCopiedText:t.formatCopiedText,autofocus:t.autoFocus,disabled:t.disabled,readonly:t.readOnly,maxlength:t.maxLength,autoDetectCode:t.autoDetectCode,noHighlight:m,onChange:f=>{t.onChange?t.onChange(f):(a.emit("update:modelValue",f),a.emit("onChange",f))},onHtmlChanged:f=>{t.onHtmlChanged?t.onHtmlChanged(f):a.emit("onHtmlChanged",f)},onGetCatalog:f=>{t.onGetCatalog?t.onGetCatalog(f):a.emit("onGetCatalog",f)},onBlur:f=>{t.onBlur?t.onBlur(f):a.emit("onBlur",f)},onFocus:f=>{t.onFocus?t.onFocus(f):a.emit("onFocus",f)}},null),((p=t.footers)==null?void 0:p.length)>0&&e.createVNode(Wt,{modelValue:t.modelValue,footers:t.footers,defFooters:b,scrollAuto:g.scrollAuto,onScrollAutoChange:f=>g.scrollAuto=f},null),v.value&&e.createVNode(Be,{theme:t.theme,class:`${o.prefix}-catalog-editor`,editorId:r,mdHeadingId:t.mdHeadingId,key:"internal-catalog"},null)])}}}),ae=zt;ae.install=t=>(t.component(ae.name,ae),t.use(Ge).use(K.DropdownToolbar).use(ne.ModalToolbar).use(Be).use(w.MdPreview),t);module.exports=ae;
60
+ `,c=3,i=-4;break}case"universal":{const{generate:x}=r,N=x(g);l=N.targetValue,s=N.select,c=N.deviationStart,i=N.deviationEnd}}return{text:l,options:{select:s,deviationStart:c,deviationEnd:i,replaceAll:m}}},ct="#e5c07b",ye="var(--md-color)",st="#56b6c2",dt="#ffffff",Z="var(--md-color)",we="#e5c07b",ut="#e5c07b",ft="var(--md-color)",Te="#d19a66",gt="#c678dd",mt="#21252b",Se="#2c313a",Me="var(--md-bk-color)",re="#353a42",ht="#ceedfa33",Ae="#528bff",bt=Q.EditorView.theme({"&":{color:Z,backgroundColor:Me},".cm-content":{caretColor:Ae},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ae},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ht},".cm-panels":{backgroundColor:mt,color:Z},".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:Me,color:Z,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Se},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:re},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:re,borderBottomColor:re},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Se,color:Z}}},{dark:!0}),pt=ee.HighlightStyle.define([{tag:n.tags.keyword,color:gt},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:ye},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:ut},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Te},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:Z},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:ct},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:st},{tag:[n.tags.meta,n.tags.comment],color:we},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:we,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:ye},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Te},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:ft},{tag:n.tags.invalid,color:dt}]),vt=[bt,ee.syntaxHighlighting(pt)],kt="#e5c07b",Ee="#3f4a54",xt="#56b6c2",Ct="#fff",J="#3f4a54",De="#2d8cf0",Vt="#2d8cf0",Nt="#3f4a54",Le="#d19a66",$t="#c678dd",yt="#21252b",He="#ceedfa33",Fe="var(--md-bk-color)",ie="#353a42",wt="#bad5fa",Ie="#3f4a54",Tt=Q.EditorView.theme({"&":{color:J,backgroundColor:Fe},".cm-content":{caretColor:Ie},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ie},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:wt},".cm-panels":{backgroundColor:yt,color:J},".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:Fe,color:J,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:He},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ie},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ie,borderBottomColor:ie},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:He,color:J}}},{dark:!0}),St=ee.HighlightStyle.define([{tag:n.tags.keyword,color:$t},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:Ee},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:Vt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Le},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:J},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:kt},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:xt},{tag:[n.tags.meta,n.tags.comment],color:De},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:De,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:Ee},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Le},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:Nt},{tag:n.tags.invalid,color:Ct}]),Mt=[Tt,ee.syntaxHighlighting(St)],U=t=>{const a=new q.Compartment;return l=>(a.get(t.state)?t.dispatch({effects:a.reconfigure(l)}):t.dispatch({effects:q.StateEffect.appendConfig.of(a.of(l))}),!0)};class At{constructor(a){R(this,"view");R(this,"toggleTabSize");R(this,"togglePlaceholder");R(this,"setExtensions");R(this,"toggleDisabled");R(this,"toggleReadOnly");R(this,"toggleMaxlength");this.view=a,this.toggleTabSize=U(this.view),this.togglePlaceholder=U(this.view),this.setExtensions=U(this.view),this.toggleDisabled=U(this.view),this.toggleReadOnly=U(this.view),this.toggleMaxlength=U(this.view)}getValue(){return this.view.state.doc.toString()}setValue(a,r=0,l=this.view.state.doc.length){this.view.dispatch({changes:{from:r,to:l,insert:a}})}getSelectedText(){const{from:a,to:r}=this.view.state.selection.main;return this.view.state.sliceDoc(a,r)}replaceSelectedText(a,r={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1}){if(r.replaceAll){this.setValue(a);return}const{from:l}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(a)),r.select){const c=l+a.length+r.deviationEnd;this.view.dispatch({selection:q.EditorSelection.create([q.EditorSelection.range(l+r.deviationStart,c),q.EditorSelection.cursor(c)],1)}),this.view.focus()}}setTabSize(a){this.toggleTabSize([q.EditorState.tabSize.of(a),ee.indentUnit.of(" ".repeat(a))])}setPlaceholder(a){this.togglePlaceholder(Q.placeholder(a))}focus(){this.view.focus()}setDisabled(a){this.toggleDisabled([Q.EditorView.editable.of(!a)])}setReadOnly(a){this.toggleReadOnly([q.EditorState.readOnly.of(a)])}setMaxLength(a){this.toggleMaxlength([q.EditorState.changeFilter.of(r=>r.newDoc.length<=a)])}}const Et=t=>{const a=e.inject("editorId");return l=>{if(l.clipboardData){if(l.clipboardData.files.length>0){const{files:c}=l.clipboardData;h.bus.emit(a,"uploadImage",Array.from(c).filter(i=>/image\/.*/.test(i.type))),l.preventDefault()}if(t.autoDetectCode&&l.clipboardData.types.includes("vscode-editor-data")){const c=JSON.parse(l.clipboardData.getData("vscode-editor-data"));h.bus.emit(a,"replace","code",{mode:c.mode,text:l.clipboardData.getData("text/plain")}),l.preventDefault()}}}},Dt=Et,Lt=t=>{const a=e.inject("editorId");e.onMounted(()=>{h.bus.on(a,{name:T.TEXTAREA_FOCUS,callback(){var r;(r=t.value)==null||r.focus()}})})},Ht=Lt,Ft=(t,a)=>{const r={key:"Ctrl-b",mac:"Cmd-b",run:()=>(h.bus.emit(t,"replace","bold"),!0)},l={key:"Ctrl-s",mac:"Cmd-s",run:S=>(h.bus.emit(t,T.ON_SAVE,S.state.doc.toString()),!0),shift:()=>(h.bus.emit(t,"replace","strikeThrough"),!0)},c={key:"Ctrl-u",mac:"Cmd-u",run:()=>(h.bus.emit(t,"replace","underline"),!0),shift:()=>(h.bus.emit(t,"replace","unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(h.bus.emit(t,"replace","italic"),!0),shift:()=>(h.bus.emit(t,"openModals","image"),!0)},s={key:"Ctrl-1",mac:"Cmd-1",run:()=>(h.bus.emit(t,"replace","h1"),!0)},m={key:"Ctrl-2",mac:"Cmd-2",run:()=>(h.bus.emit(t,"replace","h2"),!0)},g={key:"Ctrl-3",mac:"Cmd-3",run:()=>(h.bus.emit(t,"replace","h3"),!0)},d={key:"Ctrl-4",mac:"Cmd-4",run:()=>(h.bus.emit(t,"replace","h4"),!0)},u={key:"Ctrl-5",mac:"Cmd-5",run:()=>(h.bus.emit(t,"replace","h5"),!0)},v={key:"Ctrl-6",mac:"Cmd-6",run:()=>(h.bus.emit(t,"replace","h6"),!0)},k={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(h.bus.emit(t,"replace","sup"),!0)},b={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(h.bus.emit(t,"replace","sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(h.bus.emit(t,"replace","orderedList"),!0)},f={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(h.bus.emit(t,"replace","code"),!0),any(S,C){return(C.ctrlKey||C.metaKey)&&C.altKey&&C.code==="KeyC"?(h.bus.emit(t,"replace","codeRow"),!0):!1}},x={key:"Ctrl-l",mac:"Cmd-l",run:()=>(h.bus.emit(t,"openModals","link"),!0)},N={key:"Ctrl-f",mac:"Cmd-f",shift:()=>a.noPrettier?!1:(h.bus.emit(t,"replace","prettier"),!0)},y={any:(S,C)=>(C.ctrlKey||C.metaKey)&&C.altKey&&C.shiftKey&&C.code==="KeyT"?(h.bus.emit(t,"replace","table"),!0):!1},$={key:"Ctrl-d",mac:"Cmd-d",run:le.deleteLine,preventDefault:!0};return[r,$,l,c,i,s,m,g,d,u,v,k,b,p,f,x,N,y]},It=Ft,Bt=t=>{const a=e.inject("tabWidth"),r=e.inject("editorId"),l=e.inject("theme"),c=e.ref(),i=e.shallowRef(),s=It(r,t),m=Dt(t),g=[Q.keymap.of([...s,le.indentWithTab]),Y.minimalSetup,je.markdown({codeLanguages:Pe.languages}),Y.EditorView.lineWrapping,Y.EditorView.updateListener.of(u=>{u.docChanged&&t.onChange(u.state.doc.toString())}),Y.EditorView.domEventHandlers({paste:m,blur:t.onBlur,focus:t.onFocus})],d=()=>l.value==="light"?o.configOption.codeMirrorExtensions(l.value,[...g,Mt],[...s]):o.configOption.codeMirrorExtensions(l.value,[...g,vt],[...s]);return e.onMounted(()=>{const u=new Y.EditorView({doc:t.value,parent:c.value});i.value=new At(u),i.value.setTabSize(a),i.value.setExtensions(d()),i.value.setDisabled(t.disabled),i.value.setReadOnly(t.readonly),t.placeholder&&i.value.setPlaceholder(t.placeholder),t.autofocus&&u.focus(),t.maxlength&&i.value.setMaxLength(t.maxlength),h.bus.on(r,{name:"ctrlZ",callback(){le.undo(u)}}),h.bus.on(r,{name:"ctrlShiftZ",callback(){le.redo(u)}}),h.bus.on(r,{name:"replace",callback(v,k={}){var f;const{text:b,options:p}=nt(v,i.value,k);(f=i.value)==null||f.replaceSelectedText(b,p)}})}),e.watch(()=>l.value,()=>{var u,v;l.value==="dark"?(u=i.value)==null||u.setExtensions(d()):(v=i.value)==null||v.setExtensions(d())}),e.watch(()=>t.value,()=>{var u,v;((u=i.value)==null?void 0:u.getValue())!==t.value&&((v=i.value)==null||v.setValue(t.value))}),e.watch(()=>t.placeholder,()=>{var u;(u=i.value)==null||u.setPlaceholder(t.placeholder)}),e.watch(()=>t.disabled,()=>{var u;(u=i.value)==null||u.setDisabled(t.disabled)}),e.watch(()=>t.readonly,()=>{var u;(u=i.value)==null||u.setDisabled(t.readonly)}),e.watch(()=>t.maxlength,()=>{var u;t.maxlength&&((u=i.value)==null||u.setMaxLength(t.maxlength))}),Ht(i),{inputWrapperRef:c,codeMirrorUt:i}},Ot=Bt,Rt={value:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:t=>t},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:t=>t},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},noHighlight:{type:Boolean,default:!1}},qt=e.defineComponent({name:"MDEditorContent",props:Rt,setup(t){const a=e.ref(""),{inputWrapperRef:r,codeMirrorUt:l}=Ot(t);return it(t,a,l),()=>e.createVNode("div",{class:`${o.prefix}-content`},[e.createVNode("div",{class:`${o.prefix}-input-wrapper`,ref:r},null),e.createVNode(T.ContentPreview,{modelValue:t.value,setting:t.setting,onHtmlChanged:c=>{a.value=c,t.onHtmlChanged(c)},onGetCatalog:t.onGetCatalog,mdHeadingId:t.mdHeadingId,noMermaid:t.noMermaid,sanitize:t.sanitize,noKatex:t.noKatex,formatCopiedText:t.formatCopiedText,noHighlight:t.noHighlight},null)])}}),Pt=e.defineComponent({props:{modelValue:{type:String,default:""}},setup(t){const a=e.inject("usedLanguageText");return()=>{var r,l;return e.createVNode("div",{class:`${o.prefix}-footer-item`},[e.createVNode("label",{class:`${o.prefix}-footer-label`},[`${(r=a.value.footer)==null?void 0:r.markdownTotal}:`]),e.createVNode("span",null,[((l=t.modelValue)==null?void 0:l.length)||0])])}}}),jt={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Gt=e.defineComponent({props:jt,setup(t){return()=>e.createVNode("div",{class:[`${o.prefix}-checkbox`,t.checked&&`${o.prefix}-checkbox-checked`],onClick:()=>{t.onChange(!t.checked)}},null)}}),Ut={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},Kt=e.defineComponent({props:Ut,setup(t){const a=e.inject("usedLanguageText");return()=>{var r;return e.createVNode("div",{class:`${o.prefix}-footer-item`},[e.createVNode("label",{class:`${o.prefix}-footer-label`,onClick:()=>{t.onScrollAutoChange(!t.scrollAuto)}},[(r=a.value.footer)==null?void 0:r.scrollAuto]),e.createVNode(Gt,{checked:t.scrollAuto,onChange:t.onScrollAutoChange},null)])}}}),_t={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},Wt=e.defineComponent({name:"MDEditorFooter",props:_t,setup(t){const a=e.computed(()=>{const l=t.footers.indexOf("="),c=l===-1?t.footers:t.footers.slice(0,l),i=l===-1?[]:t.footers.slice(l,Number.MAX_SAFE_INTEGER);return[c,i]}),r=l=>{if(o.allFooter.includes(l))switch(l){case"markdownTotal":return e.createVNode(Pt,{modelValue:t.modelValue},null);case"scrollSwitch":return e.createVNode(Kt,{scrollAuto:t.scrollAuto,onScrollAutoChange:t.onScrollAutoChange},null)}else return t.defFooters instanceof Array?t.defFooters[l]||"":t.defFooters&&t.defFooters.children instanceof Array&&t.defFooters.children[l]||""};return()=>{const l=a.value[0].map(i=>r(i)),c=a.value[1].map(i=>r(i));return e.createVNode("div",{class:`${o.prefix}-footer`},[e.createVNode("div",{class:`${o.prefix}-footer-left`},[l]),e.createVNode("div",{class:`${o.prefix}-footer-right`},[c])])}}}),zt=e.defineComponent({name:"MdEditorV3",props:T.editorProps,emits:T.editorEmits,setup(t,a){const{editorId:r,noKatex:l,noMermaid:c,noPrettier:i,noUploadImg:s,noHighlight:m}=t,g=e.reactive({scrollAuto:t.scrollAuto});T.useOnSave(t,a),T.useProvide(t),T.useExpansion(t);const[d,u]=T.useConfig(t,a),v=T.useCatalog(t);return e.onBeforeUnmount(()=>{h.bus.clear(r)}),T.useExpose(t,a,v,d,u),()=>{var p;const k=$e.getSlot({props:t,ctx:a},"defToolbars"),b=$e.getSlot({props:t,ctx:a},"defFooters");return e.createVNode("div",{id:r,class:[o.prefix,t.class,t.theme==="dark"&&`${o.prefix}-dark`,d.fullscreen||d.pageFullscreen?`${o.prefix}-fullscreen`:""],style:t.style},[e.createVNode(ot,{noPrettier:i,toolbars:t.toolbars,toolbarsExclude:t.toolbarsExclude,setting:d,updateSetting:u,tableShape:t.tableShape,defToolbars:k,noUploadImg:s},null),e.createVNode(qt,{value:t.modelValue,setting:d,mdHeadingId:t.mdHeadingId,noMermaid:c,noPrettier:i,sanitize:t.sanitize,placeholder:t.placeholder,noKatex:l,scrollAuto:g.scrollAuto,formatCopiedText:t.formatCopiedText,autofocus:t.autoFocus,disabled:t.disabled,readonly:t.readOnly,maxlength:t.maxLength,autoDetectCode:t.autoDetectCode,noHighlight:m,onChange:f=>{t.onChange?t.onChange(f):(a.emit("update:modelValue",f),a.emit("onChange",f))},onHtmlChanged:f=>{t.onHtmlChanged?t.onHtmlChanged(f):a.emit("onHtmlChanged",f)},onGetCatalog:f=>{t.onGetCatalog?t.onGetCatalog(f):a.emit("onGetCatalog",f)},onBlur:f=>{t.onBlur?t.onBlur(f):a.emit("onBlur",f)},onFocus:f=>{t.onFocus?t.onFocus(f):a.emit("onFocus",f)}},null),((p=t.footers)==null?void 0:p.length)>0&&e.createVNode(Wt,{modelValue:t.modelValue,footers:t.footers,defFooters:b,scrollAuto:g.scrollAuto,onScrollAutoChange:f=>g.scrollAuto=f},null),v.value&&e.createVNode(Be,{theme:t.theme,class:`${o.prefix}-catalog-editor`,editorId:r,mdHeadingId:t.mdHeadingId,key:"internal-catalog"},null)])}}}),ae=zt;ae.install=t=>(t.component(ae.name,ae),t.use(Ge).use(K.DropdownToolbar).use(ne.ModalToolbar).use(Be).use(T.MdPreview),t);module.exports=ae;
@@ -1,7 +1,7 @@
1
1
  var Ze = Object.defineProperty;
2
2
  var Je = (e, o, n) => o in e ? Ze(e, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[o] = n;
3
3
  var U = (e, o, n) => (Je(e, typeof o != "symbol" ? o + "" : o, n), n);
4
- import { defineComponent as B, createVNode as t, inject as S, ref as q, onMounted as W, reactive as Y, computed as me, watch as I, nextTick as ue, Fragment as Ke, toRef as ae, shallowRef as Xe, onBeforeUnmount as Qe } from "vue";
4
+ import { defineComponent as O, createVNode as t, inject as A, ref as q, onMounted as W, reactive as Y, computed as me, watch as B, nextTick as ue, Fragment as Ke, toRef as ae, shallowRef as Xe, onBeforeUnmount as Qe } from "vue";
5
5
  import { p as a, a as G, s as et, b as tt, d as lt } from "./chunks/config.mjs";
6
6
  import { a as Q, D as ot } from "./chunks/index2.mjs";
7
7
  import { b as h, a as at } from "./chunks/index4.mjs";
@@ -26,7 +26,7 @@ import "markdown-it";
26
26
  import "markdown-it-image-figures";
27
27
  import "markdown-it-task-lists";
28
28
  import "lru-cache";
29
- const Ot = /* @__PURE__ */ B({
29
+ const Ot = /* @__PURE__ */ O({
30
30
  setup() {
31
31
  return () => t("div", {
32
32
  class: `${a}-divider`
@@ -75,7 +75,7 @@ const Ot = /* @__PURE__ */ B({
75
75
  }
76
76
  }, Rt = (e) => {
77
77
  var f, d, u, k;
78
- const o = S("editorId");
78
+ const o = A("editorId");
79
79
  let n = (d = (f = G.editorExtensions) == null ? void 0 : f.screenfull) == null ? void 0 : d.instance;
80
80
  const l = (k = (u = G.editorExtensions) == null ? void 0 : u.screenfull) == null ? void 0 : k.js, s = q(!1), r = ($) => {
81
81
  if (!n) {
@@ -114,7 +114,7 @@ const Ot = /* @__PURE__ */ B({
114
114
  default: () => {
115
115
  }
116
116
  }
117
- }, Pt = /* @__PURE__ */ B({
117
+ }, Pt = /* @__PURE__ */ O({
118
118
  name: "TableShape",
119
119
  props: Nt,
120
120
  setup(e) {
@@ -162,10 +162,10 @@ const Ot = /* @__PURE__ */ B({
162
162
  default: () => {
163
163
  }
164
164
  }
165
- }, Gt = /* @__PURE__ */ B({
165
+ }, Gt = /* @__PURE__ */ O({
166
166
  props: qt,
167
167
  setup(e) {
168
- const o = S("usedLanguageText"), n = S("editorId"), l = me(() => {
168
+ const o = A("usedLanguageText"), n = A("editorId"), l = me(() => {
169
169
  var r, c;
170
170
  switch (e.type) {
171
171
  case "link":
@@ -179,7 +179,7 @@ const Ot = /* @__PURE__ */ B({
179
179
  desc: "",
180
180
  url: ""
181
181
  });
182
- return I(() => e.visible, (r) => {
182
+ return B(() => e.visible, (r) => {
183
183
  r || setTimeout(() => {
184
184
  s.desc = "", s.url = "";
185
185
  }, 200);
@@ -247,11 +247,11 @@ const Ot = /* @__PURE__ */ B({
247
247
  default: () => {
248
248
  }
249
249
  }
250
- }, jt = /* @__PURE__ */ B({
250
+ }, jt = /* @__PURE__ */ O({
251
251
  props: Kt,
252
252
  setup(e) {
253
253
  var u, k, $;
254
- const o = S("usedLanguageText"), n = S("editorId");
254
+ const o = A("usedLanguageText"), n = A("editorId");
255
255
  let l = ($ = (k = (u = G) == null ? void 0 : u.editorExtensions) == null ? void 0 : k.cropper) == null ? void 0 : $.instance;
256
256
  const s = q(), r = q(), c = q(), g = Y({
257
257
  cropperInited: !1,
@@ -261,7 +261,7 @@ const Ot = /* @__PURE__ */ B({
261
261
  isFullscreen: !1
262
262
  });
263
263
  let f = null;
264
- I(() => e.visible, () => {
264
+ B(() => e.visible, () => {
265
265
  e.visible && !g.cropperInited && (l = l || window.Cropper, s.value.onchange = () => {
266
266
  if (!l) {
267
267
  h.emit(n, "errorCatcher", {
@@ -284,9 +284,9 @@ const Ot = /* @__PURE__ */ B({
284
284
  }, v.readAsDataURL(b[0]);
285
285
  }
286
286
  });
287
- }), I(() => [g.imgSelected], () => {
287
+ }), B(() => [g.imgSelected], () => {
288
288
  c.value.style = "";
289
- }), I(() => g.isFullscreen, () => {
289
+ }), B(() => g.isFullscreen, () => {
290
290
  ue(() => {
291
291
  f == null || f.destroy(), c.value.style = "", r.value && (f = new l(r.value, {
292
292
  viewMode: 2,
@@ -398,7 +398,7 @@ const Ot = /* @__PURE__ */ B({
398
398
  default: () => {
399
399
  }
400
400
  }
401
- }, Wt = /* @__PURE__ */ B({
401
+ }, Wt = /* @__PURE__ */ O({
402
402
  props: _t,
403
403
  setup(e) {
404
404
  return () => t(Ke, null, [t(Gt, {
@@ -412,11 +412,11 @@ const Ot = /* @__PURE__ */ B({
412
412
  onCancel: e.onCancel
413
413
  }, null)]);
414
414
  }
415
- }), zt = /* @__PURE__ */ B({
415
+ }), zt = /* @__PURE__ */ O({
416
416
  name: "MDEditorToolbar",
417
417
  props: Vt,
418
418
  setup(e) {
419
- const o = S("editorId"), n = S("usedLanguageText"), {
419
+ const o = A("editorId"), n = A("usedLanguageText"), {
420
420
  fullscreenHandler: l
421
421
  } = Rt(e), s = `${o}-toolbar-wrapper`, r = Y({
422
422
  title: !1,
@@ -453,7 +453,7 @@ const Ot = /* @__PURE__ */ B({
453
453
  u.value.addEventListener("change", k);
454
454
  });
455
455
  const $ = (b) => {
456
- var v, m, y, x, T, w, A, p, M, R, L, D, O, F, E, K, N, le, Z, j, P, J, _, H, V, X, oe, ge, he, be, ve, ke, pe, Ce, $e, ye, xe, we, Te, Se, Ae, Me, Le;
456
+ var v, m, y, x, T, w, M, p, S, R, L, D, V, F, E, K, N, le, Z, j, P, J, _, H, I, X, oe, ge, he, be, ve, ke, pe, Ce, $e, ye, xe, we, Te, Se, Ae, Me, Le;
457
457
  if (tt.includes(b))
458
458
  switch (b) {
459
459
  case "-":
@@ -537,7 +537,7 @@ const Ot = /* @__PURE__ */ B({
537
537
  onClick: () => {
538
538
  c("h3");
539
539
  }
540
- }, [(A = n.value.titleItem) == null ? void 0 : A.h3]), t("li", {
540
+ }, [(M = n.value.titleItem) == null ? void 0 : M.h3]), t("li", {
541
541
  class: `${a}-menu-item`,
542
542
  onClick: () => {
543
543
  c("h4");
@@ -547,7 +547,7 @@ const Ot = /* @__PURE__ */ B({
547
547
  onClick: () => {
548
548
  c("h5");
549
549
  }
550
- }, [(M = n.value.titleItem) == null ? void 0 : M.h5]), t("li", {
550
+ }, [(S = n.value.titleItem) == null ? void 0 : S.h5]), t("li", {
551
551
  class: `${a}-menu-item`,
552
552
  onClick: () => {
553
553
  c("h6");
@@ -596,7 +596,7 @@ const Ot = /* @__PURE__ */ B({
596
596
  case "quote":
597
597
  return t("div", {
598
598
  class: `${a}-toolbar-item`,
599
- title: (O = n.value.toolbarTips) == null ? void 0 : O.quote,
599
+ title: (V = n.value.toolbarTips) == null ? void 0 : V.quote,
600
600
  onClick: () => {
601
601
  c("quote");
602
602
  }
@@ -783,7 +783,7 @@ const Ot = /* @__PURE__ */ B({
783
783
  case "next":
784
784
  return t("div", {
785
785
  class: `${a}-toolbar-item`,
786
- title: (V = n.value.toolbarTips) == null ? void 0 : V.next,
786
+ title: (I = n.value.toolbarTips) == null ? void 0 : I.next,
787
787
  onClick: () => {
788
788
  h.emit(o, "ctrlShiftZ");
789
789
  }
@@ -1082,7 +1082,7 @@ const Ot = /* @__PURE__ */ B({
1082
1082
  };
1083
1083
  let f = 0, d = 0;
1084
1084
  const u = it((k) => {
1085
- var v, m, y, x, T, w, A;
1085
+ var v, m, y, x, T, w, M;
1086
1086
  if (!((v = o.firstElementChild) != null && v.firstElementChild))
1087
1087
  return;
1088
1088
  const $ = l.lineBlockAtHeight(l.scrollDOM.scrollTop), { number: b } = l.state.doc.lineAt($.from);
@@ -1091,11 +1091,11 @@ const Ot = /* @__PURE__ */ B({
1091
1091
  if (d !== 0)
1092
1092
  return;
1093
1093
  f++;
1094
- const p = c[b - 1], M = s(p.end) + r(p.end);
1094
+ const p = c[b - 1], S = s(p.end) + r(p.end);
1095
1095
  let R = 0;
1096
- const L = s(p.start), D = o.querySelector(`[data-line="${p.start - 1}"]`) || ((m = o.firstElementChild) == null ? void 0 : m.firstElementChild), O = o.querySelector(`[data-line="${p.end}"]`) || ((y = o.lastElementChild) == null ? void 0 : y.lastElementChild);
1096
+ const L = s(p.start), D = o.querySelector(`[data-line="${p.start - 1}"]`) || ((m = o.firstElementChild) == null ? void 0 : m.firstElementChild), V = o.querySelector(`[data-line="${p.end}"]`) || ((y = o.lastElementChild) == null ? void 0 : y.lastElementChild);
1097
1097
  let F = 0, E = 0;
1098
- L === 0 ? (R = (l.scrollDOM.scrollTop - L) / (M - L), F = O.offsetTop) : M > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (R = (l.scrollDOM.scrollTop - L) / (l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight - L), E = D.offsetTop, F = o.scrollHeight - o.clientHeight - E + 10) : (R = (l.scrollDOM.scrollTop - L) / (M - L), E = D.offsetTop, F = O.offsetTop - E);
1098
+ L === 0 ? (R = (l.scrollDOM.scrollTop - L) / (S - L), F = V.offsetTop) : S > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (R = (l.scrollDOM.scrollTop - L) / (l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight - L), E = D.offsetTop, F = o.scrollHeight - o.clientHeight - E + 10) : (R = (l.scrollDOM.scrollTop - L) / (S - L), E = D.offsetTop, F = V.offsetTop - E);
1099
1099
  const K = E - 10 + F * R;
1100
1100
  De(o, K, () => {
1101
1101
  f--;
@@ -1106,54 +1106,54 @@ const Ot = /* @__PURE__ */ B({
1106
1106
  d++;
1107
1107
  const p = Array.from(
1108
1108
  o.querySelectorAll("[data-line]")
1109
- ), M = o.scrollTop, R = o.scrollHeight;
1109
+ ), S = o.scrollTop, R = o.scrollHeight;
1110
1110
  let L = p.length === 0 ? 1 : Math.ceil(
1111
- Number(p[p.length - 1].dataset.line) * (M / R)
1111
+ Number(p[p.length - 1].dataset.line) * (S / R)
1112
1112
  ), D = (x = o.firstElementChild) == null ? void 0 : x.firstElementChild;
1113
1113
  for (let H = L; H >= 0; H--) {
1114
- const V = o.querySelector(`[data-line="${H}"]`);
1115
- if (V) {
1116
- D = V, L = H;
1114
+ const I = o.querySelector(`[data-line="${H}"]`);
1115
+ if (I && I.offsetTop <= S) {
1116
+ D = I, L = H;
1117
1117
  break;
1118
1118
  }
1119
1119
  }
1120
- let O = (T = o.firstElementChild) == null ? void 0 : T.firstElementChild, F = (w = o.firstElementChild) == null ? void 0 : w.lastElementChild;
1120
+ let V = (T = o.firstElementChild) == null ? void 0 : T.firstElementChild, F = (w = o.firstElementChild) == null ? void 0 : w.lastElementChild;
1121
1121
  for (; p.length > 0; ) {
1122
1122
  const H = p.indexOf(D);
1123
1123
  if (H + 1 >= p.length)
1124
1124
  break;
1125
- const V = p[H + 1];
1125
+ const I = p[H + 1];
1126
1126
  if (H === -1) {
1127
- F = V;
1127
+ F = I;
1128
1128
  break;
1129
1129
  }
1130
1130
  const X = D.offsetTop;
1131
- if (X > M) {
1131
+ if (X > S) {
1132
1132
  if (H === 0) {
1133
- O = D, F = V;
1133
+ V = D, F = I;
1134
1134
  break;
1135
1135
  }
1136
1136
  D = p[H - 1];
1137
1137
  continue;
1138
1138
  }
1139
- const oe = V.offsetTop;
1140
- if (X <= M && oe > M) {
1141
- O = D, F = V;
1139
+ const oe = I.offsetTop;
1140
+ if (X <= S && oe > S) {
1141
+ V = D, F = I;
1142
1142
  break;
1143
1143
  }
1144
- D = V;
1144
+ D = I;
1145
1145
  }
1146
- const E = O.offsetTop, K = F.offsetTop;
1146
+ const E = V.offsetTop, K = F.offsetTop;
1147
1147
  let N = 0;
1148
- const { start: le, end: Z } = c[Number(O.dataset.line || 0)], j = s(le);
1148
+ const { start: le, end: Z } = c[Number(V.dataset.line || 0)], j = s(le);
1149
1149
  let P = s(Z);
1150
1150
  const J = r(Z);
1151
1151
  let _ = 0;
1152
- O === ((A = o.firstElementChild) == null ? void 0 : A.firstElementChild) ? (N = Math.max(M / K, 0), _ = P + J - j) : P > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (N = Math.max(
1153
- (M - E) / (o.scrollHeight - E - o.clientHeight),
1152
+ V === ((M = o.firstElementChild) == null ? void 0 : M.firstElementChild) ? (N = Math.max(S / K, 0), _ = P + J - j) : P > l.scrollDOM.scrollHeight - l.scrollDOM.clientHeight ? (N = Math.max(
1153
+ (S - E) / (o.scrollHeight - E - o.clientHeight),
1154
1154
  0
1155
1155
  ), P = s(l.state.doc.lines) + r(l.state.doc.lines), _ = 8 + P - j - e.clientHeight) : (N = Math.max(
1156
- (M - E) / (K - E),
1156
+ (S - E) / (K - E),
1157
1157
  0
1158
1158
  ), _ = P + J - j), De(e, j + _ * N, () => {
1159
1159
  d--;
@@ -1169,7 +1169,7 @@ const Ot = /* @__PURE__ */ B({
1169
1169
  }
1170
1170
  ];
1171
1171
  }, Jt = (e, o, n) => {
1172
- const l = S("editorId");
1172
+ const l = A("editorId");
1173
1173
  let s = () => {
1174
1174
  }, r = () => {
1175
1175
  };
@@ -1186,7 +1186,7 @@ const Ot = /* @__PURE__ */ B({
1186
1186
  n.value
1187
1187
  )), e.scrollAuto && r();
1188
1188
  };
1189
- I(
1189
+ B(
1190
1190
  [
1191
1191
  o,
1192
1192
  ae(e.setting, "preview"),
@@ -1197,7 +1197,7 @@ const Ot = /* @__PURE__ */ B({
1197
1197
  () => {
1198
1198
  ue(c);
1199
1199
  }
1200
- ), I(
1200
+ ), B(
1201
1201
  () => e.scrollAuto,
1202
1202
  (g) => {
1203
1203
  g ? r() : s();
@@ -1287,7 +1287,7 @@ ${y}
1287
1287
  for (let w = 0; w <= x; w++) {
1288
1288
  l += `
1289
1289
  |`;
1290
- for (let A = 0; A <= T; A++)
1290
+ for (let M = 0; M <= T; M++)
1291
1291
  l += " content |";
1292
1292
  }
1293
1293
  s = 2, r = 5 - l.length;
@@ -1300,7 +1300,7 @@ ${y}
1300
1300
  }
1301
1301
  case "image": {
1302
1302
  const { desc: y, url: x, urls: T } = n;
1303
- T instanceof Array ? l = T.reduce((w, A) => w + `![${y}](${A})
1303
+ T instanceof Array ? l = T.reduce((w, M) => w + `![${y}](${M})
1304
1304
  `, "") : l = `![${y}](${x})
1305
1305
  `, c = !1;
1306
1306
  break;
@@ -1737,7 +1737,7 @@ class yl {
1737
1737
  }
1738
1738
  }
1739
1739
  const xl = (e) => {
1740
- const o = S("editorId");
1740
+ const o = A("editorId");
1741
1741
  return (l) => {
1742
1742
  if (l.clipboardData) {
1743
1743
  if (l.clipboardData.files.length > 0) {
@@ -1758,7 +1758,7 @@ const xl = (e) => {
1758
1758
  }
1759
1759
  };
1760
1760
  }, wl = xl, Tl = (e) => {
1761
- const o = S("editorId");
1761
+ const o = A("editorId");
1762
1762
  W(() => {
1763
1763
  h.on(o, {
1764
1764
  name: dt,
@@ -1783,7 +1783,7 @@ const xl = (e) => {
1783
1783
  {
1784
1784
  key: "Ctrl-s",
1785
1785
  mac: "Cmd-s",
1786
- run: (A) => (h.emit(e, je, A.state.doc.toString()), !0),
1786
+ run: (M) => (h.emit(e, je, M.state.doc.toString()), !0),
1787
1787
  shift: () => (h.emit(e, "replace", "strikeThrough"), !0)
1788
1788
  },
1789
1789
  {
@@ -1847,7 +1847,7 @@ const xl = (e) => {
1847
1847
  key: "Ctrl-c",
1848
1848
  mac: "Cmd-c",
1849
1849
  shift: () => (h.emit(e, "replace", "code"), !0),
1850
- any(A, p) {
1850
+ any(M, p) {
1851
1851
  return (p.ctrlKey || p.metaKey) && p.altKey && p.code === "KeyC" ? (h.emit(e, "replace", "codeRow"), !0) : !1;
1852
1852
  }
1853
1853
  },
@@ -1862,10 +1862,10 @@ const xl = (e) => {
1862
1862
  shift: () => o.noPrettier ? !1 : (h.emit(e, "replace", "prettier"), !0)
1863
1863
  },
1864
1864
  {
1865
- any: (A, p) => (p.ctrlKey || p.metaKey) && p.altKey && p.shiftKey && p.code === "KeyT" ? (h.emit(e, "replace", "table"), !0) : !1
1865
+ any: (M, p) => (p.ctrlKey || p.metaKey) && p.altKey && p.shiftKey && p.code === "KeyT" ? (h.emit(e, "replace", "table"), !0) : !1
1866
1866
  }
1867
1867
  ], Ml = Al, Ll = (e) => {
1868
- const o = S("tabWidth"), n = S("editorId"), l = S("theme"), s = q(), r = Xe(), c = Ml(n, e), g = wl(e), f = [
1868
+ const o = A("tabWidth"), n = A("editorId"), l = A("theme"), s = q(), r = Xe(), c = Ml(n, e), g = wl(e), f = [
1869
1869
  Tt.of([...c, Lt]),
1870
1870
  xt,
1871
1871
  At({ codeLanguages: St }),
@@ -1911,37 +1911,37 @@ const xl = (e) => {
1911
1911
  (m = r.value) == null || m.replaceSelectedText(b, v);
1912
1912
  }
1913
1913
  });
1914
- }), I(
1914
+ }), B(
1915
1915
  () => l.value,
1916
1916
  () => {
1917
1917
  var u, k;
1918
1918
  l.value === "dark" ? (u = r.value) == null || u.setExtensions(d()) : (k = r.value) == null || k.setExtensions(d());
1919
1919
  }
1920
- ), I(
1920
+ ), B(
1921
1921
  () => e.value,
1922
1922
  () => {
1923
1923
  var u, k;
1924
1924
  ((u = r.value) == null ? void 0 : u.getValue()) !== e.value && ((k = r.value) == null || k.setValue(e.value));
1925
1925
  }
1926
- ), I(
1926
+ ), B(
1927
1927
  () => e.placeholder,
1928
1928
  () => {
1929
1929
  var u;
1930
1930
  (u = r.value) == null || u.setPlaceholder(e.placeholder);
1931
1931
  }
1932
- ), I(
1932
+ ), B(
1933
1933
  () => e.disabled,
1934
1934
  () => {
1935
1935
  var u;
1936
1936
  (u = r.value) == null || u.setDisabled(e.disabled);
1937
1937
  }
1938
- ), I(
1938
+ ), B(
1939
1939
  () => e.readonly,
1940
1940
  () => {
1941
1941
  var u;
1942
1942
  (u = r.value) == null || u.setDisabled(e.readonly);
1943
1943
  }
1944
- ), I(
1944
+ ), B(
1945
1945
  () => e.maxlength,
1946
1946
  () => {
1947
1947
  var u;
@@ -2041,7 +2041,7 @@ const xl = (e) => {
2041
2041
  type: Boolean,
2042
2042
  default: !1
2043
2043
  }
2044
- }, Hl = /* @__PURE__ */ B({
2044
+ }, Hl = /* @__PURE__ */ O({
2045
2045
  name: "MDEditorContent",
2046
2046
  props: El,
2047
2047
  setup(e) {
@@ -2069,7 +2069,7 @@ const xl = (e) => {
2069
2069
  noHighlight: e.noHighlight
2070
2070
  }, null)]);
2071
2071
  }
2072
- }), Fl = /* @__PURE__ */ B({
2072
+ }), Fl = /* @__PURE__ */ O({
2073
2073
  props: {
2074
2074
  modelValue: {
2075
2075
  type: String,
@@ -2077,7 +2077,7 @@ const xl = (e) => {
2077
2077
  }
2078
2078
  },
2079
2079
  setup(e) {
2080
- const o = S("usedLanguageText");
2080
+ const o = A("usedLanguageText");
2081
2081
  return () => {
2082
2082
  var n, l;
2083
2083
  return t("div", {
@@ -2097,7 +2097,7 @@ const xl = (e) => {
2097
2097
  default: () => {
2098
2098
  }
2099
2099
  }
2100
- }, Bl = /* @__PURE__ */ B({
2100
+ }, Bl = /* @__PURE__ */ O({
2101
2101
  props: Il,
2102
2102
  setup(e) {
2103
2103
  return () => t("div", {
@@ -2116,10 +2116,10 @@ const xl = (e) => {
2116
2116
  default: () => {
2117
2117
  }
2118
2118
  }
2119
- }, Vl = /* @__PURE__ */ B({
2119
+ }, Vl = /* @__PURE__ */ O({
2120
2120
  props: Ol,
2121
2121
  setup(e) {
2122
- const o = S("usedLanguageText");
2122
+ const o = A("usedLanguageText");
2123
2123
  return () => {
2124
2124
  var n;
2125
2125
  return t("div", {
@@ -2155,7 +2155,7 @@ const xl = (e) => {
2155
2155
  defFooters: {
2156
2156
  type: Object
2157
2157
  }
2158
- }, Nl = /* @__PURE__ */ B({
2158
+ }, Nl = /* @__PURE__ */ O({
2159
2159
  name: "MDEditorFooter",
2160
2160
  props: Rl,
2161
2161
  setup(e) {
@@ -2189,7 +2189,7 @@ const xl = (e) => {
2189
2189
  }, [s])]);
2190
2190
  };
2191
2191
  }
2192
- }), Pl = /* @__PURE__ */ B({
2192
+ }), Pl = /* @__PURE__ */ O({
2193
2193
  name: "MdEditorV3",
2194
2194
  props: mt,
2195
2195
  emits: ft,
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function($e,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):($e=typeof globalThis<"u"?globalThis:$e||self,g($e.MdEditorV3={},$e.Vue))})(this,function($e,g){var Xa,nr,$n,Rr,rr,Ta,gt,ir,$t,Ne,pe,Bt,Qn,Ct,wt,or,Tt,Jr,ei,ar,qr,Zi,rn,Pl,mg,ko,ti,xl,bn,Vu,RT,wo,Ra,kl,Wr,Ei,zr,Ci,wl,gg,qa,Lu,Wa,Mu,Ae,Fe,vl,$g,vo,Rl;"use strict";var VK=Object.defineProperty;var EK=($e,g,W)=>g in $e?VK($e,g,{enumerable:!0,configurable:!0,writable:!0,value:W}):$e[g]=W;var je=($e,g,W)=>(EK($e,typeof g!="symbol"?g+"":g,W),W),hg=($e,g,W)=>{if(!g.has($e))throw TypeError("Cannot "+W)};var T=($e,g,W)=>(hg($e,g,"read from private field"),W?W.call($e):g.get($e)),me=($e,g,W)=>{if(g.has($e))throw TypeError("Cannot add the same private member more than once");g instanceof WeakSet?g.add($e):g.set($e,W)},ce=($e,g,W,qo)=>(hg($e,g,"write to private field"),qo?qo.call($e,W):g.set($e,W),W),Nu=($e,g,W,qo)=>({set _(Bu){ce($e,g,Bu,W)},get _(){return T($e,g,qo)}}),ae=($e,g,W)=>(hg($e,g,"access private method"),W);const W="md-editor",qo="md-editor-v3",Bu="https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js",Ie="https://cdnjs.cloudflare.com/ajax/libs",qT=`${Ie}/highlight.js/11.7.0/highlight.min.js`,Qg={main:`${Ie}/prettier/2.8.0/standalone.js`,markdown:`${Ie}/prettier/2.8.0/parser-markdown.js`},bg={css:`${Ie}/cropperjs/1.5.13/cropper.min.css`,js:`${Ie}/cropperjs/1.5.13/cropper.min.js`},WT=`${Ie}/screenfull.js/5.2.0/screenfull.min.js`,yg=["bold","underline","italic","strikeThrough","-","title","sub","sup","quote","unorderedList","orderedList","task","-","codeRow","code","link","image","table","mermaid","katex","-","revoke","next","save","=","prettier","pageFullscreen","fullscreen","preview","htmlPreview","catalog","github"],Sg=["markdownTotal","=","scrollSwitch"],Pg={"zh-CN":{toolbarTips:{bold:"加粗",underline:"下划线",italic:"斜体",strikeThrough:"删除线",title:"标题",sub:"下标",sup:"上标",quote:"引用",unorderedList:"无序列表",orderedList:"有序列表",task:"任务列表",codeRow:"行内代码",code:"块级代码",link:"链接",image:"图片",table:"表格",mermaid:"mermaid图",katex:"katex公式",revoke:"后退",next:"前进",save:"保存",prettier:"美化",pageFullscreen:"浏览器全屏",fullscreen:"屏幕全屏",preview:"预览",htmlPreview:"html代码预览",catalog:"目录",github:"源码地址"},titleItem:{h1:"一级标题",h2:"二级标题",h3:"三级标题",h4:"四级标题",h5:"五级标题",h6:"六级标题"},imgTitleItem:{link:"添加链接",upload:"上传图片",clip2upload:"裁剪上传"},linkModalTips:{linkTitle:"添加链接",imageTitle:"添加图片",descLabel:"链接描述:",descLabelPlaceHolder:"请输入描述...",urlLabel:"链接地址:",urlLabelPlaceHolder:"请输入链接...",buttonOK:"确定"},clipModalTips:{title:"裁剪图片上传",buttonUpload:"上传"},copyCode:{text:"复制代码",successTips:"已复制!",failTips:"复制失败!"},mermaid:{flow:"流程图",sequence:"时序图",gantt:"甘特图",class:"类图",state:"状态图",pie:"饼图",relationship:"关系图",journey:"旅程图"},katex:{inline:"行内公式",block:"块级公式"},footer:{markdownTotal:"字数",scrollAuto:"同步滚动"}},"en-US":{toolbarTips:{bold:"bold",underline:"underline",italic:"italic",strikeThrough:"strikeThrough",title:"title",sub:"subscript",sup:"superscript",quote:"quote",unorderedList:"unordered list",orderedList:"ordered list",task:"task list",codeRow:"inline code",code:"block-level code",link:"link",image:"image",table:"table",mermaid:"mermaid",katex:"formula",revoke:"revoke",next:"undo revoke",save:"save",prettier:"prettier",pageFullscreen:"fullscreen in page",fullscreen:"fullscreen",preview:"preview",htmlPreview:"html preview",catalog:"catalog",github:"source code"},titleItem:{h1:"Lv1 Heading",h2:"Lv2 Heading",h3:"Lv3 Heading",h4:"Lv4 Heading",h5:"Lv5 Heading",h6:"Lv6 Heading"},imgTitleItem:{link:"Add Img Link",upload:"Upload Img",clip2upload:"Clip Upload"},linkModalTips:{linkTitle:"Add Link",imageTitle:"Add Image",descLabel:"Desc:",descLabelPlaceHolder:"Enter a description...",urlLabel:"Link:",urlLabelPlaceHolder:"Enter a link...",buttonOK:"OK"},clipModalTips:{title:"Crop Image",buttonUpload:"Upload"},copyCode:{text:"Copy",successTips:"Copied!",failTips:"Copy failed!"},mermaid:{flow:"flow",sequence:"sequence",gantt:"gantt",class:"class",state:"state",pie:"pie",relationship:"relationship",journey:"journey"},katex:{inline:"inline",block:"block"},footer:{markdownTotal:"Word Count",scrollAuto:"Scroll Auto"}}},zT=`${Ie}/mermaid/10.1.0/mermaid.esm.min.mjs`,xg={js:`${Ie}/KaTeX/0.16.3/katex.min.js`,css:`${Ie}/KaTeX/0.16.3/katex.min.css`},kg={a11y:{light:`${Ie}/highlight.js/11.7.0/styles/a11y-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/a11y-dark.min.css`},atom:{light:`${Ie}/highlight.js/11.7.0/styles/atom-one-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/atom-one-dark.min.css`},github:{light:`${Ie}/highlight.js/11.7.0/styles/github.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/github-dark.min.css`},gradient:{light:`${Ie}/highlight.js/11.7.0/styles/gradient-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/gradient-dark.min.css`},kimbie:{light:`${Ie}/highlight.js/11.7.0/styles/kimbie-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/kimbie-dark.min.css`},paraiso:{light:`${Ie}/highlight.js/11.7.0/styles/paraiso-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/paraiso-dark.min.css`},qtcreator:{light:`${Ie}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${Ie}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,dark:`${Ie}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`}},Ve={editorExtensions:{},editorConfig:{},codeMirrorExtensions:(t,e)=>e,markdownItConfig:()=>{}},UT=t=>{if(t)for(const e in t){const n=t[e];n&&(Ve[e]=n)}},ZT=g.defineComponent({setup(){return()=>g.createVNode("div",{class:`${W}-divider`},null)}}),Cn=({instance:t,ctx:e,props:n={}},r="default")=>{const i=(t==null?void 0:t.$slots[r])||(e==null?void 0:e.slots[r]);return(i?i(t):"")||n[r]},YT={trigger:{type:String,default:"hover"},overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}},Wo=g.defineComponent({props:YT,setup(t,e){const n=`${W}-dropdown-hidden`,r=g.reactive({overlayClass:[n],overlayStyle:{},triggerHover:!1,overlayHover:!1}),i=g.ref(),o=g.ref(),a=()=>{var P;t.trigger==="hover"&&(r.triggerHover=!0);const u=i.value,f=o.value,d=u.getBoundingClientRect(),p=u.offsetTop,m=u.offsetLeft,$=d.height,Q=d.width,y=((P=document.querySelector(t.relative))==null?void 0:P.scrollLeft)||0;r.overlayStyle={...r.overlayStyle,top:p+$+"px",left:m-f.offsetWidth/2+Q/2-y+"px"},t.onChange(!0)},O=()=>{r.overlayHover=!0};g.watch(()=>t.visible,u=>{u?r.overlayClass=r.overlayClass.filter(f=>f!==n):r.overlayClass.push(n)});const l=u=>{const f=i.value,d=o.value;!f.contains(u.target)&&!d.contains(u.target)&&t.onChange(!1)};let s=-1;const c=u=>{i.value===u.target?r.triggerHover=!1:r.overlayHover=!1,clearTimeout(s),s=window.setTimeout(()=>{!r.overlayHover&&!r.triggerHover&&t.onChange(!1)},10)};return g.onMounted(()=>{t.trigger==="click"?(i.value.addEventListener("click",a),document.addEventListener("click",l)):(i.value.addEventListener("mouseenter",a),i.value.addEventListener("mouseleave",c),o.value.addEventListener("mouseenter",O),o.value.addEventListener("mouseleave",c))}),g.onBeforeUnmount(()=>{t.trigger==="click"?(i.value.removeEventListener("click",a),document.removeEventListener("click",l)):(i.value.removeEventListener("mouseenter",a),i.value.removeEventListener("mouseleave",c),o.value.removeEventListener("mouseenter",O),o.value.removeEventListener("mouseleave",c))}),()=>{const u=Cn({ctx:e}),f=Cn({props:t,ctx:e},"overlay"),d=g.cloneVNode(u instanceof Array?u[0]:u,{ref:i}),p=g.createVNode("div",{class:[`${W}-dropdown`,r.overlayClass],style:r.overlayStyle,ref:o},[g.createVNode("div",{class:`${W}-dropdown-overlay`},[f instanceof Array?f[0]:f])]);return[d,p]}}});class VT{constructor(){je(this,"pools",{})}remove(e,n,r){const o=this.pools[e]&&this.pools[e][n];o&&(this.pools[e][n]=o.filter(a=>a!==r))}clear(e){this.pools[e]={}}on(e,n){return this.pools[e]||(this.pools[e]={}),this.pools[e][n.name]||(this.pools[e][n.name]=[]),this.pools[e][n.name].push(n.callback),this.pools[e][n.name].includes(n.callback)}emit(e,n,...r){this.pools[e]||(this.pools[e]={});const o=this.pools[e][n];o&&o.forEach(a=>{try{a(...r)}catch(O){console.error(`${n} monitor event exception!`,O)}})}}const K=new VT,ql=(t,e=200)=>{let n=0;return(...r)=>new Promise(i=>{n&&(clearTimeout(n),i("cancel")),n=window.setTimeout(()=>{t.apply(void 0,r),n=0,i("done")},e)})},ET=(t,e={_blank:!0,nofollow:!0})=>{const n=document.createElement("a");n.href=t,e._blank&&(n.target="_blank"),e.nofollow&&(n.rel="noopener noreferrer"),n.click()},wg=(t,e,n,r=100)=>{let i=t.scrollTop;const o=()=>{const a=e-i;i=i+a/5,Math.abs(a)<1?(t.scrollTo(0,e),n&&(typeof r=="number"?setTimeout(n,r):n())):(t.scrollTo(0,i),requestAnimationFrame(o))};o()},vg=(t,e=200)=>{let n=0,r=null;return(...i)=>{const o=a=>{n===0&&(n=a),a-n>=e?(t.apply(void 0,r),r=null,n=0):window.requestAnimationFrame(o)};r===null&&window.requestAnimationFrame(o),r=i}},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}},Wl="onSave",Fu="changeCatalogVisible",Xg="changeFullscreen",_g="pageFullscreenChanged",Tg="fullscreenChanged",Rg="previewChanged",qg="htmlPreviewChanged",Wg="catalogVisibleChanged",zg="textareaFocus",Ug=(t,e)=>{const n=r=>{const i=t.parentElement||document.body,o=i.offsetWidth,a=i.offsetHeight,{clientWidth:O}=document.documentElement,{clientHeight:l}=document.documentElement,s=r.offsetX,c=r.offsetY,u=d=>{let p=d.x+document.body.scrollLeft-document.body.clientLeft-s,m=d.y+document.body.scrollTop-document.body.clientTop-c;p=p<1?1:p<O-o-1?p:O-o-1,m=m<1?1:m<l-a-1?m:l-a-1,e?e(p,m):(i.style.left=`${p}px`,i.style.top=`${m}px`)};document.addEventListener("mousemove",u);const f=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",f)};document.addEventListener("mouseup",f)};return t.addEventListener("mousedown",n),()=>{t.removeEventListener("mousedown",n)}},An=(t,e="")=>{const n=document.getElementById(t.id),r=t.onload;t.onload=null;const i=function(o){typeof r=="function"&&r.bind(this)(o),t.removeEventListener("load",i)};n?e!==""&&(n.addEventListener("load",i),Reflect.get(window,e)&&n.dispatchEvent(new Event("load"))):(t.addEventListener("load",i),document.head.appendChild(t))},AT=ql((t,e,n)=>{const r=document.getElementById(t);r&&r.setAttribute(e,n)},10),jT=t=>{var l,s,c,u;const e=g.inject("editorId");let n=(s=(l=Ve.editorExtensions)==null?void 0:l.screenfull)==null?void 0:s.instance;const r=(u=(c=Ve.editorExtensions)==null?void 0:c.screenfull)==null?void 0:u.js,i=g.ref(!1),o=f=>{if(!n){K.emit(e,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}n.isEnabled?(i.value=!0,(f===void 0?!n.isFullscreen:f)?n.request():n.exit()):console.error("browser does not support screenfull!")},a=()=>{n&&n.isEnabled&&n.on("change",()=>{(i.value||t.setting.fullscreen)&&(i.value=!1,t.updateSetting("fullscreen"))})},O=()=>{n=window.screenfull,a()};return g.onMounted(()=>{if(a(),!n){const f=document.createElement("script");f.src=r||WT,f.onload=O,f.id=`${W}-screenfull`,An(f,"screenfull")}}),g.onMounted(()=>{K.on(e,{name:Xg,callback:o})}),{fullscreenHandler:o}},IT={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},GT=g.defineComponent({name:"TableShape",props:IT,setup(t){const e=g.reactive({x:-1,y:-1});return()=>g.createVNode("div",{class:`${W}-table-shape`,onMouseleave:()=>{e.x=-1,e.y=-1}},[new Array(t.tableShape[1]).fill("").map((n,r)=>g.createVNode("div",{class:`${W}-table-shape-row`,key:`table-shape-row-${r}`},[new Array(t.tableShape[0]).fill("").map((i,o)=>g.createVNode("div",{class:`${W}-table-shape-col`,key:`table-shape-col-${o}`,onMouseenter:()=>{e.x=r,e.y=o},onClick:()=>{t.onSelected(e)}},[g.createVNode("div",{class:[`${W}-table-shape-col-default`,r<=e.x&&o<=e.y&&`${W}-table-shape-col-include`]},null)]))]))])}}),DT={title:{type:String,default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function,default:()=>{}},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>{}},class:{type:String}},Hu=g.defineComponent({props:DT,setup(t,e){const n=g.ref(t.visible),r=g.ref([`${W}-modal`]),i=g.ref(),o=g.ref();let a=()=>{};const O=g.reactive({initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),l=g.computed(()=>t.isFullscreen?{width:"100%",height:"100%"}:{width:t.width,height:t.height});return g.onMounted(()=>{a=Ug(o.value,(s,c)=>{O.initPos.left=s+"px",O.initPos.top=c+"px"})}),g.onBeforeUnmount(()=>{a()}),g.watch(()=>t.isFullscreen,s=>{s?a():a=Ug(o.value,(c,u)=>{O.initPos.left=c+"px",O.initPos.top=u+"px"})}),g.watch(()=>t.visible,s=>{s?(r.value.push("zoom-in"),n.value=s,g.nextTick(()=>{const c=i.value.offsetWidth/2,u=i.value.offsetHeight/2,f=document.documentElement.clientWidth/2,d=document.documentElement.clientHeight/2;O.initPos.left=f-c+"px",O.initPos.top=d-u+"px"}),setTimeout(()=>{r.value=r.value.filter(c=>c!=="zoom-in")},140)):(r.value.push("zoom-out"),setTimeout(()=>{r.value=r.value.filter(c=>c!=="zoom-out"),n.value=s},130))}),()=>{const s=Cn({ctx:e}),c=Cn({props:t,ctx:e},"title");return g.createVNode("div",{class:[t.class],style:{display:n.value?"block":"none"}},[g.createVNode("div",{class:`${W}-modal-mask`,onClick:t.onClose},null),g.createVNode("div",{class:r.value,style:{...O.initPos,...l.value},ref:i},[g.createVNode("div",{class:`${W}-modal-header`,ref:o},[c||""]),g.createVNode("div",{class:`${W}-modal-body`},[s]),g.createVNode("div",{class:`${W}-modal-func`},[t.showAdjust&&g.createVNode("div",{class:`${W}-modal-adjust`,onClick:u=>{u.stopPropagation(),t.isFullscreen?O.initPos=O.historyPos:(O.historyPos=O.initPos,O.initPos={left:"0",top:"0"}),t.onAdjust(!t.isFullscreen)}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":`#md-editor-icon-${t.isFullscreen?"suoxiao":"fangda"}`},null)])]),g.createVNode("div",{class:`${W}-modal-close`,onClick:u=>{u.stopPropagation(),t.onClose&&t.onClose()}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-close"},null)])])])])])}}}),NT={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},LT=g.defineComponent({props:NT,setup(t){const e=g.inject("usedLanguageText"),n=g.inject("editorId"),r=g.computed(()=>{var o,a;switch(t.type){case"link":return(o=e.value.linkModalTips)==null?void 0:o.linkTitle;case"image":return(a=e.value.linkModalTips)==null?void 0:a.imageTitle;default:return""}}),i=g.reactive({desc:"",url:""});return g.watch(()=>t.visible,o=>{o||setTimeout(()=>{i.desc="",i.url=""},200)}),()=>g.createVNode(Hu,{title:r.value,visible:t.visible,onClose:t.onCancel},{default:()=>{var o,a,O,l,s;return[g.createVNode("div",{class:`${W}-form-item`},[g.createVNode("label",{class:`${W}-label`,for:`link-desc-${n}`},[(o=e.value.linkModalTips)==null?void 0:o.descLabel]),g.createVNode("input",{placeholder:(a=e.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${W}-input`,id:`link-desc-${n}`,type:"text",value:i.desc,onChange:c=>{i.desc=c.target.value},autocomplete:"off"},null)]),g.createVNode("div",{class:`${W}-form-item`},[g.createVNode("label",{class:`${W}-label`,for:`link-url-${n}`},[(O=e.value.linkModalTips)==null?void 0:O.urlLabel]),g.createVNode("input",{placeholder:(l=e.value.linkModalTips)==null?void 0:l.urlLabelPlaceHolder,class:`${W}-input`,id:`link-url-${n}`,type:"text",value:i.url,onChange:c=>{i.url=c.target.value},autocomplete:"off"},null)]),g.createVNode("div",{class:`${W}-form-item`},[g.createVNode("button",{class:[`${W}-btn`,`${W}-btn-row`],type:"button",onClick:()=>{t.onOk(i),i.desc="",i.url=""}},[(s=e.value.linkModalTips)==null?void 0:s.buttonOK])])]}})}}),MT=(t,e="image.png")=>{const n=t.split(","),r=n[0].match(/:(.*?);/);if(r){const i=r[1],o=atob(n[1]);let a=o.length;const O=new Uint8Array(a);for(;a--;)O[a]=o.charCodeAt(a);return new File([O],e,{type:i})}return null},BT=t=>{if(!t)return t;const e=t.split(`
2
- `),n=['<span rn-wrapper aria-hidden="true">'];return e.forEach(()=>{n.push("<span></span>")}),n.push("</span>"),`<span class="code-block">${t}</span>${n.join("")}`},FT=(t,e)=>{const n=t==null?void 0:t.getBoundingClientRect();if(e===document.documentElement)return n.top-e.clientTop;const r=e==null?void 0:e.getBoundingClientRect();return n.top-r.top},HT=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`,KT={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},JT=g.defineComponent({props:KT,setup(t){var c,u;const e=g.inject("usedLanguageText"),n=g.inject("editorId");let r=(u=(c=Ve==null?void 0:Ve.editorExtensions)==null?void 0:c.cropper)==null?void 0:u.instance;const i=g.ref(),o=g.ref(),a=g.ref(),O=g.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let l=null;g.watch(()=>t.visible,()=>{t.visible&&!O.cropperInited&&(r=r||window.Cropper,i.value.onchange=()=>{if(!r){K.emit(n,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const f=i.value.files||[];if(O.imgSelected=!0,(f==null?void 0:f.length)>0){const d=new FileReader;d.onload=p=>{O.imgSrc=p.target.result,g.nextTick(()=>{l=new r(o.value,{viewMode:2,preview:`.${W}-clip-preview-target`})})},d.readAsDataURL(f[0])}})}),g.watch(()=>[O.imgSelected],()=>{a.value.style=""}),g.watch(()=>O.isFullscreen,()=>{g.nextTick(()=>{l==null||l.destroy(),a.value.style="",o.value&&(l=new r(o.value,{viewMode:2,preview:`.${W}-clip-preview-target`}))})});const s=()=>{l.clear(),l.destroy(),l=null,i.value.value="",O.imgSelected=!1};return()=>{var f;return g.createVNode(Hu,{class:`${W}-modal-clip`,title:(f=e.value.clipModalTips)==null?void 0:f.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:O.isFullscreen,onAdjust:d=>{O.isFullscreen=d},width:"668px",height:"421px"},{default:()=>{var d,p;return[g.createVNode("div",{class:`${W}-form-item ${W}-clip`},[g.createVNode("div",{class:`${W}-clip-main`},[O.imgSelected?g.createVNode("div",{class:`${W}-clip-cropper`},[g.createVNode("img",{src:O.imgSrc,ref:o,style:{display:"none"},alt:""},null),g.createVNode("div",{class:`${W}-clip-delete`,onClick:s},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):g.createVNode("div",{class:`${W}-clip-upload`,onClick:()=>{i.value.click()}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),g.createVNode("div",{class:`${W}-clip-preview`},[g.createVNode("div",{class:`${W}-clip-preview-target`,ref:a},null)])]),g.createVNode("div",{class:`${W}-form-item`},[g.createVNode("button",{class:`${W}-btn`,type:"button",onClick:()=>{if(l){const m=l.getCroppedCanvas();K.emit(n,"uploadImage",[MT(m.toDataURL("image/png"))],t.onOk),s()}}},[((d=e.value.clipModalTips)==null?void 0:d.buttonUpload)||((p=e.value.linkModalTips)==null?void 0:p.buttonOK)])]),g.createVNode("input",{ref:i,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),e0={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},t0=g.defineComponent({props:e0,setup(t){return()=>g.createVNode(g.Fragment,null,[g.createVNode(LT,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),g.createVNode(JT,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),n0=g.defineComponent({name:"MDEditorToolbar",props:CT,setup(t){const e=g.inject("editorId"),n=g.inject("usedLanguageText"),{fullscreenHandler:r}=jT(t),i=`${e}-toolbar-wrapper`,o=g.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),a=(d,p)=>{K.emit(e,"replace",d,p)},O=g.reactive({type:"link",linkVisible:!1,clipVisible:!1}),l=g.ref();g.onMounted(()=>{K.on(e,{name:"openModals",callback(d){O.type=d,O.linkVisible=!0}})});const s=g.computed(()=>{const d=t.toolbars.filter(Q=>!t.toolbarsExclude.includes(Q)),p=d.indexOf("="),m=p===-1?d:d.slice(0,p+1),$=p===-1?[]:d.slice(p,Number.MAX_SAFE_INTEGER);return[m,$]}),c=g.ref(),u=()=>{K.emit(e,"uploadImage",Array.from(c.value.files||[])),c.value.value=""};g.onMounted(()=>{c.value.addEventListener("change",u)});const f=d=>{var p,m,$,Q,y,P,R,x,w,v,X,k,z,Y,C,V,S,U,q,Z,G,N,j,D,te,Qe,At,M,Oe,xe,Ue,st,Vn,yn,Or,za,Xo,ni,Ua,Za,_o,Eu,Cu;if(yg.includes(d))switch(d){case"-":return g.createVNode(ZT,null,null);case"bold":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(p=n.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{a("bold")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(m=n.value.toolbarTips)==null?void 0:m.underline,onClick:()=>{a("underline")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return g.createVNode("div",{class:`${W}-toolbar-item`,title:($=n.value.toolbarTips)==null?void 0:$.italic,onClick:()=>{a("italic")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Q=n.value.toolbarTips)==null?void 0:Q.strikeThrough,onClick:()=>{a("strikeThrough")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return g.createVNode(Wo,{relative:`#${i}`,visible:o.title,onChange:ke=>{o.title=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.title=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h1")}},[(y=n.value.titleItem)==null?void 0:y.h1]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h2")}},[(P=n.value.titleItem)==null?void 0:P.h2]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h3")}},[(R=n.value.titleItem)==null?void 0:R.h3]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h4")}},[(x=n.value.titleItem)==null?void 0:x.h4]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h5")}},[(w=n.value.titleItem)==null?void 0:w.h5]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h6")}},[(v=n.value.titleItem)==null?void 0:v.h6])])},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.title},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(X=n.value.toolbarTips)==null?void 0:X.sub,onClick:()=>{a("sub")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(k=n.value.toolbarTips)==null?void 0:k.sup,onClick:()=>{a("sup")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(z=n.value.toolbarTips)==null?void 0:z.quote,onClick:()=>{a("quote")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Y=n.value.toolbarTips)==null?void 0:Y.unorderedList,onClick:()=>{a("unorderedList")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(C=n.value.toolbarTips)==null?void 0:C.orderedList,onClick:()=>{a("orderedList")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.task,onClick:()=>{a("task")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(S=n.value.toolbarTips)==null?void 0:S.codeRow,onClick:()=>{a("codeRow")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(U=n.value.toolbarTips)==null?void 0:U.code,onClick:()=>{a("code")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(q=n.value.toolbarTips)==null?void 0:q.link,onClick:()=>{O.type="link",O.linkVisible=!0}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?g.createVNode("div",{class:`${W}-toolbar-item`,title:(Z=n.value.toolbarTips)==null?void 0:Z.image,onClick:()=>{O.type="image",O.linkVisible=!0}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):g.createVNode(Wo,{relative:`#${i}`,visible:o.image,onChange:ke=>{o.image=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.title=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{O.type="image",O.linkVisible=!0}},[(G=n.value.imgTitleItem)==null?void 0:G.link]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{c.value.click()}},[(N=n.value.imgTitleItem)==null?void 0:N.upload]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{O.clipVisible=!0}},[(j=n.value.imgTitleItem)==null?void 0:j.clip2upload])])},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.image},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return g.createVNode(Wo,{relative:`#${i}`,visible:o.table,onChange:ke=>{o.table=ke},key:"bar-table",overlay:g.createVNode(GT,{tableShape:t.tableShape,onSelected:ke=>{a("table",{selectedShape:ke})}},null)},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.table},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(D=n.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{K.emit(e,"ctrlZ")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(te=n.value.toolbarTips)==null?void 0:te.next,onClick:()=>{K.emit(e,"ctrlShiftZ")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Qe=n.value.toolbarTips)==null?void 0:Qe.save,onClick:()=>{K.emit(e,Wl)}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":g.createVNode("div",{class:`${W}-toolbar-item`,title:(At=n.value.toolbarTips)==null?void 0:At.prettier,onClick:()=>{a("prettier")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&g.createVNode("div",{class:`${W}-toolbar-item`,title:(M=n.value.toolbarTips)==null?void 0:M.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Oe=n.value.toolbarTips)==null?void 0:Oe.fullscreen,onClick:()=>{r()}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(xe=n.value.toolbarTips)==null?void 0:xe.preview,onClick:()=>{t.updateSetting("preview")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Ue=n.value.toolbarTips)==null?void 0:Ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(st=n.value.toolbarTips)==null?void 0:st.catalog,onClick:()=>{K.emit(e,Fu)},key:"bar-catalog"},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Vn=n.value.toolbarTips)==null?void 0:Vn.github,onClick:()=>ET("https://github.com/imzbf/md-editor-v3")},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return g.createVNode(Wo,{relative:`#${i}`,visible:o.mermaid,onChange:ke=>{o.mermaid=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.mermaid=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("flow")}},[(yn=n.value.mermaid)==null?void 0:yn.flow]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("sequence")}},[(Or=n.value.mermaid)==null?void 0:Or.sequence]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("gantt")}},[(za=n.value.mermaid)==null?void 0:za.gantt]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("class")}},[(Xo=n.value.mermaid)==null?void 0:Xo.class]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("state")}},[(ni=n.value.mermaid)==null?void 0:ni.state]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("pie")}},[(Ua=n.value.mermaid)==null?void 0:Ua.pie]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("relationship")}},[(Za=n.value.mermaid)==null?void 0:Za.relationship]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("journey")}},[(_o=n.value.mermaid)==null?void 0:_o.journey])]),key:"bar-mermaid"},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.mermaid},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return g.createVNode(Wo,{relative:`#${i}`,visible:o.katex,onChange:ke=>{o.katex=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.katex=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("katexInline")}},[(Eu=n.value.katex)==null?void 0:Eu.inline]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("katexBlock")}},[(Cu=n.value.katex)==null?void 0:Cu.block])]),key:"bar-katex"},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.katex},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[d]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[d]||""};return()=>{const d=s.value[0].map(m=>f(m)),p=s.value[1].map(m=>f(m));return g.createVNode(g.Fragment,null,[t.toolbars.length>0&&g.createVNode("div",{class:`${W}-toolbar-wrapper`,id:i},[g.createVNode("div",{class:`${W}-toolbar`},[g.createVNode("div",{class:`${W}-toolbar-left`,ref:l},[d]),g.createVNode("div",{class:`${W}-toolbar-right`},[p])])]),g.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),g.createVNode(t0,{linkVisible:O.linkVisible,clipVisible:O.clipVisible,type:O.type,onCancel:()=>{O.linkVisible=!1,O.clipVisible=!1},onOk:m=>{m&&a(O.type,{desc:m.desc,url:m.url}),O.linkVisible=!1,O.clipVisible=!1}},null)])}}}),r0=(t,e)=>{const n=ql(()=>{t.removeEventListener("scroll",r),t.addEventListener("scroll",r),e.removeEventListener("scroll",r),e.addEventListener("scroll",r)},50),r=i=>{const o=t.clientHeight,a=e.clientHeight,O=t.scrollHeight,l=e.scrollHeight,s=(O-o)/(l-a);i.target===t?(e.removeEventListener("scroll",r),e.scrollTo({top:t.scrollTop/s}),n()):(t.removeEventListener("scroll",r),t.scrollTo({top:e.scrollTop*s}),n())};return[()=>{n().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",r),e.removeEventListener("scroll",r)}]},i0=(t,e,n)=>{const{view:r}=n,i=u=>r.lineBlockAt(r.state.doc.line(u).from).top,o=u=>r.lineBlockAt(r.state.doc.line(u).from).height;let a=[];const O=()=>{a=[];const u=Array.from(e.querySelectorAll("[data-line]")).map(m=>Number(m.dataset.line)+1),{lines:f}=r.state.doc;let d=1,p=u.shift()??f;for(let m=1;m<=f;m++)m===p&&(d=m,p=u.shift()||f+1),a.push({start:d,end:p-1})};let l=0,s=0;const c=vg(u=>{var p,m,$,Q,y,P,R;if(!((p=e.firstElementChild)!=null&&p.firstElementChild))return;const f=r.lineBlockAtHeight(r.scrollDOM.scrollTop),{number:d}=r.state.doc.lineAt(f.from);if(!(d>a.length)&&!(r.state.doc.lines<a[a.length-1].end))if(u.target===t){if(s!==0)return;l++;const x=a[d-1],w=i(x.end)+o(x.end);let v=0;const X=i(x.start),k=e.querySelector(`[data-line="${x.start-1}"]`)||((m=e.firstElementChild)==null?void 0:m.firstElementChild),z=e.querySelector(`[data-line="${x.end}"]`)||(($=e.lastElementChild)==null?void 0:$.lastElementChild);let Y=0,C=0;X===0?(v=(r.scrollDOM.scrollTop-X)/(w-X),Y=z.offsetTop):w>r.scrollDOM.scrollHeight-r.scrollDOM.clientHeight?(v=(r.scrollDOM.scrollTop-X)/(r.scrollDOM.scrollHeight-r.scrollDOM.clientHeight-X),C=k.offsetTop,Y=e.scrollHeight-e.clientHeight-C+10):(v=(r.scrollDOM.scrollTop-X)/(w-X),C=k.offsetTop,Y=z.offsetTop-C);const V=C-10+Y*v;wg(e,V,()=>{l--})}else{if(l!==0)return;s++;const x=Array.from(e.querySelectorAll("[data-line]")),w=e.scrollTop,v=e.scrollHeight;let X=x.length===0?1:Math.ceil(Number(x[x.length-1].dataset.line)*(w/v)),k=(Q=e.firstElementChild)==null?void 0:Q.firstElementChild;for(let D=X;D>=0;D--){const te=e.querySelector(`[data-line="${D}"]`);if(te){k=te,X=D;break}}let z=(y=e.firstElementChild)==null?void 0:y.firstElementChild,Y=(P=e.firstElementChild)==null?void 0:P.lastElementChild;for(;x.length>0;){const D=x.indexOf(k);if(D+1>=x.length)break;const te=x[D+1];if(D===-1){Y=te;break}const Qe=k.offsetTop;if(Qe>w){if(D===0){z=k,Y=te;break}k=x[D-1];continue}const At=te.offsetTop;if(Qe<=w&&At>w){z=k,Y=te;break}k=te}const C=z.offsetTop,V=Y.offsetTop;let S=0;const{start:U,end:q}=a[Number(z.dataset.line||0)],Z=i(U);let G=i(q);const N=o(q);let j=0;z===((R=e.firstElementChild)==null?void 0:R.firstElementChild)?(S=Math.max(w/V,0),j=G+N-Z):G>r.scrollDOM.scrollHeight-r.scrollDOM.clientHeight?(S=Math.max((w-C)/(e.scrollHeight-C-e.clientHeight),0),G=i(r.state.doc.lines)+o(r.state.doc.lines),j=8+G-Z-t.clientHeight):(S=Math.max((w-C)/(V-C),0),j=G+N-Z),wg(t,Z+j*S,()=>{s--})}},10);return[()=>{O(),t.addEventListener("scroll",c),e.addEventListener("scroll",c),t.dispatchEvent(new Event("scroll"))},()=>{a=[],t.removeEventListener("scroll",c),e.removeEventListener("scroll",c)}]},o0=(t,e,n)=>{const r=g.inject("editorId");let i=()=>{},o=()=>{};const a=()=>{i();const O=document.querySelector(".cm-scroller"),l=document.querySelector(`[id="${r}-preview-wrapper"][data-show="true"]`),s=document.querySelector(`[id="${r}-html-wrapper"][data-show="true"]`);(l||s)&&([o,i]=(l?i0:r0)(O,l||s,n.value)),t.scrollAuto&&o()};g.watch([e,g.toRef(t.setting,"preview"),g.toRef(t.setting,"htmlPreview"),g.toRef(t.setting,"fullscreen"),g.toRef(t.setting,"pageFullscreen")],()=>{g.nextTick(a)}),g.watch(()=>t.scrollAuto,O=>{O?o():i()}),g.onMounted(a)};let qe=class _T{constructor(){}lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),sr.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){let r=[];return this.decompose(e,n,r,0),sr.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Ca(this),o=new Ca(e);for(let a=n,O=n;;){if(i.next(a),o.next(a),a=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(O+=i.value.length,i.done||O>=r)return!0}}iter(e=1){return new Ca(this,e)}iterRange(e,n=this.length){return new Yg(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new Vg(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?_T.empty:e.length<=32?new tt(e):sr.from(tt.split(e,[]))}};class tt extends qe{constructor(e,n=a0(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let o=0;;o++){let a=this.text[o],O=i+a.length;if((n?r:O)>=e)return new O0(i,O,r,a);i=O+1,r++}}decompose(e,n,r,i){let o=e<=0&&n>=this.length?this:new tt(Zg(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let a=r.pop(),O=zl(o.text,a.text.slice(),0,o.length);if(O.length<=32)r.push(new tt(O,a.length+o.length));else{let l=O.length>>1;r.push(new tt(O.slice(0,l)),new tt(O.slice(l)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof tt))return super.replace(e,n,r);let i=zl(this.text,zl(r.text,Zg(this.text,0,e)),n),o=this.length+r.length-(n-e);return i.length<=32?new tt(i,o):sr.from(tt.split(i,[]),o)}sliceString(e,n=this.length,r=`
2
+ `),n=['<span rn-wrapper aria-hidden="true">'];return e.forEach(()=>{n.push("<span></span>")}),n.push("</span>"),`<span class="code-block">${t}</span>${n.join("")}`},FT=(t,e)=>{const n=t==null?void 0:t.getBoundingClientRect();if(e===document.documentElement)return n.top-e.clientTop;const r=e==null?void 0:e.getBoundingClientRect();return n.top-r.top},HT=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`,KT={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},JT=g.defineComponent({props:KT,setup(t){var c,u;const e=g.inject("usedLanguageText"),n=g.inject("editorId");let r=(u=(c=Ve==null?void 0:Ve.editorExtensions)==null?void 0:c.cropper)==null?void 0:u.instance;const i=g.ref(),o=g.ref(),a=g.ref(),O=g.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let l=null;g.watch(()=>t.visible,()=>{t.visible&&!O.cropperInited&&(r=r||window.Cropper,i.value.onchange=()=>{if(!r){K.emit(n,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const f=i.value.files||[];if(O.imgSelected=!0,(f==null?void 0:f.length)>0){const d=new FileReader;d.onload=p=>{O.imgSrc=p.target.result,g.nextTick(()=>{l=new r(o.value,{viewMode:2,preview:`.${W}-clip-preview-target`})})},d.readAsDataURL(f[0])}})}),g.watch(()=>[O.imgSelected],()=>{a.value.style=""}),g.watch(()=>O.isFullscreen,()=>{g.nextTick(()=>{l==null||l.destroy(),a.value.style="",o.value&&(l=new r(o.value,{viewMode:2,preview:`.${W}-clip-preview-target`}))})});const s=()=>{l.clear(),l.destroy(),l=null,i.value.value="",O.imgSelected=!1};return()=>{var f;return g.createVNode(Hu,{class:`${W}-modal-clip`,title:(f=e.value.clipModalTips)==null?void 0:f.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:O.isFullscreen,onAdjust:d=>{O.isFullscreen=d},width:"668px",height:"421px"},{default:()=>{var d,p;return[g.createVNode("div",{class:`${W}-form-item ${W}-clip`},[g.createVNode("div",{class:`${W}-clip-main`},[O.imgSelected?g.createVNode("div",{class:`${W}-clip-cropper`},[g.createVNode("img",{src:O.imgSrc,ref:o,style:{display:"none"},alt:""},null),g.createVNode("div",{class:`${W}-clip-delete`,onClick:s},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):g.createVNode("div",{class:`${W}-clip-upload`,onClick:()=>{i.value.click()}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),g.createVNode("div",{class:`${W}-clip-preview`},[g.createVNode("div",{class:`${W}-clip-preview-target`,ref:a},null)])]),g.createVNode("div",{class:`${W}-form-item`},[g.createVNode("button",{class:`${W}-btn`,type:"button",onClick:()=>{if(l){const m=l.getCroppedCanvas();K.emit(n,"uploadImage",[MT(m.toDataURL("image/png"))],t.onOk),s()}}},[((d=e.value.clipModalTips)==null?void 0:d.buttonUpload)||((p=e.value.linkModalTips)==null?void 0:p.buttonOK)])]),g.createVNode("input",{ref:i,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),e0={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},t0=g.defineComponent({props:e0,setup(t){return()=>g.createVNode(g.Fragment,null,[g.createVNode(LT,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),g.createVNode(JT,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),n0=g.defineComponent({name:"MDEditorToolbar",props:CT,setup(t){const e=g.inject("editorId"),n=g.inject("usedLanguageText"),{fullscreenHandler:r}=jT(t),i=`${e}-toolbar-wrapper`,o=g.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),a=(d,p)=>{K.emit(e,"replace",d,p)},O=g.reactive({type:"link",linkVisible:!1,clipVisible:!1}),l=g.ref();g.onMounted(()=>{K.on(e,{name:"openModals",callback(d){O.type=d,O.linkVisible=!0}})});const s=g.computed(()=>{const d=t.toolbars.filter(Q=>!t.toolbarsExclude.includes(Q)),p=d.indexOf("="),m=p===-1?d:d.slice(0,p+1),$=p===-1?[]:d.slice(p,Number.MAX_SAFE_INTEGER);return[m,$]}),c=g.ref(),u=()=>{K.emit(e,"uploadImage",Array.from(c.value.files||[])),c.value.value=""};g.onMounted(()=>{c.value.addEventListener("change",u)});const f=d=>{var p,m,$,Q,y,P,R,x,w,v,X,k,z,Y,C,V,S,U,q,Z,G,N,j,D,te,Qe,At,M,Oe,xe,Ue,st,Vn,yn,Or,za,Xo,ni,Ua,Za,_o,Eu,Cu;if(yg.includes(d))switch(d){case"-":return g.createVNode(ZT,null,null);case"bold":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(p=n.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{a("bold")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(m=n.value.toolbarTips)==null?void 0:m.underline,onClick:()=>{a("underline")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return g.createVNode("div",{class:`${W}-toolbar-item`,title:($=n.value.toolbarTips)==null?void 0:$.italic,onClick:()=>{a("italic")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Q=n.value.toolbarTips)==null?void 0:Q.strikeThrough,onClick:()=>{a("strikeThrough")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return g.createVNode(Wo,{relative:`#${i}`,visible:o.title,onChange:ke=>{o.title=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.title=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h1")}},[(y=n.value.titleItem)==null?void 0:y.h1]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h2")}},[(P=n.value.titleItem)==null?void 0:P.h2]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h3")}},[(R=n.value.titleItem)==null?void 0:R.h3]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h4")}},[(x=n.value.titleItem)==null?void 0:x.h4]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h5")}},[(w=n.value.titleItem)==null?void 0:w.h5]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("h6")}},[(v=n.value.titleItem)==null?void 0:v.h6])])},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.title},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(X=n.value.toolbarTips)==null?void 0:X.sub,onClick:()=>{a("sub")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(k=n.value.toolbarTips)==null?void 0:k.sup,onClick:()=>{a("sup")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(z=n.value.toolbarTips)==null?void 0:z.quote,onClick:()=>{a("quote")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Y=n.value.toolbarTips)==null?void 0:Y.unorderedList,onClick:()=>{a("unorderedList")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(C=n.value.toolbarTips)==null?void 0:C.orderedList,onClick:()=>{a("orderedList")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.task,onClick:()=>{a("task")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(S=n.value.toolbarTips)==null?void 0:S.codeRow,onClick:()=>{a("codeRow")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(U=n.value.toolbarTips)==null?void 0:U.code,onClick:()=>{a("code")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(q=n.value.toolbarTips)==null?void 0:q.link,onClick:()=>{O.type="link",O.linkVisible=!0}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?g.createVNode("div",{class:`${W}-toolbar-item`,title:(Z=n.value.toolbarTips)==null?void 0:Z.image,onClick:()=>{O.type="image",O.linkVisible=!0}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):g.createVNode(Wo,{relative:`#${i}`,visible:o.image,onChange:ke=>{o.image=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.title=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{O.type="image",O.linkVisible=!0}},[(G=n.value.imgTitleItem)==null?void 0:G.link]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{c.value.click()}},[(N=n.value.imgTitleItem)==null?void 0:N.upload]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{O.clipVisible=!0}},[(j=n.value.imgTitleItem)==null?void 0:j.clip2upload])])},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.image},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return g.createVNode(Wo,{relative:`#${i}`,visible:o.table,onChange:ke=>{o.table=ke},key:"bar-table",overlay:g.createVNode(GT,{tableShape:t.tableShape,onSelected:ke=>{a("table",{selectedShape:ke})}},null)},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.table},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(D=n.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{K.emit(e,"ctrlZ")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(te=n.value.toolbarTips)==null?void 0:te.next,onClick:()=>{K.emit(e,"ctrlShiftZ")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Qe=n.value.toolbarTips)==null?void 0:Qe.save,onClick:()=>{K.emit(e,Wl)}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":g.createVNode("div",{class:`${W}-toolbar-item`,title:(At=n.value.toolbarTips)==null?void 0:At.prettier,onClick:()=>{a("prettier")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&g.createVNode("div",{class:`${W}-toolbar-item`,title:(M=n.value.toolbarTips)==null?void 0:M.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Oe=n.value.toolbarTips)==null?void 0:Oe.fullscreen,onClick:()=>{r()}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(xe=n.value.toolbarTips)==null?void 0:xe.preview,onClick:()=>{t.updateSetting("preview")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Ue=n.value.toolbarTips)==null?void 0:Ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(st=n.value.toolbarTips)==null?void 0:st.catalog,onClick:()=>{K.emit(e,Fu)},key:"bar-catalog"},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return g.createVNode("div",{class:`${W}-toolbar-item`,title:(Vn=n.value.toolbarTips)==null?void 0:Vn.github,onClick:()=>ET("https://github.com/imzbf/md-editor-v3")},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return g.createVNode(Wo,{relative:`#${i}`,visible:o.mermaid,onChange:ke=>{o.mermaid=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.mermaid=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("flow")}},[(yn=n.value.mermaid)==null?void 0:yn.flow]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("sequence")}},[(Or=n.value.mermaid)==null?void 0:Or.sequence]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("gantt")}},[(za=n.value.mermaid)==null?void 0:za.gantt]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("class")}},[(Xo=n.value.mermaid)==null?void 0:Xo.class]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("state")}},[(ni=n.value.mermaid)==null?void 0:ni.state]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("pie")}},[(Ua=n.value.mermaid)==null?void 0:Ua.pie]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("relationship")}},[(Za=n.value.mermaid)==null?void 0:Za.relationship]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("journey")}},[(_o=n.value.mermaid)==null?void 0:_o.journey])]),key:"bar-mermaid"},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.mermaid},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return g.createVNode(Wo,{relative:`#${i}`,visible:o.katex,onChange:ke=>{o.katex=ke},overlay:g.createVNode("ul",{class:`${W}-menu`,onClick:()=>{o.katex=!1}},[g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("katexInline")}},[(Eu=n.value.katex)==null?void 0:Eu.inline]),g.createVNode("li",{class:`${W}-menu-item`,onClick:()=>{a("katexBlock")}},[(Cu=n.value.katex)==null?void 0:Cu.block])]),key:"bar-katex"},{default:()=>{var ke;return[g.createVNode("div",{class:`${W}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.katex},[g.createVNode("svg",{class:`${W}-icon`,"aria-hidden":"true"},[g.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[d]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[d]||""};return()=>{const d=s.value[0].map(m=>f(m)),p=s.value[1].map(m=>f(m));return g.createVNode(g.Fragment,null,[t.toolbars.length>0&&g.createVNode("div",{class:`${W}-toolbar-wrapper`,id:i},[g.createVNode("div",{class:`${W}-toolbar`},[g.createVNode("div",{class:`${W}-toolbar-left`,ref:l},[d]),g.createVNode("div",{class:`${W}-toolbar-right`},[p])])]),g.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),g.createVNode(t0,{linkVisible:O.linkVisible,clipVisible:O.clipVisible,type:O.type,onCancel:()=>{O.linkVisible=!1,O.clipVisible=!1},onOk:m=>{m&&a(O.type,{desc:m.desc,url:m.url}),O.linkVisible=!1,O.clipVisible=!1}},null)])}}}),r0=(t,e)=>{const n=ql(()=>{t.removeEventListener("scroll",r),t.addEventListener("scroll",r),e.removeEventListener("scroll",r),e.addEventListener("scroll",r)},50),r=i=>{const o=t.clientHeight,a=e.clientHeight,O=t.scrollHeight,l=e.scrollHeight,s=(O-o)/(l-a);i.target===t?(e.removeEventListener("scroll",r),e.scrollTo({top:t.scrollTop/s}),n()):(t.removeEventListener("scroll",r),t.scrollTo({top:e.scrollTop*s}),n())};return[()=>{n().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",r),e.removeEventListener("scroll",r)}]},i0=(t,e,n)=>{const{view:r}=n,i=u=>r.lineBlockAt(r.state.doc.line(u).from).top,o=u=>r.lineBlockAt(r.state.doc.line(u).from).height;let a=[];const O=()=>{a=[];const u=Array.from(e.querySelectorAll("[data-line]")).map(m=>Number(m.dataset.line)+1),{lines:f}=r.state.doc;let d=1,p=u.shift()??f;for(let m=1;m<=f;m++)m===p&&(d=m,p=u.shift()||f+1),a.push({start:d,end:p-1})};let l=0,s=0;const c=vg(u=>{var p,m,$,Q,y,P,R;if(!((p=e.firstElementChild)!=null&&p.firstElementChild))return;const f=r.lineBlockAtHeight(r.scrollDOM.scrollTop),{number:d}=r.state.doc.lineAt(f.from);if(!(d>a.length)&&!(r.state.doc.lines<a[a.length-1].end))if(u.target===t){if(s!==0)return;l++;const x=a[d-1],w=i(x.end)+o(x.end);let v=0;const X=i(x.start),k=e.querySelector(`[data-line="${x.start-1}"]`)||((m=e.firstElementChild)==null?void 0:m.firstElementChild),z=e.querySelector(`[data-line="${x.end}"]`)||(($=e.lastElementChild)==null?void 0:$.lastElementChild);let Y=0,C=0;X===0?(v=(r.scrollDOM.scrollTop-X)/(w-X),Y=z.offsetTop):w>r.scrollDOM.scrollHeight-r.scrollDOM.clientHeight?(v=(r.scrollDOM.scrollTop-X)/(r.scrollDOM.scrollHeight-r.scrollDOM.clientHeight-X),C=k.offsetTop,Y=e.scrollHeight-e.clientHeight-C+10):(v=(r.scrollDOM.scrollTop-X)/(w-X),C=k.offsetTop,Y=z.offsetTop-C);const V=C-10+Y*v;wg(e,V,()=>{l--})}else{if(l!==0)return;s++;const x=Array.from(e.querySelectorAll("[data-line]")),w=e.scrollTop,v=e.scrollHeight;let X=x.length===0?1:Math.ceil(Number(x[x.length-1].dataset.line)*(w/v)),k=(Q=e.firstElementChild)==null?void 0:Q.firstElementChild;for(let D=X;D>=0;D--){const te=e.querySelector(`[data-line="${D}"]`);if(te&&te.offsetTop<=w){k=te,X=D;break}}let z=(y=e.firstElementChild)==null?void 0:y.firstElementChild,Y=(P=e.firstElementChild)==null?void 0:P.lastElementChild;for(;x.length>0;){const D=x.indexOf(k);if(D+1>=x.length)break;const te=x[D+1];if(D===-1){Y=te;break}const Qe=k.offsetTop;if(Qe>w){if(D===0){z=k,Y=te;break}k=x[D-1];continue}const At=te.offsetTop;if(Qe<=w&&At>w){z=k,Y=te;break}k=te}const C=z.offsetTop,V=Y.offsetTop;let S=0;const{start:U,end:q}=a[Number(z.dataset.line||0)],Z=i(U);let G=i(q);const N=o(q);let j=0;z===((R=e.firstElementChild)==null?void 0:R.firstElementChild)?(S=Math.max(w/V,0),j=G+N-Z):G>r.scrollDOM.scrollHeight-r.scrollDOM.clientHeight?(S=Math.max((w-C)/(e.scrollHeight-C-e.clientHeight),0),G=i(r.state.doc.lines)+o(r.state.doc.lines),j=8+G-Z-t.clientHeight):(S=Math.max((w-C)/(V-C),0),j=G+N-Z),wg(t,Z+j*S,()=>{s--})}},10);return[()=>{O(),t.addEventListener("scroll",c),e.addEventListener("scroll",c),t.dispatchEvent(new Event("scroll"))},()=>{a=[],t.removeEventListener("scroll",c),e.removeEventListener("scroll",c)}]},o0=(t,e,n)=>{const r=g.inject("editorId");let i=()=>{},o=()=>{};const a=()=>{i();const O=document.querySelector(".cm-scroller"),l=document.querySelector(`[id="${r}-preview-wrapper"][data-show="true"]`),s=document.querySelector(`[id="${r}-html-wrapper"][data-show="true"]`);(l||s)&&([o,i]=(l?i0:r0)(O,l||s,n.value)),t.scrollAuto&&o()};g.watch([e,g.toRef(t.setting,"preview"),g.toRef(t.setting,"htmlPreview"),g.toRef(t.setting,"fullscreen"),g.toRef(t.setting,"pageFullscreen")],()=>{g.nextTick(a)}),g.watch(()=>t.scrollAuto,O=>{O?o():i()}),g.onMounted(a)};let qe=class _T{constructor(){}lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),sr.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){let r=[];return this.decompose(e,n,r,0),sr.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Ca(this),o=new Ca(e);for(let a=n,O=n;;){if(i.next(a),o.next(a),a=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(O+=i.value.length,i.done||O>=r)return!0}}iter(e=1){return new Ca(this,e)}iterRange(e,n=this.length){return new Yg(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new Vg(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?_T.empty:e.length<=32?new tt(e):sr.from(tt.split(e,[]))}};class tt extends qe{constructor(e,n=a0(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let o=0;;o++){let a=this.text[o],O=i+a.length;if((n?r:O)>=e)return new O0(i,O,r,a);i=O+1,r++}}decompose(e,n,r,i){let o=e<=0&&n>=this.length?this:new tt(Zg(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let a=r.pop(),O=zl(o.text,a.text.slice(),0,o.length);if(O.length<=32)r.push(new tt(O,a.length+o.length));else{let l=O.length>>1;r.push(new tt(O.slice(0,l)),new tt(O.slice(l)))}}else r.push(o)}replace(e,n,r){if(!(r instanceof tt))return super.replace(e,n,r);let i=zl(this.text,zl(r.text,Zg(this.text,0,e)),n),o=this.length+r.length-(n-e);return i.length<=32?new tt(i,o):sr.from(tt.split(i,[]),o)}sliceString(e,n=this.length,r=`
3
3
  `){let i="";for(let o=0,a=0;o<=n&&a<this.text.length;a++){let O=this.text[a],l=o+O.length;o>e&&a&&(i+=r),e<l&&n>o&&(i+=O.slice(Math.max(0,e-o),n-o)),o=l+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let o of e)r.push(o),i+=o.length+1,r.length==32&&(n.push(new tt(r,i)),r=[],i=-1);return i>-1&&n.push(new tt(r,i)),n}}class sr extends qe{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let o=0;;o++){let a=this.children[o],O=i+a.length,l=r+a.lines-1;if((n?l:O)>=e)return a.lineInner(e,n,r,i);i=O+1,r=l+1}}decompose(e,n,r,i){for(let o=0,a=0;a<=n&&o<this.children.length;o++){let O=this.children[o],l=a+O.length;if(e<=l&&n>=a){let s=i&((a<=e?1:0)|(l>=n?2:0));a>=e&&l<=n&&!s?r.push(O):O.decompose(e-a,n-a,r,s)}a=l+1}}replace(e,n,r){if(r.lines<this.lines)for(let i=0,o=0;i<this.children.length;i++){let a=this.children[i],O=o+a.length;if(e>=o&&n<=O){let l=a.replace(e-o,n-o,r),s=this.lines-a.lines+l.lines;if(l.lines<s>>5-1&&l.lines>s>>5+1){let c=this.children.slice();return c[i]=l,new sr(c,this.length-(n-e)+r.length)}return super.replace(o,O,l)}o=O+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
4
4
  `){let i="";for(let o=0,a=0;o<this.children.length&&a<=n;o++){let O=this.children[o],l=a+O.length;a>e&&o&&(i+=r),e<l&&n>a&&(i+=O.sliceString(e-a,n-a,r)),a=l+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof sr))return 0;let r=0,[i,o,a,O]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,o+=n){if(i==a||o==O)return r;let l=this.children[i],s=e.children[o];if(l!=s)return r+l.scanIdentical(s,n);r+=l.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new tt(d,n)}let i=Math.max(32,r>>5),o=i<<1,a=i>>1,O=[],l=0,s=-1,c=[];function u(d){let p;if(d.lines>o&&d instanceof sr)for(let m of d.children)u(m);else d.lines>a&&(l>a||!l)?(f(),O.push(d)):d instanceof tt&&l&&(p=c[c.length-1])instanceof tt&&d.lines+p.lines<=32?(l+=d.lines,s+=d.length+1,c[c.length-1]=new tt(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&f(),l+=d.lines,s+=d.length+1,c.push(d))}function f(){l!=0&&(O.push(c.length==1?c[0]:sr.from(c,s)),s=-1,l=c.length=0)}for(let d of e)u(d);return f(),O.length==1?O[0]:new sr(O,n)}}qe.empty=new tt([""],0);function a0(t){let e=-1;for(let n of t)e+=n.length+1;return e}function zl(t,e,n=0,r=1e9){for(let i=0,o=0,a=!0;o<t.length&&i<=r;o++){let O=t[o],l=i+O.length;l>=n&&(l>r&&(O=O.slice(0,r-i)),i<n&&(O=O.slice(n-i)),a?(e[e.length-1]+=O,a=!1):e.push(O)),i=l+1}return e}function Zg(t,e,n){return zl(t,[""],e,n)}class Ca{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof tt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],o=this.offsets[r],a=o>>1,O=i instanceof tt?i.text.length:i.children.length;if(a==(n>0?O:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
5
5
  `,this;e--}else if(i instanceof tt){let l=i.text[a+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[a+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof tt?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Yg{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new Ca(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Vg{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(qe.prototype[Symbol.iterator]=function(){return this.iter()},Ca.prototype[Symbol.iterator]=Yg.prototype[Symbol.iterator]=Vg.prototype[Symbol.iterator]=function(){return this});let O0=class{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}},zo="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;t<zo.length;t++)zo[t]+=zo[t-1];function l0(t){for(let e=1;e<zo.length;e+=2)if(zo[e]>t)return zo[e-1]<=t;return!1}function Eg(t){return t>=127462&&t<=127487}const Cg=8205;function on(t,e,n=!0,r=!0){return(n?Ag:s0)(t,e,r)}function Ag(t,e,n){if(e==t.length)return e;e&&jg(t.charCodeAt(e))&&Ig(t.charCodeAt(e-1))&&e--;let r=Aa(t,e);for(e+=Ku(r);e<t.length;){let i=Aa(t,e);if(r==Cg||i==Cg||n&&l0(i))e+=Ku(i),r=i;else if(Eg(i)){let o=0,a=e-2;for(;a>=0&&Eg(Aa(t,a));)o++,a-=2;if(o%2==0)break;e+=2}else break}return e}function s0(t,e,n){for(;e>0;){let r=Ag(t,e-2,n);if(r<e)return r;e--}return 0}function jg(t){return t>=56320&&t<57344}function Ig(t){return t>=55296&&t<56320}function Aa(t,e){let n=t.charCodeAt(e);if(!Ig(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return jg(r)?(n-55296<<10)+(r-56320)+65536:n}function Ku(t){return t<65536?1:2}const Ju=/\r\n?|\n/;var jt=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(jt||(jt={}));class cr{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let o=this.sections[n++],a=this.sections[n++];a<0?(e(r,i,o),i+=o):i+=a,r+=o}}iterChangedRanges(e,n=!1){ef(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new cr(e)}composeDesc(e){return this.empty?e:e.empty?this:Gg(this,e)}mapDesc(e,n=!1){return e.empty?this:tf(this,e,n)}mapPos(e,n=-1,r=jt.Simple){let i=0,o=0;for(let a=0;a<this.sections.length;){let O=this.sections[a++],l=this.sections[a++],s=i+O;if(l<0){if(s>e)return o+(e-i);o+=O}else{if(r!=jt.Simple&&s>=e&&(r==jt.TrackDel&&i<e&&s>e||r==jt.TrackBefore&&i<e||r==jt.TrackAfter&&s>e))return null;if(s>e||s==e&&n<0&&!O)return e==i||n<0?o:o+l;o+=l}i=s}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return o}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let o=this.sections[r++],a=this.sections[r++],O=i+o;if(a>=0&&i<=n&&O>=e)return i<e&&O>n?"cover":!0;i=O}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new cr(e)}static create(e){return new cr(e)}}class ct extends cr{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ef(this,(n,r,i,o,a)=>e=e.replace(i,i+(r-n),a),!1),e}mapDesc(e,n=!1){return tf(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,o=0;i<n.length;i+=2){let a=n[i],O=n[i+1];if(O>=0){n[i]=O,n[i+1]=a;let l=i>>1;for(;r.length<l;)r.push(qe.empty);r.push(a?e.slice(o,o+a):qe.empty)}o+=a}return new ct(n,r)}compose(e){return this.empty?e:e.empty?this:Gg(this,e,!0)}map(e,n=!1){return e.empty?this:tf(this,e,n,!0)}iterChanges(e,n=!1){ef(this,e,n)}get desc(){return cr.create(this.sections)}filter(e){let n=[],r=[],i=[],o=new ja(this);e:for(let a=0,O=0;;){let l=a==e.length?1e9:e[a++];for(;O<l||O==l&&o.len==0;){if(o.done)break e;let c=Math.min(o.len,l-O);qt(i,c,-1);let u=o.ins==-1?-1:o.off==0?o.ins:0;qt(n,c,u),u>0&&oi(r,n,o.text),o.forward(c),O+=c}let s=e[a++];for(;O<s;){if(o.done)break e;let c=Math.min(o.len,s-O);qt(n,c,-1),qt(i,c,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(c),O+=c}}return{changes:new ct(n,r),filtered:cr.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],o=[],a=0,O=null;function l(c=!1){if(!c&&!i.length)return;a<n&&qt(i,n-a,-1);let u=new ct(i,o);O=O?O.compose(u.map(O)):u,i=[],o=[],a=0}function s(c){if(Array.isArray(c))for(let u of c)s(u);else if(c instanceof ct){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);l(),O=O?O.compose(c.map(O)):c}else{let{from:u,to:f=u,insert:d}=c;if(u>f||u<0||f>n)throw new RangeError(`Invalid change range ${u} to ${f} (in doc of length ${n})`);let p=d?typeof d=="string"?qe.of(d.split(r||Ju)):d:qe.empty,m=p.length;if(u==f&&m==0)return;u<a&&l(),u>a&&qt(i,u-a,-1),qt(i,f-u,m),oi(o,i,p),a=f}}return s(e),l(!O),O}static empty(e){return new ct(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let o=e[i];if(typeof o=="number")n.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((a,O)=>O&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length<i;)r.push(qe.empty);r[i]=qe.of(o.slice(1)),n.push(o[0],r[i].length)}}}return new ct(n,r)}static createSet(e,n){return new ct(e,n)}}function qt(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function oi(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(qe.empty);t.push(n)}}function ef(t,e,n){let r=t.inserted;for(let i=0,o=0,a=0;a<t.sections.length;){let O=t.sections[a++],l=t.sections[a++];if(l<0)i+=O,o+=O;else{let s=i,c=o,u=qe.empty;for(;s+=O,c+=l,l&&r&&(u=u.append(r[a-2>>1])),!(n||a==t.sections.length||t.sections[a+1]<0);)O=t.sections[a++],l=t.sections[a++];e(i,s,o,c,u),i=s,o=c}}}function tf(t,e,n,r=!1){let i=[],o=r?[]:null,a=new ja(t),O=new ja(e);for(let l=-1;;)if(a.ins==-1&&O.ins==-1){let s=Math.min(a.len,O.len);qt(i,s,-1),a.forward(s),O.forward(s)}else if(O.ins>=0&&(a.ins<0||l==a.i||a.off==0&&(O.len<a.len||O.len==a.len&&!n))){let s=O.len;for(qt(i,O.ins,-1);s;){let c=Math.min(a.len,s);a.ins>=0&&l<a.i&&a.len<=c&&(qt(i,0,a.ins),o&&oi(o,i,a.text),l=a.i),a.forward(c),s-=c}O.next()}else if(a.ins>=0){let s=0,c=a.len;for(;c;)if(O.ins==-1){let u=Math.min(c,O.len);s+=u,c-=u,O.forward(u)}else if(O.ins==0&&O.len<c)c-=O.len,O.next();else break;qt(i,s,l<a.i?a.ins:0),o&&l<a.i&&oi(o,i,a.text),l=a.i,a.forward(a.len-c)}else{if(a.done&&O.done)return o?ct.createSet(i,o):cr.create(i);throw new Error("Mismatched change set lengths")}}function Gg(t,e,n=!1){let r=[],i=n?[]:null,o=new ja(t),a=new ja(e);for(let O=!1;;){if(o.done&&a.done)return i?ct.createSet(r,i):cr.create(r);if(o.ins==0)qt(r,o.len,0,O),o.next();else if(a.len==0&&!a.done)qt(r,0,a.ins,O),i&&oi(i,r,a.text),a.next();else{if(o.done||a.done)throw new Error("Mismatched change set lengths");{let l=Math.min(o.len2,a.len),s=r.length;if(o.ins==-1){let c=a.ins==-1?-1:a.off?0:a.ins;qt(r,l,c,O),i&&c&&oi(i,r,a.text)}else a.ins==-1?(qt(r,o.off?0:o.len,l,O),i&&oi(i,r,o.textBit(l))):(qt(r,o.off?0:o.len,a.off?0:a.ins,O),i&&!a.off&&oi(i,r,a.text));O=(o.ins>l||a.ins>=0&&a.len>l)&&(O||r.length>s),o.forward2(l),a.forward(l)}}}}class ja{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?qe.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?qe.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Ai{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new Ai(r,i,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return L.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return L.range(this.anchor,r)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return L.range(e.anchor,e.head)}static create(e,n,r){return new Ai(e,n,r)}}class L{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:L.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new L([this.main],0)}addRange(e,n=!0){return L.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,L.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new L(e.ranges.map(n=>Ai.fromJSON(n)),e.main)}static single(e,n=e){return new L([L.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let o=e[i];if(o.empty?o.from<=r:o.from<r)return L.normalized(e.slice(),n);r=o.to}return new L(e,n)}static cursor(e,n=0,r,i){return Ai.create(e,e,(n==0?0:n<0?4:8)|(r==null?3:Math.min(2,r))|(i??33554431)<<5)}static range(e,n,r,i){let o=(r??33554431)<<5|(i==null?3:Math.min(2,i));return n<e?Ai.create(n,e,24|o):Ai.create(e,n,(n>e?4:0)|o)}static normalized(e,n=0){let r=e[n];e.sort((i,o)=>i.from-o.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let o=e[i],a=e[i-1];if(o.empty?o.from<=a.to:o.from<a.to){let O=a.from,l=Math.max(o.to,a.to);i<=n&&n--,e.splice(--i,2,o.anchor>o.head?L.range(l,O):L.range(O,l))}}return new L(e,n)}}function Dg(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let nf=0;class fe{constructor(e,n,r,i,o){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=nf++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}static define(e={}){return new fe(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:rf),!!e.static,e.enables)}of(e){return new Ul([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ul(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ul(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function rf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Ul{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=nf++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,o=this.id,a=e[o]>>1,O=this.type==2,l=!1,s=!1,c=[];for(let u of this.dependencies)u=="doc"?l=!0:u=="selection"?s=!0:((n=e[u.id])!==null&&n!==void 0?n:1)&1||c.push(e[u.id]);return{create(u){return u.values[a]=r(u),1},update(u,f){if(l&&f.docChanged||s&&(f.docChanged||f.selection)||of(u,c)){let d=r(u);if(O?!Ng(d,u.values[a],i):!i(d,u.values[a]))return u.values[a]=d,1}return 0},reconfigure:(u,f)=>{let d,p=f.config.address[o];if(p!=null){let m=Yl(f,p);if(this.dependencies.every($=>$ instanceof fe?f.facet($)===u.facet($):$ instanceof Ur?f.field($,!1)==u.field($,!1):!0)||(O?Ng(d=r(u),m,i):i(d=r(u),m)))return u.values[a]=m,0}else d=r(u);return u.values[a]=d,1}}}}function Ng(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function of(t,e){let n=!1;for(let r of e)Da(t,r)&1&&(n=!0);return n}function c0(t,e,n){let r=n.map(l=>t[l.id]),i=n.map(l=>l.type),o=r.filter(l=>!(l&1)),a=t[e.id]>>1;function O(l){let s=[];for(let c=0;c<r.length;c++){let u=Yl(l,r[c]);if(i[c]==2)for(let f of u)s.push(f);else s.push(u)}return e.combine(s)}return{create(l){for(let s of r)Da(l,s);return l.values[a]=O(l),1},update(l,s){if(!of(l,o))return 0;let c=O(l);return e.compare(c,l.values[a])?0:(l.values[a]=c,1)},reconfigure(l,s){let c=of(l,r),u=s.config.facets[e.id],f=s.facet(e);if(u&&!c&&rf(n,u))return l.values[a]=f,0;let d=O(l);return e.compare(d,f)?(l.values[a]=f,0):(l.values[a]=d,1)}}}const Lg=fe.define({static:!0});class Ur{constructor(e,n,r,i,o){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=o,this.provides=void 0}static define(e){let n=new Ur(nf++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Lg).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let o=r.values[n],a=this.updateF(o,i);return this.compareF(o,a)?0:(r.values[n]=a,1)},reconfigure:(r,i)=>i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}init(e){return[this,Lg.of({field:this,create:e})]}get extension(){return this}}const ji={lowest:4,low:3,default:2,high:1,highest:0};function Ia(t){return e=>new Mg(e,t)}const Uo={highest:Ia(ji.highest),high:Ia(ji.high),default:Ia(ji.default),low:Ia(ji.low),lowest:Ia(ji.lowest)};class Mg{constructor(e,n){this.inner=e,this.prec=n}}class Ga{of(e){return new af(this,e)}reconfigure(e){return Ga.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class af{constructor(e,n){this.compartment=e,this.inner=n}}class Zl{constructor(e,n,r,i,o,a){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],o=Object.create(null),a=new Map;for(let f of u0(e,n,a))f instanceof Ur?i.push(f):(o[f.facet.id]||(o[f.facet.id]=[])).push(f);let O=Object.create(null),l=[],s=[];for(let f of i)O[f.id]=s.length<<1,s.push(d=>f.slot(d));let c=r==null?void 0:r.config.facets;for(let f in o){let d=o[f],p=d[0].facet,m=c&&c[f]||[];if(d.every($=>$.type==0))if(O[p.id]=l.length<<1|1,rf(m,d))l.push(r.facet(p));else{let $=p.combine(d.map(Q=>Q.value));l.push(r&&p.compare($,r.facet(p))?r.facet(p):$)}else{for(let $ of d)$.type==0?(O[$.id]=l.length<<1|1,l.push($.value)):(O[$.id]=s.length<<1,s.push(Q=>$.dynamicSlot(Q)));O[p.id]=s.length<<1,s.push($=>c0($,p,d))}}let u=s.map(f=>f(O));return new Zl(e,a,u,O,l,o)}}function u0(t,e,n){let r=[[],[],[],[],[]],i=new Map;function o(a,O){let l=i.get(a);if(l!=null){if(l<=O)return;let s=r[l].indexOf(a);s>-1&&r[l].splice(s,1),a instanceof af&&n.delete(a.compartment)}if(i.set(a,O),Array.isArray(a))for(let s of a)o(s,O);else if(a instanceof af){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let s=e.get(a.compartment)||a.inner;n.set(a.compartment,s),o(s,O)}else if(a instanceof Mg)o(a.inner,a.prec);else if(a instanceof Ur)r[O].push(a),a.provides&&o(a.provides,O);else if(a instanceof Ul)r[O].push(a),a.facet.extensions&&o(a.facet.extensions,ji.default);else{let s=a.extension;if(!s)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(s,O)}}return o(t,ji.default),r.reduce((a,O)=>a.concat(O))}function Da(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Yl(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const Bg=fe.define(),Fg=fe.define({combine:t=>t.some(e=>e),static:!0}),Hg=fe.define({combine:t=>t.length?t[0]:void 0,static:!0}),Kg=fe.define(),Jg=fe.define(),e$=fe.define(),t$=fe.define({combine:t=>t.length?t[0]:!1});class Zr{constructor(e,n){this.type=e,this.value=n}static define(){return new f0}}class f0{of(e){return new Zr(this,e)}}class d0{constructor(e){this.map=e}of(e){return new He(this,e)}}class He{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new He(this.type,n)}is(e){return this.type==e}static define(e={}){return new d0(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let o=i.map(n);o&&r.push(o)}return r}}He.reconfigure=He.define(),He.appendConfig=He.define();class ut{constructor(e,n,r,i,o,a){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=o,this.scrollIntoView=a,this._doc=null,this._state=null,r&&Dg(r,n.newLength),o.some(O=>O.type==ut.time)||(this.annotations=o.concat(ut.time.of(Date.now())))}static create(e,n,r,i,o,a){return new ut(e,n,r,i,o,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(ut.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}ut.time=Zr.define(),ut.userEvent=Zr.define(),ut.addToHistory=Zr.define(),ut.remote=Zr.define();function h0(t,e){let n=[];for(let r=0,i=0;;){let o,a;if(r<t.length&&(i==e.length||e[i]>=t[r]))o=t[r++],a=t[r++];else if(i<e.length)o=e[i++],a=e[i++];else return n;!n.length||n[n.length-1]<o?n.push(o,a):n[n.length-1]<a&&(n[n.length-1]=a)}}function n$(t,e,n){var r;let i,o,a;return n?(i=e.changes,o=ct.empty(e.changes.length),a=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),a=t.changes.compose(i)),{changes:a,selection:e.selection?e.selection.map(o):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:He.mapEffects(t.effects,i).concat(He.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Of(t,e,n){let r=e.selection,i=Zo(e.annotations);return e.userEvent&&(i=i.concat(ut.userEvent.of(e.userEvent))),{changes:e.changes instanceof ct?e.changes:ct.of(e.changes||[],n,t.facet(Hg)),selection:r&&(r instanceof L?r:L.single(r.anchor,r.head)),effects:Zo(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function r$(t,e,n){let r=Of(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(n=!1);let a=!!e[o].sequential;r=n$(r,Of(t,e[o],a?r.changes.newLength:t.doc.length),a)}let i=ut.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return m0(n?p0(i):i)}function p0(t){let e=t.startState,n=!0;for(let i of e.facet(Kg)){let o=i(t);if(o===!1){n=!1;break}Array.isArray(o)&&(n=n===!0?o:h0(n,o))}if(n!==!0){let i,o;if(n===!1)o=t.changes.invertedDesc,i=ct.empty(e.doc.length);else{let a=t.changes.filter(n);i=a.changes,o=a.filtered.mapDesc(a.changes).invertedDesc}t=ut.create(e,i,t.selection&&t.selection.map(o),He.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let r=e.facet(Jg);for(let i=r.length-1;i>=0;i--){let o=r[i](t);o instanceof ut?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof ut?t=o[0]:t=r$(e,Zo(o),!1)}return t}function m0(t){let e=t.startState,n=e.facet(e$),r=t;for(let i=n.length-1;i>=0;i--){let o=n[i](t);o&&Object.keys(o).length&&(r=n$(r,Of(e,o,t.changes.newLength),!0))}return r==t?t:ut.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const g0=[];function Zo(t){return t==null?g0:Array.isArray(t)?t:[t]}var Yr=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Yr||(Yr={}));const $0=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let lf;try{lf=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Q0(t){if(lf)return lf.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||$0.test(n)))return!0}return!1}function b0(t){return e=>{if(!/\S/.test(e))return Yr.Space;if(Q0(e))return Yr.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Yr.Word;return Yr.Other}}class ve{constructor(e,n,r,i,o,a){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=o,a&&(a._state=this);for(let O=0;O<this.config.dynamicSlots.length;O++)Da(this,O<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return Da(this,r),Yl(this,r)}update(...e){return r$(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(Ga.reconfigure)?(n&&(i=new Map,n.compartments.forEach((O,l)=>i.set(l,O)),n=null),i.set(a.value.compartment,a.value.extension)):a.is(He.reconfigure)?(n=null,r=a.value):a.is(He.appendConfig)&&(n=null,r=Zo(r).concat(a.value));let o;n?o=e.startState.values.slice():(n=Zl.resolve(r,i,this),o=new ve(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(O,l)=>l.reconfigure(O,this),null).values),new ve(n,e.newDoc,e.newSelection,o,(a,O)=>O.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:L.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),o=[r.range],a=Zo(r.effects);for(let O=1;O<n.ranges.length;O++){let l=e(n.ranges[O]),s=this.changes(l.changes),c=s.map(i);for(let f=0;f<O;f++)o[f]=o[f].map(c);let u=i.mapDesc(s,!0);o.push(l.range.map(u)),i=i.compose(c),a=He.mapEffects(a,c).concat(He.mapEffects(Zo(l.effects),u))}return{changes:i,selection:L.create(o,n.mainIndex),effects:a}}changes(e=[]){return e instanceof ct?e:ct.of(e,this.doc.length,this.facet(ve.lineSeparator))}toText(e){return qe.of(e.split(this.facet(ve.lineSeparator)||Ju))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Da(this,n),Yl(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof Ur&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let o in r)if(Object.prototype.hasOwnProperty.call(e,o)){let a=r[o],O=e[o];i.push(a.init(l=>a.spec.fromJSON(O,l)))}}return ve.create({doc:e.doc,selection:L.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Zl.resolve(e.extensions||[],new Map),r=e.doc instanceof qe?e.doc:qe.of((e.doc||"").split(n.staticFacet(ve.lineSeparator)||Ju)),i=e.selection?e.selection instanceof L?e.selection:L.single(e.selection.anchor,e.selection.head):L.single(0);return Dg(i,r.length),n.staticFacet(Fg)||(i=i.asSingle()),new ve(n,r,i,n.dynamicSlots.map(()=>null),(o,a)=>a.create(o),null)}get tabSize(){return this.facet(ve.tabSize)}get lineBreak(){return this.facet(ve.lineSeparator)||`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "4.0.4-beta.0",
3
+ "version": "4.0.4",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",