md-editor-v3 2.11.0 → 3.0.0-beta.1
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.
- package/README.md +23 -49
- package/lib/MdEditor/Editor.d.ts +43 -43
- package/lib/MdEditor/extensions/MdCatalog/CatalogLink.d.ts +11 -11
- package/lib/MdEditor/extensions/MdCatalog/index.d.ts +6 -6
- package/lib/MdEditor/index.d.ts +35 -35
- package/lib/MdEditor/type.d.ts +18 -21
- package/lib/md-editor-v3.cjs +27 -88
- package/lib/md-editor-v3.mjs +2533 -4967
- package/lib/md-editor-v3.umd.js +77 -89
- package/lib/style.css +1 -1
- package/package.json +19 -12
package/lib/md-editor-v3.cjs
CHANGED
|
@@ -1,105 +1,52 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`),t=['<span rn-wrapper aria-hidden="true">'];return e.forEach(()=>{t.push("<span></span>")}),t.push("</span>"),`<span class="code-block">${s}</span>${t.join("")}`},Rt=(s,e=200)=>{let t=0;return(...n)=>new Promise(i=>{t&&(clearTimeout(t),i("cancel")),t=window.setTimeout(()=>{s.apply(void 0,n),t=0,i("done")},e)})},Qn=(s,e=200)=>{let t=0,n=null;return(...i)=>{const l=a=>{t===0&&(t=a),a-t>=e?(s.apply(void 0,n),n=null,t=0):window.requestAnimationFrame(l)};n===null&&window.requestAnimationFrame(l),n=i}},an=(s,e="$")=>{const t=s.split(e);let n=e,i="";for(let l=1;l<t.length;l++)if(/\\$/.test(t[l]))n+=t[l]+"$",i+=t[l]+"$";else{n+=t[l]+e,i+=t[l];break}return[n,i]},Yn=s=>{var t;return navigator.userAgent.indexOf("Firefox")>-1?s.value.substring(s.selectionStart,s.selectionEnd):((t=window.getSelection())==null?void 0:t.toString())||""},Jn=(s,e)=>{const t=s==null?void 0:s.getBoundingClientRect();if(e===document.documentElement)return t.top-e.clientTop;const n=e==null?void 0:e.getBoundingClientRect();return t.top-n.top},ei=(s,e)=>{const t={...s};return e.forEach(n=>{Reflect.deleteProperty(t,n)}),t},ti=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`,cn=(s,e)=>{const t=n=>{const i=s.parentElement||document.body,l=i.offsetWidth,a=i.offsetHeight,{clientWidth:o}=document.documentElement,{clientHeight:u}=document.documentElement,f=n.offsetX,h=n.offsetY,m=g=>{let $=g.x+document.body.scrollLeft-document.body.clientLeft-f,b=g.y+document.body.scrollTop-document.body.clientTop-h;$=$<1?1:$<o-l-1?$:o-l-1,b=b<1?1:b<u-a-1?b:u-a-1,e?e($,b):(i.style.left=`${$}px`,i.style.top=`${b}px`)};document.addEventListener("mousemove",m);const v=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",v)};document.addEventListener("mouseup",v)};return s.addEventListener("mousedown",t),()=>{s.removeEventListener("mousedown",t)}},pe=(s,e="")=>{const t=document.getElementById(s.id),n=i=>{typeof s.onload=="function"&&s.onload(i),s.removeEventListener("load",n)};t?e!==""&&typeof s.onload=="function"&&(Reflect.get(window,e)?s.dispatchEvent(new Event("load")):t.addEventListener("load",n)):(s.addEventListener("load",n),document.head.appendChild(s))},ni=Rt((s,e,t)=>{const n=document.getElementById(s);n&&n.setAttribute(e,t)},10),At="onSave",Gt="changeCatalogVisible",Tn="changeFullscreen",un="pageFullscreenChanged",dn="fullscreenChanged",Ht="previewChanged",hn="htmlPreviewChanged",fn="catalogVisibleChanged",En="textareaFocus",ii=(s,e)=>{const{editorId:t,noPrettier:n,previewOnly:i}=s,l=r.reactive({buildFinished:!1,html:""}),a=o=>{if(o.target===document.querySelector(`#${s.editorId}-textarea`))if(x.emit(t,"selectTextChange"),o.ctrlKey||o.metaKey)switch(o.code){case"KeyS":{o.shiftKey?x.emit(t,"replace","strikeThrough"):(x.emit(t,At,s.modelValue),o.preventDefault());break}case"KeyB":{x.emit(t,"replace","bold"),o.preventDefault();break}case"KeyU":{o.shiftKey?(x.emit(t,"replace","unorderedList"),o.preventDefault()):(x.emit(t,"replace","underline"),o.preventDefault());break}case"KeyI":{o.shiftKey?(x.emit(t,"openModals","image"),o.preventDefault()):(x.emit(t,"replace","italic"),o.preventDefault());break}case"Digit1":{x.emit(t,"replace","h1"),o.preventDefault();break}case"Digit2":{x.emit(t,"replace","h2"),o.preventDefault();break}case"Digit3":{x.emit(t,"replace","h3"),o.preventDefault();break}case"Digit4":{x.emit(t,"replace","h4"),o.preventDefault();break}case"Digit5":{x.emit(t,"replace","h5"),o.preventDefault();break}case"Digit6":{x.emit(t,"replace","h6"),o.preventDefault();break}case"ArrowUp":{x.emit(t,"replace","sup"),o.preventDefault();break}case"ArrowDown":{x.emit(t,"replace","sub"),o.preventDefault();break}case"KeyQ":{if(o.key==="a"){o.target.select();return}x.emit(t,"replace","quote"),o.preventDefault();break}case"KeyA":if(o.key==="q"){x.emit(t,"replace","quote"),o.preventDefault();break}else return;case"KeyO":{x.emit(t,"replace","orderedList"),o.preventDefault();break}case"KeyC":{if(o.shiftKey)x.emit(t,"replace","code"),o.preventDefault();else if(o.altKey)x.emit(t,"replace","codeRow"),o.preventDefault();else{o.preventDefault(),x.emit(t,"replace","ctrlC");break}break}case"KeyL":{x.emit(t,"openModals","link"),o.preventDefault();break}case"KeyZ":{if(o.key==="w")return;o.shiftKey?(x.emit(t,"ctrlShiftZ"),o.preventDefault()):(x.emit(t,"ctrlZ"),o.preventDefault());break}case"KeyW":if(o.key==="z"){o.shiftKey?(x.emit(t,"ctrlShiftZ"),o.preventDefault()):(x.emit(t,"ctrlZ"),o.preventDefault());break}else return;case"KeyF":{o.shiftKey&&(n||(x.emit(t,"replace","prettier"),o.preventDefault()));break}case"KeyT":{o.altKey&&o.shiftKey&&(x.emit(t,"replace","table"),o.preventDefault());break}case"KeyX":{x.emit(t,"replace","ctrlX"),o.preventDefault();break}case"KeyD":{o.preventDefault(),x.emit(t,"replace","ctrlD");break}}else o.code==="Tab"&&(o.preventDefault(),o.shiftKey?x.emit(t,"replace","shiftTab"):x.emit(t,"replace","tab"))};r.watch(()=>s.modelValue,()=>{l.buildFinished=!1}),r.onMounted(()=>{i||(window.addEventListener("keydown",a),x.on(t,{name:"buildFinished",callback(o){l.buildFinished=!0,l.html=o}}),x.on(t,{name:At,callback(){const o=new Promise(u=>{if(l.buildFinished)u(l.html);else{const f=h=>{u(h),x.remove(t,"buildFinished",f)};x.on(t,{name:"buildFinished",callback:f})}});s.onSave?s.onSave(s.modelValue,o):e.emit("onSave",s.modelValue,o)}}))}),r.onBeforeUnmount(()=>{i||window.removeEventListener("keydown",a)})},si=s=>{var l;const{editorId:e,previewOnly:t}=s,n=(l=J==null?void 0:J.editorExtensions)==null?void 0:l.highlight;r.provide("editorId",e),r.provide("tabWidth",s.tabWidth),r.provide("theme",r.computed(()=>s.theme)),r.provide("highlight",r.computed(()=>{const a={...ln,...n==null?void 0:n.css},o=s.codeStyleReverse&&s.codeStyleReverseList.includes(s.previewTheme)?"dark":s.theme;return{js:(n==null?void 0:n.js)||Un,css:a[s.codeTheme]?a[s.codeTheme][o]:ln.atom[o]}})),r.provide("historyLength",s.historyLength),r.provide("previewOnly",t),r.provide("showCodeRowNumber",s.showCodeRowNumber);const i=r.computed(()=>{var o;const a={...sn,...(o=J==null?void 0:J.editorConfig)==null?void 0:o.languageUserDefined};return a[s.language]?a[s.language]:sn["zh-CN"]});r.provide("usedLanguageText",i),r.provide("previewTheme",r.computed(()=>s.previewTheme))},li=s=>{var f,h,m,v,g,$;const{noPrettier:e,previewOnly:t,noIconfont:n,noUploadImg:i}=s,{editorExtensions:l}=J,a=e||!!((h=(f=J.editorExtensions)==null?void 0:f.prettier)!=null&&h.prettierInstance),o=e||!!((v=(m=J.editorExtensions)==null?void 0:m.prettier)!=null&&v.parserMarkdownInstance),u=i||!!(($=(g=J.editorExtensions)==null?void 0:g.cropper)!=null&&$.instance);r.onMounted(()=>{var C,V,H,T;const b=document.createElement("script");b.src=(l==null?void 0:l.iconfont)||Bn,b.id=`${d}-icon`;const k=document.createElement("script"),p=document.createElement("script");k.src=((C=l==null?void 0:l.prettier)==null?void 0:C.standaloneJs)||tn.main,k.id=`${d}-prettier`,p.src=((V=l==null?void 0:l.prettier)==null?void 0:V.parserMarkdownJs)||tn.markdown,p.id=`${d}-prettierMD`;const w=document.createElement("link");w.rel="stylesheet",w.href=((H=l==null?void 0:l.cropper)==null?void 0:H.css)||nn.css,w.id=`${d}-cropperCss`;const S=document.createElement("script");S.src=((T=l==null?void 0:l.cropper)==null?void 0:T.js)||nn.js,S.id=`${d}-cropper`,n||pe(b),t||(u||(pe(w),pe(S)),a||pe(k),o||pe(p))})},oi=(s,e)=>{const{editorId:t,previewOnly:n}=s,i=r.reactive({pageFullscreen:s.pageFullscreen,fullscreen:!1,preview:s.preview,htmlPreview:s.preview?!1:s.htmlPreview}),l=(u,f)=>{i[u]=f===void 0?!i[u]:f,u==="preview"&&i.preview?i.htmlPreview=!1:u==="htmlPreview"&&i.htmlPreview&&(i.preview=!1)};let a="";const o=()=>{i.pageFullscreen||i.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=a};return r.watch(()=>[i.pageFullscreen,i.fullscreen],o),r.onMounted(()=>{n||x.on(t,{name:"uploadImage",callback(u,f){const h=m=>{x.emit(t,"replace","image",{desc:"",urls:m}),f&&f()};s.onUploadImg?s.onUploadImg(u,h):e.emit("onUploadImg",u,h)}}),a=document.body.style.overflow,o()}),[i,l]},ri=s=>{const{editorId:e}=s,t=r.ref(!1);r.onMounted(()=>{x.on(e,{name:Gt,callback:i=>{i===void 0?t.value=!t.value:t.value=i}})});const n=r.computed(()=>!s.toolbarsExclude.includes("catalog")&&s.toolbars.includes("catalog"));return[t,n]},ai=(s,e,t,n,i)=>{const{editorId:l}=s;r.watch(()=>n.pageFullscreen,o=>{x.emit(l,un,o)}),r.watch(()=>n.fullscreen,o=>{x.emit(l,dn,o)}),r.watch(()=>n.preview,o=>{x.emit(l,Ht,o)}),r.watch(()=>n.htmlPreview,o=>{x.emit(l,hn,o)}),r.watch(t,o=>{x.emit(l,fn,o)});const a={on(o,u){switch(o){case"pageFullscreen":{x.on(l,{name:un,callback(f){u(f)}});break}case"fullscreen":{x.on(l,{name:dn,callback(f){u(f)}});break}case"preview":{x.on(l,{name:Ht,callback(f){u(f)}});break}case"htmlPreview":{x.on(l,{name:hn,callback(f){u(f)}});break}case"catalog":{x.on(l,{name:fn,callback(f){u(f)}});break}}},togglePageFullscreen(o){i("pageFullscreen",o)},toggleFullscreen(o){x.emit(l,Tn,o)},togglePreview(o){i("preview",o)},toggleHtmlPreview(o){i("htmlPreview",o)},toggleCatalog(o){x.emit(l,Gt,o)},triggerSave(){x.emit(l,At)},insert(o){x.emit(l,"replace","universal",{generate:o})},focus(){x.emit(l,En)}};e.expose(a)};const ci=r.defineComponent({setup(){return()=>r.createVNode("div",{class:`${d}-divider`},null)}}),xe=({instance:s,ctx:e,props:t={}},n="default")=>{const i=(s==null?void 0:s.$slots[n])||(e==null?void 0:e.slots[n]);return(i?i(s):"")||t[n]};const ui=()=>({trigger:{type:String,default:"hover"},overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}}),Ye=r.defineComponent({props:ui(),setup(s,e){const t=`${d}-dropdown-hidden`,n=r.reactive({overlayClass:[t],overlayStyle:{},triggerHover:!1,overlayHover:!1}),i=r.ref(),l=r.ref(),a=()=>{var S;s.trigger==="hover"&&(n.triggerHover=!0);const m=i.value,v=l.value,g=m.getBoundingClientRect(),$=m.offsetTop,b=m.offsetLeft,k=g.height,p=g.width,w=((S=document.querySelector(s.relative))==null?void 0:S.scrollLeft)||0;n.overlayStyle={...n.overlayStyle,top:$+k+"px",left:b-v.offsetWidth/2+p/2-w+"px"},s.onChange(!0)},o=()=>{n.overlayHover=!0};r.watch(()=>s.visible,m=>{m?n.overlayClass=n.overlayClass.filter(v=>v!==t):n.overlayClass.push(t)});const u=m=>{const v=i.value,g=l.value;!v.contains(m.target)&&!g.contains(m.target)&&s.onChange(!1)};let f=-1;const h=m=>{i.value===m.target?n.triggerHover=!1:n.overlayHover=!1,clearTimeout(f),f=window.setTimeout(()=>{!n.overlayHover&&!n.triggerHover&&s.onChange(!1)},10)};return r.onMounted(()=>{s.trigger==="click"?(i.value.addEventListener("click",a),document.addEventListener("click",u)):(i.value.addEventListener("mouseenter",a),i.value.addEventListener("mouseleave",h),l.value.addEventListener("mouseenter",o),l.value.addEventListener("mouseleave",h))}),r.onBeforeUnmount(()=>{s.trigger==="click"?(i.value.removeEventListener("click",a),document.removeEventListener("click",u)):(i.value.removeEventListener("mouseenter",a),i.value.removeEventListener("mouseleave",h),l.value.removeEventListener("mouseenter",o),l.value.removeEventListener("mouseleave",h))}),()=>{const m=xe({ctx:e}),v=xe({props:s,ctx:e},"overlay"),g=r.cloneVNode(m instanceof Array?m[0]:m,{ref:i}),$=r.createVNode("div",{class:[`${d}-dropdown`,n.overlayClass],style:n.overlayStyle,ref:l},[r.createVNode("div",{class:`${d}-dropdown-overlay`},[v instanceof Array?v[0]:v])]);return[g,$]}}});const di=()=>({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}}),Zt=r.defineComponent({props:di(),setup(s,e){const t=r.ref(s.visible),n=r.ref([`${d}-modal`]),i=r.ref(),l=r.ref();let a=()=>{};const o=r.reactive({initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),u=r.computed(()=>s.isFullscreen?{width:"100%",height:"100%"}:{width:s.width,height:s.height});return r.onMounted(()=>{a=cn(l.value,(f,h)=>{o.initPos.left=f+"px",o.initPos.top=h+"px"})}),r.onBeforeUnmount(()=>{a()}),r.watch(()=>s.isFullscreen,f=>{f?a():a=cn(l.value,(h,m)=>{o.initPos.left=h+"px",o.initPos.top=m+"px"})}),r.watch(()=>s.visible,f=>{f?(n.value.push("zoom-in"),t.value=f,r.nextTick(()=>{const h=i.value.offsetWidth/2,m=i.value.offsetHeight/2,v=document.documentElement.clientWidth/2,g=document.documentElement.clientHeight/2;o.initPos.left=v-h+"px",o.initPos.top=g-m+"px"}),setTimeout(()=>{n.value=n.value.filter(h=>h!=="zoom-in")},140)):(n.value.push("zoom-out"),setTimeout(()=>{n.value=n.value.filter(h=>h!=="zoom-out"),t.value=f},130))}),()=>{const f=xe({ctx:e}),h=xe({props:s,ctx:e},"title");return r.createVNode("div",{class:[s.class],style:{display:t.value?"block":"none"}},[r.createVNode("div",{class:`${d}-modal-mask`,onClick:s.onClose},null),r.createVNode("div",{class:n.value,style:{...o.initPos,...u.value},ref:i},[r.createVNode("div",{class:`${d}-modal-header`,ref:l},[h||""]),r.createVNode("div",{class:`${d}-modal-body`},[f]),r.createVNode("div",{class:`${d}-modal-func`},[s.showAdjust&&r.createVNode("div",{class:`${d}-modal-adjust`,onClick:m=>{m.stopPropagation(),s.isFullscreen?o.initPos=o.historyPos:(o.historyPos=o.initPos,o.initPos={left:"0",top:"0"}),s.onAdjust(!s.isFullscreen)}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":`#md-editor-icon-${s.isFullscreen?"suoxiao":"fangda"}`},null)])]),r.createVNode("div",{class:`${d}-modal-close`,onClick:m=>{m.stopPropagation(),s.onClose&&s.onClose()}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-close"},null)])])])])])}}}),hi=()=>({type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}}),fi=r.defineComponent({props:hi(),setup(s){const e=r.inject("usedLanguageText"),t=r.inject("editorId"),n=r.computed(()=>{var l,a;switch(s.type){case"link":return(l=e.value.linkModalTips)==null?void 0:l.linkTitle;case"image":return(a=e.value.linkModalTips)==null?void 0:a.imageTitle;default:return""}}),i=r.reactive({desc:"",url:""});return r.watch(()=>s.visible,l=>{l||setTimeout(()=>{i.desc="",i.url=""},200)}),()=>r.createVNode(Zt,{title:n.value,visible:s.visible,onClose:s.onCancel},{default:()=>{var l,a,o,u,f;return[r.createVNode("div",{class:`${d}-form-item`},[r.createVNode("label",{class:`${d}-label`,for:`link-desc-${t}`},[(l=e.value.linkModalTips)==null?void 0:l.descLabel]),r.createVNode("input",{placeholder:(a=e.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${d}-input`,id:`link-desc-${t}`,type:"text",value:i.desc,onChange:h=>{i.desc=h.target.value},autocomplete:"off"},null)]),r.createVNode("div",{class:`${d}-form-item`},[r.createVNode("label",{class:`${d}-label`,for:`link-url-${t}`},[(o=e.value.linkModalTips)==null?void 0:o.urlLabel]),r.createVNode("input",{placeholder:(u=e.value.linkModalTips)==null?void 0:u.urlLabelPlaceHolder,class:`${d}-input`,id:`link-url-${t}`,type:"text",value:i.url,onChange:h=>{i.url=h.target.value},autocomplete:"off"},null)]),r.createVNode("div",{class:`${d}-form-item`},[r.createVNode("button",{class:[`${d}-btn`,`${d}-btn-row`],type:"button",onClick:()=>{s.onOk(i),i.desc="",i.url=""}},[(f=e.value.linkModalTips)==null?void 0:f.buttonOK])])]}})}});const mi=()=>({visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}}),gi=r.defineComponent({props:mi(),setup(s){var h,m;const e=r.inject("usedLanguageText"),t=r.inject("editorId");let n=(m=(h=J==null?void 0:J.editorExtensions)==null?void 0:h.cropper)==null?void 0:m.instance;const i=r.ref(),l=r.ref(),a=r.ref(),o=r.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let u=null;r.watch(()=>s.visible,()=>{s.visible&&!o.cropperInited&&(n=n||window.Cropper,i.value.onchange=()=>{if(!n){x.emit(t,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const v=i.value.files||[];if(o.imgSelected=!0,(v==null?void 0:v.length)>0){const g=new FileReader;g.onload=$=>{o.imgSrc=$.target.result,r.nextTick(()=>{u=new n(l.value,{viewMode:2,preview:`.${d}-clip-preview-target`})})},g.readAsDataURL(v[0])}})}),r.watch(()=>[o.imgSelected],()=>{a.value.style=""}),r.watch(()=>o.isFullscreen,()=>{r.nextTick(()=>{u==null||u.destroy(),a.value.style="",l.value&&(u=new n(l.value,{viewMode:2,preview:`.${d}-clip-preview-target`}))})});const f=()=>{u.clear(),u.destroy(),u=null,i.value.value="",o.imgSelected=!1};return()=>{var v;return r.createVNode(Zt,{class:`${d}-modal-clip`,title:(v=e.value.clipModalTips)==null?void 0:v.title,visible:s.visible,onClose:s.onCancel,showAdjust:!0,isFullscreen:o.isFullscreen,onAdjust:g=>{o.isFullscreen=g},width:"668px",height:"421px"},{default:()=>{var g,$;return[r.createVNode("div",{class:`${d}-form-item ${d}-clip`},[r.createVNode("div",{class:`${d}-clip-main`},[o.imgSelected?r.createVNode("div",{class:`${d}-clip-cropper`},[r.createVNode("img",{src:o.imgSrc,ref:l,style:{display:"none"},alt:""},null),r.createVNode("div",{class:`${d}-clip-delete`,onClick:f},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):r.createVNode("div",{class:`${d}-clip-upload`,onClick:()=>{i.value.click()}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),r.createVNode("div",{class:`${d}-clip-preview`},[r.createVNode("div",{class:`${d}-clip-preview-target`,ref:a},null)])]),r.createVNode("div",{class:`${d}-form-item`},[r.createVNode("button",{class:`${d}-btn`,type:"button",onClick:()=>{if(u){const b=u.getCroppedCanvas();x.emit(t,"uploadImage",[Xn(b.toDataURL("image/png"))],s.onOk),f()}}},[((g=e.value.clipModalTips)==null?void 0:g.buttonUpload)||(($=e.value.linkModalTips)==null?void 0:$.buttonOK)])]),r.createVNode("input",{ref:i,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),pi=()=>({type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}}),vi=r.defineComponent({props:pi(),setup(s){return()=>r.createVNode(r.Fragment,null,[r.createVNode(fi,{type:s.type,visible:s.linkVisible,onOk:s.onOk,onCancel:s.onCancel},null),r.createVNode(gi,{visible:s.clipVisible,onOk:s.onOk,onCancel:s.onCancel},null)])}}),bi=s=>{var u,f,h,m;const e=r.inject("editorId");let t=(f=(u=J.editorExtensions)==null?void 0:u.screenfull)==null?void 0:f.instance;const n=(m=(h=J.editorExtensions)==null?void 0:h.screenfull)==null?void 0:m.js,i=r.ref(!1),l=v=>{if(!t){x.emit(e,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}t.isEnabled?(i.value=!0,(v===void 0?!t.isFullscreen:v)?t.request():t.exit()):console.error("browser does not support screenfull!")},a=()=>{t&&t.isEnabled&&t.on("change",()=>{(i.value||s.setting.fullscreen)&&(i.value=!1,s.updateSetting("fullscreen"))})},o=()=>{t=window.screenfull,a()};return r.onMounted(()=>{if(a(),!t){const v=document.createElement("script");v.src=n||qn,v.onload=o,v.id=`${d}-screenfull`,pe(v,"screenfull")}}),r.onMounted(()=>{x.on(e,{name:Tn,callback:l})}),{fullscreenHandler:l}},ki=()=>({tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}}),yi=r.defineComponent({name:"TableShape",props:ki(),setup(s){const e=r.reactive({x:-1,y:-1});return()=>r.createVNode("div",{class:`${d}-table-shape`,onMouseleave:()=>{e.x=-1,e.y=-1}},[new Array(s.tableShape[1]).fill("").map((t,n)=>r.createVNode("div",{class:`${d}-table-shape-row`,key:`table-shape-row-${n}`},[new Array(s.tableShape[0]).fill("").map((i,l)=>r.createVNode("div",{class:`${d}-table-shape-col`,key:`table-shape-col-${l}`,onMouseenter:()=>{e.x=n,e.y=l},onClick:()=>{s.onSelected(e)}},[r.createVNode("div",{class:[`${d}-table-shape-col-default`,n<=e.x&&l<=e.y&&`${d}-table-shape-col-include`]},null)]))]))])}}),wi=()=>({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}}),xi=r.defineComponent({name:"MDEditorToolbar",props:wi(),setup(s){const e=r.inject("editorId"),t=r.inject("usedLanguageText"),{fullscreenHandler:n}=bi(s),i=`${e}-toolbar-wrapper`,l=r.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),a=(g,$)=>{x.emit(e,"replace",g,$)},o=r.reactive({type:"link",linkVisible:!1,clipVisible:!1}),u=r.ref();r.onMounted(()=>{x.on(e,{name:"openModals",callback(g){o.type=g,o.linkVisible=!0}})});const f=r.computed(()=>{const g=s.toolbars.filter(p=>!s.toolbarsExclude.includes(p)),$=g.indexOf("="),b=$===-1?g:g.slice(0,$+1),k=$===-1?[]:g.slice($,Number.MAX_SAFE_INTEGER);return[b,k]}),h=r.ref(),m=()=>{x.emit(e,"uploadImage",Array.from(h.value.files||[])),h.value.value=""};r.onMounted(()=>{h.value.addEventListener("change",m)});const v=g=>{var $,b,k,p,w,S,C,V,H,T,y,G,U,B,z,F,P,q,j,ee,I,R,M,se,oe,he,Se,Ve,Me,je,Be,pt,vt,Ge,Ze,bt,kt,Xe,yt,wt,ot,Jt,en;if(Sn.includes(g))switch(g){case"-":return r.createVNode(ci,null,null);case"bold":return r.createVNode("div",{class:`${d}-toolbar-item`,title:($=t.value.toolbarTips)==null?void 0:$.bold,onClick:()=>{a("bold")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(b=t.value.toolbarTips)==null?void 0:b.underline,onClick:()=>{a("underline")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(k=t.value.toolbarTips)==null?void 0:k.italic,onClick:()=>{a("italic")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(p=t.value.toolbarTips)==null?void 0:p.strikeThrough,onClick:()=>{a("strikeThrough")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return r.createVNode(Ye,{relative:`#${i}`,visible:l.title,onChange:W=>{l.title=W},overlay:r.createVNode("ul",{class:`${d}-menu`,onClick:()=>{l.title=!1}},[r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h1")}},[(w=t.value.titleItem)==null?void 0:w.h1]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h2")}},[(S=t.value.titleItem)==null?void 0:S.h2]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h3")}},[(C=t.value.titleItem)==null?void 0:C.h3]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h4")}},[(V=t.value.titleItem)==null?void 0:V.h4]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h5")}},[(H=t.value.titleItem)==null?void 0:H.h5]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h6")}},[(T=t.value.titleItem)==null?void 0:T.h6])])},{default:()=>{var W;return[r.createVNode("div",{class:`${d}-toolbar-item`,title:(W=t.value.toolbarTips)==null?void 0:W.title},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(y=t.value.toolbarTips)==null?void 0:y.sub,onClick:()=>{a("sub")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(G=t.value.toolbarTips)==null?void 0:G.sup,onClick:()=>{a("sup")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(U=t.value.toolbarTips)==null?void 0:U.quote,onClick:()=>{a("quote")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(B=t.value.toolbarTips)==null?void 0:B.unorderedList,onClick:()=>{a("unorderedList")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(z=t.value.toolbarTips)==null?void 0:z.orderedList,onClick:()=>{a("orderedList")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(F=t.value.toolbarTips)==null?void 0:F.task,onClick:()=>{a("task")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(P=t.value.toolbarTips)==null?void 0:P.codeRow,onClick:()=>{a("codeRow")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(q=t.value.toolbarTips)==null?void 0:q.code,onClick:()=>{a("code")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(j=t.value.toolbarTips)==null?void 0:j.link,onClick:()=>{o.type="link",o.linkVisible=!0}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return s.noUploadImg?r.createVNode("div",{class:`${d}-toolbar-item`,title:(ee=t.value.toolbarTips)==null?void 0:ee.image,onClick:()=>{o.type="image",o.linkVisible=!0}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):r.createVNode(Ye,{relative:`#${i}`,visible:l.image,onChange:W=>{l.image=W},overlay:r.createVNode("ul",{class:`${d}-menu`,onClick:()=>{l.title=!1}},[r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{o.type="image",o.linkVisible=!0}},[(I=t.value.imgTitleItem)==null?void 0:I.link]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{h.value.click()}},[(R=t.value.imgTitleItem)==null?void 0:R.upload]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{o.clipVisible=!0}},[(M=t.value.imgTitleItem)==null?void 0:M.clip2upload])])},{default:()=>{var W;return[r.createVNode("div",{class:`${d}-toolbar-item`,title:(W=t.value.toolbarTips)==null?void 0:W.image},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return r.createVNode(Ye,{relative:`#${i}`,visible:l.table,onChange:W=>{l.table=W},key:"bar-table",overlay:r.createVNode(yi,{tableShape:s.tableShape,onSelected:W=>{a("table",{selectedShape:W})}},null)},{default:()=>{var W;return[r.createVNode("div",{class:`${d}-toolbar-item`,title:(W=t.value.toolbarTips)==null?void 0:W.table},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(se=t.value.toolbarTips)==null?void 0:se.revoke,onClick:()=>{x.emit(e,"ctrlZ")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(oe=t.value.toolbarTips)==null?void 0:oe.next,onClick:()=>{x.emit(e,"ctrlShiftZ")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(he=t.value.toolbarTips)==null?void 0:he.save,onClick:()=>{x.emit(e,At)}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return s.noPrettier?"":r.createVNode("div",{class:`${d}-toolbar-item`,title:(Se=t.value.toolbarTips)==null?void 0:Se.prettier,onClick:()=>{a("prettier")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!s.setting.fullscreen&&r.createVNode("div",{class:`${d}-toolbar-item`,title:(Ve=t.value.toolbarTips)==null?void 0:Ve.pageFullscreen,onClick:()=>{s.updateSetting("pageFullscreen")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":`#md-editor-icon-${s.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(Me=t.value.toolbarTips)==null?void 0:Me.fullscreen,onClick:()=>{n()}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":`#md-editor-icon-${s.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(je=t.value.toolbarTips)==null?void 0:je.preview,onClick:()=>{s.updateSetting("preview")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(Be=t.value.toolbarTips)==null?void 0:Be.htmlPreview,onClick:()=>{s.updateSetting("htmlPreview")}},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(pt=t.value.toolbarTips)==null?void 0:pt.catalog,onClick:()=>{x.emit(e,Gt)},key:"bar-catalog"},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return r.createVNode("div",{class:`${d}-toolbar-item`,title:(vt=t.value.toolbarTips)==null?void 0:vt.github,onClick:()=>Zn("https://github.com/imzbf/md-editor-v3")},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return r.createVNode(Ye,{relative:`#${i}`,visible:l.mermaid,onChange:W=>{l.mermaid=W},overlay:r.createVNode("ul",{class:`${d}-menu`,onClick:()=>{l.mermaid=!1}},[r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("flow")}},[(Ge=t.value.mermaid)==null?void 0:Ge.flow]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("sequence")}},[(Ze=t.value.mermaid)==null?void 0:Ze.sequence]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("gantt")}},[(bt=t.value.mermaid)==null?void 0:bt.gantt]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("class")}},[(kt=t.value.mermaid)==null?void 0:kt.class]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("state")}},[(Xe=t.value.mermaid)==null?void 0:Xe.state]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("pie")}},[(yt=t.value.mermaid)==null?void 0:yt.pie]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("relationship")}},[(wt=t.value.mermaid)==null?void 0:wt.relationship]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("journey")}},[(ot=t.value.mermaid)==null?void 0:ot.journey])]),key:"bar-mermaid"},{default:()=>{var W;return[r.createVNode("div",{class:`${d}-toolbar-item`,title:(W=t.value.toolbarTips)==null?void 0:W.mermaid},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return r.createVNode(Ye,{relative:`#${i}`,visible:l.katex,onChange:W=>{l.katex=W},overlay:r.createVNode("ul",{class:`${d}-menu`,onClick:()=>{l.katex=!1}},[r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("katexInline")}},[(Jt=t.value.katex)==null?void 0:Jt.inline]),r.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("katexBlock")}},[(en=t.value.katex)==null?void 0:en.block])]),key:"bar-katex"},{default:()=>{var W;return[r.createVNode("div",{class:`${d}-toolbar-item`,title:(W=t.value.toolbarTips)==null?void 0:W.katex},[r.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[r.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return s.defToolbars instanceof Array?s.defToolbars[g]||"":s.defToolbars&&s.defToolbars.children instanceof Array&&s.defToolbars.children[g]||""};return()=>{const g=f.value[0].map(b=>v(b)),$=f.value[1].map(b=>v(b));return r.createVNode(r.Fragment,null,[s.toolbars.length>0&&r.createVNode("div",{class:`${d}-toolbar-wrapper`,id:i},[r.createVNode("div",{class:`${d}-toolbar`},[r.createVNode("div",{class:`${d}-toolbar-left`,ref:u},[g]),r.createVNode("div",{class:`${d}-toolbar-right`},[$])])]),r.createVNode("input",{ref:h,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),r.createVNode(vi,{linkVisible:o.linkVisible,clipVisible:o.clipVisible,type:o.type,onCancel:()=>{o.linkVisible=!1,o.clipVisible=!1},onOk:b=>{b&&a(o.type,{desc:b.desc,url:b.url}),o.linkVisible=!1,o.clipVisible=!1}},null)])}}});function Nn(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let lt=Nn();function $i(s){lt=s}const zn=/[&<>"']/,Si=new RegExp(zn.source,"g"),Vn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Ci=new RegExp(Vn.source,"g"),Ti={"&":"&","<":"<",">":">",'"':""","'":"'"},mn=s=>Ti[s];function ae(s,e){if(e){if(zn.test(s))return s.replace(Si,mn)}else if(Vn.test(s))return s.replace(Ci,mn);return s}const Ei=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function _n(s){return s.replace(Ei,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const Ni=/(^|[^\[])\^/g;function K(s,e){s=typeof s=="string"?s:s.source,e=e||"";const t={replace:(n,i)=>(i=i.source||i,i=i.replace(Ni,"$1"),s=s.replace(n,i),t),getRegex:()=>new RegExp(s,e)};return t}const zi=/[^\w:]/g,Vi=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function gn(s,e,t){if(s){let n;try{n=decodeURIComponent(_n(t)).replace(zi,"").toLowerCase()}catch{return null}if(n.indexOf("javascript:")===0||n.indexOf("vbscript:")===0||n.indexOf("data:")===0)return null}e&&!Vi.test(t)&&(t=Li(e,t));try{t=encodeURI(t).replace(/%25/g,"%")}catch{return null}return t}const $t={},_i=/^[^:]+:\/*[^/]*$/,Ai=/^([^:]+:)[\s\S]*$/,Ii=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Li(s,e){$t[" "+s]||(_i.test(s)?$t[" "+s]=s+"/":$t[" "+s]=Ct(s,"/",!0)),s=$t[" "+s];const t=s.indexOf(":")===-1;return e.substring(0,2)==="//"?t?e:s.replace(Ai,"$1")+e:e.charAt(0)==="/"?t?e:s.replace(Ii,"$1")+e:s+e}const It={exec:function(){}};function $e(s){let e=1,t,n;for(;e<arguments.length;e++){t=arguments[e];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s}function pn(s,e){const t=s.replace(/\|/g,(l,a,o)=>{let u=!1,f=a;for(;--f>=0&&o[f]==="\\";)u=!u;return u?"|":" |"}),n=t.split(/ \|/);let i=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(/\\\|/g,"|");return n}function Ct(s,e,t){const n=s.length;if(n===0)return"";let i=0;for(;i<n;){const l=s.charAt(n-i-1);if(l===e&&!t)i++;else if(l!==e&&t)i++;else break}return s.slice(0,n-i)}function Fi(s,e){if(s.indexOf(e[1])===-1)return-1;const t=s.length;let n=0,i=0;for(;i<t;i++)if(s[i]==="\\")i++;else if(s[i]===e[0])n++;else if(s[i]===e[1]&&(n--,n<0))return i;return-1}function An(s){s&&s.sanitize&&!s.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function vn(s,e){if(e<1)return"";let t="";for(;e>1;)e&1&&(t+=s),e>>=1,s+=s;return t+s}function bn(s,e,t,n){const i=e.href,l=e.title?ae(e.title):null,a=s[1].replace(/\\([\[\]])/g,"$1");if(s[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:t,href:i,title:l,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,o}return{type:"image",raw:t,href:i,title:l,text:ae(a)}}function Ri(s,e){const t=s.match(/^(\s+)(?:```)/);if(t===null)return e;const n=t[1];return e.split(`
|
|
3
|
-
`).
|
|
4
|
-
`)}class Xt{constructor(e){this.options=e||lt}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Ct(n,`
|
|
5
|
-
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],i=Ri(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:i}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(/#$/.test(n)){const i=Ct(n,"#");(this.options.pedantic||!i||/ $/.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const n=t[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const l=this.lexer.blockTokens(n);return this.lexer.state.top=i,{type:"blockquote",raw:t[0],tokens:l,text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,i,l,a,o,u,f,h,m,v,g,$,b=t[1].trim();const k=b.length>1,p={type:"list",raw:"",ordered:k,start:k?+b.slice(0,-1):"",loose:!1,items:[]};b=k?`\\d{1,9}\\${b.slice(-1)}`:`\\${b}`,this.options.pedantic&&(b=k?b:"[*+-]");const w=new RegExp(`^( {0,3}${b})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&($=!1,!(!(t=w.exec(e))||this.rules.block.hr.test(e)));){if(n=t[0],e=e.substring(n.length),h=t[2].split(`
|
|
6
|
-
`,1)[0].replace(/^\t+/,C=>" ".repeat(3*C.length)),m=e.split(`
|
|
7
|
-
`,1)[0],this.options.pedantic?(a=2,g=h.trimLeft()):(a=t[2].search(/[^ ]/),a=a>4?1:a,g=h.slice(a),a+=t[1].length),u=!1,!h&&/^ *$/.test(m)&&(n+=m+`
|
|
8
|
-
`,e=e.substring(m.length+1),$=!0),!$){const C=new RegExp(`^ {0,${Math.min(3,a-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),V=new RegExp(`^ {0,${Math.min(3,a-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),H=new RegExp(`^ {0,${Math.min(3,a-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,a-1)}}#`);for(;e&&(v=e.split(`
|
|
9
|
-
`,1)[0],m=v,this.options.pedantic&&(m=m.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(H.test(m)||T.test(m)||C.test(m)||V.test(e)));){if(m.search(/[^ ]/)>=a||!m.trim())g+=`
|
|
10
|
-
`+m.slice(a);else{if(u||h.search(/[^ ]/)>=4||H.test(h)||T.test(h)||V.test(h))break;g+=`
|
|
11
|
-
`+m}!u&&!m.trim()&&(u=!0),n+=v+`
|
|
12
|
-
`,e=e.substring(v.length+1),h=m.slice(a)}}p.loose||(f?p.loose=!0:/\n *\n *$/.test(n)&&(f=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(g),i&&(l=i[0]!=="[ ] ",g=g.replace(/^\[[ xX]\] +/,""))),p.items.push({type:"list_item",raw:n,task:!!i,checked:l,loose:!1,text:g}),p.raw+=n}p.items[p.items.length-1].raw=n.trimRight(),p.items[p.items.length-1].text=g.trimRight(),p.raw=p.raw.trimRight();const S=p.items.length;for(o=0;o<S;o++)if(this.lexer.state.top=!1,p.items[o].tokens=this.lexer.blockTokens(p.items[o].text,[]),!p.loose){const C=p.items[o].tokens.filter(H=>H.type==="space"),V=C.length>0&&C.some(H=>/\n.*\n/.test(H.raw));p.loose=V}if(p.loose)for(o=0;o<S;o++)p.items[o].loose=!0;return p}}html(e){const t=this.rules.block.html.exec(e);if(t){const n={type:"html",raw:t[0],pre:!this.options.sanitizer&&(t[1]==="pre"||t[1]==="script"||t[1]==="style"),text:t[0]};if(this.options.sanitize){const i=this.options.sanitizer?this.options.sanitizer(t[0]):ae(t[0]);n.type="paragraph",n.text=i,n.tokens=this.lexer.inline(i)}return n}}def(e){const t=this.rules.block.def.exec(e);if(t){const n=t[1].toLowerCase().replace(/\s+/g," "),i=t[2]?t[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",l=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:i,title:l}}}table(e){const t=this.rules.block.table.exec(e);if(t){const n={type:"table",header:pn(t[1]).map(i=>({text:i})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
|
13
|
-
`):[]};if(n.header.length===n.align.length){n.raw=t[0];let i=n.align.length,l,a,o,u;for(l=0;l<i;l++)/^ *-+: *$/.test(n.align[l])?n.align[l]="right":/^ *:-+: *$/.test(n.align[l])?n.align[l]="center":/^ *:-+ *$/.test(n.align[l])?n.align[l]="left":n.align[l]=null;for(i=n.rows.length,l=0;l<i;l++)n.rows[l]=pn(n.rows[l],n.header.length).map(f=>({text:f}));for(i=n.header.length,a=0;a<i;a++)n.header[a].tokens=this.lexer.inline(n.header[a].text);for(i=n.rows.length,a=0;a<i;a++)for(u=n.rows[a],o=0;o<u.length;o++)u[o].tokens=this.lexer.inline(u[o].text);return n}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const n=t[1].charAt(t[1].length-1)===`
|
|
14
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:ae(t[1])}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&/^<a /i.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):ae(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const n=t[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const a=Ct(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=Fi(t[2],"()");if(a>-1){const u=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,u).trim(),t[3]=""}}let i=t[2],l="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);a&&(i=a[1],l=a[3])}else l=t[3]?t[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(n)?i=i.slice(1):i=i.slice(1,-1)),bn(t,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:l&&l.replace(this.rules.inline._escapes,"$1")},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let i=(n[2]||n[1]).replace(/\s+/g," ");if(i=t[i.toLowerCase()],!i){const l=n[0].charAt(0);return{type:"text",raw:l,text:l}}return bn(n,i,n[0],this.lexer)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&n.match(/[\p{L}\p{N}]/u))return;const l=i[1]||i[2]||"";if(!l||l&&(n===""||this.rules.inline.punctuation.exec(n))){const a=i[0].length-1;let o,u,f=a,h=0;const m=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+a);(i=m.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(u=o.length,i[3]||i[4]){f+=u;continue}else if((i[5]||i[6])&&a%3&&!((a+u)%3)){h+=u;continue}if(f-=u,f>0)continue;u=Math.min(u,u+f+h);const v=e.slice(0,a+i.index+(i[0].length-o.length)+u);if(Math.min(a,u)%2){const $=v.slice(1,-1);return{type:"em",raw:v,text:$,tokens:this.lexer.inlineTokens($)}}const g=v.slice(2,-2);return{type:"strong",raw:v,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const i=/[^ ]/.test(n),l=/^ /.test(n)&&/ $/.test(n);return i&&l&&(n=n.substring(1,n.length-1)),n=ae(n,!0),{type:"codespan",raw:t[0],text:n}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){const n=this.rules.inline.autolink.exec(e);if(n){let i,l;return n[2]==="@"?(i=ae(this.options.mangle?t(n[1]):n[1]),l="mailto:"+i):(i=ae(n[1]),l=i),{type:"link",raw:n[0],text:i,href:l,tokens:[{type:"text",raw:i,text:i}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let i,l;if(n[2]==="@")i=ae(this.options.mangle?t(n[0]):n[0]),l="mailto:"+i;else{let a;do a=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0];while(a!==n[0]);i=ae(n[0]),n[1]==="www."?l="http://"+n[0]:l=n[0]}return{type:"link",raw:n[0],text:i,href:l,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,t){const n=this.rules.inline.text.exec(e);if(n){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):ae(n[0]):n[0]:i=ae(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:i}}}}const A={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:It,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};A._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;A._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;A.def=K(A.def).replace("label",A._label).replace("title",A._title).getRegex();A.bullet=/(?:[*+-]|\d{1,9}[.)])/;A.listItemStart=K(/^( *)(bull) */).replace("bull",A.bullet).getRegex();A.list=K(A.list).replace(/bull/g,A.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+A.def.source+")").getRegex();A._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";A._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/;A.html=K(A.html,"i").replace("comment",A._comment).replace("tag",A._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();A.paragraph=K(A._paragraph).replace("hr",A.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A._tag).getRegex();A.blockquote=K(A.blockquote).replace("paragraph",A.paragraph).getRegex();A.normal=$e({},A);A.gfm=$e({},A.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"});A.gfm.table=K(A.gfm.table).replace("hr",A.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A._tag).getRegex();A.gfm.paragraph=K(A._paragraph).replace("hr",A.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",A.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",A._tag).getRegex();A.pedantic=$e({},A.normal,{html:K(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",A._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:It,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:K(A.normal._paragraph).replace("hr",A.hr).replace("heading",` *#{1,6} *[^
|
|
15
|
-
]`).replace("lheading",A.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const E={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:It,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:It,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};E._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~";E.punctuation=K(E.punctuation).replace(/punctuation/g,E._punctuation).getRegex();E.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;E.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;E._comment=K(A._comment).replace("(?:-->|$)","-->").getRegex();E.emStrong.lDelim=K(E.emStrong.lDelim).replace(/punct/g,E._punctuation).getRegex();E.emStrong.rDelimAst=K(E.emStrong.rDelimAst,"g").replace(/punct/g,E._punctuation).getRegex();E.emStrong.rDelimUnd=K(E.emStrong.rDelimUnd,"g").replace(/punct/g,E._punctuation).getRegex();E._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;E._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;E._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;E.autolink=K(E.autolink).replace("scheme",E._scheme).replace("email",E._email).getRegex();E._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;E.tag=K(E.tag).replace("comment",E._comment).replace("attribute",E._attribute).getRegex();E._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;E._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;E._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;E.link=K(E.link).replace("label",E._label).replace("href",E._href).replace("title",E._title).getRegex();E.reflink=K(E.reflink).replace("label",E._label).replace("ref",A._label).getRegex();E.nolink=K(E.nolink).replace("ref",A._label).getRegex();E.reflinkSearch=K(E.reflinkSearch,"g").replace("reflink",E.reflink).replace("nolink",E.nolink).getRegex();E.normal=$e({},E);E.pedantic=$e({},E.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:K(/^!?\[(label)\]\((.*?)\)/).replace("label",E._label).getRegex(),reflink:K(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",E._label).getRegex()});E.gfm=$e({},E.normal,{escape:K(E.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/});E.gfm.url=K(E.gfm.url,"i").replace("email",E.gfm._extended_email).getRegex();E.breaks=$e({},E.gfm,{br:K(E.br).replace("{2,}","*").getRegex(),text:K(E.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});function ji(s){return s.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function kn(s){let e="",t,n;const i=s.length;for(t=0;t<i;t++)n=s.charCodeAt(t),Math.random()>.5&&(n="x"+n.toString(16)),e+="&#"+n+";";return e}class Re{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||lt,this.options.tokenizer=this.options.tokenizer||new Xt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:A.normal,inline:E.normal};this.options.pedantic?(t.block=A.pedantic,t.inline=E.pedantic):this.options.gfm&&(t.block=A.gfm,this.options.breaks?t.inline=E.breaks:t.inline=E.gfm),this.tokenizer.rules=t}static get rules(){return{block:A,inline:E}}static lex(e,t){return new Re(t).lex(e)}static lexInline(e,t){return new Re(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
|
|
16
|
-
`),this.blockTokens(e,this.tokens);let t;for(;t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(o,u,f)=>u+" ".repeat(f.length));let n,i,l,a;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(o=>(n=o.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=`
|
|
17
|
-
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
|
|
18
|
-
`+n.raw,i.text+=`
|
|
19
|
-
`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length),i=t[t.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=`
|
|
20
|
-
`+n.raw,i.text+=`
|
|
21
|
-
`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(l=e,this.options.extensions&&this.options.extensions.startBlock){let o=1/0;const u=e.slice(1);let f;this.options.extensions.startBlock.forEach(function(h){f=h.call({lexer:this},u),typeof f=="number"&&f>=0&&(o=Math.min(o,f))}),o<1/0&&o>=0&&(l=e.substring(0,o+1))}if(this.state.top&&(n=this.tokenizer.paragraph(l))){i=t[t.length-1],a&&i.type==="paragraph"?(i.raw+=`
|
|
22
|
-
`+n.raw,i.text+=`
|
|
23
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n),a=l.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),i=t[t.length-1],i&&i.type==="text"?(i.raw+=`
|
|
24
|
-
`+n.raw,i.text+=`
|
|
25
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):t.push(n);continue}if(e){const o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i,l,a=e,o,u,f;if(this.tokens.links){const h=Object.keys(this.tokens.links);if(h.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)h.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,o.index)+"["+vn("a",o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+"["+vn("a",o[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.escapedEmSt.exec(a))!=null;)a=a.slice(0,o.index+o[0].length-2)+"++"+a.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(u||(f=""),u=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(h=>(n=h.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),i=t[t.length-1],i&&n.type==="text"&&i.type==="text"?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length),i=t[t.length-1],i&&n.type==="text"&&i.type==="text"?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,a,f)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e,kn)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e,kn))){e=e.substring(n.raw.length),t.push(n);continue}if(l=e,this.options.extensions&&this.options.extensions.startInline){let h=1/0;const m=e.slice(1);let v;this.options.extensions.startInline.forEach(function(g){v=g.call({lexer:this},m),typeof v=="number"&&v>=0&&(h=Math.min(h,v))}),h<1/0&&h>=0&&(l=e.substring(0,h+1))}if(n=this.tokenizer.inlineText(l,ji)){e=e.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(f=n.raw.slice(-1)),u=!0,i=t[t.length-1],i&&i.type==="text"?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}}class Qt{constructor(e){this.options=e||lt}code(e,t,n){const i=(t||"").match(/\S*/)[0];if(this.options.highlight){const l=this.options.highlight(e,i);l!=null&&l!==e&&(n=!0,e=l)}return e=e.replace(/\n$/,"")+`
|
|
26
|
-
`,i?'<pre><code class="'+this.options.langPrefix+ae(i)+'">'+(n?e:ae(e,!0))+`</code></pre>
|
|
27
|
-
`:"<pre><code>"+(n?e:ae(e,!0))+`</code></pre>
|
|
28
|
-
`}blockquote(e){return`<blockquote>
|
|
29
|
-
${e}</blockquote>
|
|
30
|
-
`}html(e){return e}heading(e,t,n,i){if(this.options.headerIds){const l=this.options.headerPrefix+i.slug(n);return`<h${t} id="${l}">${e}</h${t}>
|
|
31
|
-
`}return`<h${t}>${e}</h${t}>
|
|
32
|
-
`}hr(){return this.options.xhtml?`<hr/>
|
|
33
|
-
`:`<hr>
|
|
34
|
-
`}list(e,t,n){const i=t?"ol":"ul",l=t&&n!==1?' start="'+n+'"':"";return"<"+i+l+`>
|
|
35
|
-
`+e+"</"+i+`>
|
|
36
|
-
`}listitem(e){return`<li>${e}</li>
|
|
37
|
-
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return`<p>${e}</p>
|
|
38
|
-
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
|
|
39
|
-
<thead>
|
|
40
|
-
`+e+`</thead>
|
|
41
|
-
`+t+`</table>
|
|
42
|
-
`}tablerow(e){return`<tr>
|
|
43
|
-
${e}</tr>
|
|
44
|
-
`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
45
|
-
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(e){return`<del>${e}</del>`}link(e,t,n){if(e=gn(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let i='<a href="'+e+'"';return t&&(i+=' title="'+t+'"'),i+=">"+n+"</a>",i}image(e,t,n){if(e=gn(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let i=`<img src="${e}" alt="${n}"`;return t&&(i+=` title="${t}"`),i+=this.options.xhtml?"/>":">",i}text(e){return e}}class In{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class Ln{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,i=0;if(this.seen.hasOwnProperty(n)){i=this.seen[e];do i++,n=e+"-"+i;while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=i,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class ze{constructor(e){this.options=e||lt,this.options.renderer=this.options.renderer||new Qt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new In,this.slugger=new Ln}static parse(e,t){return new ze(t).parse(e)}static parseInline(e,t){return new ze(t).parseInline(e)}parse(e,t=!0){let n="",i,l,a,o,u,f,h,m,v,g,$,b,k,p,w,S,C,V,H;const T=e.length;for(i=0;i<T;i++){if(g=e[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[g.type]&&(H=this.options.extensions.renderers[g.type].call({parser:this},g),H!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(g.type))){n+=H||"";continue}switch(g.type){case"space":continue;case"hr":{n+=this.renderer.hr();continue}case"heading":{n+=this.renderer.heading(this.parseInline(g.tokens),g.depth,_n(this.parseInline(g.tokens,this.textRenderer)),this.slugger);continue}case"code":{n+=this.renderer.code(g.text,g.lang,g.escaped);continue}case"table":{for(m="",h="",o=g.header.length,l=0;l<o;l++)h+=this.renderer.tablecell(this.parseInline(g.header[l].tokens),{header:!0,align:g.align[l]});for(m+=this.renderer.tablerow(h),v="",o=g.rows.length,l=0;l<o;l++){for(f=g.rows[l],h="",u=f.length,a=0;a<u;a++)h+=this.renderer.tablecell(this.parseInline(f[a].tokens),{header:!1,align:g.align[a]});v+=this.renderer.tablerow(h)}n+=this.renderer.table(m,v);continue}case"blockquote":{v=this.parse(g.tokens),n+=this.renderer.blockquote(v);continue}case"list":{for($=g.ordered,b=g.start,k=g.loose,o=g.items.length,v="",l=0;l<o;l++)w=g.items[l],S=w.checked,C=w.task,p="",w.task&&(V=this.renderer.checkbox(S),k?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=V+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=V+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:V}):p+=V),p+=this.parse(w.tokens,k),v+=this.renderer.listitem(p,C,S);n+=this.renderer.list(v,$,b);continue}case"html":{n+=this.renderer.html(g.text);continue}case"paragraph":{n+=this.renderer.paragraph(this.parseInline(g.tokens));continue}case"text":{for(v=g.tokens?this.parseInline(g.tokens):g.text;i+1<T&&e[i+1].type==="text";)g=e[++i],v+=`
|
|
46
|
-
`+(g.tokens?this.parseInline(g.tokens):g.text);n+=t?this.renderer.paragraph(v):v;continue}default:{const y='Token with "'+g.type+'" type was not found.';if(this.options.silent){console.error(y);return}else throw new Error(y)}}}return n}parseInline(e,t){t=t||this.renderer;let n="",i,l,a;const o=e.length;for(i=0;i<o;i++){if(l=e[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[l.type]&&(a=this.options.extensions.renderers[l.type].call({parser:this},l),a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type))){n+=a||"";continue}switch(l.type){case"escape":{n+=t.text(l.text);break}case"html":{n+=t.html(l.text);break}case"link":{n+=t.link(l.href,l.title,this.parseInline(l.tokens,t));break}case"image":{n+=t.image(l.href,l.title,l.text);break}case"strong":{n+=t.strong(this.parseInline(l.tokens,t));break}case"em":{n+=t.em(this.parseInline(l.tokens,t));break}case"codespan":{n+=t.codespan(l.text);break}case"br":{n+=t.br();break}case"del":{n+=t.del(this.parseInline(l.tokens,t));break}case"text":{n+=t.text(l.text);break}default:{const u='Token with "'+l.type+'" type was not found.';if(this.options.silent){console.error(u);return}else throw new Error(u)}}}return n}}function N(s,e,t){if(typeof s>"u"||s===null)throw new Error("marked(): input parameter is undefined or null");if(typeof s!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(s)+", string expected");if(typeof e=="function"&&(t=e,e=null),e=$e({},N.defaults,e||{}),An(e),t){const i=e.highlight;let l;try{l=Re.lex(s,e)}catch(u){return t(u)}const a=function(u){let f;if(!u)try{e.walkTokens&&N.walkTokens(l,e.walkTokens),f=ze.parse(l,e)}catch(h){u=h}return e.highlight=i,u?t(u):t(null,f)};if(!i||i.length<3||(delete e.highlight,!l.length))return a();let o=0;N.walkTokens(l,function(u){u.type==="code"&&(o++,setTimeout(()=>{i(u.text,u.lang,function(f,h){if(f)return a(f);h!=null&&h!==u.text&&(u.text=h,u.escaped=!0),o--,o===0&&a()})},0))}),o===0&&a();return}function n(i){if(i.message+=`
|
|
47
|
-
Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+ae(i.message+"",!0)+"</pre>";throw i}try{const i=Re.lex(s,e);if(e.walkTokens){if(e.async)return Promise.all(N.walkTokens(i,e.walkTokens)).then(()=>ze.parse(i,e)).catch(n);N.walkTokens(i,e.walkTokens)}return ze.parse(i,e)}catch(i){n(i)}}N.options=N.setOptions=function(s){return $e(N.defaults,s),$i(N.defaults),N};N.getDefaults=Nn;N.defaults=lt;N.use=function(...s){const e=N.defaults.extensions||{renderers:{},childTokens:{}};s.forEach(t=>{const n=$e({},t);if(n.async=N.defaults.async||n.async,t.extensions&&(t.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const l=e.renderers[i.name];l?e.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===!1&&(o=l.apply(this,a)),o}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),n.extensions=e),t.renderer){const i=N.defaults.renderer||new Qt;for(const l in t.renderer){const a=i[l];i[l]=(...o)=>{let u=t.renderer[l].apply(i,o);return u===!1&&(u=a.apply(i,o)),u}}n.renderer=i}if(t.tokenizer){const i=N.defaults.tokenizer||new Xt;for(const l in t.tokenizer){const a=i[l];i[l]=(...o)=>{let u=t.tokenizer[l].apply(i,o);return u===!1&&(u=a.apply(i,o)),u}}n.tokenizer=i}if(t.walkTokens){const i=N.defaults.walkTokens;n.walkTokens=function(l){let a=[];return a.push(t.walkTokens.call(this,l)),i&&(a=a.concat(i.call(this,l))),a}}N.setOptions(n)})};N.walkTokens=function(s,e){let t=[];for(const n of s)switch(t=t.concat(e.call(N,n)),n.type){case"table":{for(const i of n.header)t=t.concat(N.walkTokens(i.tokens,e));for(const i of n.rows)for(const l of i)t=t.concat(N.walkTokens(l.tokens,e));break}case"list":{t=t.concat(N.walkTokens(n.items,e));break}default:N.defaults.extensions&&N.defaults.extensions.childTokens&&N.defaults.extensions.childTokens[n.type]?N.defaults.extensions.childTokens[n.type].forEach(function(i){t=t.concat(N.walkTokens(n[i],e))}):n.tokens&&(t=t.concat(N.walkTokens(n.tokens,e)))}return t};N.parseInline=function(s,e){if(typeof s>"u"||s===null)throw new Error("marked.parseInline(): input parameter is undefined or null");if(typeof s!="string")throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(s)+", string expected");e=$e({},N.defaults,e||{}),An(e);try{const t=Re.lexInline(s,e);return e.walkTokens&&N.walkTokens(t,e.walkTokens),ze.parseInline(t,e)}catch(t){if(t.message+=`
|
|
48
|
-
Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+ae(t.message+"",!0)+"</pre>";throw t}};N.Parser=ze;N.parser=ze.parse;N.Renderer=Qt;N.TextRenderer=In;N.Lexer=Re;N.lexer=Re.lex;N.Tokenizer=Xt;N.Slugger=Ln;N.parse=N;N.options;N.setOptions;N.use;N.walkTokens;N.parseInline;ze.parse;Re.lex;var Oi=function(){var s=document.getSelection();if(!s.rangeCount)return function(){};for(var e=document.activeElement,t=[],n=0;n<s.rangeCount;n++)t.push(s.getRangeAt(n));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return s.removeAllRanges(),function(){s.type==="Caret"&&s.removeAllRanges(),s.rangeCount||t.forEach(function(i){s.addRange(i)}),e&&e.focus()}},Di=Oi,yn={"text/plain":"Text","text/html":"Url",default:"Text"},Hi="Copy to clipboard: #{key}, Enter";function Pi(s){var e=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return s.replace(/#{\s*key\s*}/g,e)}function Mi(s,e){var t,n,i,l,a,o,u=!1;e||(e={}),t=e.debug||!1;try{i=Di(),l=document.createRange(),a=document.getSelection(),o=document.createElement("span"),o.textContent=s,o.ariaHidden="true",o.style.all="unset",o.style.position="fixed",o.style.top=0,o.style.clip="rect(0, 0, 0, 0)",o.style.whiteSpace="pre",o.style.webkitUserSelect="text",o.style.MozUserSelect="text",o.style.msUserSelect="text",o.style.userSelect="text",o.addEventListener("copy",function(h){if(h.stopPropagation(),e.format)if(h.preventDefault(),typeof h.clipboardData>"u"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var m=yn[e.format]||yn.default;window.clipboardData.setData(m,s)}else h.clipboardData.clearData(),h.clipboardData.setData(e.format,s);e.onCopy&&(h.preventDefault(),e.onCopy(h.clipboardData))}),document.body.appendChild(o),l.selectNodeContents(o),a.addRange(l);var f=document.execCommand("copy");if(!f)throw new Error("copy command was unsuccessful");u=!0}catch(h){t&&console.error("unable to copy using execCommand: ",h),t&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(e.format||"text",s),e.onCopy&&e.onCopy(window.clipboardData),u=!0}catch(m){t&&console.error("unable to copy using clipboardData: ",m),t&&console.error("falling back to prompt"),n=Pi("message"in e?e.message:Hi),window.prompt(n,s)}}finally{a&&(typeof a.removeRange=="function"?a.removeRange(l):a.removeAllRanges()),o&&document.body.removeChild(o),i()}return u}var ct=Mi;/*! medium-zoom 1.0.8 | MIT License | https://github.com/francoischalifour/medium-zoom */var Ue=Object.assign||function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},St=function(e){return e.tagName==="IMG"},Bi=function(e){return NodeList.prototype.isPrototypeOf(e)},Tt=function(e){return e&&e.nodeType===1},wn=function(e){var t=e.currentSrc||e.src;return t.substr(-4).toLowerCase()===".svg"},xn=function(e){try{return Array.isArray(e)?e.filter(St):Bi(e)?[].slice.call(e).filter(St):Tt(e)?[e].filter(St):typeof e=="string"?[].slice.call(document.querySelectorAll(e)).filter(St):[]}catch{throw new TypeError(`The provided selector is invalid.
|
|
49
|
-
Expects a CSS selector, a Node element, a NodeList or an array.
|
|
50
|
-
See: https://github.com/francoischalifour/medium-zoom`)}},Ui=function(e){var t=document.createElement("div");return t.classList.add("medium-zoom-overlay"),t.style.background=e,t},qi=function(e){var t=e.getBoundingClientRect(),n=t.top,i=t.left,l=t.width,a=t.height,o=e.cloneNode(),u=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,f=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;return o.removeAttribute("id"),o.style.position="absolute",o.style.top=n+u+"px",o.style.left=i+f+"px",o.style.width=l+"px",o.style.height=a+"px",o.style.transform="",o},Qe=function(e,t){var n=Ue({bubbles:!1,cancelable:!1,detail:void 0},t);if(typeof window.CustomEvent=="function")return new CustomEvent(e,n);var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),i},Wi=function s(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=window.Promise||function(z){function F(){}z(F,F)},i=function(z){var F=z.target;if(F===G){$();return}S.indexOf(F)!==-1&&b({target:F})},l=function(){if(!(V||!y.original)){var z=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(H-z)>T.scrollOffset&&setTimeout($,150)}},a=function(z){var F=z.key||z.keyCode;(F==="Escape"||F==="Esc"||F===27)&&$()},o=function(){var z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},F=z;if(z.background&&(G.style.background=z.background),z.container&&z.container instanceof Object&&(F.container=Ue({},T.container,z.container)),z.template){var P=Tt(z.template)?z.template:document.querySelector(z.template);F.template=P}return T=Ue({},T,F),S.forEach(function(q){q.dispatchEvent(Qe("medium-zoom:update",{detail:{zoom:U}}))}),U},u=function(){var z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return s(Ue({},T,z))},f=function(){for(var z=arguments.length,F=Array(z),P=0;P<z;P++)F[P]=arguments[P];var q=F.reduce(function(j,ee){return[].concat(j,xn(ee))},[]);return q.filter(function(j){return S.indexOf(j)===-1}).forEach(function(j){S.push(j),j.classList.add("medium-zoom-image")}),C.forEach(function(j){var ee=j.type,I=j.listener,R=j.options;q.forEach(function(M){M.addEventListener(ee,I,R)})}),U},h=function(){for(var z=arguments.length,F=Array(z),P=0;P<z;P++)F[P]=arguments[P];y.zoomed&&$();var q=F.length>0?F.reduce(function(j,ee){return[].concat(j,xn(ee))},[]):S;return q.forEach(function(j){j.classList.remove("medium-zoom-image"),j.dispatchEvent(Qe("medium-zoom:detach",{detail:{zoom:U}}))}),S=S.filter(function(j){return q.indexOf(j)===-1}),U},m=function(z,F){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(q){q.addEventListener("medium-zoom:"+z,F,P)}),C.push({type:"medium-zoom:"+z,listener:F,options:P}),U},v=function(z,F){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(q){q.removeEventListener("medium-zoom:"+z,F,P)}),C=C.filter(function(q){return!(q.type==="medium-zoom:"+z&&q.listener.toString()===F.toString())}),U},g=function(){var z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},F=z.target,P=function(){var j={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},ee=void 0,I=void 0;if(T.container)if(T.container instanceof Object)j=Ue({},j,T.container),ee=j.width-j.left-j.right-T.margin*2,I=j.height-j.top-j.bottom-T.margin*2;else{var R=Tt(T.container)?T.container:document.querySelector(T.container),M=R.getBoundingClientRect(),se=M.width,oe=M.height,he=M.left,Se=M.top;j=Ue({},j,{width:se,height:oe,left:he,top:Se})}ee=ee||j.width-T.margin*2,I=I||j.height-T.margin*2;var Ve=y.zoomedHd||y.original,Me=wn(Ve)?ee:Ve.naturalWidth||ee,je=wn(Ve)?I:Ve.naturalHeight||I,Be=Ve.getBoundingClientRect(),pt=Be.top,vt=Be.left,Ge=Be.width,Ze=Be.height,bt=Math.min(Math.max(Ge,Me),ee)/Ge,kt=Math.min(Math.max(Ze,je),I)/Ze,Xe=Math.min(bt,kt),yt=(-vt+(ee-Ge)/2+T.margin+j.left)/Xe,wt=(-pt+(I-Ze)/2+T.margin+j.top)/Xe,ot="scale("+Xe+") translate3d("+yt+"px, "+wt+"px, 0)";y.zoomed.style.transform=ot,y.zoomedHd&&(y.zoomedHd.style.transform=ot)};return new n(function(q){if(F&&S.indexOf(F)===-1){q(U);return}var j=function se(){V=!1,y.zoomed.removeEventListener("transitionend",se),y.original.dispatchEvent(Qe("medium-zoom:opened",{detail:{zoom:U}})),q(U)};if(y.zoomed){q(U);return}if(F)y.original=F;else if(S.length>0){var ee=S;y.original=ee[0]}else{q(U);return}if(y.original.dispatchEvent(Qe("medium-zoom:open",{detail:{zoom:U}})),H=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,V=!0,y.zoomed=qi(y.original),document.body.appendChild(G),T.template){var I=Tt(T.template)?T.template:document.querySelector(T.template);y.template=document.createElement("div"),y.template.appendChild(I.content.cloneNode(!0)),document.body.appendChild(y.template)}if(y.original.parentElement&&y.original.parentElement.tagName==="PICTURE"&&y.original.currentSrc&&(y.zoomed.src=y.original.currentSrc),document.body.appendChild(y.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),y.original.classList.add("medium-zoom-image--hidden"),y.zoomed.classList.add("medium-zoom-image--opened"),y.zoomed.addEventListener("click",$),y.zoomed.addEventListener("transitionend",j),y.original.getAttribute("data-zoom-src")){y.zoomedHd=y.zoomed.cloneNode(),y.zoomedHd.removeAttribute("srcset"),y.zoomedHd.removeAttribute("sizes"),y.zoomedHd.removeAttribute("loading"),y.zoomedHd.src=y.zoomed.getAttribute("data-zoom-src"),y.zoomedHd.onerror=function(){clearInterval(R),console.warn("Unable to reach the zoom image target "+y.zoomedHd.src),y.zoomedHd=null,P()};var R=setInterval(function(){y.zoomedHd.complete&&(clearInterval(R),y.zoomedHd.classList.add("medium-zoom-image--opened"),y.zoomedHd.addEventListener("click",$),document.body.appendChild(y.zoomedHd),P())},10)}else if(y.original.hasAttribute("srcset")){y.zoomedHd=y.zoomed.cloneNode(),y.zoomedHd.removeAttribute("sizes"),y.zoomedHd.removeAttribute("loading");var M=y.zoomedHd.addEventListener("load",function(){y.zoomedHd.removeEventListener("load",M),y.zoomedHd.classList.add("medium-zoom-image--opened"),y.zoomedHd.addEventListener("click",$),document.body.appendChild(y.zoomedHd),P()})}else P()})},$=function(){return new n(function(z){if(V||!y.original){z(U);return}var F=function P(){y.original.classList.remove("medium-zoom-image--hidden"),document.body.removeChild(y.zoomed),y.zoomedHd&&document.body.removeChild(y.zoomedHd),document.body.removeChild(G),y.zoomed.classList.remove("medium-zoom-image--opened"),y.template&&document.body.removeChild(y.template),V=!1,y.zoomed.removeEventListener("transitionend",P),y.original.dispatchEvent(Qe("medium-zoom:closed",{detail:{zoom:U}})),y.original=null,y.zoomed=null,y.zoomedHd=null,y.template=null,z(U)};V=!0,document.body.classList.remove("medium-zoom--opened"),y.zoomed.style.transform="",y.zoomedHd&&(y.zoomedHd.style.transform=""),y.template&&(y.template.style.transition="opacity 150ms",y.template.style.opacity=0),y.original.dispatchEvent(Qe("medium-zoom:close",{detail:{zoom:U}})),y.zoomed.addEventListener("transitionend",F)})},b=function(){var z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},F=z.target;return y.original?$():g({target:F})},k=function(){return T},p=function(){return S},w=function(){return y.original},S=[],C=[],V=!1,H=0,T=t,y={original:null,zoomed:null,zoomedHd:null,template:null};Object.prototype.toString.call(e)==="[object Object]"?T=e:(e||typeof e=="string")&&f(e),T=Ue({margin:0,background:"#fff",scrollOffset:40,container:null,template:null},T);var G=Ui(T.background);document.addEventListener("click",i),document.addEventListener("keyup",a),document.addEventListener("scroll",l),window.addEventListener("resize",$);var U={open:g,close:$,toggle:b,update:o,clone:u,attach:f,detach:h,on:m,off:v,getOptions:k,getImages:p,getZoomedImage:w};return U};function Ki(s,e){e===void 0&&(e={});var t=e.insertAt;if(!(!s||typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var Gi=".medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}";Ki(Gi);const Zi=Wi,rt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Fn=new Set,Xi=(s,e,t,n)=>{typeof process=="object"&&process&&typeof process.emitWarning=="function"?process.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`)},Qi=s=>!Fn.has(s),Oe=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Rn=s=>Oe(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Et:null:null;class Et extends Array{constructor(e){super(e),this.fill(0)}}var et;const Je=class{constructor(e,t){te(this,"heap");te(this,"length");if(!c(Je,et))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}static create(e){const t=Rn(e);if(!t)return[];L(Je,et,!0);const n=new Je(e,t);return L(Je,et,!1),n}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}};let Nt=Je;et=new WeakMap,D(Nt,et,!1);var ve,fe,Ce,be,tt,ne,ke,ie,Z,O,ue,me,ce,le,ye,re,Ae,Ie,we,Te,Pe,de,dt,Mt,qe,Le,ht,ge,Ft,jn,We,nt,ft,Ee,De,Ne,He,mt,Bt,it,zt,st,Vt,X,Y,gt,Ut,Ke,ut;const Yt=class{constructor(e){D(this,dt);D(this,Ft);D(this,Ee);D(this,Ne);D(this,mt);D(this,it);D(this,st);D(this,X);D(this,gt);D(this,Ke);D(this,ve,void 0);D(this,fe,void 0);D(this,Ce,void 0);D(this,be,void 0);D(this,tt,void 0);te(this,"ttl");te(this,"ttlResolution");te(this,"ttlAutopurge");te(this,"updateAgeOnGet");te(this,"updateAgeOnHas");te(this,"allowStale");te(this,"noDisposeOnSet");te(this,"noUpdateTTL");te(this,"maxEntrySize");te(this,"sizeCalculation");te(this,"noDeleteOnFetchRejection");te(this,"noDeleteOnStaleGet");te(this,"allowStaleOnFetchAbort");te(this,"allowStaleOnFetchRejection");te(this,"ignoreFetchAbort");D(this,ne,void 0);D(this,ke,void 0);D(this,ie,void 0);D(this,Z,void 0);D(this,O,void 0);D(this,ue,void 0);D(this,me,void 0);D(this,ce,void 0);D(this,le,void 0);D(this,ye,void 0);D(this,re,void 0);D(this,Ae,void 0);D(this,Ie,void 0);D(this,we,void 0);D(this,Te,void 0);D(this,Pe,void 0);D(this,de,void 0);D(this,qe,()=>{});D(this,Le,()=>{});D(this,ht,()=>{});D(this,ge,()=>!1);D(this,We,e=>{});D(this,nt,(e,t,n)=>{});D(this,ft,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:l,updateAgeOnGet:a,updateAgeOnHas:o,allowStale:u,dispose:f,disposeAfter:h,noDisposeOnSet:m,noUpdateTTL:v,maxSize:g=0,maxEntrySize:$=0,sizeCalculation:b,fetchMethod:k,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:C,ignoreFetchAbort:V}=e;if(t!==0&&!Oe(t))throw new TypeError("max option must be a nonnegative integer");const H=t?Rn(t):Array;if(!H)throw new Error("invalid max value: "+t);if(L(this,ve,t),L(this,fe,g),this.maxEntrySize=$||c(this,fe),this.sizeCalculation=b,this.sizeCalculation){if(!c(this,fe)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(k!==void 0&&typeof k!="function")throw new TypeError("fetchMethod must be a function if specified");if(L(this,tt,k),L(this,Pe,!!k),L(this,ie,new Map),L(this,Z,new Array(t).fill(void 0)),L(this,O,new Array(t).fill(void 0)),L(this,ue,new H(t)),L(this,me,new H(t)),L(this,ce,0),L(this,le,0),L(this,ye,Nt.create(t)),L(this,ne,0),L(this,ke,0),typeof f=="function"&&L(this,Ce,f),typeof h=="function"?(L(this,be,h),L(this,re,[])):(L(this,be,void 0),L(this,re,void 0)),L(this,Te,!!c(this,Ce)),L(this,de,!!c(this,be)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!v,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!V,this.maxEntrySize!==0){if(c(this,fe)!==0&&!Oe(c(this,fe)))throw new TypeError("maxSize must be a positive integer if specified");if(!Oe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");_(this,Ft,jn).call(this)}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!o,this.ttlResolution=Oe(i)||i===0?i:1,this.ttlAutopurge=!!l,this.ttl=n||0,this.ttl){if(!Oe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");_(this,dt,Mt).call(this)}if(c(this,ve)===0&&this.ttl===0&&c(this,fe)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!c(this,ve)&&!c(this,fe)){const T="LRU_CACHE_UNBOUNDED";Qi(T)&&(Fn.add(T),Xi("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",T,Yt))}}static unsafeExposeInternals(e){return{starts:c(e,Ie),ttls:c(e,we),sizes:c(e,Ae),keyMap:c(e,ie),keyList:c(e,Z),valList:c(e,O),next:c(e,ue),prev:c(e,me),get head(){return c(e,ce)},get tail(){return c(e,le)},free:c(e,ye),isBackgroundFetch:t=>{var n;return _(n=e,X,Y).call(n,t)},backgroundFetch:(t,n,i,l)=>{var a;return _(a=e,st,Vt).call(a,t,n,i,l)},moveToTail:t=>{var n;return _(n=e,Ke,ut).call(n,t)},indexes:t=>{var n;return _(n=e,Ee,De).call(n,t)},rindexes:t=>{var n;return _(n=e,Ne,He).call(n,t)},isStale:t=>{var n;return c(n=e,ge).call(n,t)}}}get max(){return c(this,ve)}get maxSize(){return c(this,fe)}get calculatedSize(){return c(this,ke)}get size(){return c(this,ne)}get fetchMethod(){return c(this,tt)}get dispose(){return c(this,Ce)}get disposeAfter(){return c(this,be)}getRemainingTTL(e){return c(this,ie).has(e)?1/0:0}*entries(){for(const e of _(this,Ee,De).call(this))c(this,O)[e]!==void 0&&c(this,Z)[e]!==void 0&&!_(this,X,Y).call(this,c(this,O)[e])&&(yield[c(this,Z)[e],c(this,O)[e]])}*rentries(){for(const e of _(this,Ne,He).call(this))c(this,O)[e]!==void 0&&c(this,Z)[e]!==void 0&&!_(this,X,Y).call(this,c(this,O)[e])&&(yield[c(this,Z)[e],c(this,O)[e]])}*keys(){for(const e of _(this,Ee,De).call(this)){const t=c(this,Z)[e];t!==void 0&&!_(this,X,Y).call(this,c(this,O)[e])&&(yield t)}}*rkeys(){for(const e of _(this,Ne,He).call(this)){const t=c(this,Z)[e];t!==void 0&&!_(this,X,Y).call(this,c(this,O)[e])&&(yield t)}}*values(){for(const e of _(this,Ee,De).call(this))c(this,O)[e]!==void 0&&!_(this,X,Y).call(this,c(this,O)[e])&&(yield c(this,O)[e])}*rvalues(){for(const e of _(this,Ne,He).call(this))c(this,O)[e]!==void 0&&!_(this,X,Y).call(this,c(this,O)[e])&&(yield c(this,O)[e])}[Symbol.iterator](){return this.entries()}find(e,t={}){for(const n of _(this,Ee,De).call(this)){const i=c(this,O)[n],l=_(this,X,Y).call(this,i)?i.__staleWhileFetching:i;if(l!==void 0&&e(l,c(this,Z)[n],this))return this.get(c(this,Z)[n],t)}}forEach(e,t=this){for(const n of _(this,Ee,De).call(this)){const i=c(this,O)[n],l=_(this,X,Y).call(this,i)?i.__staleWhileFetching:i;l!==void 0&&e.call(t,l,c(this,Z)[n],this)}}rforEach(e,t=this){for(const n of _(this,Ne,He).call(this)){const i=c(this,O)[n],l=_(this,X,Y).call(this,i)?i.__staleWhileFetching:i;l!==void 0&&e.call(t,l,c(this,Z)[n],this)}}purgeStale(){let e=!1;for(const t of _(this,Ne,He).call(this,{allowStale:!0}))c(this,ge).call(this,t)&&(this.delete(c(this,Z)[t]),e=!0);return e}dump(){const e=[];for(const t of _(this,Ee,De).call(this,{allowStale:!0})){const n=c(this,Z)[t],i=c(this,O)[t],l=_(this,X,Y).call(this,i)?i.__staleWhileFetching:i;if(l===void 0||n===void 0)continue;const a={value:l};if(c(this,we)&&c(this,Ie)){a.ttl=c(this,we)[t];const o=rt.now()-c(this,Ie)[t];a.start=Math.floor(Date.now()-o)}c(this,Ae)&&(a.size=c(this,Ae)[t]),e.unshift([n,a])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const i=Date.now()-n.start;n.start=rt.now()-i}this.set(t,n.value,n)}}set(e,t,n={}){var v,g,$;const{ttl:i=this.ttl,start:l,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:u}=n;let{noUpdateTTL:f=this.noUpdateTTL}=n;const h=c(this,ft).call(this,e,t,n.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=!0),this.delete(e),this;let m=c(this,ne)===0?void 0:c(this,ie).get(e);if(m===void 0)m=c(this,ne)===0?c(this,le):c(this,ye).length!==0?c(this,ye).pop():c(this,ne)===c(this,ve)?_(this,it,zt).call(this,!1):c(this,ne),c(this,Z)[m]=e,c(this,O)[m]=t,c(this,ie).set(e,m),c(this,ue)[c(this,le)]=m,c(this,me)[m]=c(this,le),L(this,le,m),xt(this,ne)._++,c(this,nt).call(this,m,h,u),u&&(u.set="add"),f=!1;else{_(this,Ke,ut).call(this,m);const b=c(this,O)[m];if(t!==b){if(c(this,Pe)&&_(this,X,Y).call(this,b)?b.__abortController.abort(new Error("replaced")):a||(c(this,Te)&&((v=c(this,Ce))==null||v.call(this,b,e,"set")),c(this,de)&&((g=c(this,re))==null||g.push([b,e,"set"]))),c(this,We).call(this,m),c(this,nt).call(this,m,h,u),c(this,O)[m]=t,u){u.set="replace";const k=b&&_(this,X,Y).call(this,b)?b.__staleWhileFetching:b;k!==void 0&&(u.oldValue=k)}}else u&&(u.set="update")}if(i!==0&&!c(this,we)&&_(this,dt,Mt).call(this),c(this,we)&&(f||c(this,ht).call(this,m,i,l),u&&c(this,Le).call(this,u,m)),!a&&c(this,de)&&c(this,re)){const b=c(this,re);let k;for(;k=b==null?void 0:b.shift();)($=c(this,be))==null||$.call(this,...k)}return this}pop(){var e;try{for(;c(this,ne);){const t=c(this,O)[c(this,ce)];if(_(this,it,zt).call(this,!0),_(this,X,Y).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(c(this,de)&&c(this,re)){const t=c(this,re);let n;for(;n=t==null?void 0:t.shift();)(e=c(this,be))==null||e.call(this,...n)}}}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,l=c(this,ie).get(e);if(l!==void 0)if(c(this,ge).call(this,l))i&&(i.has="stale",c(this,Le).call(this,i,l));else return n&&c(this,qe).call(this,l),i&&(i.has="hit",c(this,Le).call(this,i,l)),!0;else i&&(i.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,i=c(this,ie).get(e);if(i!==void 0&&(n||!c(this,ge).call(this,i))){const l=c(this,O)[i];return _(this,X,Y).call(this,l)?l.__staleWhileFetching:l}}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:l=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:u=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:v=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:$=this.allowStaleOnFetchAbort,context:b,forceRefresh:k=!1,status:p,signal:w}=t;if(!c(this,Pe))return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:l,status:p});const S={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:l,ttl:a,noDisposeOnSet:o,size:u,sizeCalculation:f,noUpdateTTL:h,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:$,ignoreFetchAbort:g,status:p,signal:w};let C=c(this,ie).get(e);if(C===void 0){p&&(p.fetch="miss");const V=_(this,st,Vt).call(this,e,C,S,b);return V.__returned=V}else{const V=c(this,O)[C];if(_(this,X,Y).call(this,V)){const U=n&&V.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",U&&(p.returnedStale=!0)),U?V.__staleWhileFetching:V.__returned=V}const H=c(this,ge).call(this,C);if(!k&&!H)return p&&(p.fetch="hit"),_(this,Ke,ut).call(this,C),i&&c(this,qe).call(this,C),p&&c(this,Le).call(this,p,C),V;const T=_(this,st,Vt).call(this,e,C,S,b),G=T.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=H?"stale":"refresh",G&&H&&(p.returnedStale=!0)),G?T.__staleWhileFetching:T.__returned=T}}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:l=this.noDeleteOnStaleGet,status:a}=t,o=c(this,ie).get(e);if(o!==void 0){const u=c(this,O)[o],f=_(this,X,Y).call(this,u);return a&&c(this,Le).call(this,a,o),c(this,ge).call(this,o)?(a&&(a.get="stale"),f?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?u.__staleWhileFetching:void 0):(l||this.delete(e),a&&n&&(a.returnedStale=!0),n?u:void 0)):(a&&(a.get="hit"),f?u.__staleWhileFetching:(_(this,Ke,ut).call(this,o),i&&c(this,qe).call(this,o),u))}else a&&(a.get="miss")}delete(e){var n,i,l,a;let t=!1;if(c(this,ne)!==0){const o=c(this,ie).get(e);if(o!==void 0)if(t=!0,c(this,ne)===1)this.clear();else{c(this,We).call(this,o);const u=c(this,O)[o];_(this,X,Y).call(this,u)?u.__abortController.abort(new Error("deleted")):(c(this,Te)||c(this,de))&&(c(this,Te)&&((n=c(this,Ce))==null||n.call(this,u,e,"delete")),c(this,de)&&((i=c(this,re))==null||i.push([u,e,"delete"]))),c(this,ie).delete(e),c(this,Z)[o]=void 0,c(this,O)[o]=void 0,o===c(this,le)?L(this,le,c(this,me)[o]):o===c(this,ce)?L(this,ce,c(this,ue)[o]):(c(this,ue)[c(this,me)[o]]=c(this,ue)[o],c(this,me)[c(this,ue)[o]]=c(this,me)[o]),xt(this,ne)._--,c(this,ye).push(o)}}if(c(this,de)&&((l=c(this,re))!=null&&l.length)){const o=c(this,re);let u;for(;u=o==null?void 0:o.shift();)(a=c(this,be))==null||a.call(this,...u)}return t}clear(){var e,t,n;for(const i of _(this,Ne,He).call(this,{allowStale:!0})){const l=c(this,O)[i];if(_(this,X,Y).call(this,l))l.__abortController.abort(new Error("deleted"));else{const a=c(this,Z)[i];c(this,Te)&&((e=c(this,Ce))==null||e.call(this,l,a,"delete")),c(this,de)&&((t=c(this,re))==null||t.push([l,a,"delete"]))}}if(c(this,ie).clear(),c(this,O).fill(void 0),c(this,Z).fill(void 0),c(this,we)&&c(this,Ie)&&(c(this,we).fill(0),c(this,Ie).fill(0)),c(this,Ae)&&c(this,Ae).fill(0),L(this,ce,0),L(this,le,0),c(this,ye).length=0,L(this,ke,0),L(this,ne,0),c(this,de)&&c(this,re)){const i=c(this,re);let l;for(;l=i==null?void 0:i.shift();)(n=c(this,be))==null||n.call(this,...l)}}};let Pt=Yt;ve=new WeakMap,fe=new WeakMap,Ce=new WeakMap,be=new WeakMap,tt=new WeakMap,ne=new WeakMap,ke=new WeakMap,ie=new WeakMap,Z=new WeakMap,O=new WeakMap,ue=new WeakMap,me=new WeakMap,ce=new WeakMap,le=new WeakMap,ye=new WeakMap,re=new WeakMap,Ae=new WeakMap,Ie=new WeakMap,we=new WeakMap,Te=new WeakMap,Pe=new WeakMap,de=new WeakMap,dt=new WeakSet,Mt=function(){const e=new Et(c(this,ve)),t=new Et(c(this,ve));L(this,we,e),L(this,Ie,t),L(this,ht,(l,a,o=rt.now())=>{if(t[l]=a!==0?o:0,e[l]=a,a!==0&&this.ttlAutopurge){const u=setTimeout(()=>{c(this,ge).call(this,l)&&this.delete(c(this,Z)[l])},a+1);u.unref&&u.unref()}}),L(this,qe,l=>{t[l]=e[l]!==0?rt.now():0}),L(this,Le,(l,a)=>{if(e[a]){const o=e[a],u=t[a];l.ttl=o,l.start=u,l.now=n||i(),l.remainingTTL=l.now+o-u}});let n=0;const i=()=>{const l=rt.now();if(this.ttlResolution>0){n=l;const a=setTimeout(()=>n=0,this.ttlResolution);a.unref&&a.unref()}return l};this.getRemainingTTL=l=>{const a=c(this,ie).get(l);return a===void 0?0:e[a]===0||t[a]===0?1/0:t[a]+e[a]-(n||i())},L(this,ge,l=>e[l]!==0&&t[l]!==0&&(n||i())-t[l]>e[l])},qe=new WeakMap,Le=new WeakMap,ht=new WeakMap,ge=new WeakMap,Ft=new WeakSet,jn=function(){const e=new Et(c(this,ve));L(this,ke,0),L(this,Ae,e),L(this,We,t=>{L(this,ke,c(this,ke)-e[t]),e[t]=0}),L(this,ft,(t,n,i,l)=>{if(_(this,X,Y).call(this,n))return 0;if(!Oe(i))if(l){if(typeof l!="function")throw new TypeError("sizeCalculation must be a function");if(i=l(n,t),!Oe(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),L(this,nt,(t,n,i)=>{if(e[t]=n,c(this,fe)){const l=c(this,fe)-e[t];for(;c(this,ke)>l;)_(this,it,zt).call(this,!0)}L(this,ke,c(this,ke)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=c(this,ke))})},We=new WeakMap,nt=new WeakMap,ft=new WeakMap,Ee=new WeakSet,De=function*({allowStale:e=this.allowStale}={}){if(c(this,ne))for(let t=c(this,le);!(!_(this,mt,Bt).call(this,t)||((e||!c(this,ge).call(this,t))&&(yield t),t===c(this,ce)));)t=c(this,me)[t]},Ne=new WeakSet,He=function*({allowStale:e=this.allowStale}={}){if(c(this,ne))for(let t=c(this,ce);!(!_(this,mt,Bt).call(this,t)||((e||!c(this,ge).call(this,t))&&(yield t),t===c(this,le)));)t=c(this,ue)[t]},mt=new WeakSet,Bt=function(e){return e!==void 0&&c(this,ie).get(c(this,Z)[e])===e},it=new WeakSet,zt=function(e){var l,a;const t=c(this,ce),n=c(this,Z)[t],i=c(this,O)[t];return c(this,Pe)&&_(this,X,Y).call(this,i)?i.__abortController.abort(new Error("evicted")):(c(this,Te)||c(this,de))&&(c(this,Te)&&((l=c(this,Ce))==null||l.call(this,i,n,"evict")),c(this,de)&&((a=c(this,re))==null||a.push([i,n,"evict"]))),c(this,We).call(this,t),e&&(c(this,Z)[t]=void 0,c(this,O)[t]=void 0,c(this,ye).push(t)),c(this,ne)===1?(L(this,ce,L(this,le,0)),c(this,ye).length=0):L(this,ce,c(this,ue)[t]),c(this,ie).delete(n),xt(this,ne)._--,t},st=new WeakSet,Vt=function(e,t,n,i){const l=t===void 0?void 0:c(this,O)[t];if(_(this,X,Y).call(this,l))return l;const a=new AbortController,{signal:o}=n;o==null||o.addEventListener("abort",()=>a.abort(o.reason),{signal:a.signal});const u={signal:a.signal,options:n,context:i},f=(b,k=!1)=>{const{aborted:p}=a.signal,w=n.ignoreFetchAbort&&b!==void 0;if(n.status&&(p&&!k?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,w&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),p&&!w&&!k)return m(a.signal.reason);const S=g;return c(this,O)[t]===g&&(b===void 0?S.__staleWhileFetching?c(this,O)[t]=S.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,b,u.options))),b},h=b=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=b),m(b)),m=b=>{const{aborted:k}=a.signal,p=k&&n.allowStaleOnFetchAbort,w=p||n.allowStaleOnFetchRejection,S=w||n.noDeleteOnFetchRejection,C=g;if(c(this,O)[t]===g&&(!S||C.__staleWhileFetching===void 0?this.delete(e):p||(c(this,O)[t]=C.__staleWhileFetching)),w)return n.status&&C.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),C.__staleWhileFetching;if(C.__returned===C)throw b},v=(b,k)=>{var w;const p=(w=c(this,tt))==null?void 0:w.call(this,e,l,u);p&&p instanceof Promise&&p.then(S=>b(S),k),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(b(),n.allowStaleOnFetchAbort&&(b=S=>f(S,!0)))})};n.status&&(n.status.fetchDispatched=!0);const g=new Promise(v).then(f,h),$=Object.assign(g,{__abortController:a,__staleWhileFetching:l,__returned:void 0});return t===void 0?(this.set(e,$,{...u.options,status:void 0}),t=c(this,ie).get(e)):c(this,O)[t]=$,$},X=new WeakSet,Y=function(e){if(!c(this,Pe))return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof AbortController},gt=new WeakSet,Ut=function(e,t){c(this,me)[t]=e,c(this,ue)[e]=t},Ke=new WeakSet,ut=function(e){e!==c(this,le)&&(e===c(this,ce)?L(this,ce,c(this,ue)[e]):_(this,gt,Ut).call(this,c(this,me)[e],c(this,ue)[e]),_(this,gt,Ut).call(this,c(this,le),e),L(this,le,e))};const Yi=Pt,at=s=>{const e=s.value,t=e.substring(0,s.selectionStart),n=e.substring(s.selectionEnd,e.length),i=t.lastIndexOf(`
|
|
51
|
-
`),l=t.substring(0,i+1),a=n.indexOf(`
|
|
52
|
-
`),o=n.substring(a===-1?n.length:a,n.length),u=t.substring(i+1,t.length),f=n.substring(0,a);return{prefixStr:t,subfixStr:n,prefixStrEndRow:l,subfixStrEndRow:o,prefixSupply:u,subfixSupply:f}},Ji=(s,e="",t,n)=>{var m,v,g,$,b,k;let i="",l=0,a=0,o=!1,u,f;const h=(m=J.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(s)){const p=s.replace(/^h(\d)/,(w,S)=>new Array(Number(S)).fill("#",0,S).join(""));i=`${p} ${e}`,l=p.length+1}else if(s==="prettier"){const p=window.prettier||((g=(v=J.editorExtensions)==null?void 0:v.prettier)==null?void 0:g.prettierInstance),w=[(($=window.prettierPlugins)==null?void 0:$.markdown)||((k=(b=J.editorExtensions)==null?void 0:b.prettier)==null?void 0:k.parserMarkdownInstance)];return!p||w[0]===void 0?(x.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),t.value):p.format(t.value,{parser:"markdown",plugins:w})}else switch(s){case"bold":{i=`**${e}**`,l=2,a=-2;break}case"underline":{i=`<u>${e}</u>`,l=3,a=-4;break}case"italic":{i=`*${e}*`,l=1,a=-1;break}case"strikeThrough":{i=`~${e}~`,l=1,a=-1;break}case"sub":{i=`<sub>${e}</sub>`,l=5,a=-6;break}case"sup":{i=`<sup>${e}</sup>`,l=5,a=-6;break}case"codeRow":{i="`"+e+"`",l=1,a=-1;break}case"quote":{i=`> ${e}`,l=2;break}case"orderedList":{i=`1. ${e}`,l=3;break}case"unorderedList":{i=`- ${e}`,l=2;break}case"task":{i=`- [ ] ${e}`,l=6,o=!0;break}case"code":{const p=n.text||e||"",w=n.mode||"language";i=`\`\`\`${w}
|
|
1
|
+
"use strict";var ut=Object.defineProperty;var mt=(e,o,n)=>o in e?ut(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n;var j=(e,o,n)=>(mt(e,typeof o!="symbol"?o+"":o,n),n);const t=require("vue"),K=require("codemirror"),R=require("@codemirror/state"),Y=require("@codemirror/view"),gt=require("@codemirror/language-data"),ft=require("@codemirror/lang-markdown"),oe=require("@codemirror/commands"),Q=require("@codemirror/language"),f=require("@lezer/highlight"),ht=require("medium-zoom"),vt=require("copy-to-clipboard"),pt=require("markdown-it"),bt=require("markdown-it-image-figures"),kt=require("markdown-it-task-lists"),yt=require("lru-cache"),s="md-editor",Ct="md-editor-v3",wt="https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js",S="https://cdnjs.cloudflare.com/ajax/libs",$t=`${S}/highlight.js/11.7.0/highlight.min.js`,je={main:`${S}/prettier/2.8.0/standalone.js`,markdown:`${S}/prettier/2.8.0/parser-markdown.js`},Re={css:`${S}/cropperjs/1.5.13/cropper.min.css`,js:`${S}/cropperjs/1.5.13/cropper.min.js`},Nt=`${S}/screenfull.js/5.2.0/screenfull.min.js`,rt=["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"],it=["markdownTotal","=","scrollSwitch"],Be={"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"}}},Vt=`${S}/mermaid/9.4.0/mermaid.min.js`,Pe={js:`${S}/KaTeX/0.16.3/katex.min.js`,css:`${S}/KaTeX/0.16.3/katex.min.css`},Oe={a11y:{light:`${S}/highlight.js/11.7.0/styles/a11y-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/a11y-dark.min.css`},atom:{light:`${S}/highlight.js/11.7.0/styles/atom-one-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/atom-one-dark.min.css`},github:{light:`${S}/highlight.js/11.7.0/styles/github.min.css`,dark:`${S}/highlight.js/11.7.0/styles/github-dark.min.css`},gradient:{light:`${S}/highlight.js/11.7.0/styles/gradient-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/gradient-dark.min.css`},kimbie:{light:`${S}/highlight.js/11.7.0/styles/kimbie-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/kimbie-dark.min.css`},paraiso:{light:`${S}/highlight.js/11.7.0/styles/paraiso-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/paraiso-dark.min.css`},qtcreator:{light:`${S}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${S}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,dark:`${S}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`}},x={editorExtensions:{},editorConfig:{},codeMirrorExtensions:(e,o)=>o,markdownItConfig:()=>{}},Tt=e=>{if(e)for(const o in e){const n=e[o];n&&(x[o]=n)}};const St=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${s}-divider`},null)}}),F=({instance:e,ctx:o,props:n={}},l="default")=>{const r=(e==null?void 0:e.$slots[l])||(o==null?void 0:o.slots[l]);return(r?r(e):"")||n[l]};const xt={trigger:{type:String,default:"hover"},overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}},U=t.defineComponent({props:xt,setup(e,o){const n=`${s}-dropdown-hidden`,l=t.reactive({overlayClass:[n],overlayStyle:{},triggerHover:!1,overlayHover:!1}),r=t.ref(),a=t.ref(),i=()=>{var $;e.trigger==="hover"&&(l.triggerHover=!0);const g=r.value,h=a.value,v=g.getBoundingClientRect(),b=g.offsetTop,k=g.offsetLeft,p=v.height,y=v.width,w=(($=document.querySelector(e.relative))==null?void 0:$.scrollLeft)||0;l.overlayStyle={...l.overlayStyle,top:b+p+"px",left:k-h.offsetWidth/2+y/2-w+"px"},e.onChange(!0)},c=()=>{l.overlayHover=!0};t.watch(()=>e.visible,g=>{g?l.overlayClass=l.overlayClass.filter(h=>h!==n):l.overlayClass.push(n)});const m=g=>{const h=r.value,v=a.value;!h.contains(g.target)&&!v.contains(g.target)&&e.onChange(!1)};let u=-1;const d=g=>{r.value===g.target?l.triggerHover=!1:l.overlayHover=!1,clearTimeout(u),u=window.setTimeout(()=>{!l.overlayHover&&!l.triggerHover&&e.onChange(!1)},10)};return t.onMounted(()=>{e.trigger==="click"?(r.value.addEventListener("click",i),document.addEventListener("click",m)):(r.value.addEventListener("mouseenter",i),r.value.addEventListener("mouseleave",d),a.value.addEventListener("mouseenter",c),a.value.addEventListener("mouseleave",d))}),t.onBeforeUnmount(()=>{e.trigger==="click"?(r.value.removeEventListener("click",i),document.removeEventListener("click",m)):(r.value.removeEventListener("mouseenter",i),r.value.removeEventListener("mouseleave",d),a.value.removeEventListener("mouseenter",c),a.value.removeEventListener("mouseleave",d))}),()=>{const g=F({ctx:o}),h=F({props:e,ctx:o},"overlay"),v=t.cloneVNode(g instanceof Array?g[0]:g,{ref:r}),b=t.createVNode("div",{class:[`${s}-dropdown`,l.overlayClass],style:l.overlayStyle,ref:a},[t.createVNode("div",{class:`${s}-dropdown-overlay`},[h instanceof Array?h[0]:h])]);return[v,b]}}});class Et{constructor(){j(this,"pools",{})}remove(o,n,l){const a=this.pools[o]&&this.pools[o][n];a&&(this.pools[o][n]=a.filter(i=>i!==l))}clear(o){this.pools[o]={}}on(o,n){return this.pools[o]||(this.pools[o]={}),this.pools[o][n.name]||(this.pools[o][n.name]=[]),this.pools[o][n.name].push(n.callback),this.pools[o][n.name].includes(n.callback)}emit(o,n,...l){this.pools[o]||(this.pools[o]={});const a=this.pools[o][n];a&&a.forEach(i=>{try{i(...l)}catch(c){console.error(`${n} monitor event exception!`,c)}})}}const C=new Et,Lt=(e,o={newWindow:!0,nofollow:!0})=>{e||console.error("error link!");const n=document.createElement("a");n.href=e,n.style.display="none",o.newWindow&&(n.target="_blank"),o.nofollow&&(n.rel="noopener noreferrer"),document.body.appendChild(n),n.click(),document.body.removeChild(n)},Mt=(e,o="image.png")=>{const n=e.split(","),l=n[0].match(/:(.*?);/);if(l){const r=l[1],a=atob(n[1]);let i=a.length;const c=new Uint8Array(i);for(;i--;)c[i]=a.charCodeAt(i);return new File([c],o,{type:r})}return null},Ht=e=>{if(!e)return e;const o=e.split(`
|
|
2
|
+
`),n=['<span rn-wrapper aria-hidden="true">'];return o.forEach(()=>{n.push("<span></span>")}),n.push("</span>"),`<span class="code-block">${e}</span>${n.join("")}`},W=(e,o=200)=>{let n=0;return(...l)=>new Promise(r=>{n&&(clearTimeout(n),r("cancel")),n=window.setTimeout(()=>{e.apply(void 0,l),n=0,r("done")},o)})},It=(e,o=200)=>{let n=0,l=null;return(...r)=>{const a=i=>{n===0&&(n=i),i-n>=o?(e.apply(void 0,l),l=null,n=0):window.requestAnimationFrame(a)};l===null&&window.requestAnimationFrame(a),l=r}},Ft=(e,o)=>{const n=e==null?void 0:e.getBoundingClientRect();if(o===document.documentElement)return n.top-o.clientTop;const l=o==null?void 0:o.getBoundingClientRect();return n.top-l.top},At=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`,jt={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}},ne="onSave",ue="changeCatalogVisible",st="changeFullscreen",De="pageFullscreenChanged",_e="fullscreenChanged",ie="previewChanged",qe="htmlPreviewChanged",Ue="catalogVisibleChanged",ct="textareaFocus",We=(e,o)=>{const n=l=>{const r=e.parentElement||document.body,a=r.offsetWidth,i=r.offsetHeight,{clientWidth:c}=document.documentElement,{clientHeight:m}=document.documentElement,u=l.offsetX,d=l.offsetY,g=v=>{let b=v.x+document.body.scrollLeft-document.body.clientLeft-u,k=v.y+document.body.scrollTop-document.body.clientTop-d;b=b<1?1:b<c-a-1?b:c-a-1,k=k<1?1:k<m-i-1?k:m-i-1,o?o(b,k):(r.style.left=`${b}px`,r.style.top=`${k}px`)};document.addEventListener("mousemove",g);const h=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h)};document.addEventListener("mouseup",h)};return e.addEventListener("mousedown",n),()=>{e.removeEventListener("mousedown",n)}},I=(e,o="")=>{const n=document.getElementById(e.id),l=r=>{typeof e.onload=="function"&&e.onload(r),e.removeEventListener("load",l)};n?o!==""&&typeof e.onload=="function"&&(Reflect.get(window,o)?e.dispatchEvent(new Event("load")):n.addEventListener("load",l)):(e.addEventListener("load",l),document.head.appendChild(e))},Rt=W((e,o,n)=>{const l=document.getElementById(e);l&&l.setAttribute(o,n)},10),Bt=e=>{var m,u,d,g;const o=t.inject("editorId");let n=(u=(m=x.editorExtensions)==null?void 0:m.screenfull)==null?void 0:u.instance;const l=(g=(d=x.editorExtensions)==null?void 0:d.screenfull)==null?void 0:g.js,r=t.ref(!1),a=h=>{if(!n){C.emit(o,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}n.isEnabled?(r.value=!0,(h===void 0?!n.isFullscreen:h)?n.request():n.exit()):console.error("browser does not support screenfull!")},i=()=>{n&&n.isEnabled&&n.on("change",()=>{(r.value||e.setting.fullscreen)&&(r.value=!1,e.updateSetting("fullscreen"))})},c=()=>{n=window.screenfull,i()};return t.onMounted(()=>{if(i(),!n){const h=document.createElement("script");h.src=l||Nt,h.onload=c,h.id=`${s}-screenfull`,I(h,"screenfull")}}),t.onMounted(()=>{C.on(o,{name:st,callback:a})}),{fullscreenHandler:a}},Pt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},Ot=t.defineComponent({name:"TableShape",props:Pt,setup(e){const o=t.reactive({x:-1,y:-1});return()=>t.createVNode("div",{class:`${s}-table-shape`,onMouseleave:()=>{o.x=-1,o.y=-1}},[new Array(e.tableShape[1]).fill("").map((n,l)=>t.createVNode("div",{class:`${s}-table-shape-row`,key:`table-shape-row-${l}`},[new Array(e.tableShape[0]).fill("").map((r,a)=>t.createVNode("div",{class:`${s}-table-shape-col`,key:`table-shape-col-${a}`,onMouseenter:()=>{o.x=l,o.y=a},onClick:()=>{e.onSelected(o)}},[t.createVNode("div",{class:[`${s}-table-shape-col-default`,l<=o.x&&a<=o.y&&`${s}-table-shape-col-include`]},null)]))]))])}});const 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}},me=t.defineComponent({props:Dt,setup(e,o){const n=t.ref(e.visible),l=t.ref([`${s}-modal`]),r=t.ref(),a=t.ref();let i=()=>{};const c=t.reactive({initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),m=t.computed(()=>e.isFullscreen?{width:"100%",height:"100%"}:{width:e.width,height:e.height});return t.onMounted(()=>{i=We(a.value,(u,d)=>{c.initPos.left=u+"px",c.initPos.top=d+"px"})}),t.onBeforeUnmount(()=>{i()}),t.watch(()=>e.isFullscreen,u=>{u?i():i=We(a.value,(d,g)=>{c.initPos.left=d+"px",c.initPos.top=g+"px"})}),t.watch(()=>e.visible,u=>{u?(l.value.push("zoom-in"),n.value=u,t.nextTick(()=>{const d=r.value.offsetWidth/2,g=r.value.offsetHeight/2,h=document.documentElement.clientWidth/2,v=document.documentElement.clientHeight/2;c.initPos.left=h-d+"px",c.initPos.top=v-g+"px"}),setTimeout(()=>{l.value=l.value.filter(d=>d!=="zoom-in")},140)):(l.value.push("zoom-out"),setTimeout(()=>{l.value=l.value.filter(d=>d!=="zoom-out"),n.value=u},130))}),()=>{const u=F({ctx:o}),d=F({props:e,ctx:o},"title");return t.createVNode("div",{class:[e.class],style:{display:n.value?"block":"none"}},[t.createVNode("div",{class:`${s}-modal-mask`,onClick:e.onClose},null),t.createVNode("div",{class:l.value,style:{...c.initPos,...m.value},ref:r},[t.createVNode("div",{class:`${s}-modal-header`,ref:a},[d||""]),t.createVNode("div",{class:`${s}-modal-body`},[u]),t.createVNode("div",{class:`${s}-modal-func`},[e.showAdjust&&t.createVNode("div",{class:`${s}-modal-adjust`,onClick:g=>{g.stopPropagation(),e.isFullscreen?c.initPos=c.historyPos:(c.historyPos=c.initPos,c.initPos={left:"0",top:"0"}),e.onAdjust(!e.isFullscreen)}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":`#md-editor-icon-${e.isFullscreen?"suoxiao":"fangda"}`},null)])]),t.createVNode("div",{class:`${s}-modal-close`,onClick:g=>{g.stopPropagation(),e.onClose&&e.onClose()}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-close"},null)])])])])])}}}),_t={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},qt=t.defineComponent({props:_t,setup(e){const o=t.inject("usedLanguageText"),n=t.inject("editorId"),l=t.computed(()=>{var a,i;switch(e.type){case"link":return(a=o.value.linkModalTips)==null?void 0:a.linkTitle;case"image":return(i=o.value.linkModalTips)==null?void 0:i.imageTitle;default:return""}}),r=t.reactive({desc:"",url:""});return t.watch(()=>e.visible,a=>{a||setTimeout(()=>{r.desc="",r.url=""},200)}),()=>t.createVNode(me,{title:l.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var a,i,c,m,u;return[t.createVNode("div",{class:`${s}-form-item`},[t.createVNode("label",{class:`${s}-label`,for:`link-desc-${n}`},[(a=o.value.linkModalTips)==null?void 0:a.descLabel]),t.createVNode("input",{placeholder:(i=o.value.linkModalTips)==null?void 0:i.descLabelPlaceHolder,class:`${s}-input`,id:`link-desc-${n}`,type:"text",value:r.desc,onChange:d=>{r.desc=d.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${s}-form-item`},[t.createVNode("label",{class:`${s}-label`,for:`link-url-${n}`},[(c=o.value.linkModalTips)==null?void 0:c.urlLabel]),t.createVNode("input",{placeholder:(m=o.value.linkModalTips)==null?void 0:m.urlLabelPlaceHolder,class:`${s}-input`,id:`link-url-${n}`,type:"text",value:r.url,onChange:d=>{r.url=d.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${s}-form-item`},[t.createVNode("button",{class:[`${s}-btn`,`${s}-btn-row`],type:"button",onClick:()=>{e.onOk(r),r.desc="",r.url=""}},[(u=o.value.linkModalTips)==null?void 0:u.buttonOK])])]}})}});const Ut={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Wt=t.defineComponent({props:Ut,setup(e){var d,g;const o=t.inject("usedLanguageText"),n=t.inject("editorId");let l=(g=(d=x==null?void 0:x.editorExtensions)==null?void 0:d.cropper)==null?void 0:g.instance;const r=t.ref(),a=t.ref(),i=t.ref(),c=t.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let m=null;t.watch(()=>e.visible,()=>{e.visible&&!c.cropperInited&&(l=l||window.Cropper,r.value.onchange=()=>{if(!l){C.emit(n,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const h=r.value.files||[];if(c.imgSelected=!0,(h==null?void 0:h.length)>0){const v=new FileReader;v.onload=b=>{c.imgSrc=b.target.result,t.nextTick(()=>{m=new l(a.value,{viewMode:2,preview:`.${s}-clip-preview-target`})})},v.readAsDataURL(h[0])}})}),t.watch(()=>[c.imgSelected],()=>{i.value.style=""}),t.watch(()=>c.isFullscreen,()=>{t.nextTick(()=>{m==null||m.destroy(),i.value.style="",a.value&&(m=new l(a.value,{viewMode:2,preview:`.${s}-clip-preview-target`}))})});const u=()=>{m.clear(),m.destroy(),m=null,r.value.value="",c.imgSelected=!1};return()=>{var h;return t.createVNode(me,{class:`${s}-modal-clip`,title:(h=o.value.clipModalTips)==null?void 0:h.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:c.isFullscreen,onAdjust:v=>{c.isFullscreen=v},width:"668px",height:"421px"},{default:()=>{var v,b;return[t.createVNode("div",{class:`${s}-form-item ${s}-clip`},[t.createVNode("div",{class:`${s}-clip-main`},[c.imgSelected?t.createVNode("div",{class:`${s}-clip-cropper`},[t.createVNode("img",{src:c.imgSrc,ref:a,style:{display:"none"},alt:""},null),t.createVNode("div",{class:`${s}-clip-delete`,onClick:u},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):t.createVNode("div",{class:`${s}-clip-upload`,onClick:()=>{r.value.click()}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),t.createVNode("div",{class:`${s}-clip-preview`},[t.createVNode("div",{class:`${s}-clip-preview-target`,ref:i},null)])]),t.createVNode("div",{class:`${s}-form-item`},[t.createVNode("button",{class:`${s}-btn`,type:"button",onClick:()=>{if(m){const k=m.getCroppedCanvas();C.emit(n,"uploadImage",[Mt(k.toDataURL("image/png"))],e.onOk),u()}}},[((v=o.value.clipModalTips)==null?void 0:v.buttonUpload)||((b=o.value.linkModalTips)==null?void 0:b.buttonOK)])]),t.createVNode("input",{ref:r,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),Gt={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},zt=t.defineComponent({props:Gt,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(qt,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(Wt,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),Kt=t.defineComponent({name:"MDEditorToolbar",props:jt,setup(e){const o=t.inject("editorId"),n=t.inject("usedLanguageText"),{fullscreenHandler:l}=Bt(e),r=`${o}-toolbar-wrapper`,a=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),i=(v,b)=>{C.emit(o,"replace",v,b)},c=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),m=t.ref();t.onMounted(()=>{C.on(o,{name:"openModals",callback(v){c.type=v,c.linkVisible=!0}})});const u=t.computed(()=>{const v=e.toolbars.filter(y=>!e.toolbarsExclude.includes(y)),b=v.indexOf("="),k=b===-1?v:v.slice(0,b+1),p=b===-1?[]:v.slice(b,Number.MAX_SAFE_INTEGER);return[k,p]}),d=t.ref(),g=()=>{C.emit(o,"uploadImage",Array.from(d.value.files||[])),d.value.value=""};t.onMounted(()=>{d.value.addEventListener("change",g)});const h=v=>{var b,k,p,y,w,$,T,N,L,M,P,G,_,O,H,D,E,A,z,ee,ge,fe,he,ve,pe,be,ke,ye,Ce,we,$e,Ne,Ve,Te,Se,xe,Ee,Le,Me,He,Ie,Fe,Ae;if(rt.includes(v))switch(v){case"-":return t.createVNode(St,null,null);case"bold":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(b=n.value.toolbarTips)==null?void 0:b.bold,onClick:()=>{i("bold")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(k=n.value.toolbarTips)==null?void 0:k.underline,onClick:()=>{i("underline")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(p=n.value.toolbarTips)==null?void 0:p.italic,onClick:()=>{i("italic")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(y=n.value.toolbarTips)==null?void 0:y.strikeThrough,onClick:()=>{i("strikeThrough")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return t.createVNode(U,{relative:`#${r}`,visible:a.title,onChange:V=>{a.title=V},overlay:t.createVNode("ul",{class:`${s}-menu`,onClick:()=>{a.title=!1}},[t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("h1")}},[(w=n.value.titleItem)==null?void 0:w.h1]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("h2")}},[($=n.value.titleItem)==null?void 0:$.h2]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("h3")}},[(T=n.value.titleItem)==null?void 0:T.h3]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("h4")}},[(N=n.value.titleItem)==null?void 0:N.h4]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("h5")}},[(L=n.value.titleItem)==null?void 0:L.h5]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("h6")}},[(M=n.value.titleItem)==null?void 0:M.h6])])},{default:()=>{var V;return[t.createVNode("div",{class:`${s}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.title},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(P=n.value.toolbarTips)==null?void 0:P.sub,onClick:()=>{i("sub")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(G=n.value.toolbarTips)==null?void 0:G.sup,onClick:()=>{i("sup")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(_=n.value.toolbarTips)==null?void 0:_.quote,onClick:()=>{i("quote")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(O=n.value.toolbarTips)==null?void 0:O.unorderedList,onClick:()=>{i("unorderedList")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(H=n.value.toolbarTips)==null?void 0:H.orderedList,onClick:()=>{i("orderedList")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(D=n.value.toolbarTips)==null?void 0:D.task,onClick:()=>{i("task")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(E=n.value.toolbarTips)==null?void 0:E.codeRow,onClick:()=>{i("codeRow")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(A=n.value.toolbarTips)==null?void 0:A.code,onClick:()=>{i("code")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(z=n.value.toolbarTips)==null?void 0:z.link,onClick:()=>{c.type="link",c.linkVisible=!0}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return e.noUploadImg?t.createVNode("div",{class:`${s}-toolbar-item`,title:(ee=n.value.toolbarTips)==null?void 0:ee.image,onClick:()=>{c.type="image",c.linkVisible=!0}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):t.createVNode(U,{relative:`#${r}`,visible:a.image,onChange:V=>{a.image=V},overlay:t.createVNode("ul",{class:`${s}-menu`,onClick:()=>{a.title=!1}},[t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{c.type="image",c.linkVisible=!0}},[(ge=n.value.imgTitleItem)==null?void 0:ge.link]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{d.value.click()}},[(fe=n.value.imgTitleItem)==null?void 0:fe.upload]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{c.clipVisible=!0}},[(he=n.value.imgTitleItem)==null?void 0:he.clip2upload])])},{default:()=>{var V;return[t.createVNode("div",{class:`${s}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.image},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return t.createVNode(U,{relative:`#${r}`,visible:a.table,onChange:V=>{a.table=V},key:"bar-table",overlay:t.createVNode(Ot,{tableShape:e.tableShape,onSelected:V=>{i("table",{selectedShape:V})}},null)},{default:()=>{var V;return[t.createVNode("div",{class:`${s}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.table},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(ve=n.value.toolbarTips)==null?void 0:ve.revoke,onClick:()=>{C.emit(o,"ctrlZ")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(pe=n.value.toolbarTips)==null?void 0:pe.next,onClick:()=>{C.emit(o,"ctrlShiftZ")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(be=n.value.toolbarTips)==null?void 0:be.save,onClick:()=>{C.emit(o,ne)}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return e.noPrettier?"":t.createVNode("div",{class:`${s}-toolbar-item`,title:(ke=n.value.toolbarTips)==null?void 0:ke.prettier,onClick:()=>{i("prettier")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!e.setting.fullscreen&&t.createVNode("div",{class:`${s}-toolbar-item`,title:(ye=n.value.toolbarTips)==null?void 0:ye.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":`#md-editor-icon-${e.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(Ce=n.value.toolbarTips)==null?void 0:Ce.fullscreen,onClick:()=>{l()}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":`#md-editor-icon-${e.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(we=n.value.toolbarTips)==null?void 0:we.preview,onClick:()=>{e.updateSetting("preview")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return t.createVNode("div",{class:`${s}-toolbar-item`,title:($e=n.value.toolbarTips)==null?void 0:$e.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(Ne=n.value.toolbarTips)==null?void 0:Ne.catalog,onClick:()=>{C.emit(o,ue)},key:"bar-catalog"},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return t.createVNode("div",{class:`${s}-toolbar-item`,title:(Ve=n.value.toolbarTips)==null?void 0:Ve.github,onClick:()=>Lt("https://github.com/imzbf/md-editor-v3")},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return t.createVNode(U,{relative:`#${r}`,visible:a.mermaid,onChange:V=>{a.mermaid=V},overlay:t.createVNode("ul",{class:`${s}-menu`,onClick:()=>{a.mermaid=!1}},[t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("flow")}},[(Te=n.value.mermaid)==null?void 0:Te.flow]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("sequence")}},[(Se=n.value.mermaid)==null?void 0:Se.sequence]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("gantt")}},[(xe=n.value.mermaid)==null?void 0:xe.gantt]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("class")}},[(Ee=n.value.mermaid)==null?void 0:Ee.class]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("state")}},[(Le=n.value.mermaid)==null?void 0:Le.state]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("pie")}},[(Me=n.value.mermaid)==null?void 0:Me.pie]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("relationship")}},[(He=n.value.mermaid)==null?void 0:He.relationship]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("journey")}},[(Ie=n.value.mermaid)==null?void 0:Ie.journey])]),key:"bar-mermaid"},{default:()=>{var V;return[t.createVNode("div",{class:`${s}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.mermaid},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return t.createVNode(U,{relative:`#${r}`,visible:a.katex,onChange:V=>{a.katex=V},overlay:t.createVNode("ul",{class:`${s}-menu`,onClick:()=>{a.katex=!1}},[t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("katexInline")}},[(Fe=n.value.katex)==null?void 0:Fe.inline]),t.createVNode("li",{class:`${s}-menu-item`,onClick:()=>{i("katexBlock")}},[(Ae=n.value.katex)==null?void 0:Ae.block])]),key:"bar-katex"},{default:()=>{var V;return[t.createVNode("div",{class:`${s}-toolbar-item`,title:(V=n.value.toolbarTips)==null?void 0:V.katex},[t.createVNode("svg",{class:`${s}-icon`,"aria-hidden":"true"},[t.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return e.defToolbars instanceof Array?e.defToolbars[v]||"":e.defToolbars&&e.defToolbars.children instanceof Array&&e.defToolbars.children[v]||""};return()=>{const v=u.value[0].map(k=>h(k)),b=u.value[1].map(k=>h(k));return t.createVNode(t.Fragment,null,[e.toolbars.length>0&&t.createVNode("div",{class:`${s}-toolbar-wrapper`,id:r},[t.createVNode("div",{class:`${s}-toolbar`},[t.createVNode("div",{class:`${s}-toolbar-left`,ref:m},[v]),t.createVNode("div",{class:`${s}-toolbar-right`},[b])])]),t.createVNode("input",{ref:d,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),t.createVNode(zt,{linkVisible:c.linkVisible,clipVisible:c.clipVisible,type:c.type,onCancel:()=>{c.linkVisible=!1,c.clipVisible=!1},onOk:k=>{k&&i(c.type,{desc:k.desc,url:k.url}),c.linkVisible=!1,c.clipVisible=!1}},null)])}}}),X=(e,o,n)=>{let l=e.scrollTop;const r=()=>{const a=o-l;l=l+a/5,Math.abs(a)<1?(e.scrollTo(0,o),n&&n()):(e.scrollTo(0,l),requestAnimationFrame(r))};r()},te=e=>{const{marginTop:o}=getComputedStyle(e);return e.offsetTop-parseFloat(o)},Xt=(e,o)=>{const n=W(()=>{e.removeEventListener("scroll",l),e.addEventListener("scroll",l),o.removeEventListener("scroll",l),o.addEventListener("scroll",l)},50),l=r=>{const a=e.clientHeight,i=o.clientHeight,c=e.scrollHeight,m=o.scrollHeight,u=(c-a)/(m-i);r.target===e?(o.removeEventListener("scroll",l),o.scrollTo({top:e.scrollTop/u}),n()):(e.removeEventListener("scroll",l),e.scrollTo({top:o.scrollTop*u}),n())};return[()=>{n().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",l),o.removeEventListener("scroll",l)}]},Zt=(e,o,n,l)=>{const{view:r}=n;let a=0;const i=W(()=>{e.removeEventListener("scroll",u),e.addEventListener("scroll",u),o.removeEventListener("scroll",u),o.addEventListener("scroll",u)},50);let c=[];const m=()=>{c=[];const{width:d,lineHeight:g,fontFamily:h,fontSize:v,whiteSpace:b}=getComputedStyle(document.querySelector(".cm-content")),k=document.createElement("div");k.style.visibility="none",k.style.zIndex="-1",k.style.width=d,k.style.lineHeight=g,k.style.fontFamily=h,k.style.fontSize=v,k.style.whiteSpace=b,document.body.appendChild(k);let p=0;l.split(`
|
|
3
|
+
`).forEach(y=>{k.innerText=y||"-",p+=k.offsetHeight;const w={lineHeight:k.offsetHeight,scrollHeight:p};c.push(w)}),k.remove()},u=W(d=>{var b,k;a++;const g=r.lineBlockAtHeight(r.scrollDOM.scrollTop),h=r.state.doc.lineAt(g.from),v=Array.from(o.children[0].children).filter(p=>p.hasAttribute("data-line"));if(d.target===e){if(o.removeEventListener("scroll",u),e.scrollTop+e.clientHeight>=e.scrollHeight){X(o,o.scrollHeight-o.clientHeight,()=>{--a===0&&i()});return}const{number:p}=h;let y=(b=o.firstElementChild)==null?void 0:b.firstElementChild,w=1,$=v.length===0?(k=o.firstElementChild)==null?void 0:k.lastElementChild:v[0],T=v.length===0?0:Number(v[0].dataset.line);for(let H=0;H<v.length;H++){const D=Number(v[H].dataset.line)+1,E=Number(H+1>=v.length?-2:v[H+1].dataset.line);if(p>=D&&p<=E){y=v[H],$=v[H+1],w=D,T=E;break}}if(!y){a--;return}const N=(r.scrollDOM.scrollTop-c[w-1].scrollHeight+c[w-1].lineHeight)/(c[T-1].scrollHeight-c[w-1].scrollHeight+c[w-1].lineHeight),{marginTop:L}=getComputedStyle(y),M=y.offsetTop-parseFloat(L),{marginTop:P}=getComputedStyle($),_=$.offsetTop-parseFloat(P)-M,O=M+_*N;X(o,O,()=>{--a===0&&i()})}else{if(e.removeEventListener("scroll",u),o.scrollTop===0){X(e,0,()=>{--a===0&&i()});return}else if(o.scrollTop+o.clientHeight>=o.scrollHeight){X(e,e.scrollHeight-e.clientHeight,()=>{--a===0&&i()});return}const p=o.scrollTop,y=o.scrollHeight;let w=Math.floor(Number(v[v.length-1].dataset.line)*(p/y)),$;for(let E=w;E>=0;E--){const A=o.querySelector(`[data-line="${E}"]`);if(A){$=A,w=E;break}}if(!$){a--;return}let T,N;for(;;){const E=v.indexOf($),A=v[E+1],z=te($);if(z>p){if(E===0){T=$,N=A;break}$=v[E-1];continue}const ee=te(A);if(z<=p&&ee>p){T=$,N=A;break}$=A}const L=te(T),M=te(N),P=(p-L)/(M-L),G=Number(T.dataset.line),_=Number(N.dataset.line),O=c[G].scrollHeight,D=c[_].scrollHeight-O;X(e,O+D*P,()=>{--a===0&&i()})}},6);return[()=>{m(),i().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{a=0,e.removeEventListener("scroll",u),o.removeEventListener("scroll",u)}]},Jt=(e,o,n,l,r)=>{const a=t.inject("previewOnly");let i=()=>{},c=()=>{};const m=()=>{i();const u=document.querySelector(".cm-scroller");!a&&(n.value||l.value)&&([c,i]=(n.value?Zt:Xt)(u,n.value||l.value,r.value,e.value)),e.scrollAuto&&c()};t.watch([o,t.toRef(e.setting,"preview"),t.toRef(e.setting,"htmlPreview"),t.toRef(e.setting,"fullscreen"),t.toRef(e.setting,"pageFullscreen")],()=>{t.nextTick(m)}),t.watch(()=>e.scrollAuto,u=>{u?c():i()}),t.onMounted(m)},Yt=(e,o,n)=>{var d,g,h,v,b,k;let l="",r=0,a=0,i=!0,c=!1;const m=o.getSelectedText(),u=(d=x.editorConfig)==null?void 0:d.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const p=e.replace(/^h(\d)/,(y,w)=>new Array(Number(w)).fill("#",0,w).join(""));l=`${p} ${m}`,r=p.length+1}else if(e==="prettier"){const p=window.prettier||((h=(g=x.editorExtensions)==null?void 0:g.prettier)==null?void 0:h.prettierInstance),y=[((v=window.prettierPlugins)==null?void 0:v.markdown)||((k=(b=x.editorExtensions)==null?void 0:b.prettier)==null?void 0:k.parserMarkdownInstance)];!p||y[0]===void 0?(C.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),l=o.getValue()):l=p.format(o.getValue(),{parser:"markdown",plugins:y}),i=!1,c=!0}else switch(e){case"bold":{l=`**${m}**`,r=2,a=-2;break}case"underline":{l=`<u>${m}</u>`,r=3,a=-4;break}case"italic":{l=`*${m}*`,r=1,a=-1;break}case"strikeThrough":{l=`~${m}~`,r=1,a=-1;break}case"sub":{l=`<sub>${m}</sub>`,r=5,a=-6;break}case"sup":{l=`<sup>${m}</sup>`,r=5,a=-6;break}case"codeRow":{l="`"+m+"`",r=1,a=-1;break}case"quote":{l=`> ${m}`,r=2;break}case"orderedList":{l=`1. ${m}`,r=3;break}case"unorderedList":{l=`- ${m}`,r=2;break}case"task":{l=`- [ ] ${m}`,r=6;break}case"code":{const p=n.text||m||"",y=n.mode||"language";l=`\`\`\`${y}
|
|
53
4
|
${p}
|
|
54
5
|
\`\`\`
|
|
55
|
-
`,
|
|
56
|
-
|`;for(let
|
|
57
|
-
|`;for(let
|
|
58
|
-
`,""):
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`),u=S.substring(0,S.length-V.length),f=C.substring(H.length,C.length),o=!0,l=p,a=-V.length-H.length}else{const C=t.value.substring(0,t.selectionStart);/\n$/.test(C)||C===""?(i=`${w}${e}`,o=!0):i=w}break}case"shiftTab":{const{tabWidth:p=2}=n,{prefixStr:w,prefixStrEndRow:S,subfixStrEndRow:C,prefixSupply:V,subfixSupply:H}=at(t),T=new RegExp(`^\\s{${p}}`),y=(G=!1,U=!1)=>{const B=`${V}${e}${H}`;if(T.test(B)){const z=w.length-(U?0:p),F=G?z+e.length-p:z;return _e(t,z,F),`${S}${B.replace(T,"")}${C}`}else if(/^\s/.test(B)){const z=B.replace(/^\s/,""),F=B.length-z.length,P=t.selectionStart-(U?0:F),q=G?P+e.length-F:P;return _e(t,P,q),`${S}${z}${C}`}else i=e};if(e===""){const G=y();if(G)return G}else if(/\n/.test(e)){const U=`${V}${e}${H}`.split(`
|
|
62
|
-
`);let[B,z]=[0,0];const F=U.map((P,q)=>{if(T.test(P))return q===0&&(B=p),z+=p,P.replace(T,"");if(/^\s/.test(P)){const j=P.replace(/^\s/,"");return z+=P.length-j.length,j}return P}).join(`
|
|
63
|
-
`);return _e(t,t.selectionStart-B,t.selectionEnd-z),`${S}${F}${C}`}else{const G=y(!0,!0);if(G)return G}break}case"ctrlC":{const{prefixSupply:p,subfixSupply:w}=at(t);return ct(e===""?`${p}${w}`:e),t.value}case"ctrlX":{const{prefixStrEndRow:p,subfixStrEndRow:w,prefixStr:S,subfixStr:C,prefixSupply:V,subfixSupply:H}=at(t);return e===""?(ct(`${V}${H}`),_e(t,p.length),`${p}${w.replace(/^\n/,"")}`):(ct(e),_e(t,S.length),`${S}${C}`)}case"ctrlD":{const{prefixStrEndRow:p,subfixStrEndRow:w}=at(t);return _e(t,p.length),`${p}${w.replace(/^\n/,"")}`}case"flow":{i=`\`\`\`mermaid
|
|
64
|
-
${(h==null?void 0:h.flow)||`flowchart TD
|
|
6
|
+
`,r=3,a=3+y.length-l.length;break}case"table":{l="|";const{selectedShape:p={x:1,y:1}}=n,{x:y,y:w}=p;for(let $=0;$<=w;$++)l+=" col |";l+=`
|
|
7
|
+
|`;for(let $=0;$<=w;$++)l+=" - |";for(let $=0;$<=y;$++){l+=`
|
|
8
|
+
|`;for(let T=0;T<=w;T++)l+=" content |"}r=2,a=5-l.length;break}case"link":{const{desc:p,url:y}=n;l=`[${p}](${y})`,i=!1;break}case"image":{const{desc:p,url:y,urls:w}=n;w instanceof Array?l=w.reduce(($,T)=>$+`
|
|
9
|
+
`,""):l=`
|
|
10
|
+
`,i=!1;break}case"flow":{l=`\`\`\`mermaid
|
|
11
|
+
${(u==null?void 0:u.flow)||`flowchart TD
|
|
65
12
|
Start --> Stop`}
|
|
66
13
|
\`\`\`
|
|
67
|
-
`,l
|
|
68
|
-
${(
|
|
14
|
+
`,r=3,a=10-l.length;break}case"sequence":{l=`\`\`\`mermaid
|
|
15
|
+
${(u==null?void 0:u.sequence)||`sequenceDiagram
|
|
69
16
|
A->>B: hello!
|
|
70
17
|
B-->>A: hi!
|
|
71
18
|
A-)B: bye!`}
|
|
72
19
|
\`\`\`
|
|
73
|
-
`,l
|
|
74
|
-
${(
|
|
20
|
+
`,r=3,a=10-l.length;break}case"gantt":{l=`\`\`\`mermaid
|
|
21
|
+
${(u==null?void 0:u.gantt)||`gantt
|
|
75
22
|
title A Gantt Diagram
|
|
76
23
|
dateFormat YYYY-MM-DD
|
|
77
24
|
section Section
|
|
78
25
|
A task :a1, 2014-01-01, 30d
|
|
79
26
|
Another task :after a1, 20d`}
|
|
80
27
|
\`\`\`
|
|
81
|
-
`,l
|
|
82
|
-
${(
|
|
28
|
+
`,r=3,a=10-l.length;break}case"class":{l=`\`\`\`mermaid
|
|
29
|
+
${(u==null?void 0:u.class)||`classDiagram
|
|
83
30
|
class Animal
|
|
84
31
|
Vehicle <|-- Car`}
|
|
85
32
|
\`\`\`
|
|
86
|
-
`,l
|
|
87
|
-
${(
|
|
33
|
+
`,r=3,a=10-l.length;break}case"state":{l=`\`\`\`mermaid
|
|
34
|
+
${(u==null?void 0:u.state)||`stateDiagram-v2
|
|
88
35
|
s1 --> s2`}
|
|
89
36
|
\`\`\`
|
|
90
|
-
`,l
|
|
91
|
-
${(
|
|
37
|
+
`,r=3,a=10-l.length;break}case"pie":{l=`\`\`\`mermaid
|
|
38
|
+
${(u==null?void 0:u.pie)||`pie title Pets adopted by volunteers
|
|
92
39
|
"Dogs" : 386
|
|
93
40
|
"Cats" : 85
|
|
94
41
|
"Rats" : 15`}
|
|
95
42
|
\`\`\`
|
|
96
|
-
`,l
|
|
97
|
-
${(
|
|
43
|
+
`,r=3,a=10-l.length;break}case"relationship":{l=`\`\`\`mermaid
|
|
44
|
+
${(u==null?void 0:u.relationship)||`erDiagram
|
|
98
45
|
CAR ||--o{ NAMED-DRIVER : allows
|
|
99
46
|
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
100
47
|
\`\`\`
|
|
101
|
-
`,l
|
|
102
|
-
${(
|
|
48
|
+
`,r=3,a=10-l.length;break}case"journey":{l=`\`\`\`mermaid
|
|
49
|
+
${(u==null?void 0:u.journey)||`journey
|
|
103
50
|
title My working day
|
|
104
51
|
section Go to work
|
|
105
52
|
Make tea: 5: Me
|
|
@@ -109,17 +56,9 @@ ${(h==null?void 0:h.journey)||`journey
|
|
|
109
56
|
Go downstairs: 5: Me
|
|
110
57
|
Sit down: 5: Me`}
|
|
111
58
|
\`\`\`
|
|
112
|
-
`,l
|
|
59
|
+
`,r=3,a=10-l.length;break}case"katexInline":{l="$$",r=1,a=-1;break}case"katexBlock":{l=`$$
|
|
113
60
|
|
|
114
61
|
$$
|
|
115
|
-
`,l=1,a=-4;break}case"universal":{const{generate:p}=n,w=p(e);i=w.targetValue,o=w.select,l=w.deviationStart,a=w.deviationEnd}}return Dt(t,i,{deviationStart:l,deviationEnd:a,select:o,prefixVal:u,subfixVal:f})},$n={block(s,e){return{name:"KaTexBlockExtension",level:"block",start:t=>{var n;return(n=t.match(/\n\$\$/))==null?void 0:n.index},tokenizer(t){if(/^\$\$/.test(t)&&t.split("$$").length>2){const n=an(t,"$$");return{type:"KaTexBlockExtension",raw:n[0],text:n[1].trim(),tokens:[]}}},renderer(t){const n=e||typeof window<"u"&&window.katex;if(n){const i=n.renderToString(t.text,{throwOnError:!1,displayMode:!0});return`<p class="${s}-katex-block" data-processed>${i}</p>`}else return`<p class="${s}-katex-block">${t.text}</p>`}}},inline(s,e){return{name:"KaTexInlineExtension",level:"inline",start:t=>{var n;return(n=t.match(/\$[^\n]*/))==null?void 0:n.index},tokenizer(t){if(/^\$[^\n]*\$/.test(t)){const n=an(t);return{type:"KaTexInlineExtension",raw:n[0],text:n[1].trim(),tokens:[]}}},renderer(t){const n=e||typeof window<"u"&&window.katex;if(n){const i=n.renderToString(t.text,{throwOnError:!1});return`<span class="${s}-katex-inline" data-processed>${i}</span>`}else return`<span class="${s}-katex-inline">${t.text}</span>`}}}},On=["abstract","attention","bug","caution","danger","error","example","failure","hint","info","note","question","quote","success","tip","warning"],Ot=new RegExp(`^!!!\\s*(${On.join("|")})\\s*(.*)$`),es=/^!!!\s*$/,ts={name:"alert",level:"block",start(s){var t;return(t=s.match(new RegExp(`(^|[\\r\\n])!!!\\s*(${On.join("|")})\\s*(.*)`)))==null?void 0:t.index},tokenizer(s){const e=s.split(/\n/);if(Ot.test(e[0])){const t={x:-1,y:-1},n=[];for(let i=0,l=e.length;i<l;i++)Ot.test(e[i])?t.x=i:es.test(e[i])&&(t.y=i,t.x>=0&&(n.push({...t}),t.x=-1,t.y=-1));if(n.length){const i=n[0],[l,a,o]=Ot.exec(e[i.x])||[],u=e.slice(i.x+1,i.y).join(`
|
|
116
|
-
|
|
117
|
-
`),icon:a,title:o,text:u,titleTokens:[],tokens:[],childTokens:["title","text"]};return this.lexer.inlineTokens(h.title,h.titleTokens),this.lexer.blockTokens(h.text,h.tokens),h}}},renderer(s){return`<div class="md-editor-alert md-editor-alert-${s.icon}">
|
|
118
|
-
<p class="md-editor-alert-title">${this.parser.parseInline(s.titleTokens,null)}</p>
|
|
119
|
-
${this.parser.parse(s.tokens)}
|
|
120
|
-
</div>`}},ns=typeof window>"u",is=(s,e,t)=>{var g,$;const n=r.inject("previewOnly"),i=r.inject("historyLength"),l=r.inject("editorId");if(n)return;let a=-1;const o={list:[{content:s.value,startPos:((g=e.value)==null?void 0:g.selectionStart)||0,endPos:(($=e.value)==null?void 0:$.selectionEnd)||0}],userUpdated:!0,curr:0},u=[0,0];let f=u;const h=b=>{var S,C;const k=((S=e.value)==null?void 0:S.selectionStart)||0,p=((C=e.value)==null?void 0:C.selectionEnd)||0;o.list[o.curr].startPos=k,o.list[o.curr].endPos=p,o.userUpdated=!1,o.curr=b;const w=o.list[o.curr];f=[w.startPos,w.endPos],s.onChange(w.content),_e(e.value,w.startPos,w.endPos).then(()=>{x.emit(l,"selectTextChange")})},m=b=>{var w,S;clearTimeout(a);const k=((w=e.value)==null?void 0:w.selectionStart)||0,p=((S=e.value)==null?void 0:S.selectionEnd)||0;a=setTimeout(()=>{if(o.userUpdated){o.curr<o.list.length-1&&(o.list=o.list.slice(0,o.curr+1)),o.list.length>i&&o.list.shift();const C=o.list.pop()||{startPos:0,endPos:0,content:b};C.startPos=f[0],C.endPos=f[1],f=u,Array.prototype.push.call(o.list,C,{content:b,startPos:k,endPos:p}),o.curr=o.list.length-1}else o.userUpdated=!0},150)},v=b=>{var k,p;(f===u||b)&&(f=[(k=e.value)==null?void 0:k.selectionStart,(p=e.value)==null?void 0:p.selectionEnd])};r.watch([r.toRef(s,"value"),t],()=>{t.value&&m(s.value)}),r.watch(()=>s.value,()=>{x.emit(l,"selectTextChange")},{flush:"post"}),r.onMounted(()=>{x.on(l,{name:"ctrlZ",callback(){h(o.curr-1<0?0:o.curr-1)}}),x.on(l,{name:"ctrlShiftZ",callback(){h(o.curr+1===o.list.length?o.curr:o.curr+1)}}),x.on(l,{name:"saveHistoryPos",callback:v})})},ss=(s,e)=>{var l;const t=(l=J.editorExtensions)==null?void 0:l.katex,n=t==null?void 0:t.instance,i=r.ref(!1);return s.noKatex||e.use({extensions:[$n.inline(d,n),$n.block(d,n)]}),r.onMounted(()=>{if(!s.noKatex&&!n){const a=document.createElement("script");a.src=(t==null?void 0:t.js)||_t.js,a.onload=()=>{i.value=!0},a.id=`${d}-katex`;const o=document.createElement("link");o.rel="stylesheet",o.href=(t==null?void 0:t.css)||_t.css,o.id=`${d}-katexCss`,pe(a,"katex"),pe(o)}}),i},ls=s=>{var q,j,ee;const{markedRenderer:e,markedExtensions:t,markedOptions:n,editorExtensions:i,editorConfig:l}=J,a=r.inject("showCodeRowNumber"),o=r.inject("editorId"),u=r.inject("highlight"),f=r.inject("previewOnly"),h=r.inject("theme"),m=(q=i==null?void 0:i.highlight)==null?void 0:q.instance,v=(j=i==null?void 0:i.mermaid)==null?void 0:j.instance,g=(ee=i==null?void 0:i.katex)==null?void 0:ee.instance,$=i==null?void 0:i.katex,b=r.ref(!1),k=r.ref([]);let p=[],w=[];const S=new Yi({max:1e3,ttl:6e5}),C=as(s),V=ss(s,N),H=r.computed(()=>(s.noMermaid||C.mermaidInited)&&b.value&&(s.noKatex||V.value));let T=new N.Renderer;T.image=(I,R,M)=>`<span class="figure"><img src="${I}" title="${R||""}" alt="${M||""}" zoom><span class="figcaption">${M||""}</span></span>`,T.listitem=(I,R)=>R?`<li class="li-task">${I}</li>`:`<li>${I}</li>`,e instanceof Function&&(T=e(T));const y=T.code;T.code=(I,R,M)=>{if(!s.noMermaid&&R==="mermaid"){const se=ti();try{if(ns)return`<p class="${d}-mermaid">${I}</p>`;{const he=S.get(I);if(he)return`<p class="${d}-mermaid" data-processed>${he}</p>`;const Se=v||window.mermaid;if(C.mermaidInited){const Me=(Se.renderAsync||Se.render)(se,I);Me.then(je=>{S.set(I,typeof je=="string"?je:je.svg)}),p.push(Me)}else return`<p class="${d}-mermaid">${I}</p>`}const oe=`<script type="text/tmplate">${se}<\/script>`;return w.push(oe),oe}catch(oe){return`<p class="${d}-mermaid-error">Error: ${(oe==null?void 0:oe.message)||""}</p>`}}return y.call(T,I,R,M).replace(/^<pre><code\sclass="language-([^>]*)">/,'<pre><code class="language-$1" language="$1">')};const G=T.heading,U=G!==new N.Renderer().heading;T.heading=(I,R,M,se)=>{k.value.push({text:M,level:R});const oe=s.markedHeadingId(M,R,k.value.length);return U?G.call(T,I,R,M,se,k.value.length,oe):I!==M?`<h${R} id="${oe}">${I}</h${R}>`:`<h${R} id="${oe}"><a href="#${oe}">${M}</a></h${R}>`},m&&N.setOptions({highlight:(I,R)=>{let M;const se=m.getLanguage(R);return R&&se?M=m.highlight(I,{language:R,ignoreIllegals:!0}).value:M=m.highlightAuto(I).value,a?rn(M):`<span class="code-block">${M}</span>`}}),N.setOptions({breaks:!0,...n}),t instanceof Array&&t.length>0&&N.use({extensions:t}),N.use({extensions:[ts]});const B=r.ref(s.sanitize(N(s.value||"",{renderer:T}))),z=async I=>{let R=s.sanitize(N(I,{renderer:T}));const M=[...p],se=[...w];return w=[],p=[],(await Promise.allSettled(M)).forEach((he,Se)=>{he.status==="fulfilled"?R=R.replace(se[Se],`<p class="${d}-mermaid" data-processed>${typeof he.value=="string"?he.value:he.value.svg}</p>`):R=R.replace(se[Se],`<p class="${d}-mermaid-error">${he.reason||""}</p>`)}),R},F=Rt(async()=>{k.value=[];const I=await z(s.value||"");B.value=I,x.emit(o,"buildFinished",B.value),s.onHtmlChanged(B.value)},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:f?0:500);r.watch([H,r.toRef(C,"reRender"),r.toRef(s,"value")],F),r.watch([h],()=>{S.clear()});const P=()=>{N.setOptions({highlight:(I,R)=>{let M;const se=window.hljs.getLanguage(R);return R&&se?M=window.hljs.highlight(I,{language:R,ignoreIllegals:!0}).value:M=window.hljs.highlightAuto(I).value,a?rn(M):`<span class="code-block">${M}</span>`}}),b.value=!0};return r.watch(()=>k.value,I=>{s.onGetCatalog(I),x.emit(o,"catalogChanged",I)}),r.onMounted(()=>{if(!s.noKatex&&!g){const R=document.createElement("script");R.src=($==null?void 0:$.js)||_t.js,R.onload=()=>{V.value=!0},R.id=`${d}-katex`;const M=document.createElement("link");M.rel="stylesheet",M.href=($==null?void 0:$.css)||_t.css,M.id=`${d}-katexCss`,pe(R,"katex"),pe(M)}const I=document.createElement("link");if(I.rel="stylesheet",I.href=u.value.css,I.id=`${d}-hlCss`,pe(I),!m){const R=document.createElement("script");R.src=u.value.js,R.onload=P,R.id=`${d}-hljs`,pe(R,"hljs")}}),r.watch(()=>u.value.css,I=>{ni(`${d}-hlCss`,"href",I)}),r.onMounted(()=>{x.on(o,{name:"pushCatalog",callback(){x.emit(o,"catalogChanged",k.value)}})}),B},os=(s,e,t,n,i)=>{const l=r.inject("previewOnly"),a=r.inject("usedLanguageText"),o=r.inject("editorId");let u=()=>{},f=()=>{};const h=()=>{document.querySelectorAll(`#${o}-preview pre`).forEach(g=>{var p,w;let $=-1;(p=g.querySelector(".copy-button"))==null||p.remove();const b=((w=a.value.copyCode)==null?void 0:w.text)||"复制代码",k=document.createElement("span");k.setAttribute("class","copy-button"),k.dataset.tips=b,k.innerHTML=`<svg class="${d}-icon" aria-hidden="true"><use xlink:href="#${d}-icon-copy"></use></svg>`,k.addEventListener("click",()=>{var T,y;clearTimeout($);const S=g.querySelector("code").innerText,C=ct(s.formatCopiedText(S)),V=((T=a.value.copyCode)==null?void 0:T.successTips)||"已复制!",H=((y=a.value.copyCode)==null?void 0:y.failTips)||"已复制!";k.dataset.tips=C?V:H,$=window.setTimeout(()=>{k.dataset.tips=b},1500)}),g.appendChild(k)})},m=()=>{r.nextTick(()=>{s.setting.preview&&!l&&s.scrollAuto&&(u(),f()),h()})},v=g=>{g&&!l&&r.nextTick(()=>{u(),[f,u]=on(t.value,n.value||i.value),f(),h()})};r.watch(()=>e.value,m),r.watch(()=>a.value,h),r.watch(()=>s.setting.preview,v),r.watch(()=>s.setting.htmlPreview,v),r.watch(()=>s.scrollAuto,g=>{g?f():u()}),r.onMounted(()=>{h(),!l&&(n.value||i.value)&&([f,u]=on(t.value,n.value||i.value)),s.scrollAuto&&f()})},rs=(s,e)=>{const t=r.inject("previewOnly"),n=r.inject("tabWidth"),i=r.inject("editorId"),l=r.ref("");r.onMounted(()=>{var a;t||((a=e.value)==null||a.addEventListener("keypress",o=>{var u,f,h;if(o.key==="Enter"){const m=(u=e.value)==null?void 0:u.selectionStart,v=(f=e.value)==null?void 0:f.value.substring(0,m),g=(h=e.value)==null?void 0:h.value.substring(m),$=v==null?void 0:v.lastIndexOf(`
|
|
121
|
-
`),b=v==null?void 0:v.substring($+1,m);if(/^\d+\.\s|^-\s/.test(b))if(o.cancelBubble=!0,o.preventDefault(),o.stopPropagation(),/^(\d+\.|-)\s+(\[[x\s]\]\s+)?$/.test(b)){const k=v==null?void 0:v.replace(/(\d+\.|-)\s+(\[[x\s]\]\s+)?$/,"");s.onChange(k+g),_e(e.value,k==null?void 0:k.length)}else if(/^-\s+.+/.test(b)){const k=/^-\s+\[[x\s]\]/.test(b)?`
|
|
122
|
-
- [ ] `:`
|
|
123
|
-
- `;s.onChange(Dt(e.value,k,{}))}else{const k=b==null?void 0:b.match(/\d+(?=\.)/),p=k&&Number(k[0])+1||1,w=/^\d\.\s+\[[x\s]\]/.test(b)?`
|
|
124
|
-
${p}. [ ] `:`
|
|
125
|
-
${p}. `;s.onChange(Dt(e.value,w,{}))}}}),x.on(i,{name:"replace",callback(o,u={}){s.onChange(Ji(o,l.value,e.value,{...u,tabWidth:n,editorId:i}))}}),x.on(i,{name:"selectTextChange",callback(){l.value=Yn(e.value)}}))}),r.watch(()=>s.value,()=>{l.value=""})},as=s=>{const e=r.inject("theme"),{editorExtensions:t}=J,n=t==null?void 0:t.mermaid,i=r.reactive({reRender:!1,mermaidInited:!1}),l=()=>{const a=(n==null?void 0:n.instance)||window.mermaid;!s.noMermaid&&a&&(a.initialize({startOnLoad:!1,theme:e.value==="dark"?"dark":"default"}),i.reRender=!i.reRender)};return r.watch(()=>e.value,l),r.onMounted(()=>{if(!s.noMermaid)if(n!=null&&n.instance)l(),i.mermaidInited=!0;else{const a=document.createElement("script");a.id=`${d}-mermaid`;const o=(n==null?void 0:n.js)||Wn;/\.mjs/.test(o)?(a.setAttribute("type","module"),a.innerHTML=`import mermaid from "${o}";window.mermaid=mermaid;document.getElementById('${d}-mermaid').dispatchEvent(new Event('load'));`):a.src=o,a.onload=()=>{l(),i.mermaidInited=!0},pe(a,"mermaid")}}),i},cs=(s,e)=>{const t=r.inject("editorId"),n=r.inject("previewOnly"),i=l=>{if(l.clipboardData){if(l.clipboardData.files.length>0){const{files:a}=l.clipboardData;x.emit(t,"uploadImage",Array.from(a).filter(o=>/image\/.*/.test(o.type))),l.preventDefault()}if(s.autoDetectCode&&l.clipboardData.types.includes("vscode-editor-data")){const a=JSON.parse(l.clipboardData.getData("vscode-editor-data"));x.emit(t,"replace","code",{mode:a.mode,text:l.clipboardData.getData("text/plain")}),l.preventDefault()}}};r.onMounted(()=>{n||e.value.addEventListener("paste",i)}),r.onBeforeUnmount(()=>{n||e.value.removeEventListener("paste",i)})},us=(s,e)=>{const t=r.inject("editorId"),n=Rt(()=>{const i=document.querySelectorAll(`#${t}-preview img[zoom]`);i.length!==0&&Zi(i,{background:"#00000073"})});r.onMounted(n),r.watch([e,r.toRef(s.setting,"preview")],n)},ds=s=>{const e=r.inject("editorId");r.onMounted(()=>{x.on(e,{name:En,callback(){var t;(t=s.value)==null||t.focus()}})})},hs=()=>({value:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},markedHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:s=>s},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:s=>s},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}}}),fs=r.defineComponent({name:"MDEditorContent",props:hs(),setup(s){const e=r.ref(!0),t=r.inject("previewOnly"),n=r.inject("showCodeRowNumber"),i=r.inject("previewTheme"),l=r.inject("editorId"),a=r.ref(),o=r.ref(),u=r.ref(),f=ls(s);return os(s,f,a,o,u),rs(s,a),is(s,a,e),cs(s,a),us(s,f),ds(a),()=>{const h=ei(s,["formatCopiedText","markedHeadingId","noKatex","noMermaid","onChange","onGetCatalog","onHtmlChanged","sanitize","scrollAuto","setting","autoDetectCode","onBlur","onFocus"]);return r.createVNode(r.Fragment,null,[r.createVNode("div",{class:`${d}-content`},[!t&&r.createVNode("div",{class:`${d}-input-wrapper`},[r.createVNode("textarea",r.mergeProps(h,{id:`${l}-textarea`,class:[s.setting.preview||s.setting.htmlPreview?"":"textarea-only"],ref:a,onBlur:m=>{x.emit(l,"selectTextChange"),s.onBlur(m)},onFocus:s.onFocus,onKeydown:()=>{x.emit(l,"saveHistoryPos",!0)},onCompositionstart:()=>{e.value=!1},onInput:m=>{s.onChange(m.target.value)},onCompositionend:()=>{e.value=!0}}),null)]),s.setting.preview&&r.createVNode("div",{id:`${l}-preview-wrapper`,class:`${d}-preview-wrapper`,ref:o,key:"content-preview-wrapper"},[r.createVNode("article",{id:`${l}-preview`,class:[`${d}-preview`,`${i==null?void 0:i.value}-theme`,n&&`${d}-scrn`],innerHTML:f.value},null)]),s.setting.htmlPreview&&r.createVNode("div",{class:`${d}-preview-wrapper`,ref:u,key:"html-preview-wrapper"},[r.createVNode("div",{class:`${d}-html`},[f.value])])])])}}}),ms=r.defineComponent({props:{modelValue:{type:String,default:""}},setup(s){const e=r.inject("usedLanguageText");return()=>{var t,n;return r.createVNode("div",{class:`${d}-footer-item`},[r.createVNode("label",{class:`${d}-footer-label`},[`${(t=e.value.footer)==null?void 0:t.markdownTotal}:`]),r.createVNode("span",null,[((n=s.modelValue)==null?void 0:n.length)||0])])}}});const gs=()=>({checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}}),ps=r.defineComponent({props:gs(),setup(s){return()=>r.createVNode("div",{class:[`${d}-checkbox`,s.checked&&`${d}-checkbox-checked`],onClick:()=>{s.onChange(!s.checked)}},null)}}),vs=()=>({scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}}),bs=r.defineComponent({props:vs(),setup(s){const e=r.inject("usedLanguageText");return()=>{var t;return r.createVNode("div",{class:`${d}-footer-item`},[r.createVNode("label",{class:`${d}-footer-label`,onClick:()=>{s.onScrollAutoChange(!s.scrollAuto)}},[(t=e.value.footer)==null?void 0:t.scrollAuto]),r.createVNode(ps,{checked:s.scrollAuto,onChange:s.onScrollAutoChange},null)])}}}),ks=()=>({modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}}),ys=r.defineComponent({name:"MDEditorFooter",props:ks(),setup(s){const e=r.computed(()=>{const n=s.footers.indexOf("="),i=n===-1?s.footers:s.footers.slice(0,n),l=n===-1?[]:s.footers.slice(n,Number.MAX_SAFE_INTEGER);return[i,l]}),t=n=>{if(Cn.includes(n))switch(n){case"markdownTotal":return r.createVNode(ms,{modelValue:s.modelValue},null);case"scrollSwitch":return r.createVNode(bs,{scrollAuto:s.scrollAuto,onScrollAutoChange:s.onScrollAutoChange},null)}else return s.defFooters instanceof Array?s.defFooters[n]||"":s.defFooters&&s.defFooters.children instanceof Array&&s.defFooters.children[n]||""};return()=>{const n=e.value[0].map(l=>t(l)),i=e.value[1].map(l=>t(l));return r.createVNode("div",{class:`${d}-footer`},[r.createVNode("div",{class:`${d}-footer-left`},[n]),r.createVNode("div",{class:`${d}-footer-right`},[i])])}}}),ws=()=>({tocItem:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}}),Dn=r.defineComponent({props:ws(),setup(s){return()=>{const{tocItem:e,markedHeadingId:t,scrollElement:n,onClick:i,scrollElementOffsetTop:l}=s;return r.createVNode("div",{class:[`${d}-catalog-link`,e.active&&`${d}-catalog-active`],onClick:a=>{i(a,e),a.stopPropagation();const o=t(e.text,e.level,e.index),u=document.getElementById(o),f=n instanceof Element?n:document.querySelector(n);if(u&&f){let h=u.offsetParent,m=u.offsetTop;if(f.contains(h))for(;h&&f!=h;)m+=h==null?void 0:h.offsetTop,h=h==null?void 0:h.offsetParent;f==null||f.scrollTo({top:m-l,behavior:"smooth"})}}},[r.createVNode("span",{title:e.text},[e.text]),r.createVNode("div",{class:`${d}-catalog-wrapper`},[e.children&&e.children.map(a=>r.createVNode(Dn,{markedHeadingId:t,key:`${e.text}-link-${a.level}-${a.text}`,tocItem:a,scrollElement:n,onClick:i,scrollElementOffsetTop:l},null))])])}}});const xs=()=>({editorId:{type:String},class:{type:String,default:""},markedHeadingId:{type:Function,default:s=>s},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function}}),Lt=r.defineComponent({name:"MdCatalog",props:xs(),emits:["onClick"],setup(s,e){const t=s.editorId,n=r.reactive({list:[],show:!1,scrollElement:s.scrollElement||`#${t}-preview-wrapper`}),i=r.computed(()=>{const a=[];return n.list.forEach(({text:o,level:u,active:f},h)=>{const m={level:u,text:o,index:h+1,active:!!f};if(a.length===0)a.push(m);else{let v=a[a.length-1];if(m.level>v.level)for(let g=v.level+1;g<=6;g++){const{children:$}=v;if(!$){v.children=[m];break}if(v=$[$.length-1],m.level<=v.level){$.push(m);break}}else a.push(m)}}),a});r.onMounted(()=>{x.on(t,{name:"catalogChanged",callback:a=>{n.list=a.map((o,u)=>u===0?{...o,active:!0}:{...o})}}),x.emit(t,"pushCatalog")});const l=()=>{var o;const a=n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement);(o=a===document.documentElement?window:a)==null||o.addEventListener("scroll",Qn(()=>{if(n.list.length===0)return!1;const{activeHead:u}=n.list.reduce((f,h,m)=>{const v=document.getElementById(s.markedHeadingId(h.text,h.level,m+1));if(v instanceof HTMLElement){const g=Jn(v,a);if(g<s.offsetTop&&g>f.minTop)return{activeHead:h,minTop:g}}return f},{activeHead:n.list[0],minTop:Number.MIN_SAFE_INTEGER});n.list=n.list.map(f=>f===u?{...f,active:!0}:{...f,active:!1})}))};return r.onMounted(()=>{l(),x.on(t,{name:Ht,callback(a){a&&r.nextTick(l)}})}),()=>r.createVNode("div",{class:`${d}-catalog${s.theme==="dark"?"-dark":""} ${s.class}`},[i.value.map(a=>r.createVNode(Dn,{markedHeadingId:s.markedHeadingId,tocItem:a,key:`link-${a.level}-${a.text}`,scrollElement:n.scrollElement,onClick:(o,u)=>{s.onClick?s.onClick(o,u):e.emit("onClick",o,u)},scrollElementOffsetTop:s.scrollElementOffsetTop},null))])}}),$s=s=>s,Ss={modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},historyLength:{type:Number,default:10},onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},language:{type:String,default:"zh-CN"},toolbars:{type:Array,default:Sn},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:Mn},tabWidth:{type:Number,default:2},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:$s},tableShape:{type:Array,default:()=>[6,4]},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:s=>s},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},defToolbars:{type:[String,Object]},onError:{type:Function},codeTheme:{type:String,default:"atom"},footers:{type:Array,default:Cn},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:s=>s},noUploadImg:{type:Boolean},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function},onFocus:{type:Function}},Cs=["onChange","onSave","onUploadImg","onHtmlChanged","onGetCatalog","onError","update:modelValue","onBlur","onFocus"];const Fe=r.defineComponent({name:"MdEditorV3",props:Ss,emits:Cs,setup(s,e){const{editorId:t,previewOnly:n,noKatex:i,noMermaid:l,noPrettier:a,noUploadImg:o}=s,u=r.reactive({scrollAuto:s.scrollAuto});ii(s,e),si(s),li(s);const[f,h]=oi(s,e),[m,v]=ri(s);return r.onBeforeUnmount(()=>{x.clear(t)}),ai(s,e,m,f,h),()=>{var b;const g=xe({props:s,ctx:e},"defToolbars"),$=xe({props:s,ctx:e},"defFooters");return r.createVNode("div",{id:t,class:[d,s.class,s.theme==="dark"&&`${d}-dark`,f.fullscreen||f.pageFullscreen?`${d}-fullscreen`:"",n&&`${d}-previewOnly`],style:s.style},[!n&&r.createVNode(xi,{noPrettier:a,toolbars:s.toolbars,toolbarsExclude:s.toolbarsExclude,setting:f,updateSetting:h,tableShape:s.tableShape,defToolbars:g,noUploadImg:o},null),r.createVNode(fs,{value:s.modelValue,setting:f,markedHeadingId:s.markedHeadingId,noMermaid:l,sanitize:s.sanitize,placeholder:s.placeholder,noKatex:i,scrollAuto:u.scrollAuto,formatCopiedText:s.formatCopiedText,autofocus:s.autoFocus,disabled:s.disabled,readonly:s.readOnly,maxlength:s.maxLength,autoDetectCode:s.autoDetectCode,onChange:k=>{x.emit(t,"saveHistoryPos"),s.onChange?s.onChange(k):(e.emit("update:modelValue",k),e.emit("onChange",k))},onHtmlChanged:k=>{s.onHtmlChanged?s.onHtmlChanged(k):e.emit("onHtmlChanged",k)},onGetCatalog:k=>{s.onGetCatalog?s.onGetCatalog(k):e.emit("onGetCatalog",k)},onBlur:k=>{s.onBlur?s.onBlur(k):e.emit("onBlur",k)},onFocus:k=>{s.onFocus?s.onFocus(k):e.emit("onFocus",k)}},null),!n&&((b=s.footers)==null?void 0:b.length)>0&&r.createVNode(ys,{modelValue:s.modelValue,footers:s.footers,defFooters:$,scrollAuto:u.scrollAuto,onScrollAutoChange:k=>u.scrollAuto=k},null),v.value&&!n&&r.createVNode(Lt,{theme:s.theme,style:{display:m.value?"block":"none"},class:`${d}-catalog-editor`,editorId:t,markedHeadingId:s.markedHeadingId},null)])}}}),Ts=()=>({title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function}}),qt=r.defineComponent({name:"NormalToolbar",props:Ts(),emits:["onClick"],setup(s,e){return()=>{const t=xe({props:s,ctx:e},"trigger");return r.createVNode("div",{class:`${d}-toolbar-item`,title:s.title,onClick:n=>{s.onClick instanceof Function?s.onClick(n):e.emit("onClick",n)}},[t])}}}),Es=()=>({title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]}}),Wt=r.defineComponent({name:"DropdownToolbar",props:Es(),emits:["onChange"],setup(s,e){const t=r.inject("editorId");return()=>{const n=xe({props:s,ctx:e},"trigger"),i=xe({props:s,ctx:e},"overlay");return r.createVNode(Ye,{relative:`#${t}-toolbar-wrapper`,visible:s.visible,onChange:l=>{s.onChange instanceof Function?s.onChange(l):e.emit("onChange",l)},overlay:i},{default:()=>[r.createVNode("div",{class:`${d}-toolbar-item`,title:s.title||""},[n])]})}}});function Ns(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!r.isVNode(s)}const zs=()=>({title:{type:String,default:""},modalTitle:{type:String,default:""},visible:{type:Boolean},width:{type:String,default:"auto"},height:{type:String,default:"auto"},trigger:{type:[String,Object]},onClick:{type:Function},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function}}),Kt=r.defineComponent({name:"ModalToolbar",props:zs(),emits:["onClick","onClose","onAdjust"],setup(s,e){return()=>{const t=xe({props:s,ctx:e},"trigger"),n=xe({props:s,ctx:e},"default");return r.createVNode(r.Fragment,null,[r.createVNode("div",{class:`${d}-toolbar-item`,title:s.title,onClick:()=>{s.onClick instanceof Function?s.onClick():e.emit("onClick")}},[t]),r.createVNode(Zt,{width:s.width,height:s.height,title:s.modalTitle,visible:s.visible,onClose:()=>{s.onClose instanceof Function?s.onClose():e.emit("onClose")},showAdjust:s.showAdjust,isFullscreen:s.isFullscreen,onAdjust:i=>{s.onAdjust instanceof Function?s.onAdjust(i):e.emit("onAdjust",i)}},Ns(n)?n:{default:()=>[n]})])}}});Fe.install=s=>(s.component(Fe.name,Fe),s.component(qt.name,qt),s.component(Wt.name,Wt),s.component(Lt.name,Lt),s.component(Kt.name,Kt),s);Fe.NormalToolbar=qt;Fe.DropdownToolbar=Wt;Fe.MdCatalog=Lt;Fe.ModalToolbar=Kt;Fe.config=Kn;module.exports=Fe;
|
|
62
|
+
`,r=3,a=-4;break}case"universal":{const{generate:p}=n,y=p(m);l=y.targetValue,i=y.select,r=y.deviationStart,a=y.deviationEnd}}return{text:l,options:{select:i,deviationStart:r,deviationEnd:a,replaceAll:c}}},Qt="#e5c07b",Ge="var(--md-color)",eo="#56b6c2",to="#ffffff",Z="var(--md-color)",ze="#e5c07b",oo="#e5c07b",lo="var(--md-color)",Ke="#d19a66",no="#c678dd",ao="#21252b",Xe="#2c313a",Ze="#000",ae="#353a42",ro="#ceedfa33",Je="#528bff",io=Y.EditorView.theme({"&":{color:Z,backgroundColor:Ze},".cm-content":{caretColor:Je},".cm-cursor, .cm-dropCursor":{borderLeftColor:Je},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ro},".cm-panels":{backgroundColor:ao,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:Ze,color:Z,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Xe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ae},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ae,borderBottomColor:ae},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Xe,color:Z}}},{dark:!0}),so=Q.HighlightStyle.define([{tag:f.tags.keyword,color:no},{tag:[f.tags.name,f.tags.deleted,f.tags.character,f.tags.propertyName,f.tags.macroName],color:Ge},{tag:[f.tags.function(f.tags.variableName),f.tags.labelName],color:oo},{tag:[f.tags.color,f.tags.constant(f.tags.name),f.tags.standard(f.tags.name)],color:Ke},{tag:[f.tags.definition(f.tags.name),f.tags.separator],color:Z},{tag:[f.tags.typeName,f.tags.className,f.tags.number,f.tags.changed,f.tags.annotation,f.tags.modifier,f.tags.self,f.tags.namespace],color:Qt},{tag:[f.tags.operator,f.tags.operatorKeyword,f.tags.url,f.tags.escape,f.tags.regexp,f.tags.link,f.tags.special(f.tags.string)],color:eo},{tag:[f.tags.meta,f.tags.comment],color:ze},{tag:f.tags.strong,fontWeight:"bold"},{tag:f.tags.emphasis,fontStyle:"italic"},{tag:f.tags.strikethrough,textDecoration:"line-through"},{tag:f.tags.link,color:ze,textDecoration:"underline"},{tag:f.tags.heading,fontWeight:"bold",color:Ge},{tag:[f.tags.atom,f.tags.bool,f.tags.special(f.tags.variableName)],color:Ke},{tag:[f.tags.processingInstruction,f.tags.string,f.tags.inserted],color:lo},{tag:f.tags.invalid,color:to}]),co=[io,Q.syntaxHighlighting(so)],uo="#e5c07b",Ye="#3f4a54",mo="#56b6c2",go="#fff",J="#3f4a54",Qe="#2d8cf0",fo="#2d8cf0",ho="#3f4a54",et="#d19a66",vo="#c678dd",po="#21252b",tt="#2c313a",ot="#fff",re="#353a42",bo="#bad5fa",lt="#3f4a54",ko=Y.EditorView.theme({"&":{color:J,backgroundColor:ot},".cm-content":{caretColor:lt},".cm-cursor, .cm-dropCursor":{borderLeftColor:lt},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:bo},".cm-panels":{backgroundColor:po,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:ot,color:J,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:tt},".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:tt,color:J}}},{dark:!0}),yo=Q.HighlightStyle.define([{tag:f.tags.keyword,color:vo},{tag:[f.tags.name,f.tags.deleted,f.tags.character,f.tags.propertyName,f.tags.macroName],color:Ye},{tag:[f.tags.function(f.tags.variableName),f.tags.labelName],color:fo},{tag:[f.tags.color,f.tags.constant(f.tags.name),f.tags.standard(f.tags.name)],color:et},{tag:[f.tags.definition(f.tags.name),f.tags.separator],color:J},{tag:[f.tags.typeName,f.tags.className,f.tags.number,f.tags.changed,f.tags.annotation,f.tags.modifier,f.tags.self,f.tags.namespace],color:uo},{tag:[f.tags.operator,f.tags.operatorKeyword,f.tags.url,f.tags.escape,f.tags.regexp,f.tags.link,f.tags.special(f.tags.string)],color:mo},{tag:[f.tags.meta,f.tags.comment],color:Qe},{tag:f.tags.strong,fontWeight:"bold"},{tag:f.tags.emphasis,fontStyle:"italic"},{tag:f.tags.strikethrough,textDecoration:"line-through"},{tag:f.tags.link,color:Qe,textDecoration:"underline"},{tag:f.tags.heading,fontWeight:"bold",color:Ye},{tag:[f.tags.atom,f.tags.bool,f.tags.special(f.tags.variableName)],color:et},{tag:[f.tags.processingInstruction,f.tags.string,f.tags.inserted],color:ho},{tag:f.tags.invalid,color:go}]),Co=[ko,Q.syntaxHighlighting(yo)],q=e=>{const o=new R.Compartment;return l=>(o.get(e.state)?e.dispatch({effects:o.reconfigure(l)}):e.dispatch({effects:R.StateEffect.appendConfig.of(o.of(l))}),!0)};class wo{constructor(o){j(this,"view");j(this,"toggleTabSize");j(this,"togglePlaceholder");j(this,"setExtensions");j(this,"toggleDisabled");j(this,"toggleReadOnly");j(this,"toggleMaxlength");this.view=o,this.toggleTabSize=q(this.view),this.togglePlaceholder=q(this.view),this.setExtensions=q(this.view),this.toggleDisabled=q(this.view),this.toggleReadOnly=q(this.view),this.toggleMaxlength=q(this.view)}getValue(){return this.view.state.doc.toString()}setValue(o,n=0,l=this.view.state.doc.length){this.view.dispatch({changes:{from:n,to:l,insert:o}})}getSelectedText(){const{from:o,to:n}=this.view.state.selection.main;return this.view.state.sliceDoc(o,n)}replaceSelectedText(o,n={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1}){if(n.replaceAll){this.setValue(o);return}const{from:l}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(o)),n.select){const r=l+o.length+n.deviationEnd;this.view.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(l+n.deviationStart,r),R.EditorSelection.cursor(r)],1)}),this.view.focus()}}setTabSize(o){this.toggleTabSize([R.EditorState.tabSize.of(o),Q.indentUnit.of(" ".repeat(o))])}setPlaceholder(o){this.togglePlaceholder(Y.placeholder(o))}foucs(){this.view.focus()}setDisabled(o){this.toggleDisabled([Y.EditorView.editable.of(!o)])}setReadOnly(o){this.toggleReadOnly([R.EditorState.readOnly.of(o)])}setMaxLength(o){this.toggleMaxlength([R.EditorState.changeFilter.of(n=>n.newDoc.length<=o)])}}const $o=e=>{const o=t.inject("editorId");return l=>{if(l.clipboardData){if(l.clipboardData.files.length>0){const{files:r}=l.clipboardData;C.emit(o,"uploadImage",Array.from(r).filter(a=>/image\/.*/.test(a.type))),l.preventDefault()}if(e.autoDetectCode&&l.clipboardData.types.includes("vscode-editor-data")){const r=JSON.parse(l.clipboardData.getData("vscode-editor-data"));C.emit(o,"replace","code",{mode:r.mode,text:l.clipboardData.getData("text/plain")}),l.preventDefault()}}}},No=e=>{const o=t.inject("editorId");t.onMounted(()=>{C.on(o,{name:ct,callback(){var n;(n=e.value)==null||n.foucs()}})})},Vo=(e,o)=>{const n={key:"Ctrl-b",mac:"Cmd-b",run:()=>(C.emit(e,"replace","bold"),!0)},l={key:"Ctrl-s",mac:"Cmd-s",run:T=>(C.emit(e,ne,T.state.doc.toString()),!0),shift:()=>(C.emit(e,"replace","strikeThrough"),!0)},r={key:"Ctrl-u",mac:"Cmd-u",run:()=>(C.emit(e,"replace","underline"),!0),shift:()=>(C.emit(e,"replace","unorderedList"),!0)},a={key:"Ctrl-i",mac:"Cmd-i",run:()=>(C.emit(e,"replace","italic"),!0),shift:()=>(C.emit(e,"openModals","image"),!0)},i={key:"Ctrl-1",mac:"Cmd-1",run:()=>(C.emit(e,"replace","h1"),!0)},c={key:"Ctrl-2",mac:"Cmd-2",run:()=>(C.emit(e,"replace","h2"),!0)},m={key:"Ctrl-3",mac:"Cmd-3",run:()=>(C.emit(e,"replace","h3"),!0)},u={key:"Ctrl-4",mac:"Cmd-4",run:()=>(C.emit(e,"replace","h4"),!0)},d={key:"Ctrl-5",mac:"Cmd-5",run:()=>(C.emit(e,"replace","h5"),!0)},g={key:"Ctrl-6",mac:"Cmd-6",run:()=>(C.emit(e,"replace","h6"),!0)},h={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(C.emit(e,"replace","sup"),!0)},v={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(C.emit(e,"replace","sub"),!0)},b={key:"Ctrl-o",mac:"Cmd-o",run:()=>(C.emit(e,"replace","orderedList"),!0)},k={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(C.emit(e,"replace","code"),!0),any(T,N){return(N.ctrlKey||N.metaKey)&&N.altKey&&N.code==="KeyC"?(C.emit(e,"replace","codeRow"),!0):!1}},p={key:"Ctrl-l",mac:"Cmd-l",run:()=>(C.emit(e,"openModals","link"),!0)},y={key:"Ctrl-f",mac:"Cmd-f",shift:()=>o.noPrettier?!1:(C.emit(e,"replace","prettier"),!0)},w={any:(T,N)=>(N.ctrlKey||N.metaKey)&&N.altKey&&N.shiftKey&&N.code==="KeyT"?(C.emit(e,"replace","table"),!0):!1},$={key:"Ctrl-d",mac:"Cmd-d",run:oe.deleteLine,preventDefault:!0};return[n,$,l,r,a,i,c,m,u,d,g,h,v,b,k,p,y,w]},To=e=>{const o=t.inject("tabWidth"),n=t.inject("editorId"),l=t.inject("theme"),r=t.ref(),a=t.ref(),i=Vo(n,e),c=$o(e),m=[Y.keymap.of([...i,oe.indentWithTab]),K.minimalSetup,ft.markdown({codeLanguages:gt.languages}),K.EditorView.lineWrapping,K.EditorView.updateListener.of(d=>{e.onChange(d.state.doc.toString())}),K.EditorView.domEventHandlers({paste:c,blur:e.onBlur,focus:e.onFocus})],u=()=>l.value==="light"?x.codeMirrorExtensions(l.value,[...m,Co],i):x.codeMirrorExtensions(l.value,[...m,co],i);return t.onMounted(()=>{const d=R.EditorState.create({doc:e.value}),g=new K.EditorView({state:d,parent:r.value});a.value=new wo(g),a.value.setTabSize(o),a.value.setExtensions(u()),a.value.setPlaceholder(e.placeholder),a.value.setDisabled(e.disabled),a.value.setReadOnly(e.readonly),e.autofocus&&g.focus(),e.maxlength&&a.value.setMaxLength(e.maxlength),C.on(n,{name:"ctrlZ",callback(){oe.undo(g)}}),C.on(n,{name:"ctrlShiftZ",callback(){oe.redo(g)}}),C.on(n,{name:"replace",callback(h,v={}){var p;const{text:b,options:k}=Yt(h,a.value,v);(p=a.value)==null||p.replaceSelectedText(b,k)}})}),t.watch(()=>l.value,()=>{var d,g;l.value==="dark"?(d=a.value)==null||d.setExtensions(u()):(g=a.value)==null||g.setExtensions(u())}),t.watch(()=>e.value,()=>{var d,g;((d=a.value)==null?void 0:d.getValue())!==e.value&&((g=a.value)==null||g.setValue(e.value))}),t.watch(()=>e.value,()=>{var d;(d=a.value)==null||d.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var d;(d=a.value)==null||d.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var d;(d=a.value)==null||d.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var d;e.maxlength&&((d=a.value)==null||d.setMaxLength(e.maxlength))}),No(a),{inputWrapperRef:r,codeMirrorUt:a}},So=(e,o)=>{const n=t.inject("editorId"),l=W(()=>{const r=document.querySelectorAll(`#${n}-preview img`);r.length!==0&&ht(r,{background:"#00000073"})});t.onMounted(l),t.watch([o,t.toRef(e.setting,"preview")],l)},xo=(e,o)=>{const n=t.inject("editorId"),l=t.inject("usedLanguageText"),r=()=>{document.querySelectorAll(`#${n}-preview pre`).forEach(c=>{var g,h;let m=-1;(g=c.querySelector(".copy-button"))==null||g.remove();const u=((h=l.value.copyCode)==null?void 0:h.text)||"复制代码",d=document.createElement("span");d.setAttribute("class","copy-button"),d.dataset.tips=u,d.innerHTML=`<svg class="${s}-icon" aria-hidden="true"><use xlink:href="#${s}-icon-copy"></use></svg>`,d.addEventListener("click",()=>{var y,w;clearTimeout(m);const v=c.querySelector("code").innerText,b=vt(e.formatCopiedText(v)),k=((y=l.value.copyCode)==null?void 0:y.successTips)||"已复制!",p=((w=l.value.copyCode)==null?void 0:w.failTips)||"已复制!";d.dataset.tips=b?k:p,m=window.setTimeout(()=>{d.dataset.tips=u},1500)}),c.appendChild(d)})},a=()=>{t.nextTick(r)},i=c=>{c&&t.nextTick(r)};t.watch(()=>o.value,a),t.watch(()=>e.setting.preview,i),t.watch(()=>e.setting.htmlPreview,i),t.watch(()=>l.value,r),t.onMounted(r)},Eo=e=>{var a;const o=(a=x.editorExtensions)==null?void 0:a.highlight,n=o==null?void 0:o.instance,l=t.inject("highlight"),r=t.shallowRef(n);return t.onMounted(()=>{if(e.noHighlight)return;if(!r.value){const c=document.createElement("script");c.src=l.value.js,c.onload=()=>{r.value=window.hljs},c.id=`${s}-hljs`,I(c,"hljs")}const i=document.createElement("link");i.rel="stylesheet",i.href=l.value.css,i.id=`${s}-hlCss`,I(i)}),t.watch(()=>l.value.css,i=>{Rt(`${s}-hlCss`,"href",i)}),r},Lo=e=>{const o=t.inject("theme"),{editorExtensions:n}=x,l=n==null?void 0:n.mermaid,r=t.shallowRef(l==null?void 0:l.instance),a=t.shallowRef(!1),i=new yt({max:1e3,ttl:6e5}),c=()=>{const u=(l==null?void 0:l.instance)||window.mermaid;!e.noMermaid&&u&&(u.initialize({startOnLoad:!1,theme:o.value==="dark"?"dark":"default"}),a.value=!a.value)};return t.watch(()=>o.value,()=>{i.clear(),c()}),t.onMounted(()=>{if(!e.noMermaid&&!(l!=null&&l.instance)){const u=document.createElement("script");u.id=`${s}-mermaid`;const d=(l==null?void 0:l.js)||Vt;/\.mjs/.test(d)?(u.setAttribute("type","module"),u.innerHTML=`import mermaid from "${d}";window.mermaid=mermaid;document.getElementById('${s}-mermaid').dispatchEvent(new Event('load'));`):u.src=d,u.onload=()=>{r.value=window.mermaid,c()},I(u,"mermaid")}}),{mermaidRef:r,reRenderRef:a,replaceMermaid:()=>{t.nextTick(()=>{!e.noMermaid&&r.value&&document.querySelectorAll(`div.${s}-mermaid`).forEach(async d=>{let g=i.get(d.innerText);if(!g){const v=At(),k=await(r.value.renderAsync||r.value.render)(v,d.innerText);g=typeof k=="string"?k:k.svg,i.set(d.innerText,g)}const h=document.createElement("p");h.className=`${s}-mermaid`,h.setAttribute("data-processed",""),h.innerHTML=g,d.replaceWith(h)})})}}},Mo=e=>{var r;const o=(r=x.editorExtensions)==null?void 0:r.katex,n=o==null?void 0:o.instance,l=t.shallowRef(n);return t.onMounted(()=>{if(!e.noKatex&&!l.value){const a=document.createElement("script");a.src=(o==null?void 0:o.js)||Pe.js,a.onload=()=>{l.value=window.katex},a.id=`${s}-katex`;const i=document.createElement("link");i.rel="stylesheet",i.href=(o==null?void 0:o.css)||Pe.css,i.id=`${s}-katexCss`,I(a,"katex"),I(i)}}),l},Ho=(e,o)=>{const n=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(l,r,a,i,c)=>{const m=l[r],u=m.content.trim();return m.info==="mermaid"?`<div class="${s}-mermaid" data-mermaid-theme=${o.themeRef.value}>${u}</div>`:n(l,r,a,i,c)}},nt=(e,o)=>{let n=!0,l=!0;const r=e.posMax,a=o>0?e.src.charCodeAt(o-1):-1,i=o+1<=r?e.src.charCodeAt(o+1):-1;return(a===32||a===9||i>=48&&i<=57)&&(l=!1),(i===32||i===9)&&(n=!1),{can_open:n,can_close:l}},Io=(e,o)=>{let n,l,r,a;if(e.src[e.pos]!=="$")return!1;if(r=nt(e,e.pos),!r.can_open)return o||(e.pending+="$"),e.pos+=1,!0;const i=e.pos+1;for(n=i;(n=e.src.indexOf("$",n))!==-1;){for(a=n-1;e.src[a]==="\\";)a-=1;if((n-a)%2==1)break;n+=1}return n===-1?(o||(e.pending+="$"),e.pos=i,!0):n-i===0?(o||(e.pending+="$$"),e.pos=i+1,!0):(r=nt(e,n),r.can_close?(o||(l=e.push("math_inline","math",0),l.markup="$",l.content=e.src.slice(i,n)),e.pos=n+1,!0):(o||(e.pending+="$"),e.pos=i,!0))},Fo=(e,o,n,l)=>{let r,a,i,c,m=!1,u=e.bMarks[o]+e.tShift[o],d=e.eMarks[o];if(u+2>d||e.src.slice(u,u+2)!=="$$")return!1;if(u+=2,r=e.src.slice(u,d),l)return!0;for(r.trim().slice(-2)==="$$"&&(r=r.trim().slice(0,-2),m=!0),i=o;!m&&(i++,!(i>=n||(u=e.bMarks[i]+e.tShift[i],d=e.eMarks[i],u<d&&e.tShift[i]<e.blkIndent)));)e.src.slice(u,d).trim().slice(-2)==="$$"&&(c=e.src.slice(0,d).lastIndexOf("$$"),a=e.src.slice(u,c),m=!0);e.line=i+1;const g=e.push("math_block","math",0);return g.block=!0,g.content=(r&&r.trim()?r+`
|
|
63
|
+
`:"")+e.getLines(o+1,i,e.tShift[o],!0)+(a&&a.trim()?a:""),g.map=[o,e.line],g.markup="$$",!0},Ao=(e,o)=>{const n=r=>{if(o.katexRef.value){const a=o.katexRef.value.renderToString(r,{throwOnError:!1});return`<span class="${s}-katex-inline" data-processed>${a}</span>`}else return`<span class="${s}-katex-inline">${r}</span>`},l=(r,a)=>{if(o.katexRef.value){const i=o.katexRef.value.renderToString(r,{throwOnError:!1,displayMode:!0});return`<p class="${s}-katex-block" data-line=${a} data-processed>${i}</p>`}else return`<p class="${s}-katex-block" data-line=${a}>${r}</p>`};e.inline.ruler.after("escape","math_inline",Io),e.block.ruler.after("blockquote","math_block",Fo,{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=(r,a)=>n(r[a].content),e.renderer.rules.math_block=(r,a)=>l(r[a].content,r[a].map[0])+`
|
|
64
|
+
`},jo=(e,o)=>{o=o||{};const n=3,l=o.marker||"!",r=l.charCodeAt(0),a=l.length;let i="",c="";const m=(d,g,h,v,b)=>{const k=d[g];return k.type==="admonition_open"?(d[g].attrPush(["class",`${s}-admonition ${s}-admonition-${k.info}`]),d[g].attrSet("data-line",String(d[g].map[0]))):k.type==="admonition_title_open"&&d[g].attrPush(["class",`${s}-admonition-title`]),b.renderToken(d,g,h)},u=d=>{const g=d.trim().split(" ",2);c="",i=g[0],g.length>1&&(c=d.substring(i.length+2)),(c===""||!c)&&(c=i)};e.block.ruler.before("code","admonition",(d,g,h,v)=>{let b,k,p,y=!1,w=d.bMarks[g]+d.tShift[g],$=d.eMarks[g];if(r!==d.src.charCodeAt(w))return!1;for(b=w+1;b<=$&&l[(b-w)%a]===d.src[b];b++);const T=Math.floor((b-w)/a);if(T!==n)return!1;b-=(b-w)%a;const N=d.src.slice(w,b),L=d.src.slice(b,$);if(u(L),v)return!0;for(k=g;k++,!(k>=h||(w=d.bMarks[k]+d.tShift[k],$=d.eMarks[k],w<$&&d.sCount[k]<d.blkIndent));)if(r===d.src.charCodeAt(w)&&!(d.sCount[k]-d.blkIndent>=4)){for(b=w+1;b<=$&&l[(b-w)%a]===d.src[b];b++);if(!(Math.floor((b-w)/a)<T)&&(b-=(b-w)%a,b=d.skipSpaces(b),!(b<$))){y=!0;break}}const M=d.parentType,P=d.lineMax;return d.parentType="root",d.lineMax=k,p=d.push("admonition_open","div",1),p.markup=N,p.block=!0,p.info=i,p.map=[g,k],p=d.push("admonition_title_open","p",1),p.markup=N+" "+i,p.map=[g,k],p=d.push("inline","",0),p.content=c,p.map=[g,d.line-1],p.children=[],p=d.push("admonition_title_close","p",-1),p.markup=N+" "+i,d.md.block.tokenize(d,g+1,k),p=d.push("admonition_close","div",-1),p.markup=d.src.slice(w,b),p.block=!0,d.parentType=M,d.lineMax=P,d.line=k+(y?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=m,e.renderer.rules.admonition_title_open=m,e.renderer.rules.admonition_title_close=m,e.renderer.rules.admonition_close=m},Ro=(e,o)=>{let n;e.core.ruler.push("headingLinks",l=>{n||(n=l.Token)}),e.renderer.rules.heading_open=(l,r)=>{const a=l[r],i=l[r+1].content,c=a.markup.length;return o.headsRef.value.push({text:i,level:c}),a.map&&a.level===0&&(a.attrSet("data-line",String(a.map[0])),a.attrSet("id",o.mdHeadingId(i,c,o.headsRef.value.length))),e.renderer.renderToken(l,r,o)},e.renderer.rules.heading_close=(l,r,a,i,c)=>c.renderToken(l,r,a)},at=e=>e.replace(/<pre><code\sclass="language-([^>]*)">/g,'<pre><code class="language-$1" language="$1">'),Bo=e=>{const{editorConfig:o,markdownItConfig:n}=x,l=t.inject("editorId"),r=t.inject("showCodeRowNumber"),a=t.inject("previewOnly"),i=t.inject("theme"),c=t.ref([]),m=Eo(e),u=Mo(e),{reRenderRef:d,replaceMermaid:g}=Lo(e),h=pt({html:!0,breaks:!0});h.use(Ho,{themeRef:i}),h.use(Ao,{katexRef:u}),h.use(bt,{figcaption:!0}),h.use(jo),h.use(kt),h.use(Ro,{mdHeadingId:e.mdHeadingId,headsRef:c}),h.renderer.rules.paragraph_open=h.renderer.rules.table_open=(p,y,w,$,T)=>{let N;return p[y].map&&p[y].level===0&&(N=p[y].map[0],p[y].attrSet("data-line",String(N))),T.renderToken(p,y,w)},h.set({highlight:(p,y)=>{if(e.noHighlight||!m.value)return p;const w=m.value.getLanguage(y);let $;return w?$=m.value.highlight(p,{language:y,ignoreIllegals:!0}).value:$=m.value.highlightAuto(p).value,r?Ht($.trim()):`<span class="code-block">${$.trim()}</span>`}}),n(h);const v=t.ref(e.sanitize(at(h.render(e.value)))),b=W(async()=>{c.value=[],v.value=e.sanitize(at(h.render(e.value))),C.emit(l,"buildFinished",v.value),e.onHtmlChanged(v.value),g()},(o==null?void 0:o.renderDelay)!==void 0?o==null?void 0:o.renderDelay:a?0:500),k=t.computed(()=>e.noHighlight||m.value);return t.watch([t.toRef(e,"value"),k,d],b),t.watch(()=>c.value,p=>{e.onGetCatalog(p),C.emit(l,"catalogChanged",p)}),t.onMounted(()=>{C.on(l,{name:"pushCatalog",callback(){C.emit(l,"catalogChanged",c.value)}})}),{html:v}},Po={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:e=>e},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:e=>e},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}},Oo=t.defineComponent({name:"MDEditorContent",props:Po,setup(e){const o=t.inject("previewOnly"),n=t.inject("showCodeRowNumber"),l=t.inject("previewTheme"),r=t.inject("editorId"),a=t.ref(),i=t.ref(),{inputWrapperRef:c,codeMirrorUt:m}=To(e),{html:u}=Bo(e);return Jt(e,u,a,i,m),xo(e,u),So(e,u),()=>t.createVNode("div",{class:`${s}-content`},[!o&&t.createVNode("div",{class:`${s}-input-wrapper`,ref:c},null),e.setting.preview&&t.createVNode("div",{id:`${r}-preview-wrapper`,class:`${s}-preview-wrapper`,ref:a,key:"content-preview-wrapper"},[t.createVNode("article",{id:`${r}-preview`,class:[`${s}-preview`,`${l==null?void 0:l.value}-theme`,n&&`${s}-scrn`],innerHTML:u.value},null)]),e.setting.htmlPreview&&t.createVNode("div",{class:`${s}-preview-wrapper`,ref:i,key:"html-preview-wrapper"},[t.createVNode("div",{class:`${s}-html`},[u.value])])])}}),Do=t.defineComponent({props:{modelValue:{type:String,default:""}},setup(e){const o=t.inject("usedLanguageText");return()=>{var n,l;return t.createVNode("div",{class:`${s}-footer-item`},[t.createVNode("label",{class:`${s}-footer-label`},[`${(n=o.value.footer)==null?void 0:n.markdownTotal}:`]),t.createVNode("span",null,[((l=e.modelValue)==null?void 0:l.length)||0])])}}});const _o={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},qo=t.defineComponent({props:_o,setup(e){return()=>t.createVNode("div",{class:[`${s}-checkbox`,e.checked&&`${s}-checkbox-checked`],onClick:()=>{e.onChange(!e.checked)}},null)}}),Uo={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},Wo=t.defineComponent({props:Uo,setup(e){const o=t.inject("usedLanguageText");return()=>{var n;return t.createVNode("div",{class:`${s}-footer-item`},[t.createVNode("label",{class:`${s}-footer-label`,onClick:()=>{e.onScrollAutoChange(!e.scrollAuto)}},[(n=o.value.footer)==null?void 0:n.scrollAuto]),t.createVNode(qo,{checked:e.scrollAuto,onChange:e.onScrollAutoChange},null)])}}}),Go={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},zo=t.defineComponent({name:"MDEditorFooter",props:Go,setup(e){const o=t.computed(()=>{const l=e.footers.indexOf("="),r=l===-1?e.footers:e.footers.slice(0,l),a=l===-1?[]:e.footers.slice(l,Number.MAX_SAFE_INTEGER);return[r,a]}),n=l=>{if(it.includes(l))switch(l){case"markdownTotal":return t.createVNode(Do,{modelValue:e.modelValue},null);case"scrollSwitch":return t.createVNode(Wo,{scrollAuto:e.scrollAuto,onScrollAutoChange:e.onScrollAutoChange},null)}else return e.defFooters instanceof Array?e.defFooters[l]||"":e.defFooters&&e.defFooters.children instanceof Array&&e.defFooters.children[l]||""};return()=>{const l=o.value[0].map(a=>n(a)),r=o.value[1].map(a=>n(a));return t.createVNode("div",{class:`${s}-footer`},[t.createVNode("div",{class:`${s}-footer-left`},[l]),t.createVNode("div",{class:`${s}-footer-right`},[r])])}}}),Ko={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},dt=t.defineComponent({props:Ko,setup(e){return()=>{const{tocItem:o,mdHeadingId:n,scrollElement:l,onClick:r,scrollElementOffsetTop:a}=e;return t.createVNode("div",{class:[`${s}-catalog-link`,o.active&&`${s}-catalog-active`],onClick:i=>{r(i,o),i.stopPropagation();const c=n(o.text,o.level,o.index),m=document.getElementById(c),u=l instanceof Element?l:document.querySelector(l);if(m&&u){let d=m.offsetParent,g=m.offsetTop;if(u.contains(d))for(;d&&u!=d;)g+=d==null?void 0:d.offsetTop,d=d==null?void 0:d.offsetParent;u==null||u.scrollTo({top:g-a,behavior:"smooth"})}}},[t.createVNode("span",{title:o.text},[o.text]),t.createVNode("div",{class:`${s}-catalog-wrapper`},[o.children&&o.children.map(i=>t.createVNode(dt,{mdHeadingId:n,key:`${o.text}-link-${i.level}-${i.text}`,tocItem:i,scrollElement:l,onClick:r,scrollElementOffsetTop:a},null))])])}}});const Xo={editorId:{type:String},class:{type:String,default:""},mdHeadingId:{type:Function,default:e=>e},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function}},le=t.defineComponent({name:"MdCatalog",props:Xo,emits:["onClick"],setup(e,o){const n=e.editorId,l=t.reactive({list:[],show:!1,scrollElement:e.scrollElement||`#${n}-preview-wrapper`}),r=t.computed(()=>{const i=[];return l.list.forEach(({text:c,level:m,active:u},d)=>{const g={level:m,text:c,index:d+1,active:!!u};if(i.length===0)i.push(g);else{let h=i[i.length-1];if(g.level>h.level)for(let v=h.level+1;v<=6;v++){const{children:b}=h;if(!b){h.children=[g];break}if(h=b[b.length-1],g.level<=h.level){b.push(g);break}}else i.push(g)}}),i});t.onMounted(()=>{C.on(n,{name:"catalogChanged",callback:i=>{l.list=i.map((c,m)=>m===0?{...c,active:!0}:{...c})}}),C.emit(n,"pushCatalog")});const a=()=>{var c;const i=l.scrollElement instanceof HTMLElement?l.scrollElement:document.querySelector(l.scrollElement);(c=i===document.documentElement?window:i)==null||c.addEventListener("scroll",It(()=>{if(l.list.length===0)return!1;const{activeHead:m}=l.list.reduce((u,d,g)=>{const h=document.getElementById(e.mdHeadingId(d.text,d.level,g+1));if(h instanceof HTMLElement){const v=Ft(h,i);if(v<e.offsetTop&&v>u.minTop)return{activeHead:d,minTop:v}}return u},{activeHead:l.list[0],minTop:Number.MIN_SAFE_INTEGER});l.list=l.list.map(u=>u===m?{...u,active:!0}:{...u,active:!1})}))};return t.onMounted(()=>{a(),C.on(n,{name:ie,callback(i){i&&t.nextTick(a)}})}),()=>t.createVNode("div",{class:`${s}-catalog${e.theme==="dark"?"-dark":""} ${e.class}`},[r.value.map(i=>t.createVNode(dt,{mdHeadingId:e.mdHeadingId,tocItem:i,key:`link-${i.level}-${i.text}`,scrollElement:l.scrollElement,onClick:(c,m)=>{e.onClick?e.onClick(c,m):o.emit("onClick",c,m)},scrollElementOffsetTop:e.scrollElementOffsetTop},null))])}}),Zo=(e,o)=>{const{editorId:n,previewOnly:l}=e,r=t.reactive({buildFinished:!1,html:""});t.watch(()=>e.modelValue,()=>{r.buildFinished=!1}),t.onMounted(()=>{l||(C.on(n,{name:"buildFinished",callback(a){r.buildFinished=!0,r.html=a}}),C.on(n,{name:ne,callback(){const a=new Promise(i=>{if(r.buildFinished)i(r.html);else{const c=m=>{i(m),C.remove(n,"buildFinished",c)};C.on(n,{name:"buildFinished",callback:c})}});e.onSave?e.onSave(e.modelValue,a):o.emit("onSave",e.modelValue,a)}}))})},Jo=e=>{var a;const{editorId:o,previewOnly:n}=e,l=(a=x==null?void 0:x.editorExtensions)==null?void 0:a.highlight;t.provide("editorId",o),t.provide("tabWidth",e.tabWidth),t.provide("theme",t.computed(()=>e.theme)),t.provide("highlight",t.computed(()=>{const i={...Oe,...l==null?void 0:l.css},c=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(l==null?void 0:l.js)||$t,css:i[e.codeTheme]?i[e.codeTheme][c]:Oe.atom[c]}})),t.provide("previewOnly",n),t.provide("showCodeRowNumber",e.showCodeRowNumber);const r=t.computed(()=>{var c;const i={...Be,...(c=x==null?void 0:x.editorConfig)==null?void 0:c.languageUserDefined};return i[e.language]?i[e.language]:Be["zh-CN"]});t.provide("usedLanguageText",r),t.provide("previewTheme",t.computed(()=>e.previewTheme))},Yo=e=>{var u,d,g,h,v,b;const{noPrettier:o,previewOnly:n,noIconfont:l,noUploadImg:r}=e,{editorExtensions:a}=x,i=o||!!((d=(u=x.editorExtensions)==null?void 0:u.prettier)!=null&&d.prettierInstance),c=o||!!((h=(g=x.editorExtensions)==null?void 0:g.prettier)!=null&&h.parserMarkdownInstance),m=r||!!((b=(v=x.editorExtensions)==null?void 0:v.cropper)!=null&&b.instance);t.onMounted(()=>{var T,N,L,M;const k=document.createElement("script");k.src=(a==null?void 0:a.iconfont)||wt,k.id=`${s}-icon`;const p=document.createElement("script"),y=document.createElement("script");p.src=((T=a==null?void 0:a.prettier)==null?void 0:T.standaloneJs)||je.main,p.id=`${s}-prettier`,y.src=((N=a==null?void 0:a.prettier)==null?void 0:N.parserMarkdownJs)||je.markdown,y.id=`${s}-prettierMD`;const w=document.createElement("link");w.rel="stylesheet",w.href=((L=a==null?void 0:a.cropper)==null?void 0:L.css)||Re.css,w.id=`${s}-cropperCss`;const $=document.createElement("script");$.src=((M=a==null?void 0:a.cropper)==null?void 0:M.js)||Re.js,$.id=`${s}-cropper`,l||I(k),n||(m||(I(w),I($)),i||I(p),c||I(y))})},Qo=(e,o)=>{const{editorId:n,previewOnly:l}=e,r=t.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),a=(m,u)=>{r[m]=u===void 0?!r[m]:u,m==="preview"&&r.preview?r.htmlPreview=!1:m==="htmlPreview"&&r.htmlPreview&&(r.preview=!1)};let i="";const c=()=>{r.pageFullscreen||r.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=i};return t.watch(()=>[r.pageFullscreen,r.fullscreen],c),t.onMounted(()=>{l||C.on(n,{name:"uploadImage",callback(m,u){const d=g=>{C.emit(n,"replace","image",{desc:"",urls:g}),u&&u()};e.onUploadImg?e.onUploadImg(m,d):o.emit("onUploadImg",m,d)}}),i=document.body.style.overflow,c()}),[r,a]},el=e=>{const{editorId:o}=e,n=t.ref(!1);t.onMounted(()=>{C.on(o,{name:ue,callback:r=>{r===void 0?n.value=!n.value:n.value=r}})});const l=t.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog"));return[n,l]},tl=(e,o,n,l,r)=>{const{editorId:a}=e;t.watch(()=>l.pageFullscreen,c=>{C.emit(a,De,c)}),t.watch(()=>l.fullscreen,c=>{C.emit(a,_e,c)}),t.watch(()=>l.preview,c=>{C.emit(a,ie,c)}),t.watch(()=>l.htmlPreview,c=>{C.emit(a,qe,c)}),t.watch(n,c=>{C.emit(a,Ue,c)});const i={on(c,m){switch(c){case"pageFullscreen":{C.on(a,{name:De,callback(u){m(u)}});break}case"fullscreen":{C.on(a,{name:_e,callback(u){m(u)}});break}case"preview":{C.on(a,{name:ie,callback(u){m(u)}});break}case"htmlPreview":{C.on(a,{name:qe,callback(u){m(u)}});break}case"catalog":{C.on(a,{name:Ue,callback(u){m(u)}});break}}},togglePageFullscreen(c){r("pageFullscreen",c)},toggleFullscreen(c){C.emit(a,st,c)},togglePreview(c){r("preview",c)},toggleHtmlPreview(c){r("htmlPreview",c)},toggleCatalog(c){C.emit(a,ue,c)},triggerSave(){C.emit(a,ne)},insert(c){C.emit(a,"replace","universal",{generate:c})},focus(){C.emit(a,ct)}};o.expose(i)},ol=e=>e,ll={modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},language:{type:String,default:"zh-CN"},toolbars:{type:Array,default:rt},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:Ct},tabWidth:{type:Number,default:2},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:ol},tableShape:{type:Array,default:()=>[6,4]},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:e=>e},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},defToolbars:{type:[String,Object]},onError:{type:Function},codeTheme:{type:String,default:"atom"},footers:{type:Array,default:it},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:e=>e},noUploadImg:{type:Boolean},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function},onFocus:{type:Function},noHighlight:{type:Boolean,default:!1}},nl=["onChange","onSave","onUploadImg","onHtmlChanged","onGetCatalog","onError","update:modelValue","onBlur","onFocus"];const B=t.defineComponent({name:"MdEditorV3",props:ll,emits:nl,setup(e,o){const{editorId:n,previewOnly:l,noKatex:r,noMermaid:a,noPrettier:i,noUploadImg:c,noHighlight:m}=e,u=t.reactive({scrollAuto:e.scrollAuto});Zo(e,o),Jo(e),Yo(e);const[d,g]=Qo(e,o),[h,v]=el(e);return t.onBeforeUnmount(()=>{C.clear(n)}),tl(e,o,h,d,g),()=>{var p;const b=F({props:e,ctx:o},"defToolbars"),k=F({props:e,ctx:o},"defFooters");return t.createVNode("div",{id:n,class:[s,e.class,e.theme==="dark"&&`${s}-dark`,d.fullscreen||d.pageFullscreen?`${s}-fullscreen`:"",l&&`${s}-previewOnly`],style:e.style},[!l&&t.createVNode(Kt,{noPrettier:i,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:d,updateSetting:g,tableShape:e.tableShape,defToolbars:b,noUploadImg:c},null),t.createVNode(Oo,{value:e.modelValue,setting:d,mdHeadingId:e.mdHeadingId,noMermaid:a,noPrettier:i,sanitize:e.sanitize,placeholder:e.placeholder,noKatex:r,scrollAuto:u.scrollAuto,formatCopiedText:e.formatCopiedText,autofocus:e.autoFocus,disabled:e.disabled,readonly:e.readOnly,maxlength:e.maxLength,autoDetectCode:e.autoDetectCode,noHighlight:m,onChange:y=>{e.onChange?e.onChange(y):(o.emit("update:modelValue",y),o.emit("onChange",y))},onHtmlChanged:y=>{e.onHtmlChanged?e.onHtmlChanged(y):o.emit("onHtmlChanged",y)},onGetCatalog:y=>{e.onGetCatalog?e.onGetCatalog(y):o.emit("onGetCatalog",y)},onBlur:y=>{e.onBlur?e.onBlur(y):o.emit("onBlur",y)},onFocus:y=>{e.onFocus?e.onFocus(y):o.emit("onFocus",y)}},null),!l&&((p=e.footers)==null?void 0:p.length)>0&&t.createVNode(zo,{modelValue:e.modelValue,footers:e.footers,defFooters:k,scrollAuto:u.scrollAuto,onScrollAutoChange:y=>u.scrollAuto=y},null),v.value&&!l&&t.createVNode(le,{theme:e.theme,style:{display:h.value?"block":"none"},class:`${s}-catalog-editor`,editorId:n,mdHeadingId:e.mdHeadingId},null)])}}}),al={title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function}},se=t.defineComponent({name:"NormalToolbar",props:al,emits:["onClick"],setup(e,o){return()=>{const n=F({props:e,ctx:o},"trigger");return t.createVNode("div",{class:`${s}-toolbar-item`,title:e.title,onClick:l=>{e.onClick instanceof Function?e.onClick(l):o.emit("onClick",l)}},[n])}}}),rl={title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]}},ce=t.defineComponent({name:"DropdownToolbar",props:rl,emits:["onChange"],setup(e,o){const n=t.inject("editorId");return()=>{const l=F({props:e,ctx:o},"trigger"),r=F({props:e,ctx:o},"overlay");return t.createVNode(U,{relative:`#${n}-toolbar-wrapper`,visible:e.visible,onChange:a=>{e.onChange instanceof Function?e.onChange(a):o.emit("onChange",a)},overlay:r},{default:()=>[t.createVNode("div",{class:`${s}-toolbar-item`,title:e.title||""},[l])]})}}});function il(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const sl={title:{type:String,default:""},modalTitle:{type:String,default:""},visible:{type:Boolean},width:{type:String,default:"auto"},height:{type:String,default:"auto"},trigger:{type:[String,Object]},onClick:{type:Function},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function}},de=t.defineComponent({name:"ModalToolbar",props:sl,emits:["onClick","onClose","onAdjust"],setup(e,o){return()=>{const n=F({props:e,ctx:o},"trigger"),l=F({props:e,ctx:o},"default");return t.createVNode(t.Fragment,null,[t.createVNode("div",{class:`${s}-toolbar-item`,title:e.title,onClick:()=>{e.onClick instanceof Function?e.onClick():o.emit("onClick")}},[n]),t.createVNode(me,{width:e.width,height:e.height,title:e.modalTitle,visible:e.visible,onClose:()=>{e.onClose instanceof Function?e.onClose():o.emit("onClose")},showAdjust:e.showAdjust,isFullscreen:e.isFullscreen,onAdjust:r=>{e.onAdjust instanceof Function?e.onAdjust(r):o.emit("onAdjust",r)}},il(l)?l:{default:()=>[l]})])}}});B.install=e=>(e.component(B.name,B),e.component(se.name,se),e.component(ce.name,ce),e.component(le.name,le),e.component(de.name,de),e);B.NormalToolbar=se;B.DropdownToolbar=ce;B.MdCatalog=le;B.ModalToolbar=de;B.config=Tt;module.exports=B;
|