md-editor-v3 2.4.1 → 2.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -45
- package/lib/MdEditor/Editor.d.ts +33 -16
- package/lib/MdEditor/config.d.ts +1 -1
- package/lib/MdEditor/index.d.ts +70 -32
- package/lib/MdEditor/type.d.ts +85 -6
- package/lib/md-editor-v3.es.js +251 -78
- package/lib/md-editor-v3.umd.js +65 -65
- package/lib/style.css +1 -1
- package/package.json +1 -1
package/lib/md-editor-v3.umd.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
(function(o,
|
|
2
|
-
`),e=['<span rn-wrapper aria-hidden="true">'];return t.forEach(()=>{e.push("<span></span>")}),e.push("</span>"),`<span class="code-block">${i}</span>${e.join("")}`},ke=(i,t=200)=>{let e=0;return(...n)=>{e&&clearTimeout(e),e=window.setTimeout(()=>{i.apply(globalThis,n),e=0},t)}},Et=(i,t=200)=>{let e=0,n=null;return(...l)=>{const r=a=>{e===0&&(e=a),a-e>=t?(i.apply(globalThis,n),n=null,e=0):window.requestAnimationFrame(r)};n===null&&window.requestAnimationFrame(r),n=l}},Xe=(i,t="$")=>{const e=i.split(t);let n=t,l="";for(let r=1;r<e.length;r++)if(/\\$/.test(e[r]))n+=e[r]+"$",l+=e[r]+"$";else{n+=e[r]+t,l+=e[r];break}return[n,l]},Nt=i=>{var e;return navigator.userAgent.indexOf("Firefox")>-1?i.value.substring(i.selectionStart,i.selectionEnd):((e=window.getSelection())==null?void 0:e.toString())||""},Tt=(i,t)=>{const e=i==null?void 0:i.getBoundingClientRect();if(t===document.documentElement)return e.top-t.clientTop;const n=t==null?void 0:t.getBoundingClientRect();return e.top-n.top},Ye=(i,t)=>{const e=n=>{const l=i.parentElement||document.body,r=l.offsetWidth,a=l.offsetHeight,{clientWidth:s}=document.documentElement,{clientHeight:d}=document.documentElement,h=n.offsetX,u=n.offsetY,m=f=>{let $=f.x+document.body.scrollLeft-document.body.clientLeft-h,v=f.y+document.body.scrollTop-document.body.clientTop-u;$=$<1?1:$<s-r-1?$:s-r-1,v=v<1?1:v<d-a-1?v:d-a-1,t?t($,v):(l.style.left=`${$}px`,l.style.top=`${v}px`)};document.addEventListener("mousemove",m);const k=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",k)};document.addEventListener("mouseup",k)};return i.addEventListener("mousedown",e),()=>{i.removeEventListener("mousedown",e)}},Q=(i,t="")=>{const e=document.getElementById(i.id);e?t!==""&&i.onload instanceof Function&&(Reflect.get(window,t)?i.onload(new Event("load")):e.addEventListener("load",i.onload)):document.head.appendChild(i)},Vt=ke((i,t,e)=>{const n=document.getElementById(i);n&&n.setAttribute(t,e)},10),zt=(i,t)=>{const{editorId:e,noPrettier:n}=i,l=a=>{var s,d;return((s=i.toolbars)==null?void 0:s.includes(a))&&!((d=i.toolbarsExclude)!=null&&d.includes(a))&&!n},r=a=>{if(a.target===document.querySelector(`#${i.editorId}-textarea`))if(C.emit(e,"selectTextChange"),a.ctrlKey||a.metaKey)switch(a.code){case"KeyS":{a.shiftKey?l("strikeThrough")&&C.emit(e,"replace","strikeThrough"):l("save")&&(C.emit(e,"onSave",i.modelValue),a.preventDefault());break}case"KeyB":{l("bold")&&(C.emit(e,"replace","bold"),a.preventDefault());break}case"KeyU":{a.shiftKey?l("unorderedList")&&(C.emit(e,"replace","unorderedList"),a.preventDefault()):l("underline")&&(C.emit(e,"replace","underline"),a.preventDefault());break}case"KeyI":{a.shiftKey?l("image")&&(C.emit(e,"openModals","image"),a.preventDefault()):l("italic")&&(C.emit(e,"replace","italic"),a.preventDefault());break}case"Digit1":{l("title")&&(C.emit(e,"replace","h1"),a.preventDefault());break}case"Digit2":{l("title")&&(C.emit(e,"replace","h2"),a.preventDefault());break}case"Digit3":{l("title")&&(C.emit(e,"replace","h3"),a.preventDefault());break}case"Digit4":{l("title")&&(C.emit(e,"replace","h4"),a.preventDefault());break}case"Digit5":{l("title")&&(C.emit(e,"replace","h5"),a.preventDefault());break}case"Digit6":{l("title")&&(C.emit(e,"replace","h6"),a.preventDefault());break}case"ArrowUp":{l("sup")&&(C.emit(e,"replace","sup"),a.preventDefault());break}case"ArrowDown":{l("sub")&&(C.emit(e,"replace","sub"),a.preventDefault());break}case"KeyQ":{if(a.key==="a"){a.target.select();return}C.emit(e,"replace","quote"),a.preventDefault();break}case"KeyA":if(a.key==="q"){C.emit(e,"replace","quote"),a.preventDefault();break}else return;case"KeyO":{l("orderedList")&&(C.emit(e,"replace","orderedList"),a.preventDefault());break}case"KeyC":{if(a.shiftKey)l("code")&&(C.emit(e,"replace","code"),a.preventDefault());else if(a.altKey)l("codeRow")&&(C.emit(e,"replace","codeRow"),a.preventDefault());else{a.preventDefault(),C.emit(e,"replace","ctrlC");break}break}case"KeyL":{l("link")&&(C.emit(e,"openModals","link"),a.preventDefault());break}case"KeyZ":{if(a.key==="w")return;a.shiftKey?l("next")&&(C.emit(e,"ctrlShiftZ"),a.preventDefault()):l("revoke")&&(C.emit(e,"ctrlZ"),a.preventDefault());break}case"KeyW":if(a.key==="z"){a.shiftKey?l("next")&&(C.emit(e,"ctrlShiftZ"),a.preventDefault()):l("revoke")&&(C.emit(e,"ctrlZ"),a.preventDefault());break}else return;case"KeyF":{a.shiftKey&&l("prettier")&&(C.emit(e,"replace","prettier"),a.preventDefault());break}case"KeyT":{a.altKey&&a.shiftKey&&l("table")&&(C.emit(e,"replace","table"),a.preventDefault());break}case"KeyX":{C.emit(e,"replace","ctrlX"),a.preventDefault();break}case"KeyD":{a.preventDefault(),C.emit(e,"replace","ctrlD");break}}else a.code==="Tab"&&(a.preventDefault(),a.shiftKey?C.emit(e,"replace","shiftTab"):C.emit(e,"replace","tab"))};o.onMounted(()=>{i.previewOnly||(window.addEventListener("keydown",r),C.on(e,{name:"onSave",callback(){i.onSave?i.onSave(i.modelValue):t.emit("onSave",i.modelValue)}}))}),o.onBeforeUnmount(()=>{i.previewOnly||window.removeEventListener("keydown",r)})},It=i=>{var l;const{editorId:t}=i,e=(l=M==null?void 0:M.editorExtensions)==null?void 0:l.highlight;o.provide("editorId",t),o.provide("tabWidth",i.tabWidth),o.provide("theme",o.computed(()=>i.theme)),o.provide("highlight",o.computed(()=>{const r=K(K({},We),e==null?void 0:e.css);return{js:(e==null?void 0:e.js)||yt,css:r[i.codeTheme]?r[i.codeTheme][i.theme]:We.atom[i.theme]}})),o.provide("historyLength",i.historyLength),o.provide("previewOnly",i.previewOnly),o.provide("showCodeRowNumber",i.showCodeRowNumber);const n=o.computed(()=>{var a;const r=K(K({},Ke),(a=M==null?void 0:M.editorConfig)==null?void 0:a.languageUserDefined);return r[i.language]?r[i.language]:Ke["zh-CN"]});o.provide("usedLanguageText",n),o.provide("previewTheme",o.computed(()=>i.previewTheme))},At=i=>{var d,h,u,m,k,f;const{noPrettier:t,previewOnly:e,noIconfont:n}=i,{editorExtensions:l}=M,r=t||!!((h=(d=M.editorExtensions)==null?void 0:d.prettier)!=null&&h.prettierInstance),a=t||!!((m=(u=M.editorExtensions)==null?void 0:u.prettier)!=null&&m.parserMarkdownInstance),s=!!((f=(k=M.editorExtensions)==null?void 0:k.cropper)!=null&&f.instance);o.onMounted(()=>{var E,A,F,H;const $=document.createElement("script");$.src=(l==null?void 0:l.iconfont)||G,$.id=`${c}-icon`;const v=document.createElement("script"),w=document.createElement("script");v.src=((E=l==null?void 0:l.prettier)==null?void 0:E.standaloneJs)||Me.main,v.id=`${c}-prettier`,w.src=((A=l==null?void 0:l.prettier)==null?void 0:A.parserMarkdownJs)||Me.markdown,w.id=`${c}-prettierMD`;const b=document.createElement("link");b.rel="stylesheet",b.href=((F=l==null?void 0:l.cropper)==null?void 0:F.css)||Be.css,b.id=`${c}-cropperCss`;const y=document.createElement("script");y.src=((H=l==null?void 0:l.cropper)==null?void 0:H.js)||Be.js,y.id=`${c}-cropper`,e||(n||Q($),s||(Q(b),Q(y)),r||Q(v),a||Q(w))})},Lt=(i,t)=>{const{editorId:e}=i,n=o.reactive({pageFullScreen:i.pageFullScreen,fullscreen:!1,preview:i.preview,htmlPreview:i.preview?!1:i.htmlPreview}),l=(s,d)=>{n[d]=s,d==="preview"&&n.preview?n.htmlPreview=!1:d==="htmlPreview"&&n.htmlPreview&&(n.preview=!1)};let r="";const a=()=>{n.pageFullScreen||n.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=r};return o.watch(()=>[n.pageFullScreen,n.fullscreen],a),o.onMounted(()=>{i.previewOnly||C.on(e,{name:"uploadImage",callback(s,d){const h=u=>{C.emit(e,"replace","image",{desc:"",urls:u}),d&&d()};i.onUploadImg?i.onUploadImg(s,h):t.emit("onUploadImg",s,h)}}),r=document.body.style.overflow,a()}),[n,l]},Ft=i=>{const{editorId:t}=i,e=o.ref(!1);o.onMounted(()=>{C.on(t,{name:"catalogShow",callback:()=>{e.value=!e.value}})});const n=o.computed(()=>!i.toolbarsExclude.includes("catalog")&&i.toolbars.includes("catalog"));return[e,n]};var ti="",jt=o.defineComponent({setup(){return()=>o.createVNode("div",{class:`${c}-divider`},null)}});const X=({instance:i,ctx:t,props:e={}},n="default")=>{const l=(i==null?void 0:i.$slots[n])||(t==null?void 0:t.slots[n]);return(l?l(i):"")||e[n]};var ni="";const Dt=()=>({trigger:{type:String,default:"hover"},overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>()=>{}},relative:{type:String,default:"html"}});var re=o.defineComponent({props:Dt(),setup(i,t){const e=`${c}-dropdown-hidden`,n=o.reactive({overlayClass:[e],overlayStyle:{},triggerHover:!1,overlayHover:!1}),l=o.ref(),r=o.ref(),a=()=>{var E;i.trigger==="hover"&&(n.triggerHover=!0);const m=l.value,k=r.value,f=m.getBoundingClientRect(),$=m.offsetTop,v=m.offsetLeft,w=f.height,b=f.width,y=((E=document.querySelector(i.relative))==null?void 0:E.scrollLeft)||0;n.overlayStyle=ue(K({},n.overlayStyle),{top:$+w+"px",left:v-k.offsetWidth/2+b/2-y+"px"}),i.onChange(!0)},s=()=>{n.overlayHover=!0};o.watch(()=>i.visible,m=>{m?n.overlayClass=n.overlayClass.filter(k=>k!==e):n.overlayClass.push(e)});const d=m=>{const k=l.value,f=r.value;!k.contains(m.target)&&!f.contains(m.target)&&i.onChange(!1)};let h=-1;const u=m=>{l.value===m.target?n.triggerHover=!1:n.overlayHover=!1,clearTimeout(h),h=window.setTimeout(()=>{!n.overlayHover&&!n.triggerHover&&i.onChange(!1)},10)};return o.onMounted(()=>{i.trigger==="click"?(l.value.addEventListener("click",a),document.addEventListener("click",d)):(l.value.addEventListener("mouseenter",a),l.value.addEventListener("mouseleave",u),r.value.addEventListener("mouseenter",s),r.value.addEventListener("mouseleave",u))}),o.onBeforeUnmount(()=>{i.trigger==="click"?(l.value.removeEventListener("click",a),document.removeEventListener("click",d)):(l.value.removeEventListener("mouseenter",a),l.value.removeEventListener("mouseleave",u),r.value.removeEventListener("mouseenter",s),r.value.removeEventListener("mouseleave",u))}),()=>{const m=X({ctx:t}),k=X({props:i,ctx:t},"overlay"),f=o.cloneVNode(m instanceof Array?m[0]:m,{ref:l}),$=o.createVNode("div",{class:[`${c}-dropdown`,n.overlayClass],style:n.overlayStyle,ref:r},[o.createVNode("div",{class:`${c}-dropdown-overlay`},[k instanceof Array?k[0]:k])]);return[f,$]}}}),ii="";const _t=()=>({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:()=>()=>{}}});var De=o.defineComponent({props:_t(),setup(i,t){const e=o.ref(i.visible),n=o.ref([`${c}-modal`]),l=o.ref(),r=o.ref();let a=()=>{};const s=o.reactive({initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),d=o.computed(()=>i.isFullscreen?{width:"100%",height:"100%"}:{width:i.width,height:i.height});return o.onMounted(()=>{a=Ye(r.value,(h,u)=>{s.initPos.left=h+"px",s.initPos.top=u+"px"})}),o.onBeforeUnmount(()=>{a()}),o.watch(()=>i.isFullscreen,h=>{h?a():a=Ye(r.value,(u,m)=>{s.initPos.left=u+"px",s.initPos.top=m+"px"})}),o.watch(()=>i.visible,h=>{h?(n.value.push("zoom-in"),e.value=h,o.nextTick(()=>{const u=l.value.offsetWidth/2,m=l.value.offsetHeight/2,k=document.documentElement.clientWidth/2,f=document.documentElement.clientHeight/2;s.initPos.left=k-u+"px",s.initPos.top=f-m+"px"}),setTimeout(()=>{n.value=n.value.filter(u=>u!=="zoom-in")},140)):(n.value.push("zoom-out"),setTimeout(()=>{n.value=n.value.filter(u=>u!=="zoom-out"),e.value=h},130))}),()=>{const h=X({ctx:t}),u=X({props:i,ctx:t},"title");return o.createVNode("div",{style:{display:e.value?"block":"none"}},[o.createVNode("div",{class:`${c}-modal-mask`,onClick:i.onClose},null),o.createVNode("div",{class:n.value,style:K(K({},s.initPos),d.value),ref:l},[o.createVNode("div",{class:`${c}-modal-header`,ref:r},[u||""]),o.createVNode("div",{class:`${c}-modal-body`},[h]),o.createVNode("div",{class:`${c}-modal-func`},[i.showAdjust&&o.createVNode("div",{class:`${c}-modal-adjust`,onClick:m=>{m.stopPropagation(),i.isFullscreen?s.initPos=s.historyPos:(s.historyPos=s.initPos,s.initPos={left:"0",top:"0"}),i.onAdjust(!i.isFullscreen)}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.isFullscreen?"suoxiao":"fangda"}`},null)])]),o.createVNode("div",{class:`${c}-modal-close`,onClick:m=>{m.stopPropagation(),i.onClose&&i.onClose()}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-close"},null)])])])])])}}});const Rt=()=>({type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var Ht=o.defineComponent({props:Rt(),setup(i){const t=o.inject("usedLanguageText"),e=o.inject("editorId"),n=o.computed(()=>{var r,a,s,d;switch(i.type){case"link":return`${(r=t.value.linkModalTips)==null?void 0:r.title}${(a=t.value.toolbarTips)==null?void 0:a.link}`;case"image":return`${(s=t.value.linkModalTips)==null?void 0:s.title}${(d=t.value.toolbarTips)==null?void 0:d.image}`;default:return""}}),l=o.reactive({desc:"",url:""});return o.watch(()=>i.visible,r=>{r||setTimeout(()=>{l.desc="",l.url=""},200)}),()=>o.createVNode(De,{title:n.value,visible:i.visible,onClose:i.onCancel},{default:()=>{var r,a,s,d,h;return[o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("label",{class:`${c}-lable`,for:`link-desc-${e}`},[(r=t.value.linkModalTips)==null?void 0:r.descLable]),o.createVNode("input",{placeholder:(a=t.value.linkModalTips)==null?void 0:a.descLablePlaceHolder,class:`${c}-input`,id:`link-desc-${e}`,type:"text",value:l.desc,onChange:u=>{l.desc=u.target.value},autocomplete:"off"},null)]),o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("label",{class:`${c}-lable`,for:`link-url-${e}`},[(s=t.value.linkModalTips)==null?void 0:s.urlLable]),o.createVNode("input",{placeholder:(d=t.value.linkModalTips)==null?void 0:d.urlLablePlaceHolder,class:`${c}-input`,id:`link-url-${e}`,type:"text",value:l.url,onChange:u=>{l.url=u.target.value},autocomplete:"off"},null)]),o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("button",{class:[`${c}-btn`,`${c}-btn-row`],type:"button",onClick:()=>{i.onOk(l),l.desc="",l.url=""}},[(h=t.value.linkModalTips)==null?void 0:h.buttonOK])])]}})}}),li="";const Pt=()=>({visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var Ot=o.defineComponent({props:Pt(),setup(i){var u,m;const t=o.inject("usedLanguageText"),e=o.inject("editorId");let n=(m=(u=M==null?void 0:M.editorExtensions)==null?void 0:u.cropper)==null?void 0:m.instance;const l=o.ref(),r=o.ref(),a=o.ref(),s=o.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let d=null;o.watch(()=>i.visible,()=>{i.visible&&!s.cropperInited&&(n=n||window.Cropper,l.value.onchange=()=>{if(!n){C.emit(e,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const k=l.value.files||[];if(s.imgSelected=!0,(k==null?void 0:k.length)>0){const f=new FileReader;f.onload=$=>{s.imgSrc=$.target.result,o.nextTick(()=>{d=new n(r.value,{viewMode:2,preview:`.${c}-clip-preview-target`})})},f.readAsDataURL(k[0])}})}),o.watch(()=>[s.imgSelected],()=>{a.value.style=""}),o.watch(()=>s.isFullscreen,()=>{o.nextTick(()=>{d==null||d.destroy(),a.value.style="",r.value&&(d=new n(r.value,{viewMode:2,preview:`.${c}-clip-preview-target`}))})});const h=()=>{d.clear(),d.destroy(),d=null,l.value.value="",s.imgSelected=!1};return()=>{var k;return o.createVNode(De,{title:(k=t.value.clipModalTips)==null?void 0:k.title,visible:i.visible,onClose:i.onCancel,showAdjust:!0,isFullscreen:s.isFullscreen,onAdjust:f=>{s.isFullscreen=f},width:"668px",height:"421px"},{default:()=>{var f;return[o.createVNode("div",{class:`${c}-form-item ${c}-clip`},[o.createVNode("div",{class:`${c}-clip-main`},[s.imgSelected?o.createVNode("div",{class:`${c}-clip-cropper`},[o.createVNode("img",{src:s.imgSrc,ref:r,style:{display:"none"}},null),o.createVNode("div",{class:`${c}-clip-delete`,onClick:h},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):o.createVNode("div",{class:`${c}-clip-upload`,onClick:()=>{l.value.click()}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),o.createVNode("div",{class:`${c}-clip-preview`},[o.createVNode("div",{class:`${c}-clip-preview-target`,ref:a},null)])]),o.createVNode("div",{class:`${c}-form-item`},[o.createVNode("button",{class:`${c}-btn`,type:"button",onClick:()=>{if(d){const $=d.getCroppedCanvas();C.emit(e,"uploadImage",[St($.toDataURL("image/png"))],i.onOk),h()}}},[(f=t.value.linkModalTips)==null?void 0:f.buttonOK])]),o.createVNode("input",{ref:l,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}});const Mt=()=>({type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var Bt=o.defineComponent({props:Mt(),setup(i){return()=>o.createVNode(o.Fragment,null,[o.createVNode(Ht,{type:i.type,visible:i.linkVisible,onOk:i.onOk,onCancel:i.onCancel},null),o.createVNode(Ot,{visible:i.clipVisible,onOk:i.onOk,onCancel:i.onCancel},null)])}});const Ut=i=>{var h,u,m,k;const t=o.inject("editorId"),e=o.inject("previewOnly");let n=(u=(h=M.editorExtensions)==null?void 0:h.screenfull)==null?void 0:u.instance;const l=(k=(m=M.editorExtensions)==null?void 0:m.screenfull)==null?void 0:k.js,r=o.ref(!1),a=()=>{if(!n){C.emit(t,"errorCatcher",{name:"fullScreen",message:"fullScreen is undefined"});return}n.isEnabled?(r.value=!0,n.isFullscreen?n.exit():n.request()):console.error("browser does not support screenfull!")},s=()=>{n&&n.isEnabled&&n.on("change",()=>{(r.value||i.setting.fullscreen)&&(r.value=!1,i.updateSetting(!i.setting.fullscreen,"fullscreen"))})},d=()=>{n=window.screenfull,s()};return o.onMounted(()=>{if(s(),!e&&!n){const f=document.createElement("script");f.src=l||wt,f.onload=d,f.id=`${c}-screenfull`,Q(f,"screenfull")}}),{fullScreenHandler:a}},qt=()=>({tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}}),Kt=o.defineComponent({name:"TableShape",props:qt(),setup(i){const t=o.reactive({x:-1,y:-1});return()=>o.createVNode("div",{class:`${c}-table-shape`,onMouseleave:()=>{t.x=-1,t.y=-1}},[new Array(i.tableShape[1]).fill("").map((e,n)=>o.createVNode("div",{class:`${c}-table-shape-row`,key:`table-shape-row-${n}`},[new Array(i.tableShape[0]).fill("").map((l,r)=>o.createVNode("div",{class:`${c}-table-shape-col`,key:`table-shape-col-${r}`,onMouseenter:()=>{t.x=n,t.y=r},onClick:()=>{i.onSelected(t)}},[o.createVNode("div",{class:[`${c}-table-shape-col-default`,n<=t.x&&r<=t.y&&`${c}-table-shape-col-include`]},null)]))]))])}}),Zt=()=>({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}});var Wt=o.defineComponent({name:"MDEditorToolbar",props:Zt(),setup(i){const t=o.inject("editorId"),e=o.inject("usedLanguageText"),{fullScreenHandler:n}=Ut(i),l=`${t}-toolbar-wrapper`,r=o.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),a=(f,$)=>{C.emit(t,"replace",f,$)},s=o.reactive({type:"link",linkVisible:!1,clipVisible:!1}),d=o.ref();o.onMounted(()=>{C.on(t,{name:"openModals",callback(f){s.type=f,s.linkVisible=!0}})});const h=o.computed(()=>{const f=i.toolbars.filter(b=>!i.toolbarsExclude.includes(b)),$=f.indexOf("="),v=$===-1?f:f.slice(0,$+1),w=$===-1?[]:f.slice($,Number.MAX_SAFE_INTEGER);return[v,w]}),u=o.ref(),m=()=>{C.emit(t,"uploadImage",Array.from(u.value.files||[])),u.value.value=""};o.onMounted(()=>{u.value.addEventListener("change",m)});const k=f=>{var $,v,w,b,y,E,A,F,H,L,g,q,j,D,N,p,S,z,I,P,B,Z,W,ce,Ce,Se,Ee,ie,Ne,Te,oe,Ve,ze,me,ge,Ie,Ae,de,Le,Fe,pe,gt,pt;if(Ue.includes(f))switch(f){case"-":return o.createVNode(jt,null,null);case"bold":return o.createVNode("div",{class:`${c}-toolbar-item`,title:($=e.value.toolbarTips)==null?void 0:$.bold,onClick:()=>{a("bold")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(v=e.value.toolbarTips)==null?void 0:v.underline,onClick:()=>{a("underline")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(w=e.value.toolbarTips)==null?void 0:w.italic,onClick:()=>{a("italic")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(b=e.value.toolbarTips)==null?void 0:b.strikeThrough,onClick:()=>{a("strikeThrough")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return o.createVNode(re,{relative:`#${l}`,visible:r.title,onChange:_=>{r.title=_},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.title=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("h1")}},[(y=e.value.titleItem)==null?void 0:y.h1]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("h2")}},[(E=e.value.titleItem)==null?void 0:E.h2]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("h3")}},[(A=e.value.titleItem)==null?void 0:A.h3]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("h4")}},[(F=e.value.titleItem)==null?void 0:F.h4]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("h5")}},[(H=e.value.titleItem)==null?void 0:H.h5]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("h6")}},[(L=e.value.titleItem)==null?void 0:L.h6])])},{default:()=>{var _;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(_=e.value.toolbarTips)==null?void 0:_.title},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(g=e.value.toolbarTips)==null?void 0:g.sub,onClick:()=>{a("sub")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(q=e.value.toolbarTips)==null?void 0:q.sup,onClick:()=>{a("sup")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(j=e.value.toolbarTips)==null?void 0:j.quote,onClick:()=>{a("quote")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(D=e.value.toolbarTips)==null?void 0:D.unorderedList,onClick:()=>{a("unorderedList")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(N=e.value.toolbarTips)==null?void 0:N.orderedList,onClick:()=>{a("orderedList")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(p=e.value.toolbarTips)==null?void 0:p.task,onClick:()=>{a("task")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(S=e.value.toolbarTips)==null?void 0:S.codeRow,onClick:()=>{a("codeRow")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(z=e.value.toolbarTips)==null?void 0:z.code,onClick:()=>{a("code")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(I=e.value.toolbarTips)==null?void 0:I.link,onClick:()=>{s.type="link",s.linkVisible=!0}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return i.noUploadImg?o.createVNode("div",{class:`${c}-toolbar-item`,title:(P=e.value.toolbarTips)==null?void 0:P.image,onClick:()=>{s.type="image",s.linkVisible=!0}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):o.createVNode(re,{relative:`#${l}`,visible:r.image,onChange:_=>{r.image=_},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.title=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s.type="image",s.linkVisible=!0}},[(B=e.value.imgTitleItem)==null?void 0:B.link]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{u.value.click()}},[(Z=e.value.imgTitleItem)==null?void 0:Z.upload]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{s.clipVisible=!0}},[(W=e.value.imgTitleItem)==null?void 0:W.clip2upload])])},{default:()=>{var _;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(_=e.value.toolbarTips)==null?void 0:_.image},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return o.createVNode(re,{relative:`#${l}`,visible:r.table,onChange:_=>{r.table=_},key:"bar-table",overlay:o.createVNode(Kt,{tableShape:i.tableShape,onSelected:_=>{a("table",{selectedShape:_})}},null)},{default:()=>{var _;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(_=e.value.toolbarTips)==null?void 0:_.table},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(ce=e.value.toolbarTips)==null?void 0:ce.revoke,onClick:()=>{C.emit(t,"ctrlZ")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ce=e.value.toolbarTips)==null?void 0:Ce.next,onClick:()=>{C.emit(t,"ctrlShiftZ")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Se=e.value.toolbarTips)==null?void 0:Se.save,onClick:()=>{C.emit(t,"onSave")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return i.noPrettier?"":o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ee=e.value.toolbarTips)==null?void 0:Ee.prettier,onClick:()=>{a("prettier")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!i.setting.fullscreen&&o.createVNode("div",{class:`${c}-toolbar-item`,title:(ie=e.value.toolbarTips)==null?void 0:ie.pageFullscreen,onClick:()=>{i.updateSetting(!i.setting.pageFullScreen,"pageFullScreen")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.setting.pageFullScreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ne=e.value.toolbarTips)==null?void 0:Ne.fullscreen,onClick:n},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.setting.fullscreen?"fullScreen-exit":"fullScreen"}`},null)])]);case"preview":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Te=e.value.toolbarTips)==null?void 0:Te.preview,onClick:()=>{i.updateSetting(!i.setting.preview,"preview")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(oe=e.value.toolbarTips)==null?void 0:oe.htmlPreview,onClick:()=>{i.updateSetting(!i.setting.htmlPreview,"htmlPreview")}},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(Ve=e.value.toolbarTips)==null?void 0:Ve.catalog,onClick:()=>{C.emit(t,"catalogShow")},key:"bar-catalog"},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return o.createVNode("div",{class:`${c}-toolbar-item`,title:(ze=e.value.toolbarTips)==null?void 0:ze.github,onClick:()=>Ct("https://github.com/imzbf/md-editor-v3")},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return o.createVNode(re,{relative:`#${l}`,visible:r.mermaid,onChange:_=>{r.mermaid=_},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.mermaid=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("flow")}},[(me=e.value.mermaid)==null?void 0:me.flow]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("sequence")}},[(ge=e.value.mermaid)==null?void 0:ge.sequence]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("gantt")}},[(Ie=e.value.mermaid)==null?void 0:Ie.gantt]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("class")}},[(Ae=e.value.mermaid)==null?void 0:Ae.class]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("state")}},[(de=e.value.mermaid)==null?void 0:de.state]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("pie")}},[(Le=e.value.mermaid)==null?void 0:Le.pie]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("relationship")}},[(Fe=e.value.mermaid)==null?void 0:Fe.relationship]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("journey")}},[(pe=e.value.mermaid)==null?void 0:pe.journey])]),key:"bar-mermaid"},{default:()=>{var _;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(_=e.value.toolbarTips)==null?void 0:_.mermaid},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return o.createVNode(re,{relative:`#${l}`,visible:r.katex,onChange:_=>{r.katex=_},overlay:o.createVNode("ul",{class:`${c}-menu`,onClick:()=>{r.katex=!1}},[o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("katexInline")}},[(gt=e.value.katex)==null?void 0:gt.inline]),o.createVNode("li",{class:`${c}-menu-item`,onClick:()=>{a("katexBlock")}},[(pt=e.value.katex)==null?void 0:pt.block])]),key:"bar-katex"},{default:()=>{var _;return[o.createVNode("div",{class:`${c}-toolbar-item`,title:(_=e.value.toolbarTips)==null?void 0:_.katex},[o.createVNode("svg",{class:`${c}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return i.defToolbars instanceof Array?i.defToolbars[f]||"":i.defToolbars&&i.defToolbars.children instanceof Array&&i.defToolbars.children[f]||""};return()=>{const f=h.value[0].map(v=>k(v)),$=h.value[1].map(v=>k(v));return o.createVNode("div",{class:`${c}-toolbar-wrapper`,id:l},[o.createVNode("div",{class:`${c}-toolbar`,onMouseenter:()=>{C.emit(t,"selectTextChange")}},[o.createVNode("div",{class:`${c}-toolbar-left`,ref:d},[f]),o.createVNode("div",{class:`${c}-toolbar-right`},[$])]),o.createVNode("input",{ref:u,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),o.createVNode(Bt,{linkVisible:s.linkVisible,clipVisible:s.clipVisible,type:s.type,onCancel:()=>{s.linkVisible=!1,s.clipVisible=!1},onOk:v=>{v&&a(s.type,{desc:v.desc,url:v.url}),s.linkVisible=!1,s.clipVisible=!1}},null)])}}});function Je(){return{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,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let ae=Je();function Gt(i){ae=i}const Qt=/[&<>"']/,Xt=/[&<>"']/g,Yt=/[<>"']|&(?!#?\w+;)/,Jt=/[<>"']|&(?!#?\w+;)/g,en={"&":"&","<":"<",">":">",'"':""","'":"'"},et=i=>en[i];function U(i,t){if(t){if(Qt.test(i))return i.replace(Xt,et)}else if(Yt.test(i))return i.replace(Jt,et);return i}const tn=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function tt(i){return i.replace(tn,(t,e)=>(e=e.toLowerCase(),e==="colon"?":":e.charAt(0)==="#"?e.charAt(1)==="x"?String.fromCharCode(parseInt(e.substring(2),16)):String.fromCharCode(+e.substring(1)):""))}const nn=/(^|[^\[])\^/g;function R(i,t){i=typeof i=="string"?i:i.source,t=t||"";const e={replace:(n,l)=>(l=l.source||l,l=l.replace(nn,"$1"),i=i.replace(n,l),e),getRegex:()=>new RegExp(i,t)};return e}const ln=/[^\w:]/g,on=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function nt(i,t,e){if(i){let n;try{n=decodeURIComponent(tt(e)).replace(ln,"").toLowerCase()}catch{return null}if(n.indexOf("javascript:")===0||n.indexOf("vbscript:")===0||n.indexOf("data:")===0)return null}t&&!on.test(e)&&(e=cn(t,e));try{e=encodeURI(e).replace(/%25/g,"%")}catch{return null}return e}const be={},rn=/^[^:]+:\/*[^/]*$/,an=/^([^:]+:)[\s\S]*$/,sn=/^([^:]+:\/*[^/]*)[\s\S]*$/;function cn(i,t){be[" "+i]||(rn.test(i)?be[" "+i]=i+"/":be[" "+i]=we(i,"/",!0)),i=be[" "+i];const e=i.indexOf(":")===-1;return t.substring(0,2)==="//"?e?t:i.replace(an,"$1")+t:t.charAt(0)==="/"?e?t:i.replace(sn,"$1")+t:i+t}const ye={exec:function(){}};function Y(i){let t=1,e,n;for(;t<arguments.length;t++){e=arguments[t];for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n])}return i}function it(i,t){const e=i.replace(/\|/g,(r,a,s)=>{let d=!1,h=a;for(;--h>=0&&s[h]==="\\";)d=!d;return d?"|":" |"}),n=e.split(/ \|/);let l=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;l<n.length;l++)n[l]=n[l].trim().replace(/\\\|/g,"|");return n}function we(i,t,e){const n=i.length;if(n===0)return"";let l=0;for(;l<n;){const r=i.charAt(n-l-1);if(r===t&&!e)l++;else if(r!==t&&e)l++;else break}return i.slice(0,n-l)}function dn(i,t){if(i.indexOf(t[1])===-1)return-1;const e=i.length;let n=0,l=0;for(;l<e;l++)if(i[l]==="\\")l++;else if(i[l]===t[0])n++;else if(i[l]===t[1]&&(n--,n<0))return l;return-1}function lt(i){i&&i.sanitize&&!i.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 ot(i,t){if(t<1)return"";let e="";for(;t>1;)t&1&&(e+=i),t>>=1,i+=i;return e+i}function rt(i,t,e,n){const l=t.href,r=t.title?U(t.title):null,a=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const s={type:"link",raw:e,href:l,title:r,text:a,tokens:n.inlineTokens(a,[])};return n.state.inLink=!1,s}return{type:"image",raw:e,href:l,title:r,text:U(a)}}function un(i,t){const e=i.match(/^(\s+)(?:```)/);if(e===null)return t;const n=e[1];return t.split(`
|
|
1
|
+
(function(o,d){typeof exports=="object"&&typeof module!="undefined"?module.exports=d(require("vue")):typeof define=="function"&&define.amd?define(["vue"],d):(o=typeof globalThis!="undefined"?globalThis:o||self,o.MdEditorV3=d(o.Vue))})(this,function(o){"use strict";var oi=Object.defineProperty,ri=Object.defineProperties;var ai=Object.getOwnPropertyDescriptors;var Et=Object.getOwnPropertySymbols;var si=Object.prototype.hasOwnProperty,ci=Object.prototype.propertyIsEnumerable;var St=(o,d,W)=>d in o?oi(o,d,{enumerable:!0,configurable:!0,writable:!0,value:W}):o[d]=W,K=(o,d)=>{for(var W in d||(d={}))si.call(d,W)&&St(o,W,d[W]);if(Et)for(var W of Et(d))ci.call(d,W)&&St(o,W,d[W]);return o},ue=(o,d)=>ri(o,ai(d));const d="md-editor",W="https://at.alicdn.com/t/c/font_2605852_gymddm8qwtd.js",O="https://cdnjs.cloudflare.com/ajax/libs",Nt=`${O}/highlight.js/11.5.1/highlight.min.js`,Ue={main:`${O}/prettier/2.4.0/standalone.js`,markdown:`${O}/prettier/2.4.0/parser-markdown.js`},qe={css:`${O}/cropperjs/1.5.12/cropper.min.css`,js:`${O}/cropperjs/1.5.12/cropper.min.js`},Tt=`${O}/screenfull.js/5.1.0/screenfull.min.js`,Ke=["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"],Ze=["markdownTotal","=","scrollSwitch"],Ge={"zh-CN":{toolbarTips:{bold:"\u52A0\u7C97",underline:"\u4E0B\u5212\u7EBF",italic:"\u659C\u4F53",strikeThrough:"\u5220\u9664\u7EBF",title:"\u6807\u9898",sub:"\u4E0B\u6807",sup:"\u4E0A\u6807",quote:"\u5F15\u7528",unorderedList:"\u65E0\u5E8F\u5217\u8868",orderedList:"\u6709\u5E8F\u5217\u8868",task:"\u4EFB\u52A1\u5217\u8868",codeRow:"\u884C\u5185\u4EE3\u7801",code:"\u5757\u7EA7\u4EE3\u7801",link:"\u94FE\u63A5",image:"\u56FE\u7247",table:"\u8868\u683C",mermaid:"mermaid\u56FE",katex:"katex\u516C\u5F0F",revoke:"\u540E\u9000",next:"\u524D\u8FDB",save:"\u4FDD\u5B58",prettier:"\u7F8E\u5316",pageFullscreen:"\u6D4F\u89C8\u5668\u5168\u5C4F",fullscreen:"\u5C4F\u5E55\u5168\u5C4F",preview:"\u9884\u89C8",htmlPreview:"html\u4EE3\u7801\u9884\u89C8",catalog:"\u76EE\u5F55",github:"\u6E90\u7801\u5730\u5740"},titleItem:{h1:"\u4E00\u7EA7\u6807\u9898",h2:"\u4E8C\u7EA7\u6807\u9898",h3:"\u4E09\u7EA7\u6807\u9898",h4:"\u56DB\u7EA7\u6807\u9898",h5:"\u4E94\u7EA7\u6807\u9898",h6:"\u516D\u7EA7\u6807\u9898"},imgTitleItem:{link:"\u6DFB\u52A0\u94FE\u63A5",upload:"\u4E0A\u4F20\u56FE\u7247",clip2upload:"\u88C1\u526A\u4E0A\u4F20"},linkModalTips:{linkTitle:"\u6DFB\u52A0\u94FE\u63A5",imageTitle:"\u6DFB\u52A0\u56FE\u7247",descLabel:"\u94FE\u63A5\u63CF\u8FF0\uFF1A",descLabelPlaceHolder:"\u8BF7\u8F93\u5165\u63CF\u8FF0...",urlLabel:"\u94FE\u63A5\u5730\u5740\uFF1A",urlLabelPlaceHolder:"\u8BF7\u8F93\u5165\u94FE\u63A5...",buttonOK:"\u786E\u5B9A"},clipModalTips:{title:"\u88C1\u526A\u56FE\u7247\u4E0A\u4F20",buttonUpload:"\u4E0A\u4F20"},copyCode:{text:"\u590D\u5236\u4EE3\u7801",successTips:"\u5DF2\u590D\u5236\uFF01",failTips:"\u590D\u5236\u5931\u8D25\uFF01"},mermaid:{flow:"\u6D41\u7A0B\u56FE",sequence:"\u65F6\u5E8F\u56FE",gantt:"\u7518\u7279\u56FE",class:"\u7C7B\u56FE",state:"\u72B6\u6001\u56FE",pie:"\u997C\u56FE",relationship:"\u5173\u7CFB\u56FE",journey:"\u65C5\u7A0B\u56FE"},katex:{inline:"\u884C\u5185\u516C\u5F0F",block:"\u5757\u7EA7\u516C\u5F0F"},footer:{markdownTotal:"\u5B57\u6570",scrollAuto:"\u540C\u6B65\u6EDA\u52A8"}},"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=`${O}/mermaid/8.13.5/mermaid.min.js`,We={js:`${O}/KaTeX/0.15.1/katex.min.js`,css:`${O}/KaTeX/0.15.1/katex.min.css`},Qe={a11y:{light:`${O}/highlight.js/11.5.1/styles/a11y-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/a11y-dark.min.css`},atom:{light:`${O}/highlight.js/11.5.1/styles/atom-one-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/atom-one-dark.min.css`},github:{light:`${O}/highlight.js/11.5.1/styles/github.min.css`,dark:`${O}/highlight.js/11.5.1/styles/github-dark.min.css`},gradient:{light:`${O}/highlight.js/11.5.1/styles/gradient-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/gradient-dark.min.css`},kimbie:{light:`${O}/highlight.js/11.5.1/styles/kimbie-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/kimbie-dark.min.css`},paraiso:{light:`${O}/highlight.js/11.5.1/styles/paraiso-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/paraiso-dark.min.css`},qtcreator:{light:`${O}/highlight.js/11.5.1/styles/qtcreator-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/qtcreator-dark.min.css`},stackoverflow:{light:`${O}/highlight.js/11.5.1/styles/stackoverflow-light.min.css`,dark:`${O}/highlight.js/11.5.1/styles/stackoverflow-dark.min.css`}},M={markedRenderer:i=>i,markedExtensions:[],markedOptions:{},editorExtensions:{},editorConfig:{}},zt=i=>{if(i)for(const e in i){const t=i[e];t&&(M[e]=t)}};class It{constructor(){this.pools={}}remove(e,t,n){const r=this.pools[e]&&this.pools[e][t];r&&(this.pools[e][t]=r.filter(a=>a!==n))}clear(e){this.pools[e]={}}on(e,t){return this.pools[e]||(this.pools[e]={}),this.pools[e][t.name]||(this.pools[e][t.name]=[]),this.pools[e][t.name].push(t.callback),this.pools[e][t.name].includes(t.callback)}emit(e,t,...n){this.pools[e]||(this.pools[e]={});const r=this.pools[e][t];r&&r.forEach(a=>{try{a(...n)}catch(s){console.error(`${t} monitor event exception\uFF01`,s)}})}}var y=new It;const J=(i,e=0,t=e)=>new Promise((n,l)=>{i.setSelectionRange?setTimeout(()=>{i.setSelectionRange(e,t),i.focus(),n(!0)},0):(console.error("Can not reset position!"),l())}),je=(i,e,t)=>{const{deviationStart:n=0,deviationEnd:l=0,direct:r=!1,select:a=!1}=t;let s="";if(i.selectionStart||i.selectionStart===0){const c=i.selectionStart,u=i.selectionEnd||0,{prefixVal:h=i.value.substring(0,c),subfixVal:m=i.value.substring(u,i.value.length)}=t;s=h+e+m,J(i,a?c+n:c+e.length+l,c+e.length+l)}else s+=e;return r&&(i.value=s),s},Ft=(i,e={newWindow:!0,nofollow:!0})=>{i||console.error("error link!");const t=document.createElement("a");t.href=i,t.style.display="none",e.newWindow&&(t.target="_blank"),e.nofollow&&(t.rel="noopener noreferrer"),document.body.appendChild(t),t.click(),document.body.removeChild(t)},Xe=(i,e)=>{const t=ke(()=>{i.removeEventListener("scroll",n),i.addEventListener("scroll",n),e.removeEventListener("scroll",n),e.addEventListener("scroll",n)},50),n=l=>{const r=i.clientHeight,a=e.clientHeight,s=i.scrollHeight,c=e.scrollHeight,u=(s-r)/(c-a);l.target===i?(e.removeEventListener("scroll",n),e.scrollTo({top:i.scrollTop/u}),t()):(i.removeEventListener("scroll",n),i.scrollTo({top:e.scrollTop*u}),t())};return[t,()=>{i.removeEventListener("scroll",n),e.removeEventListener("scroll",n)}]},At=(i,e="image.png")=>{const t=i.split(","),n=t[0].match(/:(.*?);/);if(n){const l=n[1],r=atob(t[1]);let a=r.length;const s=new Uint8Array(a);for(;a--;)s[a]=r.charCodeAt(a);return new File([s],e,{type:l})}return null},Ye=i=>{if(!i.trim())return i;const e=i.split(`
|
|
2
|
+
`),t=['<span rn-wrapper aria-hidden="true">'];return e.forEach(()=>{t.push("<span></span>")}),t.push("</span>"),`<span class="code-block">${i}</span>${t.join("")}`},ke=(i,e=200)=>{let t=0;return(...n)=>{t&&clearTimeout(t),t=window.setTimeout(()=>{i.apply(globalThis,n),t=0},e)}},Lt=(i,e=200)=>{let t=0,n=null;return(...l)=>{const r=a=>{t===0&&(t=a),a-t>=e?(i.apply(globalThis,n),n=null,t=0):window.requestAnimationFrame(r)};n===null&&window.requestAnimationFrame(r),n=l}},Je=(i,e="$")=>{const t=i.split(e);let n=e,l="";for(let r=1;r<t.length;r++)if(/\\$/.test(t[r]))n+=t[r]+"$",l+=t[r]+"$";else{n+=t[r]+e,l+=t[r];break}return[n,l]},_t=i=>{var t;return navigator.userAgent.indexOf("Firefox")>-1?i.value.substring(i.selectionStart,i.selectionEnd):((t=window.getSelection())==null?void 0:t.toString())||""},jt=(i,e)=>{const t=i==null?void 0:i.getBoundingClientRect();if(e===document.documentElement)return t.top-e.clientTop;const n=e==null?void 0:e.getBoundingClientRect();return t.top-n.top},et=(i,e)=>{const t=n=>{const l=i.parentElement||document.body,r=l.offsetWidth,a=l.offsetHeight,{clientWidth:s}=document.documentElement,{clientHeight:c}=document.documentElement,u=n.offsetX,h=n.offsetY,m=f=>{let $=f.x+document.body.scrollLeft-document.body.clientLeft-u,x=f.y+document.body.scrollTop-document.body.clientTop-h;$=$<1?1:$<s-r-1?$:s-r-1,x=x<1?1:x<c-a-1?x:c-a-1,e?e($,x):(l.style.left=`${$}px`,l.style.top=`${x}px`)};document.addEventListener("mousemove",m);const p=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)};document.addEventListener("mouseup",p)};return i.addEventListener("mousedown",t),()=>{i.removeEventListener("mousedown",t)}},Q=(i,e="")=>{const t=document.getElementById(i.id);t?e!==""&&i.onload instanceof Function&&(Reflect.get(window,e)?i.onload(new Event("load")):t.addEventListener("load",i.onload)):document.head.appendChild(i)},Rt=ke((i,e,t)=>{const n=document.getElementById(i);n&&n.setAttribute(e,t)},10),be="onSave",Re="changeCatalogVisible",tt="changeFullscreen",nt="pageFullscreenChanged",it="fullscreenChanged",lt="previewChanged",ot="htmlPreviewChanged",rt="catalogVisibleChanged",Dt=(i,e)=>{const{editorId:t,noPrettier:n,previewOnly:l}=i,r=o.reactive({buildFinished:!1,html:""}),a=c=>{var u,h;return((u=i.toolbars)==null?void 0:u.includes(c))&&!((h=i.toolbarsExclude)!=null&&h.includes(c))},s=c=>{if(c.target===document.querySelector(`#${i.editorId}-textarea`))if(y.emit(t,"selectTextChange"),c.ctrlKey||c.metaKey)switch(c.code){case"KeyS":{c.shiftKey?a("strikeThrough")&&y.emit(t,"replace","strikeThrough"):a("save")&&(y.emit(t,be,i.modelValue),c.preventDefault());break}case"KeyB":{a("bold")&&(y.emit(t,"replace","bold"),c.preventDefault());break}case"KeyU":{c.shiftKey?a("unorderedList")&&(y.emit(t,"replace","unorderedList"),c.preventDefault()):a("underline")&&(y.emit(t,"replace","underline"),c.preventDefault());break}case"KeyI":{c.shiftKey?a("image")&&(y.emit(t,"openModals","image"),c.preventDefault()):a("italic")&&(y.emit(t,"replace","italic"),c.preventDefault());break}case"Digit1":{a("title")&&(y.emit(t,"replace","h1"),c.preventDefault());break}case"Digit2":{a("title")&&(y.emit(t,"replace","h2"),c.preventDefault());break}case"Digit3":{a("title")&&(y.emit(t,"replace","h3"),c.preventDefault());break}case"Digit4":{a("title")&&(y.emit(t,"replace","h4"),c.preventDefault());break}case"Digit5":{a("title")&&(y.emit(t,"replace","h5"),c.preventDefault());break}case"Digit6":{a("title")&&(y.emit(t,"replace","h6"),c.preventDefault());break}case"ArrowUp":{a("sup")&&(y.emit(t,"replace","sup"),c.preventDefault());break}case"ArrowDown":{a("sub")&&(y.emit(t,"replace","sub"),c.preventDefault());break}case"KeyQ":{if(c.key==="a"){c.target.select();return}y.emit(t,"replace","quote"),c.preventDefault();break}case"KeyA":if(c.key==="q"){y.emit(t,"replace","quote"),c.preventDefault();break}else return;case"KeyO":{a("orderedList")&&(y.emit(t,"replace","orderedList"),c.preventDefault());break}case"KeyC":{if(c.shiftKey)a("code")&&(y.emit(t,"replace","code"),c.preventDefault());else if(c.altKey)a("codeRow")&&(y.emit(t,"replace","codeRow"),c.preventDefault());else{c.preventDefault(),y.emit(t,"replace","ctrlC");break}break}case"KeyL":{a("link")&&(y.emit(t,"openModals","link"),c.preventDefault());break}case"KeyZ":{if(c.key==="w")return;c.shiftKey?a("next")&&(y.emit(t,"ctrlShiftZ"),c.preventDefault()):a("revoke")&&(y.emit(t,"ctrlZ"),c.preventDefault());break}case"KeyW":if(c.key==="z"){c.shiftKey?a("next")&&(y.emit(t,"ctrlShiftZ"),c.preventDefault()):a("revoke")&&(y.emit(t,"ctrlZ"),c.preventDefault());break}else return;case"KeyF":{c.shiftKey&&a("prettier")&&!n&&(y.emit(t,"replace","prettier"),c.preventDefault());break}case"KeyT":{c.altKey&&c.shiftKey&&a("table")&&(y.emit(t,"replace","table"),c.preventDefault());break}case"KeyX":{y.emit(t,"replace","ctrlX"),c.preventDefault();break}case"KeyD":{c.preventDefault(),y.emit(t,"replace","ctrlD");break}}else c.code==="Tab"&&(c.preventDefault(),c.shiftKey?y.emit(t,"replace","shiftTab"):y.emit(t,"replace","tab"))};o.watch(()=>i.modelValue,()=>{r.buildFinished=!1}),o.onMounted(()=>{l||(window.addEventListener("keydown",s),y.on(t,{name:"buildFinished",callback(c){r.buildFinished=!0,r.html=c}}),y.on(t,{name:be,callback(){const c=new Promise(u=>{if(r.buildFinished)u(r.html);else{const h=m=>{u(m),y.remove(t,"buildFinished",h)};y.on(t,{name:"buildFinished",callback:h})}});i.onSave?i.onSave(i.modelValue,c):e.emit("onSave",i.modelValue,c)}}))}),o.onBeforeUnmount(()=>{l||window.removeEventListener("keydown",s)})},Ht=i=>{var r;const{editorId:e,previewOnly:t}=i,n=(r=M==null?void 0:M.editorExtensions)==null?void 0:r.highlight;o.provide("editorId",e),o.provide("tabWidth",i.tabWidth),o.provide("theme",o.computed(()=>i.theme)),o.provide("highlight",o.computed(()=>{const a=K(K({},Qe),n==null?void 0:n.css),s=i.codeStyleReverse&&i.codeStyleReverseList.includes(i.previewTheme)?"dark":i.theme;return{js:(n==null?void 0:n.js)||Nt,css:a[i.codeTheme]?a[i.codeTheme][s]:Qe.atom[s]}})),o.provide("historyLength",i.historyLength),o.provide("previewOnly",t),o.provide("showCodeRowNumber",i.showCodeRowNumber);const l=o.computed(()=>{var s;const a=K(K({},Ge),(s=M==null?void 0:M.editorConfig)==null?void 0:s.languageUserDefined);return a[i.language]?a[i.language]:Ge["zh-CN"]});o.provide("usedLanguageText",l),o.provide("previewTheme",o.computed(()=>i.previewTheme))},Pt=i=>{var u,h,m,p,f,$;const{noPrettier:e,previewOnly:t,noIconfont:n,noUploadImg:l}=i,{editorExtensions:r}=M,a=e||!!((h=(u=M.editorExtensions)==null?void 0:u.prettier)!=null&&h.prettierInstance),s=e||!!((p=(m=M.editorExtensions)==null?void 0:m.prettier)!=null&&p.parserMarkdownInstance),c=l||!!(($=(f=M.editorExtensions)==null?void 0:f.cropper)!=null&&$.instance);o.onMounted(()=>{var A,L,H,F;const x=document.createElement("script");x.src=(r==null?void 0:r.iconfont)||W,x.id=`${d}-icon`;const b=document.createElement("script"),w=document.createElement("script");b.src=((A=r==null?void 0:r.prettier)==null?void 0:A.standaloneJs)||Ue.main,b.id=`${d}-prettier`,w.src=((L=r==null?void 0:r.prettier)==null?void 0:L.parserMarkdownJs)||Ue.markdown,w.id=`${d}-prettierMD`;const v=document.createElement("link");v.rel="stylesheet",v.href=((H=r==null?void 0:r.cropper)==null?void 0:H.css)||qe.css,v.id=`${d}-cropperCss`;const S=document.createElement("script");S.src=((F=r==null?void 0:r.cropper)==null?void 0:F.js)||qe.js,S.id=`${d}-cropper`,t||(n||Q(x),c||(Q(v),Q(S)),a||Q(b),s||Q(w))})},Ot=(i,e)=>{const{editorId:t,previewOnly:n}=i,l=o.reactive({pageFullscreen:i.pageFullscreen,fullscreen:!1,preview:i.preview,htmlPreview:i.preview?!1:i.htmlPreview}),r=(c,u)=>{l[u]=c===void 0?!l[u]:c,u==="preview"&&l.preview?l.htmlPreview=!1:u==="htmlPreview"&&l.htmlPreview&&(l.preview=!1)};let a="";const s=()=>{l.pageFullscreen||l.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=a};return o.watch(()=>[l.pageFullscreen,l.fullscreen],s),o.onMounted(()=>{n||y.on(t,{name:"uploadImage",callback(c,u){const h=m=>{y.emit(t,"replace","image",{desc:"",urls:m}),u&&u()};i.onUploadImg?i.onUploadImg(c,h):e.emit("onUploadImg",c,h)}}),a=document.body.style.overflow,s()}),[l,r]},Mt=i=>{const{editorId:e}=i,t=o.ref(!1);o.onMounted(()=>{y.on(e,{name:Re,callback:l=>{l===void 0?t.value=!t.value:t.value=l}})});const n=o.computed(()=>!i.toolbarsExclude.includes("catalog")&&i.toolbars.includes("catalog"));return[t,n]},Bt=(i,e,t,n,l)=>{const{editorId:r}=i;o.watch(()=>n.pageFullscreen,s=>{y.emit(r,nt,s)}),o.watch(()=>n.fullscreen,s=>{y.emit(r,it,s)}),o.watch(()=>n.preview,s=>{y.emit(r,lt,s)}),o.watch(()=>n.htmlPreview,s=>{y.emit(r,ot,s)}),o.watch(t,s=>{y.emit(r,rt,s)});const a={on(s,c){switch(s){case"pageFullscreen":{y.on(r,{name:nt,callback(u){c(u)}});break}case"fullscreen":{y.on(r,{name:it,callback(u){c(u)}});break}case"preview":{y.on(r,{name:lt,callback(u){c(u)}});break}case"htmlPreview":{y.on(r,{name:ot,callback(u){c(u)}});break}case"catalog":{y.on(r,{name:rt,callback(u){c(u)}});break}}},togglePageFullscreen(s){l(s,"pageFullscreen")},toggleFullscreen(s){y.emit(r,tt,s)},togglePreview(s){l(s,"preview")},toggleHtmlPreview(s){l(s,"htmlPreview")},toggleCatalog(s){y.emit(r,Re,s)},triggerSave(){y.emit(r,be)},insert(s){y.emit(r,"replace","universal",{generate:s})}};e.expose(a)};var di="",Ut=o.defineComponent({setup(){return()=>o.createVNode("div",{class:`${d}-divider`},null)}});const X=({instance:i,ctx:e,props:t={}},n="default")=>{const l=(i==null?void 0:i.$slots[n])||(e==null?void 0:e.slots[n]);return(l?l(i):"")||t[n]};var ui="";const qt=()=>({trigger:{type:String,default:"hover"},overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>()=>{}},relative:{type:String,default:"html"}});var re=o.defineComponent({props:qt(),setup(i,e){const t=`${d}-dropdown-hidden`,n=o.reactive({overlayClass:[t],overlayStyle:{},triggerHover:!1,overlayHover:!1}),l=o.ref(),r=o.ref(),a=()=>{var S;i.trigger==="hover"&&(n.triggerHover=!0);const m=l.value,p=r.value,f=m.getBoundingClientRect(),$=m.offsetTop,x=m.offsetLeft,b=f.height,w=f.width,v=((S=document.querySelector(i.relative))==null?void 0:S.scrollLeft)||0;n.overlayStyle=ue(K({},n.overlayStyle),{top:$+b+"px",left:x-p.offsetWidth/2+w/2-v+"px"}),i.onChange(!0)},s=()=>{n.overlayHover=!0};o.watch(()=>i.visible,m=>{m?n.overlayClass=n.overlayClass.filter(p=>p!==t):n.overlayClass.push(t)});const c=m=>{const p=l.value,f=r.value;!p.contains(m.target)&&!f.contains(m.target)&&i.onChange(!1)};let u=-1;const h=m=>{l.value===m.target?n.triggerHover=!1:n.overlayHover=!1,clearTimeout(u),u=window.setTimeout(()=>{!n.overlayHover&&!n.triggerHover&&i.onChange(!1)},10)};return o.onMounted(()=>{i.trigger==="click"?(l.value.addEventListener("click",a),document.addEventListener("click",c)):(l.value.addEventListener("mouseenter",a),l.value.addEventListener("mouseleave",h),r.value.addEventListener("mouseenter",s),r.value.addEventListener("mouseleave",h))}),o.onBeforeUnmount(()=>{i.trigger==="click"?(l.value.removeEventListener("click",a),document.removeEventListener("click",c)):(l.value.removeEventListener("mouseenter",a),l.value.removeEventListener("mouseleave",h),r.value.removeEventListener("mouseenter",s),r.value.removeEventListener("mouseleave",h))}),()=>{const m=X({ctx:e}),p=X({props:i,ctx:e},"overlay"),f=o.cloneVNode(m instanceof Array?m[0]:m,{ref:l}),$=o.createVNode("div",{class:[`${d}-dropdown`,n.overlayClass],style:n.overlayStyle,ref:r},[o.createVNode("div",{class:`${d}-dropdown-overlay`},[p instanceof Array?p[0]:p])]);return[f,$]}}}),hi="";const Kt=()=>({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}});var De=o.defineComponent({props:Kt(),setup(i,e){const t=o.ref(i.visible),n=o.ref([`${d}-modal`]),l=o.ref(),r=o.ref();let a=()=>{};const s=o.reactive({initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),c=o.computed(()=>i.isFullscreen?{width:"100%",height:"100%"}:{width:i.width,height:i.height});return o.onMounted(()=>{a=et(r.value,(u,h)=>{s.initPos.left=u+"px",s.initPos.top=h+"px"})}),o.onBeforeUnmount(()=>{a()}),o.watch(()=>i.isFullscreen,u=>{u?a():a=et(r.value,(h,m)=>{s.initPos.left=h+"px",s.initPos.top=m+"px"})}),o.watch(()=>i.visible,u=>{u?(n.value.push("zoom-in"),t.value=u,o.nextTick(()=>{const h=l.value.offsetWidth/2,m=l.value.offsetHeight/2,p=document.documentElement.clientWidth/2,f=document.documentElement.clientHeight/2;s.initPos.left=p-h+"px",s.initPos.top=f-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=u},130))}),()=>{const u=X({ctx:e}),h=X({props:i,ctx:e},"title");return o.createVNode("div",{class:[i.class],style:{display:t.value?"block":"none"}},[o.createVNode("div",{class:`${d}-modal-mask`,onClick:i.onClose},null),o.createVNode("div",{class:n.value,style:K(K({},s.initPos),c.value),ref:l},[o.createVNode("div",{class:`${d}-modal-header`,ref:r},[h||""]),o.createVNode("div",{class:`${d}-modal-body`},[u]),o.createVNode("div",{class:`${d}-modal-func`},[i.showAdjust&&o.createVNode("div",{class:`${d}-modal-adjust`,onClick:m=>{m.stopPropagation(),i.isFullscreen?s.initPos=s.historyPos:(s.historyPos=s.initPos,s.initPos={left:"0",top:"0"}),i.onAdjust(!i.isFullscreen)}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.isFullscreen?"suoxiao":"fangda"}`},null)])]),o.createVNode("div",{class:`${d}-modal-close`,onClick:m=>{m.stopPropagation(),i.onClose&&i.onClose()}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-close"},null)])])])])])}}});const Zt=()=>({type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var Gt=o.defineComponent({props:Zt(),setup(i){const e=o.inject("usedLanguageText"),t=o.inject("editorId"),n=o.computed(()=>{var r,a;switch(i.type){case"link":return(r=e.value.linkModalTips)==null?void 0:r.linkTitle;case"image":return(a=e.value.linkModalTips)==null?void 0:a.imageTitle;default:return""}}),l=o.reactive({desc:"",url:""});return o.watch(()=>i.visible,r=>{r||setTimeout(()=>{l.desc="",l.url=""},200)}),()=>o.createVNode(De,{title:n.value,visible:i.visible,onClose:i.onCancel},{default:()=>{var r,a,s,c,u;return[o.createVNode("div",{class:`${d}-form-item`},[o.createVNode("label",{class:`${d}-label`,for:`link-desc-${t}`},[(r=e.value.linkModalTips)==null?void 0:r.descLabel]),o.createVNode("input",{placeholder:(a=e.value.linkModalTips)==null?void 0:a.descLabelPlaceHolder,class:`${d}-input`,id:`link-desc-${t}`,type:"text",value:l.desc,onChange:h=>{l.desc=h.target.value},autocomplete:"off"},null)]),o.createVNode("div",{class:`${d}-form-item`},[o.createVNode("label",{class:`${d}-label`,for:`link-url-${t}`},[(s=e.value.linkModalTips)==null?void 0:s.urlLabel]),o.createVNode("input",{placeholder:(c=e.value.linkModalTips)==null?void 0:c.urlLabelPlaceHolder,class:`${d}-input`,id:`link-url-${t}`,type:"text",value:l.url,onChange:h=>{l.url=h.target.value},autocomplete:"off"},null)]),o.createVNode("div",{class:`${d}-form-item`},[o.createVNode("button",{class:[`${d}-btn`,`${d}-btn-row`],type:"button",onClick:()=>{i.onOk(l),l.desc="",l.url=""}},[(u=e.value.linkModalTips)==null?void 0:u.buttonOK])])]}})}}),fi="";const Wt=()=>({visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var Qt=o.defineComponent({props:Wt(),setup(i){var h,m;const e=o.inject("usedLanguageText"),t=o.inject("editorId");let n=(m=(h=M==null?void 0:M.editorExtensions)==null?void 0:h.cropper)==null?void 0:m.instance;const l=o.ref(),r=o.ref(),a=o.ref(),s=o.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let c=null;o.watch(()=>i.visible,()=>{i.visible&&!s.cropperInited&&(n=n||window.Cropper,l.value.onchange=()=>{if(!n){y.emit(t,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const p=l.value.files||[];if(s.imgSelected=!0,(p==null?void 0:p.length)>0){const f=new FileReader;f.onload=$=>{s.imgSrc=$.target.result,o.nextTick(()=>{c=new n(r.value,{viewMode:2,preview:`.${d}-clip-preview-target`})})},f.readAsDataURL(p[0])}})}),o.watch(()=>[s.imgSelected],()=>{a.value.style=""}),o.watch(()=>s.isFullscreen,()=>{o.nextTick(()=>{c==null||c.destroy(),a.value.style="",r.value&&(c=new n(r.value,{viewMode:2,preview:`.${d}-clip-preview-target`}))})});const u=()=>{c.clear(),c.destroy(),c=null,l.value.value="",s.imgSelected=!1};return()=>{var p;return o.createVNode(De,{class:`${d}-modal-clip`,title:(p=e.value.clipModalTips)==null?void 0:p.title,visible:i.visible,onClose:i.onCancel,showAdjust:!0,isFullscreen:s.isFullscreen,onAdjust:f=>{s.isFullscreen=f},width:"668px",height:"421px"},{default:()=>{var f,$;return[o.createVNode("div",{class:`${d}-form-item ${d}-clip`},[o.createVNode("div",{class:`${d}-clip-main`},[s.imgSelected?o.createVNode("div",{class:`${d}-clip-cropper`},[o.createVNode("img",{src:s.imgSrc,ref:r,style:{display:"none"}},null),o.createVNode("div",{class:`${d}-clip-delete`,onClick:u},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):o.createVNode("div",{class:`${d}-clip-upload`,onClick:()=>{l.value.click()}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),o.createVNode("div",{class:`${d}-clip-preview`},[o.createVNode("div",{class:`${d}-clip-preview-target`,ref:a},null)])]),o.createVNode("div",{class:`${d}-form-item`},[o.createVNode("button",{class:`${d}-btn`,type:"button",onClick:()=>{if(c){const x=c.getCroppedCanvas();y.emit(t,"uploadImage",[At(x.toDataURL("image/png"))],i.onOk),u()}}},[((f=e.value.clipModalTips)==null?void 0:f.buttonUpload)||(($=e.value.linkModalTips)==null?void 0:$.buttonOK)])]),o.createVNode("input",{ref:l,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}});const Xt=()=>({type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>()=>{}},onOk:{type:Function,default:()=>()=>{}}});var Yt=o.defineComponent({props:Xt(),setup(i){return()=>o.createVNode(o.Fragment,null,[o.createVNode(Gt,{type:i.type,visible:i.linkVisible,onOk:i.onOk,onCancel:i.onCancel},null),o.createVNode(Qt,{visible:i.clipVisible,onOk:i.onOk,onCancel:i.onCancel},null)])}});const Jt=i=>{var u,h,m,p;const e=o.inject("editorId"),t=o.inject("previewOnly");let n=(h=(u=M.editorExtensions)==null?void 0:u.screenfull)==null?void 0:h.instance;const l=(p=(m=M.editorExtensions)==null?void 0:m.screenfull)==null?void 0:p.js,r=o.ref(!1),a=f=>{if(!n){y.emit(e,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}n.isEnabled?(r.value=!0,(f===void 0?!n.isFullscreen:!!f)?n.request():n.exit()):console.error("browser does not support screenfull!")},s=()=>{n&&n.isEnabled&&n.on("change",()=>{(r.value||i.setting.fullscreen)&&(r.value=!1,i.updateSetting(!i.setting.fullscreen,"fullscreen"))})},c=()=>{n=window.screenfull,s()};return o.onMounted(()=>{if(s(),!t&&!n){const f=document.createElement("script");f.src=l||Tt,f.onload=c,f.id=`${d}-screenfull`,Q(f,"screenfull")}}),o.onMounted(()=>{t||y.on(e,{name:tt,callback:a})}),{fullscreenHandler:a}},en=()=>({tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}}),tn=o.defineComponent({name:"TableShape",props:en(),setup(i){const e=o.reactive({x:-1,y:-1});return()=>o.createVNode("div",{class:`${d}-table-shape`,onMouseleave:()=>{e.x=-1,e.y=-1}},[new Array(i.tableShape[1]).fill("").map((t,n)=>o.createVNode("div",{class:`${d}-table-shape-row`,key:`table-shape-row-${n}`},[new Array(i.tableShape[0]).fill("").map((l,r)=>o.createVNode("div",{class:`${d}-table-shape-col`,key:`table-shape-col-${r}`,onMouseenter:()=>{e.x=n,e.y=r},onClick:()=>{i.onSelected(e)}},[o.createVNode("div",{class:[`${d}-table-shape-col-default`,n<=e.x&&r<=e.y&&`${d}-table-shape-col-include`]},null)]))]))])}}),nn=()=>({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}});var ln=o.defineComponent({name:"MDEditorToolbar",props:nn(),setup(i){const e=o.inject("editorId"),t=o.inject("usedLanguageText"),{fullscreenHandler:n}=Jt(i),l=`${e}-toolbar-wrapper`,r=o.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),a=(f,$)=>{y.emit(e,"replace",f,$)},s=o.reactive({type:"link",linkVisible:!1,clipVisible:!1}),c=o.ref();o.onMounted(()=>{y.on(e,{name:"openModals",callback(f){s.type=f,s.linkVisible=!0}})});const u=o.computed(()=>{const f=i.toolbars.filter(w=>!i.toolbarsExclude.includes(w)),$=f.indexOf("="),x=$===-1?f:f.slice(0,$+1),b=$===-1?[]:f.slice($,Number.MAX_SAFE_INTEGER);return[x,b]}),h=o.ref(),m=()=>{y.emit(e,"uploadImage",Array.from(h.value.files||[])),h.value.value=""};o.onMounted(()=>{h.value.addEventListener("change",m)});const p=f=>{var $,x,b,w,v,S,A,L,H,F,g,q,_,j,N,k,E,z,I,P,B,Z,G,ce,Ee,Se,Ne,ie,Te,Ve,oe,ze,Ie,me,ge,Fe,Ae,de,Le,_e,pe,$t,Ct;if(Ke.includes(f))switch(f){case"-":return o.createVNode(Ut,null,null);case"bold":return o.createVNode("div",{class:`${d}-toolbar-item`,title:($=t.value.toolbarTips)==null?void 0:$.bold,onClick:()=>{a("bold")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(x=t.value.toolbarTips)==null?void 0:x.underline,onClick:()=>{a("underline")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(b=t.value.toolbarTips)==null?void 0:b.italic,onClick:()=>{a("italic")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(w=t.value.toolbarTips)==null?void 0:w.strikeThrough,onClick:()=>{a("strikeThrough")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return o.createVNode(re,{relative:`#${l}`,visible:r.title,onChange:R=>{r.title=R},overlay:o.createVNode("ul",{class:`${d}-menu`,onClick:()=>{r.title=!1}},[o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h1")}},[(v=t.value.titleItem)==null?void 0:v.h1]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h2")}},[(S=t.value.titleItem)==null?void 0:S.h2]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h3")}},[(A=t.value.titleItem)==null?void 0:A.h3]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h4")}},[(L=t.value.titleItem)==null?void 0:L.h4]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h5")}},[(H=t.value.titleItem)==null?void 0:H.h5]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("h6")}},[(F=t.value.titleItem)==null?void 0:F.h6])])},{default:()=>{var R;return[o.createVNode("div",{class:`${d}-toolbar-item`,title:(R=t.value.toolbarTips)==null?void 0:R.title},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(g=t.value.toolbarTips)==null?void 0:g.sub,onClick:()=>{a("sub")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(q=t.value.toolbarTips)==null?void 0:q.sup,onClick:()=>{a("sup")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(_=t.value.toolbarTips)==null?void 0:_.quote,onClick:()=>{a("quote")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(j=t.value.toolbarTips)==null?void 0:j.unorderedList,onClick:()=>{a("unorderedList")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(N=t.value.toolbarTips)==null?void 0:N.orderedList,onClick:()=>{a("orderedList")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(k=t.value.toolbarTips)==null?void 0:k.task,onClick:()=>{a("task")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(E=t.value.toolbarTips)==null?void 0:E.codeRow,onClick:()=>{a("codeRow")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(z=t.value.toolbarTips)==null?void 0:z.code,onClick:()=>{a("code")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(I=t.value.toolbarTips)==null?void 0:I.link,onClick:()=>{s.type="link",s.linkVisible=!0}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return i.noUploadImg?o.createVNode("div",{class:`${d}-toolbar-item`,title:(P=t.value.toolbarTips)==null?void 0:P.image,onClick:()=>{s.type="image",s.linkVisible=!0}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):o.createVNode(re,{relative:`#${l}`,visible:r.image,onChange:R=>{r.image=R},overlay:o.createVNode("ul",{class:`${d}-menu`,onClick:()=>{r.title=!1}},[o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{s.type="image",s.linkVisible=!0}},[(B=t.value.imgTitleItem)==null?void 0:B.link]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{h.value.click()}},[(Z=t.value.imgTitleItem)==null?void 0:Z.upload]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{s.clipVisible=!0}},[(G=t.value.imgTitleItem)==null?void 0:G.clip2upload])])},{default:()=>{var R;return[o.createVNode("div",{class:`${d}-toolbar-item`,title:(R=t.value.toolbarTips)==null?void 0:R.image},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return o.createVNode(re,{relative:`#${l}`,visible:r.table,onChange:R=>{r.table=R},key:"bar-table",overlay:o.createVNode(tn,{tableShape:i.tableShape,onSelected:R=>{a("table",{selectedShape:R})}},null)},{default:()=>{var R;return[o.createVNode("div",{class:`${d}-toolbar-item`,title:(R=t.value.toolbarTips)==null?void 0:R.table},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(ce=t.value.toolbarTips)==null?void 0:ce.revoke,onClick:()=>{y.emit(e,"ctrlZ")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(Ee=t.value.toolbarTips)==null?void 0:Ee.next,onClick:()=>{y.emit(e,"ctrlShiftZ")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(Se=t.value.toolbarTips)==null?void 0:Se.save,onClick:()=>{y.emit(e,be)}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return i.noPrettier?"":o.createVNode("div",{class:`${d}-toolbar-item`,title:(Ne=t.value.toolbarTips)==null?void 0:Ne.prettier,onClick:()=>{a("prettier")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!i.setting.fullscreen&&o.createVNode("div",{class:`${d}-toolbar-item`,title:(ie=t.value.toolbarTips)==null?void 0:ie.pageFullscreen,onClick:()=>{i.updateSetting(!i.setting.pageFullscreen,"pageFullscreen")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(Te=t.value.toolbarTips)==null?void 0:Te.fullscreen,onClick:()=>{n()}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":`#md-editor-icon-${i.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(Ve=t.value.toolbarTips)==null?void 0:Ve.preview,onClick:()=>{i.updateSetting(!i.setting.preview,"preview")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(oe=t.value.toolbarTips)==null?void 0:oe.htmlPreview,onClick:()=>{i.updateSetting(!i.setting.htmlPreview,"htmlPreview")}},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(ze=t.value.toolbarTips)==null?void 0:ze.catalog,onClick:()=>{y.emit(e,Re)},key:"bar-catalog"},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return o.createVNode("div",{class:`${d}-toolbar-item`,title:(Ie=t.value.toolbarTips)==null?void 0:Ie.github,onClick:()=>Ft("https://github.com/imzbf/md-editor-v3")},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return o.createVNode(re,{relative:`#${l}`,visible:r.mermaid,onChange:R=>{r.mermaid=R},overlay:o.createVNode("ul",{class:`${d}-menu`,onClick:()=>{r.mermaid=!1}},[o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("flow")}},[(me=t.value.mermaid)==null?void 0:me.flow]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("sequence")}},[(ge=t.value.mermaid)==null?void 0:ge.sequence]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("gantt")}},[(Fe=t.value.mermaid)==null?void 0:Fe.gantt]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("class")}},[(Ae=t.value.mermaid)==null?void 0:Ae.class]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("state")}},[(de=t.value.mermaid)==null?void 0:de.state]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("pie")}},[(Le=t.value.mermaid)==null?void 0:Le.pie]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("relationship")}},[(_e=t.value.mermaid)==null?void 0:_e.relationship]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("journey")}},[(pe=t.value.mermaid)==null?void 0:pe.journey])]),key:"bar-mermaid"},{default:()=>{var R;return[o.createVNode("div",{class:`${d}-toolbar-item`,title:(R=t.value.toolbarTips)==null?void 0:R.mermaid},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return o.createVNode(re,{relative:`#${l}`,visible:r.katex,onChange:R=>{r.katex=R},overlay:o.createVNode("ul",{class:`${d}-menu`,onClick:()=>{r.katex=!1}},[o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("katexInline")}},[($t=t.value.katex)==null?void 0:$t.inline]),o.createVNode("li",{class:`${d}-menu-item`,onClick:()=>{a("katexBlock")}},[(Ct=t.value.katex)==null?void 0:Ct.block])]),key:"bar-katex"},{default:()=>{var R;return[o.createVNode("div",{class:`${d}-toolbar-item`,title:(R=t.value.toolbarTips)==null?void 0:R.katex},[o.createVNode("svg",{class:`${d}-icon`,"aria-hidden":"true"},[o.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return i.defToolbars instanceof Array?i.defToolbars[f]||"":i.defToolbars&&i.defToolbars.children instanceof Array&&i.defToolbars.children[f]||""};return()=>{const f=u.value[0].map(x=>p(x)),$=u.value[1].map(x=>p(x));return o.createVNode("div",{class:`${d}-toolbar-wrapper`,id:l},[o.createVNode("div",{class:`${d}-toolbar`},[o.createVNode("div",{class:`${d}-toolbar-left`,ref:c},[f]),o.createVNode("div",{class:`${d}-toolbar-right`},[$])]),o.createVNode("input",{ref:h,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),o.createVNode(Yt,{linkVisible:s.linkVisible,clipVisible:s.clipVisible,type:s.type,onCancel:()=>{s.linkVisible=!1,s.clipVisible=!1},onOk:x=>{x&&a(s.type,{desc:x.desc,url:x.url}),s.linkVisible=!1,s.clipVisible=!1}},null)])}}});function at(){return{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,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let ae=at();function on(i){ae=i}const rn=/[&<>"']/,an=/[&<>"']/g,sn=/[<>"']|&(?!#?\w+;)/,cn=/[<>"']|&(?!#?\w+;)/g,dn={"&":"&","<":"<",">":">",'"':""","'":"'"},st=i=>dn[i];function U(i,e){if(e){if(rn.test(i))return i.replace(an,st)}else if(sn.test(i))return i.replace(cn,st);return i}const un=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ct(i){return i.replace(un,(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 hn=/(^|[^\[])\^/g;function D(i,e){i=typeof i=="string"?i:i.source,e=e||"";const t={replace:(n,l)=>(l=l.source||l,l=l.replace(hn,"$1"),i=i.replace(n,l),t),getRegex:()=>new RegExp(i,e)};return t}const fn=/[^\w:]/g,mn=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function dt(i,e,t){if(i){let n;try{n=decodeURIComponent(ct(t)).replace(fn,"").toLowerCase()}catch{return null}if(n.indexOf("javascript:")===0||n.indexOf("vbscript:")===0||n.indexOf("data:")===0)return null}e&&!mn.test(t)&&(t=bn(e,t));try{t=encodeURI(t).replace(/%25/g,"%")}catch{return null}return t}const ye={},gn=/^[^:]+:\/*[^/]*$/,pn=/^([^:]+:)[\s\S]*$/,kn=/^([^:]+:\/*[^/]*)[\s\S]*$/;function bn(i,e){ye[" "+i]||(gn.test(i)?ye[" "+i]=i+"/":ye[" "+i]=ve(i,"/",!0)),i=ye[" "+i];const t=i.indexOf(":")===-1;return e.substring(0,2)==="//"?t?e:i.replace(pn,"$1")+e:e.charAt(0)==="/"?t?e:i.replace(kn,"$1")+e:i+e}const we={exec:function(){}};function Y(i){let e=1,t,n;for(;e<arguments.length;e++){t=arguments[e];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i}function ut(i,e){const t=i.replace(/\|/g,(r,a,s)=>{let c=!1,u=a;for(;--u>=0&&s[u]==="\\";)c=!c;return c?"|":" |"}),n=t.split(/ \|/);let l=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(;l<n.length;l++)n[l]=n[l].trim().replace(/\\\|/g,"|");return n}function ve(i,e,t){const n=i.length;if(n===0)return"";let l=0;for(;l<n;){const r=i.charAt(n-l-1);if(r===e&&!t)l++;else if(r!==e&&t)l++;else break}return i.slice(0,n-l)}function yn(i,e){if(i.indexOf(e[1])===-1)return-1;const t=i.length;let n=0,l=0;for(;l<t;l++)if(i[l]==="\\")l++;else if(i[l]===e[0])n++;else if(i[l]===e[1]&&(n--,n<0))return l;return-1}function ht(i){i&&i.sanitize&&!i.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 ft(i,e){if(e<1)return"";let t="";for(;e>1;)e&1&&(t+=i),e>>=1,i+=i;return t+i}function mt(i,e,t,n){const l=e.href,r=e.title?U(e.title):null,a=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const s={type:"link",raw:t,href:l,title:r,text:a,tokens:n.inlineTokens(a,[])};return n.state.inLink=!1,s}return{type:"image",raw:t,href:l,title:r,text:U(a)}}function wn(i,e){const t=i.match(/^(\s+)(?:```)/);if(t===null)return e;const n=t[1];return e.split(`
|
|
3
3
|
`).map(l=>{const r=l.match(/^\s+/);if(r===null)return l;const[a]=r;return a.length>=n.length?l.slice(n.length):l}).join(`
|
|
4
|
-
`)}class
|
|
5
|
-
`)}}}fences(
|
|
6
|
-
`,1)[0],m=
|
|
7
|
-
`,1)[0],this.options.pedantic?(a=2,f=
|
|
8
|
-
`,
|
|
9
|
-
`,1)[0],
|
|
10
|
-
`+
|
|
11
|
-
`+
|
|
12
|
-
`,
|
|
13
|
-
`&&(g+=1),g>1)return!0;return!1});!
|
|
14
|
-
`):[]};if(n.header.length===n.align.length){n.raw=
|
|
15
|
-
`?
|
|
16
|
-
]`).replace("lheading",T.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const
|
|
17
|
-
`),this.blockTokens(
|
|
18
|
-
`:
|
|
4
|
+
`)}class He{constructor(e){this.options=e||ae}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:ve(n,`
|
|
5
|
+
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const n=t[0],l=wn(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim():t[2],text:l}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(/#$/.test(n)){const r=ve(n,"#");(this.options.pedantic||!r||/ $/.test(r))&&(n=r.trim())}const l={type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:[]};return this.lexer.inline(l.text,l.tokens),l}}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,"");return{type:"blockquote",raw:t[0],tokens:this.lexer.blockTokens(n,[]),text:n}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,l,r,a,s,c,u,h,m,p,f,$,x=t[1].trim();const b=x.length>1,w={type:"list",raw:"",ordered:b,start:b?+x.slice(0,-1):"",loose:!1,items:[]};x=b?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=b?x:"[*+-]");const v=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&($=!1,!(!(t=v.exec(e))||this.rules.block.hr.test(e)));){if(n=t[0],e=e.substring(n.length),h=t[2].split(`
|
|
6
|
+
`,1)[0],m=e.split(`
|
|
7
|
+
`,1)[0],this.options.pedantic?(a=2,f=h.trimLeft()):(a=t[2].search(/[^ ]/),a=a>4?1:a,f=h.slice(a),a+=t[1].length),c=!1,!h&&/^ *$/.test(m)&&(n+=m+`
|
|
8
|
+
`,e=e.substring(m.length+1),$=!0),!$){const A=new RegExp(`^ {0,${Math.min(3,a-1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`),L=new RegExp(`^ {0,${Math.min(3,a-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);for(;e&&(p=e.split(`
|
|
9
|
+
`,1)[0],h=p,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(A.test(h)||L.test(e)));){if(h.search(/[^ ]/)>=a||!h.trim())f+=`
|
|
10
|
+
`+h.slice(a);else if(!c)f+=`
|
|
11
|
+
`+h;else break;!c&&!h.trim()&&(c=!0),n+=p+`
|
|
12
|
+
`,e=e.substring(p.length+1)}}w.loose||(u?w.loose=!0:/\n *\n *$/.test(n)&&(u=!0)),this.options.gfm&&(l=/^\[[ xX]\] /.exec(f),l&&(r=l[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),w.items.push({type:"list_item",raw:n,task:!!l,checked:r,loose:!1,text:f}),w.raw+=n}w.items[w.items.length-1].raw=n.trimRight(),w.items[w.items.length-1].text=f.trimRight(),w.raw=w.raw.trimRight();const S=w.items.length;for(s=0;s<S;s++){this.lexer.state.top=!1,w.items[s].tokens=this.lexer.blockTokens(w.items[s].text,[]);const A=w.items[s].tokens.filter(H=>H.type==="space"),L=A.every(H=>{const F=H.raw.split("");let g=0;for(const q of F)if(q===`
|
|
13
|
+
`&&(g+=1),g>1)return!0;return!1});!w.loose&&A.length&&L&&(w.loose=!0,w.items[s].loose=!0)}return w}}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]};return this.options.sanitize&&(n.type="paragraph",n.text=this.options.sanitizer?this.options.sanitizer(t[0]):U(t[0]),n.tokens=[],this.lexer.inline(n.text,n.tokens)),n}}def(e){const t=this.rules.block.def.exec(e);if(t){t[3]&&(t[3]=t[3].substring(1,t[3].length-1));const n=t[1].toLowerCase().replace(/\s+/g," ");return{type:"def",tag:n,raw:t[0],href:t[2],title:t[3]}}}table(e){const t=this.rules.block.table.exec(e);if(t){const n={type:"table",header:ut(t[1]).map(l=>({text:l})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(`
|
|
14
|
+
`):[]};if(n.header.length===n.align.length){n.raw=t[0];let l=n.align.length,r,a,s,c;for(r=0;r<l;r++)/^ *-+: *$/.test(n.align[r])?n.align[r]="right":/^ *:-+: *$/.test(n.align[r])?n.align[r]="center":/^ *:-+ *$/.test(n.align[r])?n.align[r]="left":n.align[r]=null;for(l=n.rows.length,r=0;r<l;r++)n.rows[r]=ut(n.rows[r],n.header.length).map(u=>({text:u}));for(l=n.header.length,a=0;a<l;a++)n.header[a].tokens=[],this.lexer.inlineTokens(n.header[a].text,n.header[a].tokens);for(l=n.rows.length,a=0;a<l;a++)for(c=n.rows[a],s=0;s<c.length;s++)c[s].tokens=[],this.lexer.inlineTokens(c[s].text,c[s].tokens);return n}}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t){const n={type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:[]};return this.lexer.inline(n.text,n.tokens),n}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const n={type:"paragraph",raw:t[0],text:t[1].charAt(t[1].length-1)===`
|
|
15
|
+
`?t[1].slice(0,-1):t[1],tokens:[]};return this.lexer.inline(n.text,n.tokens),n}}text(e){const t=this.rules.block.text.exec(e);if(t){const n={type:"text",raw:t[0],text:t[0],tokens:[]};return this.lexer.inline(n.text,n.tokens),n}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:U(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]):U(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=ve(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{const a=yn(t[2],"()");if(a>-1){const c=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let l=t[2],r="";if(this.options.pedantic){const a=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(l);a&&(l=a[1],r=a[3])}else r=t[3]?t[3].slice(1,-1):"";return l=l.trim(),/^</.test(l)&&(this.options.pedantic&&!/>$/.test(n)?l=l.slice(1):l=l.slice(1,-1)),mt(t,{href:l&&l.replace(this.rules.inline._escapes,"$1"),title:r&&r.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 l=(n[2]||n[1]).replace(/\s+/g," ");if(l=t[l.toLowerCase()],!l||!l.href){const r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return mt(n,l,n[0],this.lexer)}}emStrong(e,t,n=""){let l=this.rules.inline.emStrong.lDelim.exec(e);if(!l||l[3]&&n.match(/[\p{L}\p{N}]/u))return;const r=l[1]||l[2]||"";if(!r||r&&(n===""||this.rules.inline.punctuation.exec(n))){const a=l[0].length-1;let s,c,u=a,h=0;const m=l[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(m.lastIndex=0,t=t.slice(-1*e.length+a);(l=m.exec(t))!=null;){if(s=l[1]||l[2]||l[3]||l[4]||l[5]||l[6],!s)continue;if(c=s.length,l[3]||l[4]){u+=c;continue}else if((l[5]||l[6])&&a%3&&!((a+c)%3)){h+=c;continue}if(u-=c,u>0)continue;if(c=Math.min(c,c+u+h),Math.min(a,c)%2){const f=e.slice(1,a+l.index+c);return{type:"em",raw:e.slice(0,a+l.index+c+1),text:f,tokens:this.lexer.inlineTokens(f,[])}}const p=e.slice(2,a+l.index+c-1);return{type:"strong",raw:e.slice(0,a+l.index+c+1),text:p,tokens:this.lexer.inlineTokens(p,[])}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(/\n/g," ");const l=/[^ ]/.test(n),r=/^ /.test(n)&&/ $/.test(n);return l&&r&&(n=n.substring(1,n.length-1)),n=U(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 l,r;return n[2]==="@"?(l=U(this.options.mangle?t(n[1]):n[1]),r="mailto:"+l):(l=U(n[1]),r=l),{type:"link",raw:n[0],text:l,href:r,tokens:[{type:"text",raw:l,text:l}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let l,r;if(n[2]==="@")l=U(this.options.mangle?t(n[0]):n[0]),r="mailto:"+l;else{let a;do a=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0];while(a!==n[0]);l=U(n[0]),n[1]==="www."?r="http://"+l:r=l}return{type:"link",raw:n[0],text:l,href:r,tokens:[{type:"text",raw:l,text:l}]}}}inlineText(e,t){const n=this.rules.inline.text.exec(e);if(n){let l;return this.lexer.state.inRawBlock?l=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):U(n[0]):n[0]:l=U(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:l}}}}const T={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>]+)>?(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:we,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};T._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,T._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,T.def=D(T.def).replace("label",T._label).replace("title",T._title).getRegex(),T.bullet=/(?:[*+-]|\d{1,9}[.)])/,T.listItemStart=D(/^( *)(bull) */).replace("bull",T.bullet).getRegex(),T.list=D(T.list).replace(/bull/g,T.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+T.def.source+")").getRegex(),T._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",T._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,T.html=D(T.html,"i").replace("comment",T._comment).replace("tag",T._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),T.paragraph=D(T._paragraph).replace("hr",T.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",T._tag).getRegex(),T.blockquote=D(T.blockquote).replace("paragraph",T.paragraph).getRegex(),T.normal=Y({},T),T.gfm=Y({},T.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),T.gfm.table=D(T.gfm.table).replace("hr",T.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",T._tag).getRegex(),T.gfm.paragraph=D(T._paragraph).replace("hr",T.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",T.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",T._tag).getRegex(),T.pedantic=Y({},T.normal,{html:D(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",T._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:we,paragraph:D(T.normal._paragraph).replace("hr",T.hr).replace("heading",` *#{1,6} *[^
|
|
16
|
+
]`).replace("lheading",T.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const C={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:we,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:we,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};C._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",C.punctuation=D(C.punctuation).replace(/punctuation/g,C._punctuation).getRegex(),C.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,C.escapedEmSt=/\\\*|\\_/g,C._comment=D(T._comment).replace("(?:-->|$)","-->").getRegex(),C.emStrong.lDelim=D(C.emStrong.lDelim).replace(/punct/g,C._punctuation).getRegex(),C.emStrong.rDelimAst=D(C.emStrong.rDelimAst,"g").replace(/punct/g,C._punctuation).getRegex(),C.emStrong.rDelimUnd=D(C.emStrong.rDelimUnd,"g").replace(/punct/g,C._punctuation).getRegex(),C._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,C._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,C._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])?)+(?![-_])/,C.autolink=D(C.autolink).replace("scheme",C._scheme).replace("email",C._email).getRegex(),C._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,C.tag=D(C.tag).replace("comment",C._comment).replace("attribute",C._attribute).getRegex(),C._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,C._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,C._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,C.link=D(C.link).replace("label",C._label).replace("href",C._href).replace("title",C._title).getRegex(),C.reflink=D(C.reflink).replace("label",C._label).replace("ref",T._label).getRegex(),C.nolink=D(C.nolink).replace("ref",T._label).getRegex(),C.reflinkSearch=D(C.reflinkSearch,"g").replace("reflink",C.reflink).replace("nolink",C.nolink).getRegex(),C.normal=Y({},C),C.pedantic=Y({},C.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:D(/^!?\[(label)\]\((.*?)\)/).replace("label",C._label).getRegex(),reflink:D(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",C._label).getRegex()}),C.gfm=Y({},C.normal,{escape:D(C.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.!#$%&'*+\/=?_`{\|}~-]+@)))/}),C.gfm.url=D(C.gfm.url,"i").replace("email",C.gfm._extended_email).getRegex(),C.breaks=Y({},C.gfm,{br:D(C.br).replace("{2,}","*").getRegex(),text:D(C.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});function vn(i){return i.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function gt(i){let e="",t,n;const l=i.length;for(t=0;t<l;t++)n=i.charCodeAt(t),Math.random()>.5&&(n="x"+n.toString(16)),e+="&#"+n+";";return e}class ee{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ae,this.options.tokenizer=this.options.tokenizer||new He,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:T.normal,inline:C.normal};this.options.pedantic?(t.block=T.pedantic,t.inline=C.pedantic):this.options.gfm&&(t.block=T.gfm,this.options.breaks?t.inline=C.breaks:t.inline=C.gfm),this.tokenizer.rules=t}static get rules(){return{block:T,inline:C}}static lex(e,t){return new ee(t).lex(e)}static lexInline(e,t){return new ee(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
|
|
17
|
+
`),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,(s,c,u)=>c+" ".repeat(u.length));let n,l,r,a;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(s=>(n=s.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+=`
|
|
18
|
+
`:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length),l=t[t.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
|
|
19
19
|
`+n.raw,l.text+=`
|
|
20
|
-
`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=l.text):
|
|
20
|
+
`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=l.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),l=t[t.length-1],l&&(l.type==="paragraph"||l.type==="text")?(l.raw+=`
|
|
21
21
|
`+n.raw,l.text+=`
|
|
22
|
-
`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=l.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(
|
|
22
|
+
`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=l.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(r=e,this.options.extensions&&this.options.extensions.startBlock){let s=1/0;const c=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(h){u=h.call({lexer:this},c),typeof u=="number"&&u>=0&&(s=Math.min(s,u))}),s<1/0&&s>=0&&(r=e.substring(0,s+1))}if(this.state.top&&(n=this.tokenizer.paragraph(r))){l=t[t.length-1],a&&l.type==="paragraph"?(l.raw+=`
|
|
23
23
|
`+n.raw,l.text+=`
|
|
24
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):
|
|
24
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):t.push(n),a=r.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length),l=t[t.length-1],l&&l.type==="text"?(l.raw+=`
|
|
25
25
|
`+n.raw,l.text+=`
|
|
26
|
-
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):
|
|
27
|
-
`,l?'<pre><code class="'+this.options.langPrefix+U(l,!0)+'">'+(n?
|
|
28
|
-
`:"<pre><code>"+(n?
|
|
29
|
-
`}blockquote(
|
|
30
|
-
${
|
|
31
|
-
`}html(
|
|
32
|
-
`}return`<h${
|
|
26
|
+
`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=l.text):t.push(n);continue}if(e){const s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=!0,t}inline(e,t){this.inlineQueue.push({src:e,tokens:t})}inlineTokens(e,t=[]){let n,l,r,a=e,s,c,u;if(this.tokens.links){const h=Object.keys(this.tokens.links);if(h.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)h.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(a=a.slice(0,s.index)+"["+ft("a",s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,s.index)+"["+ft("a",s[0].length-2)+"]"+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(s=this.tokenizer.rules.inline.escapedEmSt.exec(a))!=null;)a=a.slice(0,s.index)+"++"+a.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(c||(u=""),c=!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),l=t[t.length-1],l&&n.type==="text"&&l.type==="text"?(l.raw+=n.raw,l.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),l=t[t.length-1],l&&n.type==="text"&&l.type==="text"?(l.raw+=n.raw,l.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,a,u)){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,gt)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e,gt))){e=e.substring(n.raw.length),t.push(n);continue}if(r=e,this.options.extensions&&this.options.extensions.startInline){let h=1/0;const m=e.slice(1);let p;this.options.extensions.startInline.forEach(function(f){p=f.call({lexer:this},m),typeof p=="number"&&p>=0&&(h=Math.min(h,p))}),h<1/0&&h>=0&&(r=e.substring(0,h+1))}if(n=this.tokenizer.inlineText(r,vn)){e=e.substring(n.raw.length),n.raw.slice(-1)!=="_"&&(u=n.raw.slice(-1)),c=!0,l=t[t.length-1],l&&l.type==="text"?(l.raw+=n.raw,l.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 Pe{constructor(e){this.options=e||ae}code(e,t,n){const l=(t||"").match(/\S*/)[0];if(this.options.highlight){const r=this.options.highlight(e,l);r!=null&&r!==e&&(n=!0,e=r)}return e=e.replace(/\n$/,"")+`
|
|
27
|
+
`,l?'<pre><code class="'+this.options.langPrefix+U(l,!0)+'">'+(n?e:U(e,!0))+`</code></pre>
|
|
28
|
+
`:"<pre><code>"+(n?e:U(e,!0))+`</code></pre>
|
|
29
|
+
`}blockquote(e){return`<blockquote>
|
|
30
|
+
${e}</blockquote>
|
|
31
|
+
`}html(e){return e}heading(e,t,n,l){if(this.options.headerIds){const r=this.options.headerPrefix+l.slug(n);return`<h${t} id="${r}">${e}</h${t}>
|
|
32
|
+
`}return`<h${t}>${e}</h${t}>
|
|
33
33
|
`}hr(){return this.options.xhtml?`<hr/>
|
|
34
34
|
`:`<hr>
|
|
35
|
-
`}list(t,
|
|
36
|
-
`+
|
|
37
|
-
`}listitem(
|
|
38
|
-
`}checkbox(
|
|
39
|
-
`}table(t
|
|
35
|
+
`}list(e,t,n){const l=t?"ol":"ul",r=t&&n!==1?' start="'+n+'"':"";return"<"+l+r+`>
|
|
36
|
+
`+e+"</"+l+`>
|
|
37
|
+
`}listitem(e){return`<li>${e}</li>
|
|
38
|
+
`}checkbox(e){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "}paragraph(e){return`<p>${e}</p>
|
|
39
|
+
`}table(e,t){return t&&(t=`<tbody>${t}</tbody>`),`<table>
|
|
40
40
|
<thead>
|
|
41
|
-
`+
|
|
42
|
-
`+
|
|
43
|
-
`}tablerow(
|
|
44
|
-
${
|
|
45
|
-
`}tablecell(t
|
|
46
|
-
`}strong(
|
|
47
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);n+=
|
|
48
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
49
|
-
Please report this to https://github.com/markedjs/marked.`,
|
|
41
|
+
`+e+`</thead>
|
|
42
|
+
`+t+`</table>
|
|
43
|
+
`}tablerow(e){return`<tr>
|
|
44
|
+
${e}</tr>
|
|
45
|
+
`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
46
|
+
`}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=dt(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let l='<a href="'+U(e)+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>",l}image(e,t,n){if(e=dt(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let l=`<img src="${e}" alt="${n}"`;return t&&(l+=` title="${t}"`),l+=this.options.xhtml?"/>":">",l}text(e){return e}}class pt{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 kt{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,l=0;if(this.seen.hasOwnProperty(n)){l=this.seen[e];do l++,n=e+"-"+l;while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=l,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class te{constructor(e){this.options=e||ae,this.options.renderer=this.options.renderer||new Pe,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new pt,this.slugger=new kt}static parse(e,t){return new te(t).parse(e)}static parseInline(e,t){return new te(t).parseInline(e)}parse(e,t=!0){let n="",l,r,a,s,c,u,h,m,p,f,$,x,b,w,v,S,A,L,H;const F=e.length;for(l=0;l<F;l++){if(f=e[l],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(H=this.options.extensions.renderers[f.type].call({parser:this},f),H!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){n+=H||"";continue}switch(f.type){case"space":continue;case"hr":{n+=this.renderer.hr();continue}case"heading":{n+=this.renderer.heading(this.parseInline(f.tokens),f.depth,ct(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{n+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(m="",h="",s=f.header.length,r=0;r<s;r++)h+=this.renderer.tablecell(this.parseInline(f.header[r].tokens),{header:!0,align:f.align[r]});for(m+=this.renderer.tablerow(h),p="",s=f.rows.length,r=0;r<s;r++){for(u=f.rows[r],h="",c=u.length,a=0;a<c;a++)h+=this.renderer.tablecell(this.parseInline(u[a].tokens),{header:!1,align:f.align[a]});p+=this.renderer.tablerow(h)}n+=this.renderer.table(m,p);continue}case"blockquote":{p=this.parse(f.tokens),n+=this.renderer.blockquote(p);continue}case"list":{for($=f.ordered,x=f.start,b=f.loose,s=f.items.length,p="",r=0;r<s;r++)v=f.items[r],S=v.checked,A=v.task,w="",v.task&&(L=this.renderer.checkbox(S),b?v.tokens.length>0&&v.tokens[0].type==="paragraph"?(v.tokens[0].text=L+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&v.tokens[0].tokens[0].type==="text"&&(v.tokens[0].tokens[0].text=L+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:L}):w+=L),w+=this.parse(v.tokens,b),p+=this.renderer.listitem(w,A,S);n+=this.renderer.list(p,$,x);continue}case"html":{n+=this.renderer.html(f.text);continue}case"paragraph":{n+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(p=f.tokens?this.parseInline(f.tokens):f.text;l+1<F&&e[l+1].type==="text";)f=e[++l],p+=`
|
|
47
|
+
`+(f.tokens?this.parseInline(f.tokens):f.text);n+=t?this.renderer.paragraph(p):p;continue}default:{const g='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(g);return}else throw new Error(g)}}}return n}parseInline(e,t){t=t||this.renderer;let n="",l,r,a;const s=e.length;for(l=0;l<s;l++){if(r=e[l],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]&&(a=this.options.extensions.renderers[r.type].call({parser:this},r),a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(r.type))){n+=a||"";continue}switch(r.type){case"escape":{n+=t.text(r.text);break}case"html":{n+=t.html(r.text);break}case"link":{n+=t.link(r.href,r.title,this.parseInline(r.tokens,t));break}case"image":{n+=t.image(r.href,r.title,r.text);break}case"strong":{n+=t.strong(this.parseInline(r.tokens,t));break}case"em":{n+=t.em(this.parseInline(r.tokens,t));break}case"codespan":{n+=t.codespan(r.text);break}case"br":{n+=t.br();break}case"del":{n+=t.del(this.parseInline(r.tokens,t));break}case"text":{n+=t.text(r.text);break}default:{const c='Token with "'+r.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return n}}function V(i,e,t){if(typeof i=="undefined"||i===null)throw new Error("marked(): input parameter is undefined or null");if(typeof i!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected");if(typeof e=="function"&&(t=e,e=null),e=Y({},V.defaults,e||{}),ht(e),t){const n=e.highlight;let l;try{l=ee.lex(i,e)}catch(s){return t(s)}const r=function(s){let c;if(!s)try{e.walkTokens&&V.walkTokens(l,e.walkTokens),c=te.parse(l,e)}catch(u){s=u}return e.highlight=n,s?t(s):t(null,c)};if(!n||n.length<3||(delete e.highlight,!l.length))return r();let a=0;V.walkTokens(l,function(s){s.type==="code"&&(a++,setTimeout(()=>{n(s.text,s.lang,function(c,u){if(c)return r(c);u!=null&&u!==s.text&&(s.text=u,s.escaped=!0),a--,a===0&&r()})},0))}),a===0&&r();return}try{const n=ee.lex(i,e);return e.walkTokens&&V.walkTokens(n,e.walkTokens),te.parse(n,e)}catch(n){if(n.message+=`
|
|
48
|
+
Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+U(n.message+"",!0)+"</pre>";throw n}}V.options=V.setOptions=function(i){return Y(V.defaults,i),on(V.defaults),V},V.getDefaults=at,V.defaults=ae,V.use=function(...i){const e=Y({},...i),t=V.defaults.extensions||{renderers:{},childTokens:{}};let n;i.forEach(l=>{if(l.extensions&&(n=!0,l.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if(r.renderer){const a=t.renderers?t.renderers[r.name]:null;a?t.renderers[r.name]=function(...s){let c=r.renderer.apply(this,s);return c===!1&&(c=a.apply(this,s)),c}:t.renderers[r.name]=r.renderer}if(r.tokenizer){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[r.level]?t[r.level].unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}r.childTokens&&(t.childTokens[r.name]=r.childTokens)})),l.renderer){const r=V.defaults.renderer||new Pe;for(const a in l.renderer){const s=r[a];r[a]=(...c)=>{let u=l.renderer[a].apply(r,c);return u===!1&&(u=s.apply(r,c)),u}}e.renderer=r}if(l.tokenizer){const r=V.defaults.tokenizer||new He;for(const a in l.tokenizer){const s=r[a];r[a]=(...c)=>{let u=l.tokenizer[a].apply(r,c);return u===!1&&(u=s.apply(r,c)),u}}e.tokenizer=r}if(l.walkTokens){const r=V.defaults.walkTokens;e.walkTokens=function(a){l.walkTokens.call(this,a),r&&r.call(this,a)}}n&&(e.extensions=t),V.setOptions(e)})},V.walkTokens=function(i,e){for(const t of i)switch(e.call(V,t),t.type){case"table":{for(const n of t.header)V.walkTokens(n.tokens,e);for(const n of t.rows)for(const l of n)V.walkTokens(l.tokens,e);break}case"list":{V.walkTokens(t.items,e);break}default:V.defaults.extensions&&V.defaults.extensions.childTokens&&V.defaults.extensions.childTokens[t.type]?V.defaults.extensions.childTokens[t.type].forEach(function(n){V.walkTokens(t[n],e)}):t.tokens&&V.walkTokens(t.tokens,e)}},V.parseInline=function(i,e){if(typeof i=="undefined"||i===null)throw new Error("marked.parseInline(): input parameter is undefined or null");if(typeof i!="string")throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected");e=Y({},V.defaults,e||{}),ht(e);try{const t=ee.lexInline(i,e);return e.walkTokens&&V.walkTokens(t,e.walkTokens),te.parseInline(t,e)}catch(t){if(t.message+=`
|
|
49
|
+
Please report this to https://github.com/markedjs/marked.`,e.silent)return"<p>An error occurred:</p><pre>"+U(t.message+"",!0)+"</pre>";throw t}},V.Parser=te,V.parser=te.parse,V.Renderer=Pe,V.TextRenderer=pt,V.Lexer=ee,V.lexer=ee.lex,V.Tokenizer=He,V.Slugger=kt,V.parse=V,te.parse,ee.lex;var xn=function(){var i=document.getSelection();if(!i.rangeCount)return function(){};for(var e=document.activeElement,t=[],n=0;n<i.rangeCount;n++)t.push(i.getRangeAt(n));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return i.removeAllRanges(),function(){i.type==="Caret"&&i.removeAllRanges(),i.rangeCount||t.forEach(function(l){i.addRange(l)}),e&&e.focus()}},$n=xn,bt={"text/plain":"Text","text/html":"Url",default:"Text"},Cn="Copy to clipboard: #{key}, Enter";function En(i){var e=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return i.replace(/#{\s*key\s*}/g,e)}function Sn(i,e){var t,n,l,r,a,s,c=!1;e||(e={}),t=e.debug||!1;try{l=$n(),r=document.createRange(),a=document.getSelection(),s=document.createElement("span"),s.textContent=i,s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",function(h){if(h.stopPropagation(),e.format)if(h.preventDefault(),typeof h.clipboardData=="undefined"){t&&console.warn("unable to use e.clipboardData"),t&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var m=bt[e.format]||bt.default;window.clipboardData.setData(m,i)}else h.clipboardData.clearData(),h.clipboardData.setData(e.format,i);e.onCopy&&(h.preventDefault(),e.onCopy(h.clipboardData))}),document.body.appendChild(s),r.selectNodeContents(s),a.addRange(r);var u=document.execCommand("copy");if(!u)throw new Error("copy command was unsuccessful");c=!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",i),e.onCopy&&e.onCopy(window.clipboardData),c=!0}catch(m){t&&console.error("unable to copy using clipboardData: ",m),t&&console.error("falling back to prompt"),n=En("message"in e?e.message:Cn),window.prompt(n,i)}}finally{a&&(typeof a.removeRange=="function"?a.removeRange(r):a.removeAllRanges()),s&&document.body.removeChild(s),l()}return c}var he=Sn;/*! medium-zoom 1.0.6 | MIT License | https://github.com/francoischalifour/medium-zoom */var le=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},xe=function(e){return e.tagName==="IMG"},Nn=function(e){return NodeList.prototype.isPrototypeOf(e)},$e=function(e){return e&&e.nodeType===1},yt=function(e){var t=e.currentSrc||e.src;return t.substr(-4).toLowerCase()===".svg"},wt=function(e){try{return Array.isArray(e)?e.filter(xe):Nn(e)?[].slice.call(e).filter(xe):$e(e)?[e].filter(xe):typeof e=="string"?[].slice.call(document.querySelectorAll(e)).filter(xe):[]}catch{throw new TypeError(`The provided selector is invalid.
|
|
50
50
|
Expects a CSS selector, a Node element, a NodeList or an array.
|
|
51
|
-
See: https://github.com/francoischalifour/medium-zoom`)}},
|
|
52
|
-
`),r=
|
|
53
|
-
`),s=n.substring(a===-1?n.length:a,n.length),
|
|
54
|
-
|`;for(let
|
|
55
|
-
|`;for(let A=0;A<=
|
|
56
|
-
`,""):l=`![${
|
|
57
|
-
`;break}case"tab":{const{tabWidth:
|
|
58
|
-
`).map(g=>`${
|
|
59
|
-
`),
|
|
60
|
-
`);let[j
|
|
61
|
-
`);return J(
|
|
62
|
-
${(
|
|
51
|
+
See: https://github.com/francoischalifour/medium-zoom`)}},Tn=function(e){var t=document.createElement("div");return t.classList.add("medium-zoom-overlay"),t.style.background=e,t},Vn=function(e){var t=e.getBoundingClientRect(),n=t.top,l=t.left,r=t.width,a=t.height,s=e.cloneNode(),c=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,u=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;return s.removeAttribute("id"),s.style.position="absolute",s.style.top=n+c+"px",s.style.left=l+u+"px",s.style.width=r+"px",s.style.height=a+"px",s.style.transform="",s},se=function(e,t){var n=le({bubbles:!1,cancelable:!1,detail:void 0},t);if(typeof window.CustomEvent=="function")return new CustomEvent(e,n);var l=document.createEvent("CustomEvent");return l.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),l},zn=function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=window.Promise||function(N){function k(){}N(k,k)},l=function(N){var k=N.target;if(k===q){$();return}S.indexOf(k)!==-1&&x({target:k})},r=function(){if(!(L||!g.original)){var N=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;Math.abs(H-N)>F.scrollOffset&&setTimeout($,150)}},a=function(N){var k=N.key||N.keyCode;(k==="Escape"||k==="Esc"||k===27)&&$()},s=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=N;if(N.background&&(q.style.background=N.background),N.container&&N.container instanceof Object&&(k.container=le({},F.container,N.container)),N.template){var E=$e(N.template)?N.template:document.querySelector(N.template);k.template=E}return F=le({},F,k),S.forEach(function(z){z.dispatchEvent(se("medium-zoom:update",{detail:{zoom:_}}))}),_},c=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return i(le({},F,N))},u=function(){for(var N=arguments.length,k=Array(N),E=0;E<N;E++)k[E]=arguments[E];var z=k.reduce(function(I,P){return[].concat(I,wt(P))},[]);return z.filter(function(I){return S.indexOf(I)===-1}).forEach(function(I){S.push(I),I.classList.add("medium-zoom-image")}),A.forEach(function(I){var P=I.type,B=I.listener,Z=I.options;z.forEach(function(G){G.addEventListener(P,B,Z)})}),_},h=function(){for(var N=arguments.length,k=Array(N),E=0;E<N;E++)k[E]=arguments[E];g.zoomed&&$();var z=k.length>0?k.reduce(function(I,P){return[].concat(I,wt(P))},[]):S;return z.forEach(function(I){I.classList.remove("medium-zoom-image"),I.dispatchEvent(se("medium-zoom:detach",{detail:{zoom:_}}))}),S=S.filter(function(I){return z.indexOf(I)===-1}),_},m=function(N,k){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(z){z.addEventListener("medium-zoom:"+N,k,E)}),A.push({type:"medium-zoom:"+N,listener:k,options:E}),_},p=function(N,k){var E=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return S.forEach(function(z){z.removeEventListener("medium-zoom:"+N,k,E)}),A=A.filter(function(z){return!(z.type==="medium-zoom:"+N&&z.listener.toString()===k.toString())}),_},f=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=N.target,E=function(){var I={width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,left:0,top:0,right:0,bottom:0},P=void 0,B=void 0;if(F.container)if(F.container instanceof Object)I=le({},I,F.container),P=I.width-I.left-I.right-F.margin*2,B=I.height-I.top-I.bottom-F.margin*2;else{var Z=$e(F.container)?F.container:document.querySelector(F.container),G=Z.getBoundingClientRect(),ce=G.width,Ee=G.height,Se=G.left,Ne=G.top;I=le({},I,{width:ce,height:Ee,left:Se,top:Ne})}P=P||I.width-F.margin*2,B=B||I.height-F.margin*2;var ie=g.zoomedHd||g.original,Te=yt(ie)?P:ie.naturalWidth||P,Ve=yt(ie)?B:ie.naturalHeight||B,oe=ie.getBoundingClientRect(),ze=oe.top,Ie=oe.left,me=oe.width,ge=oe.height,Fe=Math.min(Te,P)/me,Ae=Math.min(Ve,B)/ge,de=Math.min(Fe,Ae),Le=(-Ie+(P-me)/2+F.margin+I.left)/de,_e=(-ze+(B-ge)/2+F.margin+I.top)/de,pe="scale("+de+") translate3d("+Le+"px, "+_e+"px, 0)";g.zoomed.style.transform=pe,g.zoomedHd&&(g.zoomedHd.style.transform=pe)};return new n(function(z){if(k&&S.indexOf(k)===-1){z(_);return}var I=function ce(){L=!1,g.zoomed.removeEventListener("transitionend",ce),g.original.dispatchEvent(se("medium-zoom:opened",{detail:{zoom:_}})),z(_)};if(g.zoomed){z(_);return}if(k)g.original=k;else if(S.length>0){var P=S;g.original=P[0]}else{z(_);return}if(g.original.dispatchEvent(se("medium-zoom:open",{detail:{zoom:_}})),H=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0,L=!0,g.zoomed=Vn(g.original),document.body.appendChild(q),F.template){var B=$e(F.template)?F.template:document.querySelector(F.template);g.template=document.createElement("div"),g.template.appendChild(B.content.cloneNode(!0)),document.body.appendChild(g.template)}if(document.body.appendChild(g.zoomed),window.requestAnimationFrame(function(){document.body.classList.add("medium-zoom--opened")}),g.original.classList.add("medium-zoom-image--hidden"),g.zoomed.classList.add("medium-zoom-image--opened"),g.zoomed.addEventListener("click",$),g.zoomed.addEventListener("transitionend",I),g.original.getAttribute("data-zoom-src")){g.zoomedHd=g.zoomed.cloneNode(),g.zoomedHd.removeAttribute("srcset"),g.zoomedHd.removeAttribute("sizes"),g.zoomedHd.src=g.zoomed.getAttribute("data-zoom-src"),g.zoomedHd.onerror=function(){clearInterval(Z),console.warn("Unable to reach the zoom image target "+g.zoomedHd.src),g.zoomedHd=null,E()};var Z=setInterval(function(){g.zoomedHd.complete&&(clearInterval(Z),g.zoomedHd.classList.add("medium-zoom-image--opened"),g.zoomedHd.addEventListener("click",$),document.body.appendChild(g.zoomedHd),E())},10)}else if(g.original.hasAttribute("srcset")){g.zoomedHd=g.zoomed.cloneNode(),g.zoomedHd.removeAttribute("sizes"),g.zoomedHd.removeAttribute("loading");var G=g.zoomedHd.addEventListener("load",function(){g.zoomedHd.removeEventListener("load",G),g.zoomedHd.classList.add("medium-zoom-image--opened"),g.zoomedHd.addEventListener("click",$),document.body.appendChild(g.zoomedHd),E()})}else E()})},$=function(){return new n(function(N){if(L||!g.original){N(_);return}var k=function E(){g.original.classList.remove("medium-zoom-image--hidden"),document.body.removeChild(g.zoomed),g.zoomedHd&&document.body.removeChild(g.zoomedHd),document.body.removeChild(q),g.zoomed.classList.remove("medium-zoom-image--opened"),g.template&&document.body.removeChild(g.template),L=!1,g.zoomed.removeEventListener("transitionend",E),g.original.dispatchEvent(se("medium-zoom:closed",{detail:{zoom:_}})),g.original=null,g.zoomed=null,g.zoomedHd=null,g.template=null,N(_)};L=!0,document.body.classList.remove("medium-zoom--opened"),g.zoomed.style.transform="",g.zoomedHd&&(g.zoomedHd.style.transform=""),g.template&&(g.template.style.transition="opacity 150ms",g.template.style.opacity=0),g.original.dispatchEvent(se("medium-zoom:close",{detail:{zoom:_}})),g.zoomed.addEventListener("transitionend",k)})},x=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=N.target;return g.original?$():f({target:k})},b=function(){return F},w=function(){return S},v=function(){return g.original},S=[],A=[],L=!1,H=0,F=t,g={original:null,zoomed:null,zoomedHd:null,template:null};Object.prototype.toString.call(e)==="[object Object]"?F=e:(e||typeof e=="string")&&u(e),F=le({margin:0,background:"#fff",scrollOffset:40,container:null,template:null},F);var q=Tn(F.background);document.addEventListener("click",l),document.addEventListener("keyup",a),document.addEventListener("scroll",r),window.addEventListener("resize",$);var _={open:f,close:$,toggle:x,update:s,clone:c,attach:u,detach:h,on:m,off:p,getOptions:b,getImages:w,getZoomedImage:v};return _};function In(i,e){e===void 0&&(e={});var t=e.insertAt;if(!(!i||typeof document=="undefined")){var n=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css",t==="top"&&n.firstChild?n.insertBefore(l,n.firstChild):n.appendChild(l),l.styleSheet?l.styleSheet.cssText=i:l.appendChild(document.createTextNode(i))}}var Fn=".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}";In(Fn);var An=zn;const fe=i=>{const e=i.value,t=e.substring(0,i.selectionStart),n=e.substring(i.selectionEnd,e.length),l=t.lastIndexOf(`
|
|
52
|
+
`),r=t.substring(0,l+1),a=n.indexOf(`
|
|
53
|
+
`),s=n.substring(a===-1?n.length:a,n.length),c=t.substring(l+1,t.length),u=n.substring(0,a);return{prefixStr:t,subfixStr:n,prefixStrEndRow:r,subfixStrEndRow:s,prefixSupply:c,subfixSupply:u}},Ln=(i,e="",t,n)=>{var m,p,f,$,x;let l="",r=0,a=0,s=!1,c,u;const h=(m=M.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(i)){const b=i.replace(/^h(\d)/,(w,v)=>new Array(Number(v)).fill("#",0,v).join(""));l=`${b} ${e}`,r=b.length+1}else if(i==="prettier"){const b=window.prettier||((f=(p=M.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.prettierInstance),w=window.prettierPlugins||[(x=($=M.editorExtensions)==null?void 0:$.prettier)==null?void 0:x.parserMarkdownInstance];return!b||w[0]===void 0?(y.emit(n.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),t.value):b.format(t.value,{parser:"markdown",plugins:w})}else switch(i){case"bold":{l=`**${e}**`,r=2,a=-2;break}case"underline":{l=`<u>${e}</u>`,r=3,a=-4;break}case"italic":{l=`*${e}*`,r=1,a=-1;break}case"strikeThrough":{l=`~${e}~`,r=1,a=-1;break}case"sub":{l=`<sub>${e}</sub>`,r=5,a=-6;break}case"sup":{l=`<sup>${e}</sup>`,r=5,a=-6;break}case"codeRow":{l="`"+e+"`",r=1,a=-1;break}case"quote":{l=`> ${e}`,r=2;break}case"orderedList":{l=`1. ${e}`,r=3;break}case"unorderedList":{l=`- ${e}`,r=2;break}case"task":{l=`- [ ] ${e}`,r=6,s=!0;break}case"code":{l="```language\n"+e+"\n```\n",r=3,a=11-l.length,s=!0;break}case"table":{l="|";const{selectedShape:b={x:1,y:1}}=n,{x:w,y:v}=b;for(let S=0;S<=v;S++)l+=" col |";l+=`
|
|
54
|
+
|`;for(let S=0;S<=v;S++)l+=" - |";for(let S=0;S<=w;S++){l+=`
|
|
55
|
+
|`;for(let A=0;A<=v;A++)l+=" content |"}r=2,a=5-l.length,s=!0;break}case"link":{const{desc:b,url:w}=n;l=`[${b}](${w})`;break}case"image":{const{desc:b,url:w,urls:v}=n;v instanceof Array?l=v.reduce((S,A)=>S+`
|
|
56
|
+
`,""):l=`
|
|
57
|
+
`;break}case"tab":{const{tabWidth:b=2}=n,w=new Array(b).fill(" ").join("");if(e==="")l=w;else if(/\n/.test(e)){const{prefixStr:v,subfixStr:S,prefixSupply:A,subfixSupply:L}=fe(t);l=`${A}${e}${L}`.split(`
|
|
58
|
+
`).map(g=>`${w}${g}`).join(`
|
|
59
|
+
`),c=v.substring(0,v.length-A.length),u=S.substring(L.length,S.length),s=!0,r=b,a=-A.length-L.length}else{const S=t.value.substring(0,t.selectionStart);/\n$/.test(S)||S===""?(l=`${w}${e}`,s=!0):l=w}break}case"shiftTab":{const{tabWidth:b=2}=n,{prefixStr:w,prefixStrEndRow:v,subfixStrEndRow:S,prefixSupply:A,subfixSupply:L}=fe(t),H=new RegExp(`^\\s{${b}}`),F=(g=!1,q=!1)=>{const _=`${A}${e}${L}`;if(H.test(_)){const j=w.length-(q?0:b),N=g?j+e.length-b:j;return J(t,j,N),`${v}${_.replace(H,"")}${S}`}else if(/^\s/.test(_)){const j=_.replace(/^\s/,""),N=_.length-j.length,k=t.selectionStart-(q?0:N),E=g?k+e.length-N:k;return J(t,k,E),`${v}${j}${S}`}else l=e};if(e===""){const g=F();if(g)return g}else if(/\n/.test(e)){const q=`${A}${e}${L}`.split(`
|
|
60
|
+
`);let[_,j]=[0,0];const N=q.map((k,E)=>{if(H.test(k))return E===0&&(_=b),j+=b,k.replace(H,"");if(/^\s/.test(k)){const z=k.replace(/^\s/,"");return j+=k.length-z.length,z}return k}).join(`
|
|
61
|
+
`);return J(t,t.selectionStart-_,t.selectionEnd-j),`${v}${N}${S}`}else{const g=F(!0,!0);if(g)return g}break}case"ctrlC":{const{prefixSupply:b,subfixSupply:w}=fe(t);return he(e===""?`${b}${w}`:e),t.value}case"ctrlX":{const{prefixStrEndRow:b,subfixStrEndRow:w,prefixStr:v,subfixStr:S,prefixSupply:A,subfixSupply:L}=fe(t);return e===""?(he(`${A}${L}`),J(t,b.length),`${b}${w.replace(/^\n/,"")}`):(he(e),J(t,v.length),`${v}${S}`)}case"ctrlD":{const{prefixStrEndRow:b,subfixStrEndRow:w}=fe(t);return J(t,b.length),`${b}${w.replace(/^\n/,"")}`}case"flow":{l=`\`\`\`mermaid
|
|
62
|
+
${(h==null?void 0:h.flow)||`flowchart TD
|
|
63
63
|
Start --> Stop`}
|
|
64
64
|
\`\`\`
|
|
65
65
|
`,r=2;break}case"sequence":{l=`\`\`\`mermaid
|
|
66
|
-
${(
|
|
66
|
+
${(h==null?void 0:h.sequence)||`sequenceDiagram
|
|
67
67
|
A->>B: hello!
|
|
68
68
|
B-->>A: hi!
|
|
69
69
|
A-)B: bye!`}
|
|
70
70
|
\`\`\`
|
|
71
71
|
`,r=2;break}case"gantt":{l=`\`\`\`mermaid
|
|
72
|
-
${(
|
|
72
|
+
${(h==null?void 0:h.gantt)||`gantt
|
|
73
73
|
title A Gantt Diagram
|
|
74
74
|
dateFormat YYYY-MM-DD
|
|
75
75
|
section Section
|
|
@@ -77,27 +77,27 @@ A task :a1, 2014-01-01, 30d
|
|
|
77
77
|
Another task :after a1, 20d`}
|
|
78
78
|
\`\`\`
|
|
79
79
|
`,r=2;break}case"class":{l=`\`\`\`mermaid
|
|
80
|
-
${(
|
|
80
|
+
${(h==null?void 0:h.class)||`classDiagram
|
|
81
81
|
class Animal
|
|
82
82
|
Vehicle <|-- Car`}
|
|
83
83
|
\`\`\`
|
|
84
84
|
`,r=2;break}case"state":{l=`\`\`\`mermaid
|
|
85
|
-
${(
|
|
85
|
+
${(h==null?void 0:h.state)||`stateDiagram-v2
|
|
86
86
|
s1 --> s2`}
|
|
87
87
|
\`\`\`
|
|
88
88
|
`,r=2;break}case"pie":{l=`\`\`\`mermaid
|
|
89
|
-
${(
|
|
89
|
+
${(h==null?void 0:h.pie)||`pie title Pets adopted by volunteers
|
|
90
90
|
"Dogs" : 386
|
|
91
91
|
"Cats" : 85
|
|
92
92
|
"Rats" : 15`}
|
|
93
93
|
\`\`\`
|
|
94
94
|
`,r=2;break}case"relationship":{l=`\`\`\`mermaid
|
|
95
|
-
${(
|
|
95
|
+
${(h==null?void 0:h.relationship)||`erDiagram
|
|
96
96
|
CAR ||--o{ NAMED-DRIVER : allows
|
|
97
97
|
PERSON ||--o{ NAMED-DRIVER : is`}
|
|
98
98
|
\`\`\`
|
|
99
99
|
`,r=2;break}case"journey":{l=`\`\`\`mermaid
|
|
100
|
-
${(
|
|
100
|
+
${(h==null?void 0:h.journey)||`journey
|
|
101
101
|
title My working day
|
|
102
102
|
section Go to work
|
|
103
103
|
Make tea: 5: Me
|
|
@@ -110,9 +110,9 @@ ${(u==null?void 0:u.journey)||`journey
|
|
|
110
110
|
`,r=2;break}case"katexInline":{l="$$",r=1,a=-1;break}case"katexBlock":{l=`$$
|
|
111
111
|
|
|
112
112
|
$$
|
|
113
|
-
`,r=1,a=-4;break}}return je(
|
|
114
|
-
`),
|
|
113
|
+
`,r=1,a=-4;break}case"universal":{const{generate:b}=n,w=b(e);l=w.targetValue,s=w.select,r=w.deviationStart,a=w.deviationEnd}}return je(t,l,{deviationStart:r,deviationEnd:a,select:s,prefixVal:c,subfixVal:u})};var vt={block(i,e){return{name:"KaTexBlockExtension",level:"block",start:t=>{var n;return(n=t.match(/\n\$\$\n/))==null?void 0:n.index},tokenizer(t){if(/^\$\$\n/.test(t)&&t.split("$$").length>2){const n=Je(t,"$$");return{type:"KaTexBlockExtension",raw:n[0],text:n[1].trim(),tokens:[]}}},renderer(t){const n=e||typeof window!="undefined"&&window.katex;if(n){const l=n.renderToString(t.text,{throwOnError:!1,displayMode:!0});return`<span class="${i}-katex-block" data-processed>${l}</span>`}else return`<span class="${i}-katex-block">${t.text}</span>`}}},inline(i,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=Je(t);return{type:"KaTexInlineExtension",raw:n[0],text:n[1].trim(),tokens:[]}}},renderer(t){const n=e||typeof window!="undefined"&&window.katex;if(n){const l=n.renderToString(t.text,{throwOnError:!1});return`<span class="${i}-katex-inline" data-processed>${l}</span>`}else return`<span class="${i}-katex-inline">${t.text}</span>`}}}};const _n=(i,e,t)=>{var f,$;const n=o.inject("previewOnly"),l=o.inject("historyLength"),r=o.inject("editorId");if(n)return;let a=-1;const s={list:[{content:i.value,startPos:((f=e.value)==null?void 0:f.selectionStart)||0,endPos:(($=e.value)==null?void 0:$.selectionEnd)||0}],userUpdated:!0,curr:0},c=[0,0];let u=c;const h=x=>{var S,A;const b=((S=e.value)==null?void 0:S.selectionStart)||0,w=((A=e.value)==null?void 0:A.selectionEnd)||0;s.list[s.curr].startPos=b,s.list[s.curr].endPos=w,s.userUpdated=!1,s.curr=x;const v=s.list[s.curr];u=[v.startPos,v.endPos],i.onChange(v.content),J(e.value,v.startPos,v.endPos).then(()=>{y.emit(r,"selectTextChange")})},m=x=>{var v,S;clearTimeout(a);const b=((v=e.value)==null?void 0:v.selectionStart)||0,w=((S=e.value)==null?void 0:S.selectionEnd)||0;a=setTimeout(()=>{if(s.userUpdated){s.curr<s.list.length-1&&(s.list=s.list.slice(0,s.curr+1)),s.list.length>l&&s.list.shift();const A=s.list.pop()||{startPos:0,endPos:0,content:x};A.startPos=u[0],A.endPos=u[1],u=c,Array.prototype.push.call(s.list,A,{content:x,startPos:b,endPos:w}),s.curr=s.list.length-1}else s.userUpdated=!0},150)},p=x=>{var b,w;(u===c||x)&&(u=[(b=e.value)==null?void 0:b.selectionStart,(w=e.value)==null?void 0:w.selectionEnd])};o.watch([o.toRef(i,"value"),t],()=>{t.value&&m(i.value)}),o.watch(()=>i.value,()=>{y.emit(r,"selectTextChange")},{flush:"post"}),o.onMounted(()=>{y.on(r,{name:"ctrlZ",callback(){h(s.curr-1<0?0:s.curr-1)}}),y.on(r,{name:"ctrlShiftZ",callback(){h(s.curr+1===s.list.length?s.curr:s.curr+1)}}),y.on(r,{name:"saveHistoryPos",callback:p})})},jn=(i,e)=>{var _,j,N;const{markedRenderer:t,markedExtensions:n,markedOptions:l,editorExtensions:r,editorConfig:a}=M,s=o.inject("showCodeRowNumber"),c=o.inject("editorId"),u=o.inject("highlight"),h=o.inject("previewOnly"),m=(_=r==null?void 0:r.highlight)==null?void 0:_.instance,p=(j=r==null?void 0:r.mermaid)==null?void 0:j.instance,f=(N=r==null?void 0:r.katex)==null?void 0:N.instance,$=r==null?void 0:r.katex,x=o.ref(!1),b=o.ref(!1),w=o.ref([]);let v=new V.Renderer;const S=v.code;v.code=(k,E,z)=>{var I;if(!i.noMermaid&&E==="mermaid"){const P=`${d}-mermaid-${Date.now().toString(36)}`;try{let B="";return p?B=p.mermaidAPI.render(P,k):typeof window!="undefined"&&window.mermaid?B=window.mermaid.mermaidAPI.render(P,k):B=`<div class="mermaid">${k}</div>`,`<div class="${d}-mermaid">${B}</div>`}catch{if(typeof document!="undefined"){const Z=document.querySelector(`#${P}`);if(Z){const G=Z.outerHTML;return(I=Z.parentElement)==null||I.remove(),G}}return""}}return S.call(v,k,E,z)},v.image=(k,E,z)=>`<span class="figure"><img src="${k}" title="${E||""}" alt="${z||""}" zoom><span class="figcaption">${z||""}</span></span>`,v.listitem=(k,E)=>E?`<li class="li-task">${k}</li>`:`<li>${k}</li>`;const A=v.heading;t instanceof Function&&(v=t(v));const L=v.heading,H=A!==L;v.heading=(k,E,z,I)=>{if(w.value.push({text:z,level:E}),H)return L.call(v,k,E,z,I,w.value.length);const P=i.markedHeadingId(z,E,w.value.length);return k!==z?`<h${E} id="${P}">${k}</h${E}>`:`<h${E} id="${P}"><a href="#${P}">${z}</a></h${E}>`},V.setOptions(K({breaks:!0},l)),i.noKatex||V.use({extensions:[vt.inline(d,f),vt.block(d,f)]}),m&&V.setOptions({highlight:(k,E)=>{let z="";const I=m.getLanguage(E);return E&&I?z=m.highlight(k,{language:E,ignoreIllegals:!0}).value:z=m.highlightAuto(k).value,s?Ye(z):`<span class="code-block">${z}</span>`}}),n instanceof Array&&n.length>0&&V.use({extensions:n});const F=o.ref(i.sanitize(V(i.value||"",{renderer:v}))),g=ke(()=>{w.value=[];const k=i.sanitize(V(i.value||"",{renderer:v}));F.value=k,y.emit(c,"buildFinished",k),i.onHtmlChanged(k)},(a==null?void 0:a.renderDelay)!==void 0?a==null?void 0:a.renderDelay:h?0:500);o.watch([x,o.toRef(e,"reRender"),o.toRef(e,"mermaidInited"),b,o.toRef(i,"value")],g);const q=()=>{V.setOptions({highlight:(k,E)=>{let z="";const I=window.hljs.getLanguage(E);return E&&I?z=window.hljs.highlight(k,{language:E,ignoreIllegals:!0}).value:z=window.hljs.highlightAuto(k).value,s?Ye(z):`<span class="code-block">${z}</span>`}}),x.value=!0};return o.watch(()=>w.value,k=>{i.onGetCatalog(k),y.emit(c,"catalogChanged",k)}),o.onMounted(()=>{if(!i.noKatex&&!f){const k=document.createElement("script");k.src=($==null?void 0:$.js)||We.js,k.onload=()=>{b.value=!0},k.id=`${d}-katex`;const E=document.createElement("link");E.rel="stylesheet",E.href=($==null?void 0:$.css)||We.css,E.id=`${d}-katexCss`,Q(k,"katex"),Q(E)}if(!m){const k=document.createElement("link");k.rel="stylesheet",k.href=u.value.css,k.id=`${d}-hlCss`;const E=document.createElement("script");E.src=u.value.js,E.onload=q,E.id=`${d}-hljs`,Q(k),Q(E,"hljs")}}),o.watch(()=>u.value.css,k=>{Rt(`${d}-hlCss`,"href",k)}),o.onMounted(()=>{y.on(c,{name:"pushCatalog",callback(){y.emit(c,"catalogChanged",w.value)}})}),{html:F}},Rn=(i,e,t,n,l)=>{const r=o.inject("previewOnly"),a=o.inject("usedLanguageText"),s=o.inject("editorId");let c=()=>{},u=()=>{};const h=()=>{document.querySelectorAll(`#${s}-preview pre`).forEach(f=>{var b;const $=((b=a.value.copyCode)==null?void 0:b.text)||"\u590D\u5236\u4EE3\u7801",x=document.createElement("span");x.setAttribute("class","copy-button"),x.innerText=$,x.addEventListener("click",()=>{var L,H;const w=f.querySelector("code").innerText,v=he(i.formatCopiedText(w)),S=((L=a.value.copyCode)==null?void 0:L.successTips)||"\u5DF2\u590D\u5236\uFF01",A=((H=a.value.copyCode)==null?void 0:H.failTips)||"\u5DF2\u590D\u5236\uFF01";x.innerText=v?S:A,setTimeout(()=>{x.innerText=$},1500)}),f.appendChild(x)})},m=()=>{o.nextTick(()=>{i.setting.preview&&!r&&i.scrollAuto&&(c(),u()),h()})},p=f=>{f&&!r&&o.nextTick(()=>{c(),[u,c]=Xe(t.value,n.value||l.value),u()})};o.watch(()=>e.value,m),o.watch(()=>i.setting.preview,p),o.watch(()=>i.setting.htmlPreview,p),o.watch(()=>i.scrollAuto,f=>{f?u():c()}),o.onMounted(()=>{h(),!r&&(n.value||l.value)&&([u,c]=Xe(t.value,n.value||l.value)),i.scrollAuto&&u()})},Dn=(i,e)=>{const t=o.inject("previewOnly"),n=o.inject("tabWidth"),l=o.inject("editorId"),r=o.ref("");o.onMounted(()=>{var a;t||((a=e.value)==null||a.addEventListener("keypress",s=>{var c,u,h;if(s.key==="Enter"){const m=(c=e.value)==null?void 0:c.selectionStart,p=(u=e.value)==null?void 0:u.value.substring(0,m),f=(h=e.value)==null?void 0:h.value.substring(m),$=p==null?void 0:p.lastIndexOf(`
|
|
114
|
+
`),x=p==null?void 0:p.substring($+1,m);if(/^\d+\.\s|^-\s/.test(x))if(s.cancelBubble=!0,s.preventDefault(),s.stopPropagation(),/^(\d+\.|-)\s+(\[[x\s]\]\s+)?$/.test(x)){const b=p==null?void 0:p.replace(/(\d+\.|-)\s+(\[[x\s]\]\s+)?$/,"");i.onChange(b+f),J(e.value,b==null?void 0:b.length)}else if(/^-\s+.+/.test(x)){const b=/^-\s+\[[x\s]\]/.test(x)?`
|
|
115
115
|
- [ ] `:`
|
|
116
|
-
- `;i.onChange(je(
|
|
117
|
-
${
|
|
118
|
-
${b}. `;i.onChange(je(t.value,y,{}))}}}),C.on(l,{name:"replace",callback(s,d={}){i.onChange(Sn(s,r.value,t.value,ue(K({},d),{tabWidth:n,editorId:l})))}}))}),o.watch(()=>i.value,()=>{r.value=""}),C.on(l,{name:"selectTextChange",callback(){r.value=Nt(t.value)}})},zn=i=>{const t=o.inject("theme"),{editorExtensions:e}=M,n=e==null?void 0:e.mermaid,l=o.reactive({reRender:!1,mermaidInited:!!(n!=null&&n.instance)}),r=()=>{i.noMermaid||(n!=null&&n.instance?n.instance.initialize({theme:t.value==="dark"?"dark":"default"}):window.mermaid&&window.mermaid.initialize({theme:t.value==="dark"?"dark":"default"}),l.reRender=!l.reRender)};o.watch(()=>t.value,r);let a;return o.onMounted(()=>{!i.noMermaid&&!(n!=null&&n.instance)?(a=document.createElement("script"),a.src=(n==null?void 0:n.js)||vt,a.onload=()=>{window.mermaid.initialize({theme:t.value==="dark"?"dark":"default",logLevel:"Fatal"}),l.mermaidInited=!0},a.id=`${c}-mermaid`,Q(a,"mermaid")):i.noMermaid||r()}),l},In=i=>{const t=o.inject("editorId"),e=o.inject("previewOnly"),n=l=>{if(l.clipboardData&&l.clipboardData.files.length>0){const{files:r}=l.clipboardData;C.emit(t,"uploadImage",Array.from(r).filter(a=>/image\/.*/.test(a.type))),l.preventDefault()}};o.onMounted(()=>{e||i.value.addEventListener("paste",n)}),o.onBeforeUnmount(()=>{e||i.value.removeEventListener("paste",n)})},An=i=>{const t=o.inject("editorId"),e=ke(()=>{const n=document.querySelectorAll(`#${t}-preview img[zoom]`);n.length!==0&&Cn(n,{background:"#00000073"})});o.onMounted(e),o.watch([i],e)},Ln=()=>({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:i=>i},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:i=>i}});var Fn=o.defineComponent({name:"MDEditorContent",props:Ln(),setup(i){const t=o.ref(!0),e=o.inject("previewOnly"),n=o.inject("showCodeRowNumber"),l=o.inject("previewTheme"),r=o.inject("editorId"),a=o.ref(),s=o.ref(),d=o.ref(),h=zn(i),{html:u}=Nn(i,h);return Tn(i,u,a,s,d),Vn(i,a),En(i,a,t),In(a),An(u),()=>o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${c}-content`},[!e&&o.createVNode("div",{class:`${c}-input-wrapper`},[o.createVNode("textarea",{id:`${r}-textarea`,ref:a,value:i.value,onKeydown:()=>{C.emit(r,"saveHistoryPos",!0)},onCompositionstart:()=>{t.value=!1},onInput:m=>{i.onChange(m.target.value)},onCompositionend:()=>{t.value=!0},class:[i.setting.preview||i.setting.htmlPreview?"":"textarea-only"],placeholder:i.placeholder},null)]),i.setting.preview&&o.createVNode("div",{id:`${r}-preview-wrapper`,class:`${c}-preview-wrapper`,ref:s,key:"content-preview-wrapper"},[o.createVNode("div",{id:`${r}-preview`,class:[`${c}-preview`,`${l==null?void 0:l.value}-theme`,n&&`${c}-scrn`],innerHTML:u.value},null)]),i.setting.htmlPreview&&o.createVNode("div",{class:`${c}-preview-wrapper`,ref:d,key:"html-preview-wrapper"},[o.createVNode("div",{class:`${c}-html`},[u.value])])])])}}),jn=o.defineComponent({props:{modelValue:{type:String,default:""}},setup(i){const t=o.inject("usedLanguageText");return()=>{var e,n;return o.createVNode("div",{class:`${c}-footer-item`},[o.createVNode("label",{class:`${c}-footer-label`},[`${(e=t.value.footer)==null?void 0:e.markdownTotal}:`]),o.createVNode("span",null,[((n=i.modelValue)==null?void 0:n.length)||0])])}}}),oi="";const Dn=()=>({checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>()=>{}}});var _n=o.defineComponent({props:Dn(),setup(i){return()=>o.createVNode("div",{class:[`${c}-checkbox`,i.checked&&`${c}-checkbox-checked`],onClick:()=>{i.onChange(!i.checked)}},null)}});const Rn=()=>({scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>()=>{}}});var Hn=o.defineComponent({props:Rn(),setup(i){const t=o.inject("usedLanguageText");return()=>{var e;return o.createVNode("div",{class:`${c}-footer-item`},[o.createVNode("label",{class:`${c}-footer-label`,onClick:()=>{i.onScrollAutoChange(!i.scrollAuto)}},[(e=t.value.footer)==null?void 0:e.scrollAuto]),o.createVNode(_n,{checked:i.scrollAuto,onChange:i.onScrollAutoChange},null)])}}});const Pn=()=>({modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>()=>{}},defFooters:{type:Object}});var On=o.defineComponent({name:"MDEditorFooter",props:Pn(),setup(i){const t=o.computed(()=>{const n=i.footers.indexOf("="),l=n===-1?i.footers:i.footers.slice(0,n),r=n===-1?[]:i.footers.slice(n,Number.MAX_SAFE_INTEGER);return[l,r]}),e=n=>{if(qe.includes(n))switch(n){case"markdownTotal":return o.createVNode(jn,{modelValue:i.modelValue},null);case"scrollSwitch":return o.createVNode(Hn,{scrollAuto:i.scrollAuto,onScrollAutoChange:i.onScrollAutoChange},null)}else return i.defFooters instanceof Array?i.defFooters[n]||"":i.defFooters&&i.defFooters.children instanceof Array&&i.defFooters.children[n]||""};return()=>{const n=t.value[0].map(r=>e(r)),l=t.value[1].map(r=>e(r));return o.createVNode("div",{class:`${c}-footer`},[o.createVNode("div",{class:`${c}-footer-left`},[n]),o.createVNode("div",{class:`${c}-footer-right`},[l])])}}});const Mn=()=>({tocItem:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:()=>()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>()=>{}}}),mt=o.defineComponent({props:Mn(),setup(i){return()=>{const{tocItem:t,markedHeadingId:e,scrollElement:n,onClick:l}=i;return o.createVNode("div",{class:[`${c}-catalog-link`,t.active&&`${c}-catalog-active`],onClick:r=>{l(r,t),r.stopPropagation();const a=e(t.text,t.level,t.index),s=document.getElementById(a),d=n instanceof Element?n:document.querySelector(n);if(s&&d){let h=s.offsetParent,u=s.offsetTop;if(d.contains(h))for(;h&&d!=h;)u+=h==null?void 0:h.offsetTop,h=h==null?void 0:h.offsetParent;d==null||d.scrollTo({top:u,behavior:"smooth"})}}},[o.createVNode("span",{title:t.text},[t.text]),o.createVNode("div",{class:`${c}-catalog-wrapper`},[t.children&&t.children.map(r=>o.createVNode(mt,{markedHeadingId:e,key:`${t.text}-link-${r.level}-${r.text}`,tocItem:r,scrollElement:n,onClick:l},null))])])}}});var ri="";const Bn=()=>({editorId:{type:String},class:{type:String,default:""},markedHeadingId:{type:Function,default:i=>i},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20}}),$e=o.defineComponent({name:"MdCatalog",props:Bn(),emits:["onClick"],setup(i,t){const e=i.editorId,n=o.reactive({list:[],show:!1,scrollElement:i.scrollElement||`#${e}-preview-wrapper`}),l=o.computed(()=>{const r=[];return n.list.forEach(({text:a,level:s,active:d},h)=>{const u={level:s,text:a,index:h+1,active:!!d};if(r.length===0)r.push(u);else{let m=r[r.length-1];if(u.level>m.level)for(let k=m.level+1;k<=6;k++){const{children:f}=m;if(!f){m.children=[u];break}if(m=f[f.length-1],u.level<=m.level){f.push(u);break}}else r.push(u)}}),r});return o.onMounted(()=>{C.on(e,{name:"catalogChanged",callback:r=>{n.list=r.map((a,s)=>s===0?ue(K({},a),{active:!0}):K({},a))}}),C.emit(e,"pushCatalog")}),o.onMounted(()=>{var a;const r=n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement);(a=r===document.documentElement?window:r)==null||a.addEventListener("scroll",Et(()=>{if(n.list.length===0)return!1;const{activeHead:s}=n.list.reduce((d,h,u)=>{const m=document.getElementById(i.markedHeadingId(h.text,h.level,u+1));if(m instanceof HTMLElement){const k=Tt(m,r);if(k<i.offsetTop&&k>d.minTop)return{activeHead:h,minTop:k}}return d},{activeHead:n.list[0],minTop:Number.MIN_SAFE_INTEGER});n.list=n.list.map(d=>d===s?ue(K({},d),{active:!0}):ue(K({},d),{active:!1}))}))}),()=>o.createVNode("div",{class:`${c}-catalog${i.theme==="dark"?"-dark":""} ${i.class}`},[l.value.map(r=>o.createVNode(mt,{markedHeadingId:i.markedHeadingId,tocItem:r,key:`link-${r.level}-${r.text}`,scrollElement:n.scrollElement,onClick:(a,s)=>{t.emit("onClick",a,s)}},null))])}});var ai="",si="";const Un=()=>({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:Ue},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:"md-editor-v3"},tabWidth:{type:Number,default:2},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:qn},tableShape:{type:Array,default:()=>[6,4]},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:i=>i},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:qe},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:i=>i},noUploadImg:{type:Boolean}}),qn=i=>i,ne=o.defineComponent({name:"MdEditorV3",props:Un(),emits:["onChange","onSave","onUploadImg","onHtmlChanged","onGetCatalog","onError","update:modelValue"],setup(i,t){const{editorId:e}=i,n=o.reactive({scrollAuto:i.scrollAuto});zt(i,t),It(i),At(i);const[l,r]=Lt(i,t),[a,s]=Ft(i);return o.onBeforeUnmount(()=>{C.clear(e)}),()=>{var u;const d=X({props:i,ctx:t},"defToolbars"),h=X({props:i,ctx:t},"defFooters");return o.createVNode("div",{id:e,class:[c,i.class,i.theme==="dark"&&`${c}-dark`,l.fullscreen||l.pageFullScreen?`${c}-fullscreen`:"",i.previewOnly&&`${c}-previewOnly`],style:i.style},[!i.previewOnly&&o.createVNode(Wt,{noPrettier:i.noPrettier,toolbars:i.toolbars,toolbarsExclude:i.toolbarsExclude,setting:l,updateSetting:r,tableShape:i.tableShape,defToolbars:d,noUploadImg:i.noUploadImg},null),o.createVNode(Fn,{value:i.modelValue,onChange:m=>{C.emit(e,"saveHistoryPos"),i.onChange?i.onChange(m):(t.emit("update:modelValue",m),t.emit("onChange",m))},setting:l,onHtmlChanged:m=>{i.onHtmlChanged?i.onHtmlChanged(m):t.emit("onHtmlChanged",m)},onGetCatalog:m=>{i.onGetCatalog?i.onGetCatalog(m):t.emit("onGetCatalog",m)},markedHeadingId:i.markedHeadingId,noMermaid:i.noMermaid,sanitize:i.sanitize,placeholder:i.placeholder,noKatex:i.noKatex,scrollAuto:n.scrollAuto,formatCopiedText:i.formatCopiedText},null),!i.previewOnly&&((u=i.footers)==null?void 0:u.length)>0&&o.createVNode(On,{modelValue:i.modelValue,footers:i.footers,defFooters:h,scrollAuto:n.scrollAuto,onScrollAutoChange:m=>n.scrollAuto=m},null),s.value&&!i.previewOnly&&o.createVNode($e,{theme:i.theme,style:{display:a.value?"block":"none"},class:`${c}-catalog-editor`,editorId:e,markedHeadingId:i.markedHeadingId},null)])}}}),Kn=()=>({title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function}});var He=o.defineComponent({name:"NormalToolbar",props:Kn(),emits:["onClick"],setup(i,t){return()=>{const e=X({props:i,ctx:t},"trigger");return o.createVNode("div",{class:`${c}-toolbar-item`,title:i.title,onClick:n=>{i.onClick instanceof Function?i.onClick(n):t.emit("onClick",n)}},[e])}}});const Zn=()=>({title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]}});var Pe=o.defineComponent({name:"DropdownToolbar",props:Zn(),emits:["onChange"],setup(i,t){const e=o.inject("editorId");return()=>{const n=X({props:i,ctx:t},"trigger"),l=X({props:i,ctx:t},"overlay");return o.createVNode(re,{relative:`#${e}-toolbar-wrapper`,visible:i.visible,onChange:r=>{i.onChange instanceof Function?i.onChange(r):t.emit("onChange",r)},overlay:l},{default:()=>[o.createVNode("div",{class:`${c}-toolbar-item`,title:i.title||""},[n])]})}}});function Wn(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Object]"&&!o.isVNode(i)}const Gn=()=>({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}});var Oe=o.defineComponent({name:"ModalToolbar",props:Gn(),emits:["onClick","onClose","onAdjust"],setup(i,t){return()=>{const e=X({props:i,ctx:t},"trigger"),n=X({props:i,ctx:t},"default");return o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${c}-toolbar-item`,title:i.title,onClick:()=>{i.onClick instanceof Function?i.onClick():t.emit("onClick")}},[e]),o.createVNode(De,{width:i.width,height:i.height,title:i.modalTitle,visible:i.visible,onClose:()=>{i.onClose instanceof Function?i.onClose():t.emit("onClose")},showAdjust:i.showAdjust,isFullscreen:i.isFullscreen,onAdjust:l=>{i.onAdjust instanceof Function?i.onAdjust(l):t.emit("onAdjust",l)}},Wn(n)?n:{default:()=>[n]})])}}});return ne.install=i=>(i.component(ne.name,ne),i.component(He.name,He),i.component(Pe.name,Pe),i.component($e.name,$e),i.component(Oe.name,Oe),i),ne.NormalToolbar=He,ne.DropdownToolbar=Pe,ne.MdCatalog=$e,ne.ModalToolbar=Oe,ne.config=xt,ne});
|
|
116
|
+
- `;i.onChange(je(e.value,b,{}))}else{const b=x==null?void 0:x.match(/\d+(?=\.)/),w=b&&Number(b[0])+1||1,v=/^\d\.\s+\[[x\s]\]/.test(x)?`
|
|
117
|
+
${w}. [ ] `:`
|
|
118
|
+
${w}. `;i.onChange(je(e.value,v,{}))}}}),y.on(l,{name:"replace",callback(s,c={}){i.onChange(Ln(s,r.value,e.value,ue(K({},c),{tabWidth:n,editorId:l})))}}))}),o.watch(()=>i.value,()=>{r.value=""}),y.on(l,{name:"selectTextChange",callback(){r.value=_t(e.value)}})},Hn=i=>{const e=o.inject("theme"),{editorExtensions:t}=M,n=t==null?void 0:t.mermaid,l=o.reactive({reRender:!1,mermaidInited:!!(n!=null&&n.instance)}),r=()=>{i.noMermaid||(n!=null&&n.instance?n.instance.initialize({theme:e.value==="dark"?"dark":"default"}):window.mermaid&&window.mermaid.initialize({theme:e.value==="dark"?"dark":"default"}),l.reRender=!l.reRender)};o.watch(()=>e.value,r);let a;return o.onMounted(()=>{!i.noMermaid&&!(n!=null&&n.instance)?(a=document.createElement("script"),a.src=(n==null?void 0:n.js)||Vt,a.onload=()=>{window.mermaid.initialize({theme:e.value==="dark"?"dark":"default",logLevel:"Fatal"}),l.mermaidInited=!0},a.id=`${d}-mermaid`,Q(a,"mermaid")):i.noMermaid||r()}),l},Pn=i=>{const e=o.inject("editorId"),t=o.inject("previewOnly"),n=l=>{if(l.clipboardData&&l.clipboardData.files.length>0){const{files:r}=l.clipboardData;y.emit(e,"uploadImage",Array.from(r).filter(a=>/image\/.*/.test(a.type))),l.preventDefault()}};o.onMounted(()=>{t||i.value.addEventListener("paste",n)}),o.onBeforeUnmount(()=>{t||i.value.removeEventListener("paste",n)})},On=(i,e)=>{const t=o.inject("editorId"),n=ke(()=>{const l=document.querySelectorAll(`#${t}-preview img[zoom]`);l.length!==0&&An(l,{background:"#00000073"})});o.onMounted(n),o.watch([e,o.toRef(i.setting,"preview")],n)},Mn=()=>({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:i=>i},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:i=>i}});var Bn=o.defineComponent({name:"MDEditorContent",props:Mn(),setup(i){const e=o.ref(!0),t=o.inject("previewOnly"),n=o.inject("showCodeRowNumber"),l=o.inject("previewTheme"),r=o.inject("editorId"),a=o.ref(),s=o.ref(),c=o.ref(),u=Hn(i),{html:h}=jn(i,u);return Rn(i,h,a,s,c),Dn(i,a),_n(i,a,e),Pn(a),On(i,h),()=>o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${d}-content`},[!t&&o.createVNode("div",{class:`${d}-input-wrapper`},[o.createVNode("textarea",{id:`${r}-textarea`,ref:a,value:i.value,onBlur:()=>{y.emit(r,"selectTextChange")},onKeydown:()=>{y.emit(r,"saveHistoryPos",!0)},onCompositionstart:()=>{e.value=!1},onInput:m=>{i.onChange(m.target.value)},onCompositionend:()=>{e.value=!0},class:[i.setting.preview||i.setting.htmlPreview?"":"textarea-only"],placeholder:i.placeholder},null)]),i.setting.preview&&o.createVNode("div",{id:`${r}-preview-wrapper`,class:`${d}-preview-wrapper`,ref:s,key:"content-preview-wrapper"},[o.createVNode("div",{id:`${r}-preview`,class:[`${d}-preview`,`${l==null?void 0:l.value}-theme`,n&&`${d}-scrn`],innerHTML:h.value},null)]),i.setting.htmlPreview&&o.createVNode("div",{class:`${d}-preview-wrapper`,ref:c,key:"html-preview-wrapper"},[o.createVNode("div",{class:`${d}-html`},[h.value])])])])}}),Un=o.defineComponent({props:{modelValue:{type:String,default:""}},setup(i){const e=o.inject("usedLanguageText");return()=>{var t,n;return o.createVNode("div",{class:`${d}-footer-item`},[o.createVNode("label",{class:`${d}-footer-label`},[`${(t=e.value.footer)==null?void 0:t.markdownTotal}:`]),o.createVNode("span",null,[((n=i.modelValue)==null?void 0:n.length)||0])])}}}),mi="";const qn=()=>({checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>()=>{}}});var Kn=o.defineComponent({props:qn(),setup(i){return()=>o.createVNode("div",{class:[`${d}-checkbox`,i.checked&&`${d}-checkbox-checked`],onClick:()=>{i.onChange(!i.checked)}},null)}});const Zn=()=>({scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>()=>{}}});var Gn=o.defineComponent({props:Zn(),setup(i){const e=o.inject("usedLanguageText");return()=>{var t;return o.createVNode("div",{class:`${d}-footer-item`},[o.createVNode("label",{class:`${d}-footer-label`,onClick:()=>{i.onScrollAutoChange(!i.scrollAuto)}},[(t=e.value.footer)==null?void 0:t.scrollAuto]),o.createVNode(Kn,{checked:i.scrollAuto,onChange:i.onScrollAutoChange},null)])}}});const Wn=()=>({modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>()=>{}},defFooters:{type:Object}});var Qn=o.defineComponent({name:"MDEditorFooter",props:Wn(),setup(i){const e=o.computed(()=>{const n=i.footers.indexOf("="),l=n===-1?i.footers:i.footers.slice(0,n),r=n===-1?[]:i.footers.slice(n,Number.MAX_SAFE_INTEGER);return[l,r]}),t=n=>{if(Ze.includes(n))switch(n){case"markdownTotal":return o.createVNode(Un,{modelValue:i.modelValue},null);case"scrollSwitch":return o.createVNode(Gn,{scrollAuto:i.scrollAuto,onScrollAutoChange:i.onScrollAutoChange},null)}else return i.defFooters instanceof Array?i.defFooters[n]||"":i.defFooters&&i.defFooters.children instanceof Array&&i.defFooters.children[n]||""};return()=>{const n=e.value[0].map(r=>t(r)),l=e.value[1].map(r=>t(r));return o.createVNode("div",{class:`${d}-footer`},[o.createVNode("div",{class:`${d}-footer-left`},[n]),o.createVNode("div",{class:`${d}-footer-right`},[l])])}}});const Xn=()=>({tocItem:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:()=>()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>()=>{}}}),xt=o.defineComponent({props:Xn(),setup(i){return()=>{const{tocItem:e,markedHeadingId:t,scrollElement:n,onClick:l}=i;return o.createVNode("div",{class:[`${d}-catalog-link`,e.active&&`${d}-catalog-active`],onClick:r=>{l(r,e),r.stopPropagation();const a=t(e.text,e.level,e.index),s=document.getElementById(a),c=n instanceof Element?n:document.querySelector(n);if(s&&c){let u=s.offsetParent,h=s.offsetTop;if(c.contains(u))for(;u&&c!=u;)h+=u==null?void 0:u.offsetTop,u=u==null?void 0:u.offsetParent;c==null||c.scrollTo({top:h,behavior:"smooth"})}}},[o.createVNode("span",{title:e.text},[e.text]),o.createVNode("div",{class:`${d}-catalog-wrapper`},[e.children&&e.children.map(r=>o.createVNode(xt,{markedHeadingId:t,key:`${e.text}-link-${r.level}-${r.text}`,tocItem:r,scrollElement:n,onClick:l},null))])])}}});var gi="";const Yn=()=>({editorId:{type:String},class:{type:String,default:""},markedHeadingId:{type:Function,default:i=>i},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20}}),Ce=o.defineComponent({name:"MdCatalog",props:Yn(),emits:["onClick"],setup(i,e){const t=i.editorId,n=o.reactive({list:[],show:!1,scrollElement:i.scrollElement||`#${t}-preview-wrapper`}),l=o.computed(()=>{const r=[];return n.list.forEach(({text:a,level:s,active:c},u)=>{const h={level:s,text:a,index:u+1,active:!!c};if(r.length===0)r.push(h);else{let m=r[r.length-1];if(h.level>m.level)for(let p=m.level+1;p<=6;p++){const{children:f}=m;if(!f){m.children=[h];break}if(m=f[f.length-1],h.level<=m.level){f.push(h);break}}else r.push(h)}}),r});return o.onMounted(()=>{y.on(t,{name:"catalogChanged",callback:r=>{n.list=r.map((a,s)=>s===0?ue(K({},a),{active:!0}):K({},a))}}),y.emit(t,"pushCatalog")}),o.onMounted(()=>{var a;const r=n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement);(a=r===document.documentElement?window:r)==null||a.addEventListener("scroll",Lt(()=>{if(n.list.length===0)return!1;const{activeHead:s}=n.list.reduce((c,u,h)=>{const m=document.getElementById(i.markedHeadingId(u.text,u.level,h+1));if(m instanceof HTMLElement){const p=jt(m,r);if(p<i.offsetTop&&p>c.minTop)return{activeHead:u,minTop:p}}return c},{activeHead:n.list[0],minTop:Number.MIN_SAFE_INTEGER});n.list=n.list.map(c=>c===s?ue(K({},c),{active:!0}):ue(K({},c),{active:!1}))}))}),()=>o.createVNode("div",{class:`${d}-catalog${i.theme==="dark"?"-dark":""} ${i.class}`},[l.value.map(r=>o.createVNode(xt,{markedHeadingId:i.markedHeadingId,tocItem:r,key:`link-${r.level}-${r.text}`,scrollElement:n.scrollElement,onClick:(a,s)=>{e.emit("onClick",a,s)}},null))])}});var pi="",ki="";const Jn=()=>({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:Ke},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:"md-editor-v3"},tabWidth:{type:Number,default:2},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},markedHeadingId:{type:Function,default:ei},tableShape:{type:Array,default:()=>[6,4]},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:i=>i},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:Ze},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:i=>i},noUploadImg:{type:Boolean},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]}}),ei=i=>i,ne=o.defineComponent({name:"MdEditorV3",props:Jn(),emits:["onChange","onSave","onUploadImg","onHtmlChanged","onGetCatalog","onError","update:modelValue"],setup(i,e){const{editorId:t,previewOnly:n,noKatex:l,noMermaid:r,noPrettier:a,noUploadImg:s}=i,c=o.reactive({scrollAuto:i.scrollAuto});Dt(i,e),Ht(i),Pt(i);const[u,h]=Ot(i,e),[m,p]=Mt(i);return o.onBeforeUnmount(()=>{y.clear(t)}),Bt(i,e,m,u,h),()=>{var x;const f=X({props:i,ctx:e},"defToolbars"),$=X({props:i,ctx:e},"defFooters");return o.createVNode("div",{id:t,class:[d,i.class,i.theme==="dark"&&`${d}-dark`,u.fullscreen||u.pageFullscreen?`${d}-fullscreen`:"",n&&`${d}-previewOnly`],style:i.style},[!n&&o.createVNode(ln,{noPrettier:a,toolbars:i.toolbars,toolbarsExclude:i.toolbarsExclude,setting:u,updateSetting:h,tableShape:i.tableShape,defToolbars:f,noUploadImg:s},null),o.createVNode(Bn,{value:i.modelValue,onChange:b=>{y.emit(t,"saveHistoryPos"),i.onChange?i.onChange(b):(e.emit("update:modelValue",b),e.emit("onChange",b))},setting:u,onHtmlChanged:b=>{i.onHtmlChanged?i.onHtmlChanged(b):e.emit("onHtmlChanged",b)},onGetCatalog:b=>{i.onGetCatalog?i.onGetCatalog(b):e.emit("onGetCatalog",b)},markedHeadingId:i.markedHeadingId,noMermaid:r,sanitize:i.sanitize,placeholder:i.placeholder,noKatex:l,scrollAuto:c.scrollAuto,formatCopiedText:i.formatCopiedText},null),!n&&((x=i.footers)==null?void 0:x.length)>0&&o.createVNode(Qn,{modelValue:i.modelValue,footers:i.footers,defFooters:$,scrollAuto:c.scrollAuto,onScrollAutoChange:b=>c.scrollAuto=b},null),p.value&&!n&&o.createVNode(Ce,{theme:i.theme,style:{display:m.value?"block":"none"},class:`${d}-catalog-editor`,editorId:t,markedHeadingId:i.markedHeadingId},null)])}}}),ti=()=>({title:{type:String,default:""},trigger:{type:[String,Object]},onClick:{type:Function}});var Oe=o.defineComponent({name:"NormalToolbar",props:ti(),emits:["onClick"],setup(i,e){return()=>{const t=X({props:i,ctx:e},"trigger");return o.createVNode("div",{class:`${d}-toolbar-item`,title:i.title,onClick:n=>{i.onClick instanceof Function?i.onClick(n):e.emit("onClick",n)}},[t])}}});const ni=()=>({title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]}});var Me=o.defineComponent({name:"DropdownToolbar",props:ni(),emits:["onChange"],setup(i,e){const t=o.inject("editorId");return()=>{const n=X({props:i,ctx:e},"trigger"),l=X({props:i,ctx:e},"overlay");return o.createVNode(re,{relative:`#${t}-toolbar-wrapper`,visible:i.visible,onChange:r=>{i.onChange instanceof Function?i.onChange(r):e.emit("onChange",r)},overlay:l},{default:()=>[o.createVNode("div",{class:`${d}-toolbar-item`,title:i.title||""},[n])]})}}});function ii(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Object]"&&!o.isVNode(i)}const li=()=>({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}});var Be=o.defineComponent({name:"ModalToolbar",props:li(),emits:["onClick","onClose","onAdjust"],setup(i,e){return()=>{const t=X({props:i,ctx:e},"trigger"),n=X({props:i,ctx:e},"default");return o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${d}-toolbar-item`,title:i.title,onClick:()=>{i.onClick instanceof Function?i.onClick():e.emit("onClick")}},[t]),o.createVNode(De,{width:i.width,height:i.height,title:i.modalTitle,visible:i.visible,onClose:()=>{i.onClose instanceof Function?i.onClose():e.emit("onClose")},showAdjust:i.showAdjust,isFullscreen:i.isFullscreen,onAdjust:l=>{i.onAdjust instanceof Function?i.onAdjust(l):e.emit("onAdjust",l)}},ii(n)?n:{default:()=>[n]})])}}});return ne.install=i=>(i.component(ne.name,ne),i.component(Oe.name,Oe),i.component(Me.name,Me),i.component(Ce.name,Ce),i.component(Be.name,Be),i),ne.NormalToolbar=Oe,ne.DropdownToolbar=Me,ne.MdCatalog=Ce,ne.ModalToolbar=Be,ne.config=zt,ne});
|