md-editor-v3 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,66 +1,66 @@
1
- "use strict";const o=require("vue"),N=require("@vavt/util"),p=require("./config.cjs"),f=require("./event-bus.cjs"),I=require("./dom.cjs"),re=require("@vavt/copy2clipboard"),ae=require("markdown-it"),ie=require("markdown-it-image-figures"),le=require("markdown-it-sub"),se=require("markdown-it-sup"),ce=require("./index5.cjs"),de=require("lru-cache"),ue=require("medium-zoom"),T={hljs:`${p.prefix}-hljs`,hlcss:`${p.prefix}-hlCss`,prettier:`${p.prefix}-prettier`,prettierMD:`${p.prefix}-prettierMD`,cropperjs:`${p.prefix}-cropper`,croppercss:`${p.prefix}-cropperCss`,screenfull:`${p.prefix}-screenfull`,mermaidM:`${p.prefix}-mermaid-m`,mermaid:`${p.prefix}-mermaid`,katexjs:`${p.prefix}-katex`,katexcss:`${p.prefix}-katexCss`,echarts:`${p.prefix}-echarts`},me=(e,t,i)=>{const{editorId:n}=i,r=o.reactive({buildFinished:!1,html:""});o.watch(()=>e.modelValue,()=>{r.buildFinished=!1}),o.onMounted(()=>{f.bus.on(n,{name:f.BUILD_FINISHED,callback(h){r.buildFinished=!0,r.html=h}}),f.bus.on(n,{name:f.ON_SAVE,callback(){const h=new Promise(c=>{if(r.buildFinished)c(r.html);else{const u=s=>{c(s),f.bus.remove(n,f.BUILD_FINISHED,u)};f.bus.on(n,{name:f.BUILD_FINISHED,callback:u})}});e.onSave?e.onSave(e.modelValue,h):t.emit("onSave",e.modelValue,h)}})})},J=(e,{editorId:t,rootRef:i})=>{const n=p.globalConfig.editorExtensions.highlight,r=p.globalConfig.editorExtensionsAttrs.highlight;o.provide("editorId",t),o.provide("rootRef",i),o.provide("theme",o.computed(()=>e.theme)),o.provide("language",o.computed(()=>e.language)),o.provide("highlight",o.computed(()=>{const{js:c}=n,u={...p.codeCss,...n.css},{js:s,css:d={}}=r||{},l=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme,a=u[e.codeTheme]?u[e.codeTheme][l]:p.codeCss.atom[l],m=u[e.codeTheme]&&d[e.codeTheme]?d[e.codeTheme][l]:d.atom?d.atom[l]:{};return{js:{src:c,...s},css:{href:a,...m}}})),o.provide("showCodeRowNumber",e.showCodeRowNumber);const h=o.computed(()=>{const c={...p.staticTextDefault,...p.globalConfig.editorConfig.languageUserDefined};return N.deepMerge(N.deepClone(p.staticTextDefault["en-US"]),c[e.language]||{})});return o.provide("usedLanguageText",h),o.provide("previewTheme",o.computed(()=>e.previewTheme)),o.provide("customIcon",o.computed(()=>e.customIcon)),{editorId:t}},fe=(e,t)=>(o.provide("tabWidth",e.tabWidth),o.provide("disabled",o.computed(()=>e.disabled)),o.provide("showToolbarName",o.computed(()=>e.showToolbarName)),o.provide("noUploadImg",e.noUploadImg),o.provide("tableShape",o.computed(()=>e.tableShape)),o.provide("noPrettier",e.noPrettier),o.provide("codeTheme",o.computed(()=>e.codeTheme)),o.provide("setting",o.computed(()=>({...t.setting}))),o.provide("updateSetting",t.updateSetting),o.provide("catalogVisible",o.computed(()=>t.catalogVisible.value)),o.provide("defToolbars",t.defToolbars),o.provide("floatingToolbars",o.computed(()=>e.floatingToolbars)),J(e,t)),pe=e=>{const{noPrettier:t,noUploadImg:i}=e,{editorExtensions:n,editorExtensionsAttrs:r}=p.globalConfig,h=t||n.prettier.prettierInstance,c=t||n.prettier.parserMarkdownInstance,u=i||n.cropper.instance;o.onMounted(()=>{if(!u){const{js:s={},css:d={}}=r.cropper||{};I.appendHandler("link",{...d,rel:"stylesheet",href:n.cropper.css,id:T.croppercss}),I.appendHandler("script",{...s,src:n.cropper.js,id:T.cropperjs})}if(!h){const{standaloneJs:s={}}=r.prettier||{};I.appendHandler("script",{...s,src:n.prettier.standaloneJs,id:T.prettier})}if(!c){const{parserMarkdownJs:s={}}=r.prettier||{};I.appendHandler("script",{...s,src:n.prettier.parserMarkdownJs,id:T.prettierMD})}})},he=(e,t,i)=>{const{editorId:n}=i;o.onMounted(()=>{f.bus.on(n,{name:f.ERROR_CATCHER,callback:r=>{e.onError?.(r),t.emit("onError",r)}})})},ge=(e,t,i)=>{const{editorId:n}=i,r=o.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview,previewOnly:!1}),h=o.reactive({...r}),c=(d,l)=>{const a=l===void 0?!r[d]:l;switch(d){case"preview":{r.htmlPreview=!1,r.previewOnly=!1;break}case"htmlPreview":{r.preview=!1,r.previewOnly=!1;break}case"previewOnly":{a?!r.preview&&!r.htmlPreview&&(r.preview=!0):(h.preview||(r.preview=!1),h.htmlPreview||(r.htmlPreview=!1));break}}h[d]=a,r[d]=a};let u="";const s=()=>{r.pageFullscreen||r.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=u};return o.watch(()=>[r.pageFullscreen,r.fullscreen],s),o.onMounted(()=>{f.bus.on(n,{name:f.UPLOAD_IMAGE,callback(d,l){const a=m=>{f.bus.emit(n,f.REPLACE,"image",{desc:"",urls:m}),l?.()};e.onUploadImg?e.onUploadImg(d,a):t.emit("onUploadImg",d,a)}}),u=document.body.style.overflow,s()}),[r,c]},ve=(e,t)=>{const{editorId:i}=t,n=o.ref(!1);return o.onMounted(()=>{f.bus.on(i,{name:f.CHANGE_CATALOG_VISIBLE,callback:r=>{r===void 0?n.value=!n.value:n.value=r}})}),n},be=(e,t,i)=>{const{editorId:n,catalogVisible:r,setting:h,updateSetting:c,codeRef:u}=i;o.watch(()=>h.pageFullscreen,d=>{f.bus.emit(n,f.PAGE_FULL_SCREEN_CHANGED,d)}),o.watch(()=>h.fullscreen,d=>{f.bus.emit(n,f.FULL_SCREEN_CHANGED,d)}),o.watch(()=>h.preview,d=>{f.bus.emit(n,f.PREVIEW_CHANGED,d)}),o.watch(()=>h.previewOnly,d=>{f.bus.emit(n,f.PREVIEW_ONLY_CHANGED,d)}),o.watch(()=>h.htmlPreview,d=>{f.bus.emit(n,f.HTML_PREVIEW_CHANGED,d)}),o.watch(r,d=>{f.bus.emit(n,f.CATALOG_VISIBLE_CHANGED,d)});const s={on(d,l){switch(d){case"pageFullscreen":{f.bus.on(n,{name:f.PAGE_FULL_SCREEN_CHANGED,callback(a){l(a)}});break}case"fullscreen":{f.bus.on(n,{name:f.FULL_SCREEN_CHANGED,callback(a){l(a)}});break}case"preview":{f.bus.on(n,{name:f.PREVIEW_CHANGED,callback(a){l(a)}});break}case"previewOnly":{f.bus.on(n,{name:f.PREVIEW_ONLY_CHANGED,callback(a){l(a)}});break}case"htmlPreview":{f.bus.on(n,{name:f.HTML_PREVIEW_CHANGED,callback(a){l(a)}});break}case"catalog":{f.bus.on(n,{name:f.CATALOG_VISIBLE_CHANGED,callback(a){l(a)}});break}}},togglePageFullscreen(d){c("pageFullscreen",d)},toggleFullscreen(d){f.bus.emit(n,f.CHANGE_FULL_SCREEN,d)},togglePreview(d){c("preview",d)},togglePreviewOnly(d){c("previewOnly",d)},toggleHtmlPreview(d){c("htmlPreview",d)},toggleCatalog(d){f.bus.emit(n,f.CHANGE_CATALOG_VISIBLE,d)},triggerSave(){f.bus.emit(n,f.ON_SAVE)},insert(d){f.bus.emit(n,f.REPLACE,"universal",{generate:d})},focus(d){u.value?.focus(d)},rerender(){f.bus.emit(n,f.RERENDER)},getSelectedText(){return u.value?.getSelectedText()},resetHistory(){u.value?.resetHistory()},domEventHandlers(d){f.bus.emit(n,f.EVENT_LISTENER,d)},execCommand(d){f.bus.emit(n,f.REPLACE,d)},getEditorView(){return u.value?.getEditorView()}};t.expose(s)},X=e=>{const t=o.useId();return e.id||e.editorId||`${p.prefix}-${t}`},ye=(e,t,i)=>{const n=o.inject("editorId"),r=o.inject("rootRef"),h=o.inject("usedLanguageText"),c=()=>{r.value.querySelectorAll(`#${n} .${p.prefix}-preview .${p.prefix}-code`).forEach(d=>{let l=-1;const a=d.querySelector(`.${p.prefix}-copy-button`);a&&(a.onclick=m=>{m.preventDefault(),clearTimeout(l);const g=(d.querySelector("input:checked + pre code")||d.querySelector("pre code")).textContent,{text:b,successTips:y,failTips:k}=h.value.copyCode;let w=y;re(e.formatCopiedText(g)).catch(()=>{w=k}).finally(()=>{a.dataset.isIcon?a.dataset.tips=w:a.innerHTML=w,l=window.setTimeout(()=>{a.dataset.isIcon?a.dataset.tips=b:a.innerHTML=b},1500)})})})},u=()=>{o.nextTick(c)},s=d=>{d&&o.nextTick(c)};o.watch([t,i],u),o.watch(()=>e.setting.preview,s),o.watch(()=>e.setting.htmlPreview,s),o.onMounted(c)},we=e=>{const t=o.inject("editorId"),i=o.inject("theme"),n=o.inject("rootRef"),{editorExtensions:r,editorExtensionsAttrs:h}=p.globalConfig;let c=r.echarts.instance;const u=o.shallowRef(-1),s=()=>{!e.noEcharts&&c&&(u.value=u.value+1)};o.watch(()=>i.value,()=>{s()}),o.onMounted(()=>{if(e.noEcharts||c)return;const g=r.echarts.js;I.appendHandler("script",{...h.echarts?.js,src:g,id:T.echarts,onload(){c=window.echarts,s()}},"echarts")});let d,l=[],a=[];const m=()=>{l.forEach(g=>{g.dispose()}),a.forEach(g=>{g.disconnect()}),l=[],d=[],a=[]},v=()=>{m(),!e.noEcharts&&c&&(d=Array.from(n.value.querySelectorAll(`#${t} div.${p.prefix}-echarts:not([data-processed])`)),d.forEach(g=>{if(g.dataset.closed==="false")return!1;try{const b=new Function(`return ${g.innerText}`)(),y=c.init(g,i.value);y.setOption(b),g.setAttribute("data-processed",""),l.push(y);const k=new ResizeObserver(()=>{y.resize()});k.observe(g),a.push(k)}catch(b){f.bus.emit(t,f.ERROR_CATCHER,{name:"echarts",message:b?.message,error:b})}}))};return o.onBeforeUnmount(()=>{m()}),{reRenderEcharts:u,replaceEcharts:v}},xe=e=>{const t=o.inject("highlight"),i=o.shallowRef(p.globalConfig.editorExtensions.highlight.instance);return o.onMounted(()=>{e.noHighlight||i.value||(I.appendHandler("link",{...t.value.css,rel:"stylesheet",id:T.hlcss}),I.appendHandler("script",{...t.value.js,id:T.hljs,onload(){i.value=window.hljs}},"hljs"))}),o.watch(()=>t.value.css,()=>{e.noHighlight||p.globalConfig.editorExtensions.highlight.instance||I.updateHandler("link",{...t.value.css,rel:"stylesheet",id:T.hlcss})}),i},Ce=e=>{const t=o.shallowRef(p.globalConfig.editorExtensions.katex.instance);return o.onMounted(()=>{if(e.noKatex||t.value)return;const{editorExtensions:i,editorExtensionsAttrs:n}=p.globalConfig;I.appendHandler("script",{...n.katex?.js,src:i.katex.js,id:T.katexjs,onload(){t.value=window.katex}},"katex"),I.appendHandler("link",{...n.katex?.css,rel:"stylesheet",href:i.katex.css,id:T.katexcss})}),t},D=new de.LRUCache({max:1e3,ttl:6e5}),Ee=e=>{const t=o.inject("editorId"),i=o.inject("theme"),n=o.inject("rootRef"),{editorExtensions:r,editorExtensionsAttrs:h,mermaidConfig:c}=p.globalConfig;let u=r.mermaid.instance;const s=o.shallowRef(-1),d=()=>{!e.noMermaid&&u&&(u.initialize(c({startOnLoad:!1,theme:i.value==="dark"?"dark":"default"})),s.value=s.value+1)};return o.watch(()=>i.value,()=>{D.clear(),d()}),o.onMounted(()=>{if(e.noMermaid||u)return;const a=r.mermaid.js;/\.mjs/.test(a)?(I.appendHandler("link",{...h.mermaid?.js,rel:"modulepreload",href:a,id:T.mermaidM}),import(a).then(m=>{u=m.default,d()}).catch(m=>{f.bus.emit(t,f.ERROR_CATCHER,{name:"mermaid",message:`Failed to load mermaid module: ${m.message}`,error:m})})):I.appendHandler("script",{...h.mermaid?.js,src:a,id:T.mermaid,onload(){u=window.mermaid,d()}},"mermaid")}),{reRenderRef:s,replaceMermaid:async()=>{if(!e.noMermaid&&u){const a=n.value.querySelectorAll(`div.${p.prefix}-mermaid`),m=document.createElement("div"),v=document.body.offsetWidth>1366?document.body.offsetWidth:1366,g=document.body.offsetHeight>768?document.body.offsetHeight:768;m.style.width=v+"px",m.style.height=g+"px",m.style.position="fixed",m.style.zIndex="-10000",m.style.top="-10000";let b=a.length;b>0&&document.body.appendChild(m),await Promise.allSettled(Array.from(a).map(y=>(async w=>{if(w.dataset.closed==="false")return!1;const $=w.innerText;let S=D.get($);if(!S){const x=N.randomId();let R={svg:""};try{R=await u.render(x,$,m),S=await e.sanitizeMermaid(R.svg);const C=document.createElement("p");C.className=`${p.prefix}-mermaid`,C.setAttribute("data-processed",""),C.innerHTML=S,C.children[0]?.removeAttribute("height"),D.set($,C.innerHTML),w.dataset.line!==void 0&&(C.dataset.line=w.dataset.line),w.replaceWith(C)}catch(C){f.bus.emit(t,f.ERROR_CATCHER,{name:"mermaid",message:C.message,error:C})}--b===0&&m.remove()}})(y)))}}}},$e=(e,t)=>{t=t||{};const i=3,n=t.marker||"!",r=n.charCodeAt(0),h=n.length;let c="",u="";const s=(l,a,m,v,g)=>{const b=l[a];return b.type==="admonition_open"?l[a].attrPush(["class",`${p.prefix}-admonition ${p.prefix}-admonition-${b.info}`]):b.type==="admonition_title_open"&&l[a].attrPush(["class",`${p.prefix}-admonition-title`]),g.renderToken(l,a,m)},d=l=>{const a=l.trim().split(" ",2);u="",c=a[0],a.length>1&&(u=l.substring(c.length+2))};e.block.ruler.before("code","admonition",(l,a,m,v)=>{let g,b,y,k=!1,w=l.bMarks[a]+l.tShift[a],$=l.eMarks[a];if(r!==l.src.charCodeAt(w))return!1;for(g=w+1;g<=$&&n[(g-w)%h]===l.src[g];g++);const S=Math.floor((g-w)/h);if(S!==i)return!1;g-=(g-w)%h;const x=l.src.slice(w,g),R=l.src.slice(g,$);if(d(R),v)return!0;for(b=a;b++,!(b>=m||(w=l.bMarks[b]+l.tShift[b],$=l.eMarks[b],w<$&&l.sCount[b]<l.blkIndent));)if(r===l.src.charCodeAt(w)&&!(l.sCount[b]-l.blkIndent>=4)){for(g=w+1;g<=$&&n[(g-w)%h]===l.src[g];g++);if(!(Math.floor((g-w)/h)<S)&&(g-=(g-w)%h,g=l.skipSpaces(g),!(g<$))){k=!0;break}}const C=l.parentType,F=l.lineMax;return l.parentType="root",l.lineMax=b,y=l.push("admonition_open","div",1),y.markup=x,y.block=!0,y.info=c,y.map=[a,b],u&&(y=l.push("admonition_title_open","p",1),y.markup=x+" "+c,y.map=[a,b],y=l.push("inline","",0),y.content=u,y.map=[a,l.line-1],y.children=[],y=l.push("admonition_title_close","p",-1),y.markup=x+" "+c),l.md.block.tokenize(l,a+1,b),y=l.push("admonition_close","div",-1),y.markup=l.src.slice(w,g),y.block=!0,l.parentType=C,l.lineMax=F,l.line=b+(k?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=s,e.renderer.rules.admonition_title_open=s,e.renderer.rules.admonition_title_close=s,e.renderer.rules.admonition_close=s},V=(e,t)=>{const i=e.attrs?e.attrs.slice():[];return t.forEach(n=>{const r=e.attrIndex(n[0]);r<0?i.push(n):(i[r]=i[r].slice(),i[r][1]+=` ${n[1]}`)}),i},Ie=(e,t)=>{const i=e.renderer.rules.fence,n=e.utils.unescapeAll,r=/\[(\w*)(?::([\w ]*))?\]/,h=/::(open|close)/,c=a=>a.info?n(a.info).trim():"",u=a=>{const m=c(a),[v=null,g=""]=(r.exec(m)||[]).slice(1);return[v,g]},s=a=>{const m=c(a);return m?m.split(/(\s+)/g)[0]:""},d=a=>{const m=a.info.match(h)||[],v=m[1]==="open"||m[1]!=="close"&&t.codeFoldable&&a.content.trim().split(`
2
- `).length<t.autoFoldThreshold,g=m[1]||t.codeFoldable?"details":"div",b=m[1]||t.codeFoldable?"summary":"div";return{open:v,tagContainer:g,tagHeader:b}},l=(a,m,v,g,b)=>{if(a[m].hidden)return"";const y=t.usedLanguageTextRef.value?.copyCode.text,k=t.customIconRef.value.copy||y,w=!!t.customIconRef.value.copy,$=`<span class="${p.prefix}-collapse-tips">${I.StrIcon("collapse-tips",t.customIconRef.value)}</span>`,[S]=u(a[m]);if(S===null){const{open:E,tagContainer:H,tagHeader:_}=d(a[m]),q=[["class",`${p.prefix}-code`]];E&&q.push(["open",""]);const ne={attrs:V(a[m],q)};a[m].info=a[m].info.replace(h,"");const oe=i(a,m,v,g,b);return`
3
- <${H} ${b.renderAttrs(ne)}>
4
- <${_} class="${p.prefix}-code-head">
5
- <div class="${p.prefix}-code-flag"><span></span><span></span><span></span></div>
6
- <div class="${p.prefix}-code-action">
7
- <span class="${p.prefix}-code-lang">${e.utils.escapeHtml(a[m].info.trim())}</span>
8
- <span class="${p.prefix}-copy-button" data-tips="${y}"${w?" data-is-icon=true":""}>${k}</span>
9
- ${t.extraTools instanceof Function?t.extraTools({lang:a[m].info.trim()}):t.extraTools||""}
10
- ${H==="details"?$:""}
1
+ "use strict";const r=require("vue"),_=require("@vavt/util"),f=require("./config.cjs"),p=require("./event-bus.cjs"),I=require("./dom.cjs"),re=require("@vavt/copy2clipboard"),ae=require("markdown-it"),ie=require("markdown-it-image-figures"),le=require("markdown-it-sub"),se=require("markdown-it-sup"),ce=require("./index5.cjs"),de=require("lru-cache"),ue=require("medium-zoom"),S={hljs:`${f.prefix}-hljs`,hlcss:`${f.prefix}-hlCss`,prettier:`${f.prefix}-prettier`,prettierMD:`${f.prefix}-prettierMD`,cropperjs:`${f.prefix}-cropper`,croppercss:`${f.prefix}-cropperCss`,screenfull:`${f.prefix}-screenfull`,mermaidM:`${f.prefix}-mermaid-m`,mermaid:`${f.prefix}-mermaid`,katexjs:`${f.prefix}-katex`,katexcss:`${f.prefix}-katexCss`,echarts:`${f.prefix}-echarts`},me=(e,t,i)=>{const{editorId:o}=i,n=r.reactive({buildFinished:!1,html:""});r.watch(()=>e.modelValue,()=>{n.buildFinished=!1}),r.onMounted(()=>{p.bus.on(o,{name:p.BUILD_FINISHED,callback(h){n.buildFinished=!0,n.html=h}}),p.bus.on(o,{name:p.ON_SAVE,callback(){const h=new Promise(c=>{if(n.buildFinished)c(n.html);else{const u=s=>{c(s),p.bus.remove(o,p.BUILD_FINISHED,u)};p.bus.on(o,{name:p.BUILD_FINISHED,callback:u})}});e.onSave?e.onSave(e.modelValue,h):t.emit("onSave",e.modelValue,h)}})})},J=(e,{editorId:t,rootRef:i,setting:o})=>{const n=f.globalConfig.editorExtensions.highlight,h=f.globalConfig.editorExtensionsAttrs.highlight;r.provide("editorId",t),r.provide("rootRef",i),r.provide("theme",r.computed(()=>e.theme)),r.provide("language",r.computed(()=>e.language)),r.provide("highlight",r.computed(()=>{const{js:u}=n,s={...f.codeCss,...n.css},{js:m,css:l={}}=h||{},a=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme,d=s[e.codeTheme]?s[e.codeTheme][a]:f.codeCss.atom[a],v=s[e.codeTheme]&&l[e.codeTheme]?l[e.codeTheme][a]:l.atom?l.atom[a]:{};return{js:{src:u,...m},css:{href:d,...v}}})),r.provide("showCodeRowNumber",e.showCodeRowNumber);const c=r.computed(()=>{const u={...f.staticTextDefault,...f.globalConfig.editorConfig.languageUserDefined};return _.deepMerge(_.deepClone(f.staticTextDefault["en-US"]),u[e.language]||{})});return r.provide("usedLanguageText",c),r.provide("previewTheme",r.computed(()=>e.previewTheme)),r.provide("customIcon",r.computed(()=>e.customIcon)),r.provide("setting",r.computed(()=>o?{...o}:{preview:!0,htmlPreview:!1,previewOnly:!1,pageFullscreen:!1,fullscreen:!1})),{editorId:t}},pe=(e,t)=>(r.provide("tabWidth",e.tabWidth),r.provide("disabled",r.computed(()=>e.disabled)),r.provide("showToolbarName",r.computed(()=>e.showToolbarName)),r.provide("noUploadImg",e.noUploadImg),r.provide("tableShape",r.computed(()=>e.tableShape)),r.provide("noPrettier",e.noPrettier),r.provide("codeTheme",r.computed(()=>e.codeTheme)),r.provide("updateSetting",t.updateSetting),r.provide("catalogVisible",r.computed(()=>t.catalogVisible.value)),r.provide("defToolbars",t.defToolbars),r.provide("floatingToolbars",r.computed(()=>e.floatingToolbars)),J(e,t)),fe=e=>{const{noPrettier:t,noUploadImg:i}=e,{editorExtensions:o,editorExtensionsAttrs:n}=f.globalConfig,h=t||o.prettier.prettierInstance,c=t||o.prettier.parserMarkdownInstance,u=i||o.cropper.instance;r.onMounted(()=>{if(!u){const{js:s={},css:m={}}=n.cropper||{};I.appendHandler("link",{...m,rel:"stylesheet",href:o.cropper.css,id:S.croppercss}),I.appendHandler("script",{...s,src:o.cropper.js,id:S.cropperjs})}if(!h){const{standaloneJs:s={}}=n.prettier||{};I.appendHandler("script",{...s,src:o.prettier.standaloneJs,id:S.prettier})}if(!c){const{parserMarkdownJs:s={}}=n.prettier||{};I.appendHandler("script",{...s,src:o.prettier.parserMarkdownJs,id:S.prettierMD})}})},he=(e,t,i)=>{const{editorId:o}=i;r.onMounted(()=>{p.bus.on(o,{name:p.ERROR_CATCHER,callback:n=>{e.onError?.(n),t.emit("onError",n)}})})},ge=(e,t,i)=>{const{editorId:o}=i,n=r.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview,previewOnly:!1}),h=r.reactive({...n}),c=(m,l)=>{const a=l===void 0?!n[m]:l;switch(m){case"preview":{n.htmlPreview=!1,n.previewOnly=!1;break}case"htmlPreview":{n.preview=!1,n.previewOnly=!1;break}case"previewOnly":{a?!n.preview&&!n.htmlPreview&&(n.preview=!0):(h.preview||(n.preview=!1),h.htmlPreview||(n.htmlPreview=!1));break}}h[m]=a,n[m]=a};let u="";const s=()=>{n.pageFullscreen||n.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=u};return r.watch(()=>[n.pageFullscreen,n.fullscreen],s),r.onMounted(()=>{p.bus.on(o,{name:p.UPLOAD_IMAGE,callback(m,l){const a=d=>{p.bus.emit(o,p.REPLACE,"image",{desc:"",urls:d}),l?.()};e.onUploadImg?e.onUploadImg(m,a):t.emit("onUploadImg",m,a)}}),u=document.body.style.overflow,s()}),[n,c]},ve=(e,t)=>{const{editorId:i}=t,o=r.ref(!1);return r.onMounted(()=>{p.bus.on(i,{name:p.CHANGE_CATALOG_VISIBLE,callback:n=>{n===void 0?o.value=!o.value:o.value=n}})}),o},be=(e,t,i)=>{const{editorId:o,catalogVisible:n,setting:h,updateSetting:c,codeRef:u}=i;r.watch(()=>h.pageFullscreen,m=>{p.bus.emit(o,p.PAGE_FULL_SCREEN_CHANGED,m)}),r.watch(()=>h.fullscreen,m=>{p.bus.emit(o,p.FULL_SCREEN_CHANGED,m)}),r.watch(()=>h.preview,m=>{p.bus.emit(o,p.PREVIEW_CHANGED,m)}),r.watch(()=>h.previewOnly,m=>{p.bus.emit(o,p.PREVIEW_ONLY_CHANGED,m)}),r.watch(()=>h.htmlPreview,m=>{p.bus.emit(o,p.HTML_PREVIEW_CHANGED,m)}),r.watch(n,m=>{p.bus.emit(o,p.CATALOG_VISIBLE_CHANGED,m)});const s={on(m,l){switch(m){case"pageFullscreen":{p.bus.on(o,{name:p.PAGE_FULL_SCREEN_CHANGED,callback(a){l(a)}});break}case"fullscreen":{p.bus.on(o,{name:p.FULL_SCREEN_CHANGED,callback(a){l(a)}});break}case"preview":{p.bus.on(o,{name:p.PREVIEW_CHANGED,callback(a){l(a)}});break}case"previewOnly":{p.bus.on(o,{name:p.PREVIEW_ONLY_CHANGED,callback(a){l(a)}});break}case"htmlPreview":{p.bus.on(o,{name:p.HTML_PREVIEW_CHANGED,callback(a){l(a)}});break}case"catalog":{p.bus.on(o,{name:p.CATALOG_VISIBLE_CHANGED,callback(a){l(a)}});break}}},togglePageFullscreen(m){c("pageFullscreen",m)},toggleFullscreen(m){p.bus.emit(o,p.CHANGE_FULL_SCREEN,m)},togglePreview(m){c("preview",m)},togglePreviewOnly(m){c("previewOnly",m)},toggleHtmlPreview(m){c("htmlPreview",m)},toggleCatalog(m){p.bus.emit(o,p.CHANGE_CATALOG_VISIBLE,m)},triggerSave(){p.bus.emit(o,p.ON_SAVE)},insert(m){p.bus.emit(o,p.REPLACE,"universal",{generate:m})},focus(m){u.value?.focus(m)},rerender(){p.bus.emit(o,p.RERENDER)},getSelectedText(){return u.value?.getSelectedText()},resetHistory(){u.value?.resetHistory()},domEventHandlers(m){p.bus.emit(o,p.EVENT_LISTENER,m)},execCommand(m){p.bus.emit(o,p.REPLACE,m)},getEditorView(){return u.value?.getEditorView()}};t.expose(s)},X=e=>{const t=r.useId();return e.id||e.editorId||`${f.prefix}-${t}`},ye=(e,t,i)=>{const o=r.inject("editorId"),n=r.inject("rootRef"),h=r.inject("usedLanguageText"),c=r.inject("setting"),u=()=>{n.value.querySelectorAll(`#${o} .${f.prefix}-preview .${f.prefix}-code`).forEach(l=>{let a=-1;const d=l.querySelector(`.${f.prefix}-copy-button`);d&&(d.onclick=v=>{v.preventDefault(),clearTimeout(a);const b=(l.querySelector("input:checked + pre code")||l.querySelector("pre code")).textContent,{text:y,successTips:k,failTips:w}=h.value.copyCode;let x=k;re(e.formatCopiedText(b||"")).catch(()=>{x=w}).finally(()=>{d.dataset.isIcon?d.dataset.tips=x:d.innerHTML=x,a=window.setTimeout(()=>{d.dataset.isIcon?d.dataset.tips=y:d.innerHTML=y},1500)})})})},s=()=>{r.nextTick(u)},m=l=>{l&&r.nextTick(u)};r.watch([t,i],s),r.watch(()=>c.value.preview,m),r.watch(()=>c.value.htmlPreview,m),r.onMounted(u)},we=e=>{const t=r.inject("editorId"),i=r.inject("theme"),o=r.inject("rootRef"),{editorExtensions:n,editorExtensionsAttrs:h}=f.globalConfig;let c=n.echarts.instance;const u=r.shallowRef(-1),s=()=>{!e.noEcharts&&c&&(u.value=u.value+1)};r.watch(()=>i.value,()=>{s()}),r.onMounted(()=>{if(e.noEcharts||c)return;const g=n.echarts.js;I.appendHandler("script",{...h.echarts?.js,src:g,id:S.echarts,onload(){c=window.echarts,s()}},"echarts")});let m,l=[],a=[];const d=()=>{l.forEach(g=>{g.dispose()}),a.forEach(g=>{g.disconnect()}),l=[],m=[],a=[]},v=()=>{d(),!e.noEcharts&&c&&(m=Array.from(o.value.querySelectorAll(`#${t} div.${f.prefix}-echarts:not([data-processed])`)),m.forEach(g=>{if(g.dataset.closed==="false")return!1;try{const b=new Function(`return ${g.innerText}`)(),y=c.init(g,i.value);y.setOption(b),g.setAttribute("data-processed",""),l.push(y);const k=new ResizeObserver(()=>{y.resize()});k.observe(g),a.push(k)}catch(b){p.bus.emit(t,p.ERROR_CATCHER,{name:"echarts",message:b?.message,error:b})}}))};return r.onBeforeUnmount(()=>{d()}),{reRenderEcharts:u,replaceEcharts:v}},xe=e=>{const t=r.inject("highlight"),i=r.shallowRef(f.globalConfig.editorExtensions.highlight.instance);return r.onMounted(()=>{e.noHighlight||i.value||(I.appendHandler("link",{...t.value.css,rel:"stylesheet",id:S.hlcss}),I.appendHandler("script",{...t.value.js,id:S.hljs,onload(){i.value=window.hljs}},"hljs"))}),r.watch(()=>t.value.css,()=>{e.noHighlight||f.globalConfig.editorExtensions.highlight.instance||I.updateHandler("link",{...t.value.css,rel:"stylesheet",id:S.hlcss})}),i},Ce=e=>{const t=r.shallowRef(f.globalConfig.editorExtensions.katex.instance);return r.onMounted(()=>{if(e.noKatex||t.value)return;const{editorExtensions:i,editorExtensionsAttrs:o}=f.globalConfig;I.appendHandler("script",{...o.katex?.js,src:i.katex.js,id:S.katexjs,onload(){t.value=window.katex}},"katex"),I.appendHandler("link",{...o.katex?.css,rel:"stylesheet",href:i.katex.css,id:S.katexcss})}),t},G=new de.LRUCache({max:1e3,ttl:6e5}),Ee=e=>{const t=r.inject("editorId"),i=r.inject("theme"),o=r.inject("rootRef"),{editorExtensions:n,editorExtensionsAttrs:h,mermaidConfig:c}=f.globalConfig;let u=n.mermaid.instance;const s=r.shallowRef(-1),m=()=>{!e.noMermaid&&u&&(u.initialize(c({startOnLoad:!1,theme:i.value==="dark"?"dark":"default"})),s.value=s.value+1)};return r.watch(()=>i.value,()=>{G.clear(),m()}),r.onMounted(()=>{if(e.noMermaid||u)return;const a=n.mermaid.js;/\.mjs/.test(a)?(I.appendHandler("link",{...h.mermaid?.js,rel:"modulepreload",href:a,id:S.mermaidM}),import(a).then(d=>{u=d.default,m()}).catch(d=>{p.bus.emit(t,p.ERROR_CATCHER,{name:"mermaid",message:`Failed to load mermaid module: ${d.message}`,error:d})})):I.appendHandler("script",{...h.mermaid?.js,src:a,id:S.mermaid,onload(){u=window.mermaid,m()}},"mermaid")}),{reRenderRef:s,replaceMermaid:async()=>{if(!e.noMermaid&&u){const a=o.value.querySelectorAll(`div.${f.prefix}-mermaid`),d=document.createElement("div"),v=document.body.offsetWidth>1366?document.body.offsetWidth:1366,g=document.body.offsetHeight>768?document.body.offsetHeight:768;d.style.width=v+"px",d.style.height=g+"px",d.style.position="fixed",d.style.zIndex="-10000",d.style.top="-10000";let b=a.length;b>0&&document.body.appendChild(d),await Promise.allSettled(Array.from(a).map(y=>(async w=>{if(w.dataset.closed==="false")return!1;const x=w.innerText;let A=G.get(x);if(!A){const E=_.randomId();let $={svg:""};try{$=await u.render(E,x,d),A=await e.sanitizeMermaid($.svg);const C=document.createElement("p");C.className=`${f.prefix}-mermaid`,C.setAttribute("data-processed",""),C.innerHTML=A,C.children[0]?.removeAttribute("height"),G.set(x,C.innerHTML),w.dataset.line!==void 0&&(C.dataset.line=w.dataset.line),w.replaceWith(C)}catch(C){p.bus.emit(t,p.ERROR_CATCHER,{name:"mermaid",message:C.message,error:C})}--b===0&&d.remove()}})(y)))}}}},$e=(e,t)=>{t=t||{};const i=3,o=t.marker||"!",n=o.charCodeAt(0),h=o.length;let c="",u="";const s=(l,a,d,v,g)=>{const b=l[a];return b.type==="admonition_open"?l[a].attrPush(["class",`${f.prefix}-admonition ${f.prefix}-admonition-${b.info}`]):b.type==="admonition_title_open"&&l[a].attrPush(["class",`${f.prefix}-admonition-title`]),g.renderToken(l,a,d)},m=l=>{const a=l.trim().split(" ",2);u="",c=a[0],a.length>1&&(u=l.substring(c.length+2))};e.block.ruler.before("code","admonition",(l,a,d,v)=>{let g,b,y,k=!1,w=l.bMarks[a]+l.tShift[a],x=l.eMarks[a];if(n!==l.src.charCodeAt(w))return!1;for(g=w+1;g<=x&&o[(g-w)%h]===l.src[g];g++);const A=Math.floor((g-w)/h);if(A!==i)return!1;g-=(g-w)%h;const E=l.src.slice(w,g),$=l.src.slice(g,x);if(m($),v)return!0;for(b=a;b++,!(b>=d||(w=l.bMarks[b]+l.tShift[b],x=l.eMarks[b],w<x&&l.sCount[b]<l.blkIndent));)if(n===l.src.charCodeAt(w)&&!(l.sCount[b]-l.blkIndent>=4)){for(g=w+1;g<=x&&o[(g-w)%h]===l.src[g];g++);if(!(Math.floor((g-w)/h)<A)&&(g-=(g-w)%h,g=l.skipSpaces(g),!(g<x))){k=!0;break}}const C=l.parentType,F=l.lineMax;return l.parentType="root",l.lineMax=b,y=l.push("admonition_open","div",1),y.markup=E,y.block=!0,y.info=c,y.map=[a,b],u&&(y=l.push("admonition_title_open","p",1),y.markup=E+" "+c,y.map=[a,b],y=l.push("inline","",0),y.content=u,y.map=[a,l.line-1],y.children=[],y=l.push("admonition_title_close","p",-1),y.markup=E+" "+c),l.md.block.tokenize(l,a+1,b),y=l.push("admonition_close","div",-1),y.markup=l.src.slice(w,g),y.block=!0,l.parentType=C,l.lineMax=F,l.line=b+(k?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=s,e.renderer.rules.admonition_title_open=s,e.renderer.rules.admonition_title_close=s,e.renderer.rules.admonition_close=s},q=(e,t)=>{const i=e.attrs?e.attrs.slice():[];return t.forEach(o=>{const n=e.attrIndex(o[0]);n<0?i.push(o):(i[n]=i[n].slice(),i[n][1]+=` ${o[1]}`)}),i},Ie=(e,t)=>{const i=e.renderer.rules.fence,o=e.utils.unescapeAll,n=/\[(\w*)(?::([\w ]*))?\]/,h=/::(open|close)/,c=a=>a.info?o(a.info).trim():"",u=a=>{const d=c(a),[v=null,g=""]=(n.exec(d)||[]).slice(1);return[v,g]},s=a=>{const d=c(a);return d?d.split(/(\s+)/g)[0]:""},m=a=>{const d=a.info.match(h)||[],v=d[1]==="open"||d[1]!=="close"&&t.codeFoldable&&a.content.trim().split(`
2
+ `).length<t.autoFoldThreshold,g=d[1]||t.codeFoldable?"details":"div",b=d[1]||t.codeFoldable?"summary":"div";return{open:v,tagContainer:g,tagHeader:b}},l=(a,d,v,g,b)=>{if(a[d].hidden)return"";const y=t.usedLanguageTextRef.value?.copyCode.text,k=t.customIconRef.value.copy||y,w=!!t.customIconRef.value.copy,x=`<span class="${f.prefix}-collapse-tips">${I.StrIcon("collapse-tips",t.customIconRef.value)}</span>`,[A]=u(a[d]);if(A===null){const{open:R,tagContainer:T,tagHeader:V}=m(a[d]),L=[["class",`${f.prefix}-code`]];R&&L.push(["open",""]);const ne={attrs:q(a[d],L)};a[d].info=a[d].info.replace(h,"");const oe=i(a,d,v,g,b);return`
3
+ <${T} ${b.renderAttrs(ne)}>
4
+ <${V} class="${f.prefix}-code-head">
5
+ <div class="${f.prefix}-code-flag"><span></span><span></span><span></span></div>
6
+ <div class="${f.prefix}-code-action">
7
+ <span class="${f.prefix}-code-lang">${e.utils.escapeHtml(a[d].info.trim())}</span>
8
+ <span class="${f.prefix}-copy-button" data-tips="${y}"${w?" data-is-icon=true":""}>${k}</span>
9
+ ${t.extraTools instanceof Function?t.extraTools({lang:a[d].info.trim()}):t.extraTools||""}
10
+ ${T==="details"?x:""}
11
11
  </div>
12
- </${_}>
12
+ </${V}>
13
13
  ${oe}
14
- </${H}>
15
- `}let x,R,C,F,M="",j="",O="";const{open:G,tagContainer:P,tagHeader:A}=d(a[m]),L=[["class",`${p.prefix}-code`]];G&&L.push(["open",""]);const U={attrs:V(a[m],L)};for(let E=m;E<a.length&&(x=a[E],[R,C]=u(x),R===S);E++){x.info=x.info.replace(r,"").replace(h,""),x.hidden=!0;const H=`${p.prefix}-codetab-${t.editorId}-${m}-${E-m}`;F=E-m>0?"":"checked",M+=`
14
+ </${T}>
15
+ `}let E,$,C,F,N="",M="",j="";const{open:B,tagContainer:O,tagHeader:D}=m(a[d]),H=[["class",`${f.prefix}-code`]];B&&H.push(["open",""]);const P={attrs:q(a[d],H)};for(let R=d;R<a.length&&(E=a[R],[$,C]=u(E),$===A);R++){E.info=E.info.replace(n,"").replace(h,""),E.hidden=!0;const T=`${f.prefix}-codetab-${t.editorId}-${d}-${R-d}`;F=R-d>0?"":"checked",N+=`
16
16
  <li>
17
17
  <input
18
18
  type="radio"
19
- id="label-${p.prefix}-codetab-label-1-${t.editorId}-${m}-${E-m}"
20
- name="${p.prefix}-codetab-label-${t.editorId}-${m}"
21
- class="${H}"
19
+ id="label-${f.prefix}-codetab-label-1-${t.editorId}-${d}-${R-d}"
20
+ name="${f.prefix}-codetab-label-${t.editorId}-${d}"
21
+ class="${T}"
22
22
  ${F}
23
23
  >
24
24
  <label
25
- for="label-${p.prefix}-codetab-label-1-${t.editorId}-${m}-${E-m}"
26
- onclick="this.getRootNode().querySelectorAll('.${H}').forEach(e => e.click())"
25
+ for="label-${f.prefix}-codetab-label-1-${t.editorId}-${d}-${R-d}"
26
+ onclick="this.getRootNode().querySelectorAll('.${T}').forEach(e => e.click())"
27
27
  >
28
- ${e.utils.escapeHtml(C||s(x))}
28
+ ${e.utils.escapeHtml(C||s(E))}
29
29
  </label>
30
- </li>`,j+=`
30
+ </li>`,M+=`
31
31
  <div role="tabpanel">
32
32
  <input
33
33
  type="radio"
34
- name="${p.prefix}-codetab-pre-${t.editorId}-${m}"
35
- class="${H}"
34
+ name="${f.prefix}-codetab-pre-${t.editorId}-${d}"
35
+ class="${T}"
36
36
  ${F}
37
37
  role="presentation">
38
- ${i(a,E,v,g,b)}
39
- </div>`,O+=`
38
+ ${i(a,R,v,g,b)}
39
+ </div>`,j+=`
40
40
  <input
41
41
  type="radio"
42
- name="${p.prefix}-codetab-lang-${t.editorId}-${m}"
43
- class="${H}"
42
+ name="${f.prefix}-codetab-lang-${t.editorId}-${d}"
43
+ class="${T}"
44
44
  ${F}
45
45
  role="presentation">
46
- <span class=${p.prefix}-code-lang role="note">${e.utils.escapeHtml(s(x))}</span>`}return`
47
- <${P} ${b.renderAttrs(U)}>
48
- <${A} class="${p.prefix}-code-head">
49
- <div class="${p.prefix}-code-flag">
50
- <ul class="${p.prefix}-codetab-label" role="tablist">${M}</ul>
46
+ <span class=${f.prefix}-code-lang role="note">${e.utils.escapeHtml(s(E))}</span>`}return`
47
+ <${O} ${b.renderAttrs(P)}>
48
+ <${D} class="${f.prefix}-code-head">
49
+ <div class="${f.prefix}-code-flag">
50
+ <ul class="${f.prefix}-codetab-label" role="tablist">${N}</ul>
51
51
  </div>
52
- <div class="${p.prefix}-code-action">
53
- <span class="${p.prefix}-codetab-lang">${O}</span>
54
- <span class="${p.prefix}-copy-button" data-tips="${y}"${w?" data-is-icon=true":""}>${k}</span>
55
- ${t.extraTools instanceof Function?t.extraTools({lang:a[m].info.trim()}):t.extraTools||""}
56
- ${P==="details"?$:""}
52
+ <div class="${f.prefix}-code-action">
53
+ <span class="${f.prefix}-codetab-lang">${j}</span>
54
+ <span class="${f.prefix}-copy-button" data-tips="${y}"${w?" data-is-icon=true":""}>${k}</span>
55
+ ${t.extraTools instanceof Function?t.extraTools({lang:a[d].info.trim()}):t.extraTools||""}
56
+ ${O==="details"?x:""}
57
57
  </div>
58
- </${A}>
59
- ${j}
60
- </${P}>
61
- `};e.renderer.rules.fence=l,e.renderer.rules.code_block=l},ke=(e,t)=>{const i=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(n,r,h,c,u)=>{const s=n[r],d=s.content.trim();if(s.info==="echarts"){if(s.attrSet("class",`${p.prefix}-echarts`),s.attrSet("data-echarts-theme",t.themeRef.value),s.map&&s.level===0){const l=s.map[1]-1,m=!!c.srcLines[l]?.trim()?.startsWith("```");s.attrSet("data-closed",`${m}`),s.attrSet("data-line",String(s.map[0]))}return`<div ${u.renderAttrs(s)} style="width: 100%; aspect-ratio: 4 / 3;">${e.utils.escapeHtml(d)}</div>`}return i(n,r,h,c,u)}},Te=(e,t)=>{e.renderer.rules.heading_open=(i,n)=>{const r=i[n],h=i[n+1].children?.reduce((u,s)=>u+(["text","code_inline","math_inline"].includes(s.type)&&s.content||""),"")||"",c=r.markup.length;return t.headsRef.value.push({text:h,level:c,line:r.map[0],currentToken:r,nextToken:i[n+1]}),r.map&&r.level===0&&r.attrSet("id",t.mdHeadingId({text:h,level:c,index:t.headsRef.value.length,currentToken:r,nextToken:i[n+1]})),e.renderer.renderToken(i,n,t)},e.renderer.rules.heading_close=(i,n,r,h,c)=>c.renderToken(i,n,r)},z={block:[{open:"$$",close:"$$"},{open:"\\[",close:"\\]"}],inline:[{open:"$$",close:"$$"},{open:"$",close:"$"},{open:"\\[",close:"\\]"},{open:"\\(",close:"\\)"}]},Se=e=>(t,i)=>{const n=e.delimiters;let r,h,c;for(const u of n)if(t.src.startsWith(u.open,t.pos)){const s=t.pos+u.open.length;for(r=s;(r=t.src.indexOf(u.close,r))!==-1;){for(c=r-1;t.src[c]==="\\";)c-=1;if((r-c)%2===1)break;r+=u.close.length}if(r===-1)return i||(t.pending+=u.open),t.pos=s,!0;if(r-s===0)return i||(t.pending+=u.open+u.close),t.pos=s+u.close.length,!0;if(!i){const d=t.src.slice(s,r);h=t.push("math_inline","math",0),h.markup=u.open,h.content=d}return t.pos=r+u.close.length,!0}return!1},Re=e=>(t,i,n,r)=>{const h=e.delimiters;let c,u,s,d,l=!1,a=t.bMarks[i]+t.tShift[i],m=t.eMarks[i];for(const v of h)if(t.src.slice(a,a+v.open.length)===v.open&&t.src.slice(m-v.close.length,m)===v.close){if(a+=v.open.length,c=t.src.slice(a,m),r)return!0;for(c.trim().slice(-v.close.length)===v.close&&(c=c.trim().slice(0,-v.close.length),l=!0),s=i;!l&&(s++,!(s>=n||(a=t.bMarks[s]+t.tShift[s],m=t.eMarks[s],a<m&&t.tShift[s]<t.blkIndent)));)t.src.slice(a,m).trim().slice(-v.close.length)===v.close&&(d=t.src.slice(0,m).lastIndexOf(v.close),u=t.src.slice(a,d),l=!0);t.line=s+1;const g=t.push("math_block","math",0);return g.block=!0,g.content=(c&&c.trim()?c+`
62
- `:"")+t.getLines(i+1,s,t.tShift[i],!0)+(u&&u.trim()?u:""),g.map=[i,t.line],g.markup=v.open,!0}return!1},Ae=(e,{katexRef:t,inlineDelimiters:i,blockDelimiters:n})=>{const r=(c,u,s,d,l)=>{const a=c[u],m={attrs:V(a,[["class",`${p.prefix}-katex-inline`]])};if(t.value){const v=t.value.renderToString(a.content,p.globalConfig.katexConfig({throwOnError:!1}));return`<span ${l.renderAttrs(m)} data-processed>${v}</span>`}else return`<span ${l.renderAttrs(m)}>${a.content}</span>`},h=(c,u,s,d,l)=>{const a=c[u],m={attrs:V(a,[["class",`${p.prefix}-katex-block`]])};if(t.value){const v=t.value.renderToString(a.content,p.globalConfig.katexConfig({throwOnError:!1,displayMode:!0}));return`<p ${l.renderAttrs(m)} data-processed>${v}</p>`}else return`<p ${l.renderAttrs(m)}>${a.content}</p>`};e.inline.ruler.before("escape","math_inline",Se({delimiters:i||z.inline})),e.block.ruler.after("blockquote","math_block",Re({delimiters:n||z.block}),{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=r,e.renderer.rules.math_block=h},He=(e,t)=>{const i=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(n,r,h,c,u)=>{const s=n[r],d=s.content.trim();if(s.info==="mermaid"){if(s.attrSet("class",`${p.prefix}-mermaid`),s.attrSet("data-mermaid-theme",t.themeRef.value),s.map&&s.level===0){const a=s.map[1]-1,v=!!c.srcLines[a]?.trim()?.startsWith("```");s.attrSet("data-closed",`${v}`),s.attrSet("data-line",String(s.map[0]))}const l=D.get(d);return l?(s.attrSet("data-processed",""),`<p ${u.renderAttrs(s)}>${l}</p>`):`<div ${u.renderAttrs(s)}>${e.utils.escapeHtml(d)}</div>`}return i(n,r,h,c,u)}},W=(e,t,i)=>{const n=e.attrIndex(t),r=[t,i];n<0?e.attrPush(r):(e.attrs=e.attrs||[],e.attrs[n]=r)},Fe=e=>e.type==="inline",Me=e=>e.type==="paragraph_open",Le=e=>e.type==="list_item_open",Pe=e=>e.content.indexOf("[ ] ")===0||e.content.indexOf("[x] ")===0||e.content.indexOf("[X] ")===0,_e=(e,t)=>Fe(e[t])&&Me(e[t-1])&&Le(e[t-2])&&Pe(e[t]),Ne=(e,t)=>{const i=e[t].level-1;for(let n=t-1;n>=0;n--)if(e[n].level===i)return n;return-1},je=e=>{const t=new e("html_inline","",0);return t.content="<label>",t},Oe=e=>{const t=new e("html_inline","",0);return t.content="</label>",t},De=(e,t,i)=>{const n=new i("html_inline","",0);return n.content='<label class="task-list-item-label" for="'+t+'">'+e+"</label>",n.attrs=[["for",t]],n},Be=(e,t,i)=>{const n=new t("html_inline","",0),r=i.enabled?" ":' disabled="" ';return e.content.indexOf("[ ] ")===0?n.content='<input class="task-list-item-checkbox"'+r+'type="checkbox">':(e.content.indexOf("[x] ")===0||e.content.indexOf("[X] ")===0)&&(n.content='<input class="task-list-item-checkbox" checked=""'+r+'type="checkbox">'),n},Ve=(e,t,i)=>{if(e.children=e.children||[],e.children.unshift(Be(e,t,i)),e.children[1].content=e.children[1].content.slice(3),e.content=e.content.slice(3),i.label)if(i.labelAfter){e.children.pop();const n="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);e.children[0].content=e.children[0].content.slice(0,-1)+' id="'+n+'">',e.children.push(De(e.content,n,t))}else e.children.unshift(je(t)),e.children.push(Oe(t))},Ge=(e,t={})=>{e.core.ruler.after("inline","github-task-lists",i=>{const n=i.tokens;for(let r=2;r<n.length;r++)_e(n,r)&&(Ve(n[r],i.Token,t),W(n[r-2],"class","task-list-item"+(t.enabled?" enabled":" ")),W(n[Ne(n,r-2)],"class","contains-task-list"))})},Ue=e=>{e.core.ruler.push("init-line-number",t=>(t.tokens.forEach(i=>{i.map&&(i.attrs||(i.attrs=[]),i.attrs.push(["data-line",i.map[0].toString()]))}),!0))},qe=(e,t)=>{const{editorConfig:i,markdownItConfig:n,markdownItPlugins:r,editorExtensions:h}=p.globalConfig,c=o.inject("editorId"),u=o.inject("language"),s=o.inject("usedLanguageText"),d=o.inject("showCodeRowNumber"),l=o.inject("theme"),a=o.inject("customIcon"),m=o.inject("rootRef"),v=o.ref([]);let g=()=>{};const b=xe(e),y=Ce(e),{reRenderRef:k,replaceMermaid:w}=Ee(e),{reRenderEcharts:$,replaceEcharts:S}=we(e),x=ae({html:!0,breaks:!0,linkify:!0});n(x,{editorId:c});const R=[{type:"image",plugin:ie,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:$e,options:{}},{type:"taskList",plugin:Ge,options:{}},{type:"heading",plugin:Te,options:{mdHeadingId:e.mdHeadingId,headsRef:v}},{type:"code",plugin:Ie,options:{editorId:c,usedLanguageTextRef:s,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,customIconRef:a}},{type:"sub",plugin:le,options:{}},{type:"sup",plugin:se,options:{}}];e.noKatex||R.push({type:"katex",plugin:Ae,options:{katexRef:y}}),e.noMermaid||R.push({type:"mermaid",plugin:He,options:{themeRef:l}}),e.noEcharts||R.push({type:"echarts",plugin:ke,options:{themeRef:l}}),r(R,{editorId:c}).forEach(A=>{x.use(A.plugin,A.options)});const C=x.options.highlight;x.set({highlight:(A,L,U)=>{if(C){const _=C(A,L,U);if(_)return _}let E;!e.noHighlight&&b.value?b.value.getLanguage(L)?E=b.value.highlight(A,{language:L,ignoreIllegals:!0}).value:E=b.value.highlightAuto(A).value:E=x.utils.escapeHtml(A);const H=d?ce.generateCodeRowNumber(E.replace(/^\n+|\n+$/g,""),A.replace(/^\n+|\n+$/g,"")):`<span class="${p.prefix}-code-block">${E.replace(/^\n+|\n+$/g,"")}</span>`;return`<pre><code class="language-${L}" language=${L}>${H}</code></pre>`}}),Ue(x);const F=o.ref(`_article-key_${N.randomId()}`),M=o.ref(e.sanitize(x.render(e.modelValue,{srcLines:e.modelValue.split(`
63
- `)}))),j=()=>{f.bus.emit(c,f.BUILD_FINISHED,M.value),e.onHtmlChanged(M.value),e.onGetCatalog(v.value),f.bus.emit(c,f.CATALOG_CHANGED,v.value),o.nextTick(()=>{w().then(()=>{h.mermaid?.enableZoom&&(g(),g=I.zoomMermaid(m.value?.querySelectorAll(`#${c} p.${p.prefix}-mermaid:not([data-closed=false])`),{customIcon:a.value}))}),S()})},O=()=>{v.value=[],M.value=e.sanitize(x.render(e.modelValue,{srcLines:e.modelValue.split(`
64
- `)}))},G=o.computed(()=>(e.noKatex||!!y.value)&&(e.noHighlight||!!b.value));let P=-1;return o.watch([o.toRef(e,"modelValue"),G,k,u],()=>{P=window.setTimeout(()=>{O()},t?0:i.renderDelay)}),o.watch(()=>e.setting.preview,()=>{e.setting.preview&&o.nextTick(()=>{w().then(()=>{h.mermaid?.enableZoom&&(g(),g=I.zoomMermaid(m.value?.querySelectorAll(`#${c} p.${p.prefix}-mermaid:not([data-closed=false])`),{customIcon:a.value}))}),S(),f.bus.emit(c,f.CATALOG_CHANGED,v.value)})}),o.watch([M,$],()=>{j()}),o.onMounted(j),o.onMounted(()=>{f.bus.on(c,{name:f.PUSH_CATALOG,callback(){f.bus.emit(c,f.CATALOG_CHANGED,v.value)}}),f.bus.on(c,{name:f.RERENDER,callback:()=>{F.value=`_article-key_${N.randomId()}`,O()}})}),o.onBeforeUnmount(()=>{g(),clearTimeout(P)}),{html:M,key:F}},ze=(e,t)=>{const i=o.inject("editorId"),{noImgZoomIn:n}=e,r=N.debounce(()=>{const h=document.querySelectorAll(`#${i}-preview img:not(.not-zoom):not(.medium-zoom-image)`);h.length!==0&&ue(h,{background:"#00000073"})});o.onMounted(async()=>{!n&&e.setting.preview&&await r()}),o.watch([t,o.toRef(e.setting,"preview")],async()=>{!n&&e.setting.preview&&await r()})},K={checked:{regexp:/- \[x\]/,value:"- [ ]"},unChecked:{regexp:/- \[\s\]/,value:"- [x]"}},We=(e,t)=>{const i=o.inject("editorId"),n=o.inject("rootRef");let r=()=>{};const h=()=>{if(!n.value)return!1;const c=n.value.querySelectorAll(".task-list-item.enabled"),u=s=>{s.preventDefault();const d=s.target.checked?"unChecked":"checked",l=s.target.parentElement?.dataset.line;if(!l)return;const a=Number(l),m=e.modelValue.split(`
65
- `),v=m[Number(a)].replace(K[d].regexp,K[d].value);e.previewOnly?(m[Number(a)]=v,e.onChange(m.join(`
66
- `))):f.bus.emit(i,f.TASK_STATE_CHANGED,a+1,v)};c.forEach(s=>{s.addEventListener("click",u)}),r=()=>{c.forEach(s=>{s.removeEventListener("click",u)})}};o.onBeforeUnmount(()=>{r()}),o.watch([t],()=>{r(),o.nextTick(h)},{immediate:!0})},Ke=(e,t,i)=>{const n=()=>{o.nextTick(()=>{e.onRemount?.()})},r=h=>{h&&n()};o.watch([t,i],n),o.watch(()=>e.setting.preview,r),o.watch(()=>e.setting.htmlPreview,r),o.onMounted(n)},Y={modelValue:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({preview:!0})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:e=>e},noKatex:{type:Boolean,default:!1},formatCopiedText:{type:Function,default:e=>e},noHighlight:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean},sanitizeMermaid:{type:Function},codeFoldable:{type:Boolean},autoFoldThreshold:{type:Number},onRemount:{type:Function},noEcharts:{type:Boolean}},Ze={...Y,updateModelValue:{type:Function,default:()=>{}},placeholder:{type:String,default:""},scrollAuto:{type:Boolean},autofocus:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},completions:{type:Array},onInput:{type:Function},onDrop:{type:Function,default:()=>{}},inputBoxWidth:{type:String},oninputBoxWidthChange:{type:Function},transformImgUrl:{type:Function,default:e=>e},catalogLayout:{type:String},catalogMaxDepth:{type:Number}},Je=e=>{const i=new DOMParser().parseFromString(e,"text/html");return Array.from(i.body.childNodes)},Xe=(e,t)=>{const i=[],n=[];if(e.forEach((r,h)=>{const c=t[h];if(!c){i.push({index:h,newNode:r});return}(r.nodeType!==c.nodeType||r.textContent!==c.textContent||r.nodeType===1&&r.outerHTML!==c.outerHTML)&&i.push({index:h,newNode:r})}),t.length>e.length)for(let r=e.length;r<t.length;r++)n.push(t[r]);return{updates:i,deletes:n}},Z=o.defineComponent({name:"UpdateOnDemand",props:{html:{type:String,required:!0}},setup(e){const t=o.inject("editorId"),i=o.inject("previewTheme"),n=o.inject("showCodeRowNumber"),r=o.ref(),h=e.html,c=(u,s)=>{r.value&&(s.forEach(d=>{d.remove()}),u.forEach(({index:d,newNode:l})=>{const a=r.value?.childNodes[d];a?r.value?.replaceChild(l.cloneNode(!0),a):r.value?.appendChild(l.cloneNode(!0))}))};return o.watch(()=>e.html,u=>{const s=Je(u),d=Array.from(r.value?.childNodes||[]),{updates:l,deletes:a}=Xe(s,d);c(l,a)}),()=>o.createVNode("div",{id:`${t}-preview`,class:[`${p.prefix}-preview`,`${i?.value}-theme`,n&&`${p.prefix}-scrn`],innerHTML:h,ref:r},null)}}),Q=o.defineComponent({name:"ContentPreview",props:Y,setup(e){const t=o.inject("editorId"),{html:i,key:n}=qe(e,e.previewOnly);return ye(e,i,n),ze(e,i),We(e,i),Ke(e,i,n),()=>o.createVNode(o.Fragment,null,[e.setting.preview&&(e.previewOnly?o.createVNode(Z,{key:n.value,html:i.value},null):o.createVNode("div",{id:`${t}-preview-wrapper`,class:`${p.prefix}-preview-wrapper`,key:"content-preview-wrapper"},[o.createVNode(Z,{key:n.value,html:i.value},null)])),e.setting.htmlPreview&&o.createVNode("div",{id:`${t}-html-wrapper`,class:`${p.prefix}-preview-wrapper`,key:"html-preview-wrapper"},[o.createVNode("div",{class:`${p.prefix}-html`},[i.value])])])}}),Ye=({text:e})=>e,ee={modelValue:{type:String,default:""},onChange:{type:Function,default:void 0},theme:{type:String,default:"light"},class:{type:String,default:""},language:{type:String,default:"zh-CN"},onHtmlChanged:{type:Function,default:void 0},onGetCatalog:{type:Function,default:void 0},editorId:{type:String,default:void 0},id:{type:String,default:void 0},showCodeRowNumber:{type:Boolean,default:!0},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:Ye},sanitize:{type:Function,default:e=>e},noMermaid:{type:Boolean,default:!1},noKatex:{type:Boolean,default:!1},codeTheme:{type:String,default:"atom"},formatCopiedText:{type:Function,default:e=>e},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},noHighlight:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean,default:!1},customIcon:{type:Object,default:{}},sanitizeMermaid:{type:Function,default:e=>Promise.resolve(e)},codeFoldable:{type:Boolean,default:!0},autoFoldThreshold:{type:Number,default:30},onRemount:{type:Function,default:void 0},noEcharts:{type:Boolean,default:!1}},Qe={...ee,onSave:{type:Function,default:void 0},onUploadImg:{type:Function,default:void 0},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},toolbars:{type:Array,default:p.allToolbar},floatingToolbars:{type:Array,default:[]},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},tabWidth:{type:Number,default:2},tableShape:{type:Array,default:[6,4]},placeholder:{type:String,default:""},defToolbars:{type:[String,Object],default:void 0},onError:{type:Function,default:void 0},footers:{type:Array,default:p.allFooter},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object],default:void 0},noUploadImg:{type:Boolean,default:!1},autoFocus:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},maxLength:{type:Number,default:void 0},autoDetectCode:{type:Boolean,default:!1},onBlur:{type:Function,default:void 0},onFocus:{type:Function,default:void 0},completions:{type:Array,default:void 0},showToolbarName:{type:Boolean,default:!1},onInput:{type:Function,default:void 0},onDrop:{type:Function,default:void 0},inputBoxWidth:{type:String,default:"50%"},oninputBoxWidthChange:{type:Function,default:void 0},transformImgUrl:{type:Function,default:e=>e},catalogLayout:{type:String,default:"fixed"},catalogMaxDepth:{type:Number,default:void 0}},te=["onHtmlChanged","onGetCatalog","onChange","onRemount","update:modelValue"],et=[...te,"onSave","onUploadImg","onError","onBlur","onFocus","onInput","onDrop","oninputBoxWidthChange"],tt=(e,t,i)=>{const{editorId:n}=i,r={rerender(){f.bus.emit(n,f.RERENDER)}};t.expose(r)},B=o.defineComponent({name:"MdPreview",props:ee,emits:te,setup(e,t){const{noKatex:i,noMermaid:n,noHighlight:r}=e,h=o.ref(),c=X(e);return J(e,{rootRef:h,editorId:c}),tt(e,t,{editorId:c}),o.onBeforeUnmount(()=>{f.bus.clear(c)}),()=>o.createVNode("div",{id:c,class:[p.prefix,e.class,e.theme==="dark"&&`${p.prefix}-dark`,`${p.prefix}-previewOnly`],style:e.style,ref:h},[o.createVNode(Q,{modelValue:e.modelValue,onChange:u=>{e.onChange?.(u),t.emit("onChange",u),t.emit("update:modelValue",u)},onHtmlChanged:u=>{e.onHtmlChanged?.(u),t.emit("onHtmlChanged",u)},onGetCatalog:u=>{e.onGetCatalog?.(u),t.emit("onGetCatalog",u)},mdHeadingId:e.mdHeadingId,noMermaid:n,sanitize:e.sanitize,noKatex:i,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0,sanitizeMermaid:e.sanitizeMermaid,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,onRemount:()=>{e.onRemount?.(),t.emit("onRemount")},noEcharts:e.noEcharts},null)])}});B.install=e=>(e.component(B.name,B),e);exports.CDN_IDS=T;exports.ContentPreview=Q;exports.MdPreview=B;exports.contentProps=Ze;exports.editorEmits=et;exports.editorProps=Qe;exports.useCatalog=ve;exports.useConfig=ge;exports.useEditorId=X;exports.useErrorCatcher=he;exports.useExpansion=pe;exports.useExpose=be;exports.useOnSave=me;exports.useProvide=fe;
58
+ </${D}>
59
+ ${M}
60
+ </${O}>
61
+ `};e.renderer.rules.fence=l,e.renderer.rules.code_block=l},ke=(e,t)=>{const i=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(o,n,h,c,u)=>{const s=o[n],m=s.content.trim();if(s.info==="echarts"){if(s.attrSet("class",`${f.prefix}-echarts`),s.attrSet("data-echarts-theme",t.themeRef.value),s.map&&s.level===0){const l=s.map[1]-1,d=!!c.srcLines[l]?.trim()?.startsWith("```");s.attrSet("data-closed",`${d}`),s.attrSet("data-line",String(s.map[0]))}return`<div ${u.renderAttrs(s)} style="width: 100%; aspect-ratio: 4 / 3;">${e.utils.escapeHtml(m)}</div>`}return i(o,n,h,c,u)}},Te=(e,t)=>{e.renderer.rules.heading_open=(i,o)=>{const n=i[o],h=i[o+1].children?.reduce((u,s)=>u+(["text","code_inline","math_inline"].includes(s.type)&&s.content||""),"")||"",c=n.markup.length;return t.headsRef.value.push({text:h,level:c,line:n.map[0],currentToken:n,nextToken:i[o+1]}),n.map&&n.level===0&&n.attrSet("id",t.mdHeadingId({text:h,level:c,index:t.headsRef.value.length,currentToken:n,nextToken:i[o+1]})),e.renderer.renderToken(i,o,t)},e.renderer.rules.heading_close=(i,o,n,h,c)=>c.renderToken(i,o,n)},z={block:[{open:"$$",close:"$$"},{open:"\\[",close:"\\]"}],inline:[{open:"$$",close:"$$"},{open:"$",close:"$"},{open:"\\[",close:"\\]"},{open:"\\(",close:"\\)"}]},Se=e=>(t,i)=>{const o=e.delimiters;let n,h,c;for(const u of o)if(t.src.startsWith(u.open,t.pos)){const s=t.pos+u.open.length;for(n=s;(n=t.src.indexOf(u.close,n))!==-1;){for(c=n-1;t.src[c]==="\\";)c-=1;if((n-c)%2===1)break;n+=u.close.length}if(n===-1)return i||(t.pending+=u.open),t.pos=s,!0;if(n-s===0)return i||(t.pending+=u.open+u.close),t.pos=s+u.close.length,!0;if(!i){const m=t.src.slice(s,n);h=t.push("math_inline","math",0),h.markup=u.open,h.content=m}return t.pos=n+u.close.length,!0}return!1},Re=e=>(t,i,o,n)=>{const h=e.delimiters;let c,u,s,m,l=!1,a=t.bMarks[i]+t.tShift[i],d=t.eMarks[i];for(const v of h)if(t.src.slice(a,a+v.open.length)===v.open&&t.src.slice(d-v.close.length,d)===v.close){if(a+=v.open.length,c=t.src.slice(a,d),n)return!0;for(c.trim().slice(-v.close.length)===v.close&&(c=c.trim().slice(0,-v.close.length),l=!0),s=i;!l&&(s++,!(s>=o||(a=t.bMarks[s]+t.tShift[s],d=t.eMarks[s],a<d&&t.tShift[s]<t.blkIndent)));)t.src.slice(a,d).trim().slice(-v.close.length)===v.close&&(m=t.src.slice(0,d).lastIndexOf(v.close),u=t.src.slice(a,m),l=!0);t.line=s+1;const g=t.push("math_block","math",0);return g.block=!0,g.content=(c&&c.trim()?c+`
62
+ `:"")+t.getLines(i+1,s,t.tShift[i],!0)+(u&&u.trim()?u:""),g.map=[i,t.line],g.markup=v.open,!0}return!1},Ae=(e,{katexRef:t,inlineDelimiters:i,blockDelimiters:o})=>{const n=(c,u,s,m,l)=>{const a=c[u],d={attrs:q(a,[["class",`${f.prefix}-katex-inline`]])};if(t.value){const v=t.value.renderToString(a.content,f.globalConfig.katexConfig({throwOnError:!1}));return`<span ${l.renderAttrs(d)} data-processed>${v}</span>`}else return`<span ${l.renderAttrs(d)}>${a.content}</span>`},h=(c,u,s,m,l)=>{const a=c[u],d={attrs:q(a,[["class",`${f.prefix}-katex-block`]])};if(t.value){const v=t.value.renderToString(a.content,f.globalConfig.katexConfig({throwOnError:!1,displayMode:!0}));return`<p ${l.renderAttrs(d)} data-processed>${v}</p>`}else return`<p ${l.renderAttrs(d)}>${a.content}</p>`};e.inline.ruler.before("escape","math_inline",Se({delimiters:i||z.inline})),e.block.ruler.after("blockquote","math_block",Re({delimiters:o||z.block}),{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=n,e.renderer.rules.math_block=h},He=(e,t)=>{const i=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(o,n,h,c,u)=>{const s=o[n],m=s.content.trim();if(s.info==="mermaid"){if(s.attrSet("class",`${f.prefix}-mermaid`),s.attrSet("data-mermaid-theme",t.themeRef.value),s.map&&s.level===0){const a=s.map[1]-1,v=!!c.srcLines[a]?.trim()?.startsWith("```");s.attrSet("data-closed",`${v}`),s.attrSet("data-line",String(s.map[0]))}const l=G.get(m);return l?(s.attrSet("data-processed",""),`<p ${u.renderAttrs(s)}>${l}</p>`):`<div ${u.renderAttrs(s)}>${e.utils.escapeHtml(m)}</div>`}return i(o,n,h,c,u)}},W=(e,t,i)=>{const o=e.attrIndex(t),n=[t,i];o<0?e.attrPush(n):(e.attrs=e.attrs||[],e.attrs[o]=n)},Fe=e=>e.type==="inline",Me=e=>e.type==="paragraph_open",Pe=e=>e.type==="list_item_open",Le=e=>e.content.indexOf("[ ] ")===0||e.content.indexOf("[x] ")===0||e.content.indexOf("[X] ")===0,_e=(e,t)=>Fe(e[t])&&Me(e[t-1])&&Pe(e[t-2])&&Le(e[t]),Ne=(e,t)=>{const i=e[t].level-1;for(let o=t-1;o>=0;o--)if(e[o].level===i)return o;return-1},je=e=>{const t=new e("html_inline","",0);return t.content="<label>",t},Oe=e=>{const t=new e("html_inline","",0);return t.content="</label>",t},De=(e,t,i)=>{const o=new i("html_inline","",0);return o.content='<label class="task-list-item-label" for="'+t+'">'+e+"</label>",o.attrs=[["for",t]],o},Be=(e,t,i)=>{const o=new t("html_inline","",0),n=i.enabled?" ":' disabled="" ';return e.content.indexOf("[ ] ")===0?o.content='<input class="task-list-item-checkbox"'+n+'type="checkbox">':(e.content.indexOf("[x] ")===0||e.content.indexOf("[X] ")===0)&&(o.content='<input class="task-list-item-checkbox" checked=""'+n+'type="checkbox">'),o},Ve=(e,t,i)=>{if(e.children=e.children||[],e.children.unshift(Be(e,t,i)),e.children[1].content=e.children[1].content.slice(3),e.content=e.content.slice(3),i.label)if(i.labelAfter){e.children.pop();const o="task-item-"+Math.ceil(Math.random()*(1e4*1e3)-1e3);e.children[0].content=e.children[0].content.slice(0,-1)+' id="'+o+'">',e.children.push(De(e.content,o,t))}else e.children.unshift(je(t)),e.children.push(Oe(t))},Ge=(e,t={})=>{e.core.ruler.after("inline","github-task-lists",i=>{const o=i.tokens;for(let n=2;n<o.length;n++)_e(o,n)&&(Ve(o[n],i.Token,t),W(o[n-2],"class","task-list-item"+(t.enabled?" enabled":" ")),W(o[Ne(o,n-2)],"class","contains-task-list"))})},Ue=e=>{e.core.ruler.push("init-line-number",t=>(t.tokens.forEach(i=>{i.map&&(i.attrs||(i.attrs=[]),i.attrs.push(["data-line",i.map[0].toString()]))}),!0))},qe=(e,t)=>{const{editorConfig:i,markdownItConfig:o,markdownItPlugins:n,editorExtensions:h}=f.globalConfig,c=r.inject("editorId"),u=r.inject("language"),s=r.inject("usedLanguageText"),m=r.inject("showCodeRowNumber"),l=r.inject("theme"),a=r.inject("customIcon"),d=r.inject("rootRef"),v=r.inject("setting"),g=r.ref([]);let b=()=>{};const y=xe(e),k=Ce(e),{reRenderRef:w,replaceMermaid:x}=Ee(e),{reRenderEcharts:A,replaceEcharts:E}=we(e),$=ae({html:!0,breaks:!0,linkify:!0});o($,{editorId:c});const C=[{type:"image",plugin:ie,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:$e,options:{}},{type:"taskList",plugin:Ge,options:{}},{type:"heading",plugin:Te,options:{mdHeadingId:e.mdHeadingId,headsRef:g}},{type:"code",plugin:Ie,options:{editorId:c,usedLanguageTextRef:s,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,customIconRef:a}},{type:"sub",plugin:le,options:{}},{type:"sup",plugin:se,options:{}}];e.noKatex||C.push({type:"katex",plugin:Ae,options:{katexRef:k}}),e.noMermaid||C.push({type:"mermaid",plugin:He,options:{themeRef:l}}),e.noEcharts||C.push({type:"echarts",plugin:ke,options:{themeRef:l}}),n(C,{editorId:c}).forEach(H=>{$.use(H.plugin,H.options)});const F=$.options.highlight;$.set({highlight:(H,P,R)=>{if(F){const L=F(H,P,R);if(L)return L}let T;!e.noHighlight&&y.value?y.value.getLanguage(P)?T=y.value.highlight(H,{language:P,ignoreIllegals:!0}).value:T=y.value.highlightAuto(H).value:T=$.utils.escapeHtml(H);const V=m?ce.generateCodeRowNumber(T.replace(/^\n+|\n+$/g,""),H.replace(/^\n+|\n+$/g,"")):`<span class="${f.prefix}-code-block">${T.replace(/^\n+|\n+$/g,"")}</span>`;return`<pre><code class="language-${P}" language=${P}>${V}</code></pre>`}}),Ue($);const N=r.ref(`_article-key_${_.randomId()}`),M=r.ref(e.sanitize($.render(e.modelValue,{srcLines:e.modelValue.split(`
63
+ `)}))),j=()=>{p.bus.emit(c,p.BUILD_FINISHED,M.value),e.onHtmlChanged(M.value),e.onGetCatalog(g.value),p.bus.emit(c,p.CATALOG_CHANGED,g.value),r.nextTick(()=>{x().then(()=>{h.mermaid?.enableZoom&&(b(),b=I.zoomMermaid(d.value?.querySelectorAll(`#${c} p.${f.prefix}-mermaid:not([data-closed=false])`),{customIcon:a.value}))}),E()})},B=()=>{g.value=[],M.value=e.sanitize($.render(e.modelValue,{srcLines:e.modelValue.split(`
64
+ `)}))},O=r.computed(()=>(e.noKatex||!!k.value)&&(e.noHighlight||!!y.value));let D=-1;return r.watch([r.toRef(e,"modelValue"),O,w,u],()=>{D=window.setTimeout(()=>{B()},t?0:i.renderDelay)}),r.watch(()=>v.value.preview,()=>{v.value.preview&&r.nextTick(()=>{x().then(()=>{h.mermaid?.enableZoom&&(b(),b=I.zoomMermaid(d.value?.querySelectorAll(`#${c} p.${f.prefix}-mermaid:not([data-closed=false])`),{customIcon:a.value}))}),E(),p.bus.emit(c,p.CATALOG_CHANGED,g.value)})}),r.watch([M,A],()=>{j()}),r.onMounted(j),r.onMounted(()=>{p.bus.on(c,{name:p.PUSH_CATALOG,callback(){p.bus.emit(c,p.CATALOG_CHANGED,g.value)}}),p.bus.on(c,{name:p.RERENDER,callback:()=>{N.value=`_article-key_${_.randomId()}`,B()}})}),r.onBeforeUnmount(()=>{b(),clearTimeout(D)}),{html:M,key:N}},ze=(e,t)=>{const i=r.inject("editorId"),o=r.inject("setting"),{noImgZoomIn:n}=e,h=_.debounce(()=>{const c=document.querySelectorAll(`#${i}-preview img:not(.not-zoom):not(.medium-zoom-image)`);c.length!==0&&ue(c,{background:"#00000073"})});r.onMounted(async()=>{!n&&o.value.preview&&await h()}),r.watch([t,()=>o.value.preview],async()=>{!n&&o.value.preview&&await h()})},K={checked:{regexp:/- \[x\]/,value:"- [ ]"},unChecked:{regexp:/- \[\s\]/,value:"- [x]"}},We=(e,t)=>{const i=r.inject("editorId"),o=r.inject("rootRef");let n=()=>{};const h=()=>{if(!o.value)return!1;const c=o.value.querySelectorAll(".task-list-item.enabled"),u=s=>{s.preventDefault();const m=s.target.checked?"unChecked":"checked",l=s.target.parentElement?.dataset.line;if(!l)return;const a=Number(l),d=e.modelValue.split(`
65
+ `),v=d[Number(a)].replace(K[m].regexp,K[m].value);e.previewOnly?(d[Number(a)]=v,e.onChange(d.join(`
66
+ `))):p.bus.emit(i,p.TASK_STATE_CHANGED,a+1,v)};c.forEach(s=>{s.addEventListener("click",u)}),n=()=>{c.forEach(s=>{s.removeEventListener("click",u)})}};r.onBeforeUnmount(()=>{n()}),r.watch([t],()=>{n(),r.nextTick(h)},{immediate:!0})},Ke=(e,t,i)=>{const o=r.inject("setting"),n=()=>{r.nextTick(()=>{e.onRemount?.()})},h=c=>{c&&n()};r.watch([t,i],n),r.watch(()=>o.value.preview,h),r.watch(()=>o.value.htmlPreview,h),r.onMounted(n)},Y={modelValue:{type:String,default:""},onChange:{type:Function,default:()=>{}},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:e=>e},noKatex:{type:Boolean,default:!1},formatCopiedText:{type:Function,default:e=>e},noHighlight:{type:Boolean,default:!1},previewOnly:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean},sanitizeMermaid:{type:Function},codeFoldable:{type:Boolean},autoFoldThreshold:{type:Number},onRemount:{type:Function},noEcharts:{type:Boolean}},Ze={...Y,updateModelValue:{type:Function,default:()=>{}},placeholder:{type:String,default:""},scrollAuto:{type:Boolean},autofocus:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},completions:{type:Array},onInput:{type:Function},onDrop:{type:Function,default:()=>{}},inputBoxWidth:{type:String},oninputBoxWidthChange:{type:Function},transformImgUrl:{type:Function,default:e=>e},catalogLayout:{type:String},catalogMaxDepth:{type:Number}},Je=e=>{const i=new DOMParser().parseFromString(e,"text/html");return Array.from(i.body.childNodes)},Xe=(e,t)=>{const i=[],o=[];if(e.forEach((n,h)=>{const c=t[h];if(!c){i.push({index:h,newNode:n});return}(n.nodeType!==c.nodeType||n.textContent!==c.textContent||n.nodeType===1&&n.outerHTML!==c.outerHTML)&&i.push({index:h,newNode:n})}),t.length>e.length)for(let n=e.length;n<t.length;n++)o.push(t[n]);return{updates:i,deletes:o}},Z=r.defineComponent({name:"UpdateOnDemand",props:{html:{type:String,required:!0}},setup(e){const t=r.inject("editorId"),i=r.inject("previewTheme"),o=r.inject("showCodeRowNumber"),n=r.ref(),h=e.html,c=(u,s)=>{n.value&&(s.forEach(m=>{m.remove()}),u.forEach(({index:m,newNode:l})=>{const a=n.value?.childNodes[m];a?n.value?.replaceChild(l.cloneNode(!0),a):n.value?.appendChild(l.cloneNode(!0))}))};return r.watch(()=>e.html,u=>{const s=Je(u),m=Array.from(n.value?.childNodes||[]),{updates:l,deletes:a}=Xe(s,m);c(l,a)}),()=>r.createVNode("div",{id:`${t}-preview`,class:[`${f.prefix}-preview`,`${i?.value}-theme`,o&&`${f.prefix}-scrn`],innerHTML:h,ref:n},null)}}),Q=r.defineComponent({name:"ContentPreview",props:Y,setup(e){const t=r.inject("editorId"),i=r.inject("setting"),{html:o,key:n}=qe(e,e.previewOnly);return ye(e,o,n),ze(e,o),We(e,o),Ke(e,o,n),()=>r.createVNode(r.Fragment,null,[i.value.preview&&(e.previewOnly?r.createVNode(Z,{key:n.value,html:o.value},null):r.createVNode("div",{id:`${t}-preview-wrapper`,class:`${f.prefix}-preview-wrapper`,key:"content-preview-wrapper"},[r.createVNode(Z,{key:n.value,html:o.value},null)])),i.value.htmlPreview&&r.createVNode("div",{id:`${t}-html-wrapper`,class:`${f.prefix}-preview-wrapper`,key:"html-preview-wrapper"},[r.createVNode("div",{class:`${f.prefix}-html`},[o.value])])])}}),Ye=({text:e})=>e,ee={modelValue:{type:String,default:""},onChange:{type:Function,default:void 0},theme:{type:String,default:"light"},class:{type:String,default:""},language:{type:String,default:"zh-CN"},onHtmlChanged:{type:Function,default:void 0},onGetCatalog:{type:Function,default:void 0},editorId:{type:String,default:void 0},id:{type:String,default:void 0},showCodeRowNumber:{type:Boolean,default:!0},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:Ye},sanitize:{type:Function,default:e=>e},noMermaid:{type:Boolean,default:!1},noKatex:{type:Boolean,default:!1},codeTheme:{type:String,default:"atom"},formatCopiedText:{type:Function,default:e=>e},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},noHighlight:{type:Boolean,default:!1},noImgZoomIn:{type:Boolean,default:!1},customIcon:{type:Object,default:{}},sanitizeMermaid:{type:Function,default:e=>Promise.resolve(e)},codeFoldable:{type:Boolean,default:!0},autoFoldThreshold:{type:Number,default:30},onRemount:{type:Function,default:void 0},noEcharts:{type:Boolean,default:!1}},Qe={...ee,onSave:{type:Function,default:void 0},onUploadImg:{type:Function,default:void 0},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},toolbars:{type:Array,default:f.allToolbar},floatingToolbars:{type:Array,default:[]},toolbarsExclude:{type:Array,default:[]},noPrettier:{type:Boolean,default:!1},tabWidth:{type:Number,default:2},tableShape:{type:Array,default:[6,4]},placeholder:{type:String,default:""},defToolbars:{type:[String,Object],default:void 0},onError:{type:Function,default:void 0},footers:{type:Array,default:f.allFooter},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object],default:void 0},noUploadImg:{type:Boolean,default:!1},autoFocus:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},maxLength:{type:Number,default:void 0},autoDetectCode:{type:Boolean,default:!1},onBlur:{type:Function,default:void 0},onFocus:{type:Function,default:void 0},completions:{type:Array,default:void 0},showToolbarName:{type:Boolean,default:!1},onInput:{type:Function,default:void 0},onDrop:{type:Function,default:void 0},inputBoxWidth:{type:String,default:"50%"},oninputBoxWidthChange:{type:Function,default:void 0},transformImgUrl:{type:Function,default:e=>e},catalogLayout:{type:String,default:"fixed"},catalogMaxDepth:{type:Number,default:void 0}},te=["onHtmlChanged","onGetCatalog","onChange","onRemount","update:modelValue"],et=[...te,"onSave","onUploadImg","onError","onBlur","onFocus","onInput","onDrop","oninputBoxWidthChange"],tt=(e,t,i)=>{const{editorId:o}=i,n={rerender(){p.bus.emit(o,p.RERENDER)}};t.expose(n)},U=r.defineComponent({name:"MdPreview",props:ee,emits:te,setup(e,t){const{noKatex:i,noMermaid:o,noHighlight:n}=e,h=r.ref(),c=X(e);return J(e,{rootRef:h,editorId:c}),tt(e,t,{editorId:c}),r.onBeforeUnmount(()=>{p.bus.clear(c)}),()=>r.createVNode("div",{id:c,class:[f.prefix,e.class,e.theme==="dark"&&`${f.prefix}-dark`,`${f.prefix}-previewOnly`],style:e.style,ref:h},[r.createVNode(Q,{modelValue:e.modelValue,onChange:u=>{e.onChange?.(u),t.emit("onChange",u),t.emit("update:modelValue",u)},onHtmlChanged:u=>{e.onHtmlChanged?.(u),t.emit("onHtmlChanged",u)},onGetCatalog:u=>{e.onGetCatalog?.(u),t.emit("onGetCatalog",u)},mdHeadingId:e.mdHeadingId,noMermaid:o,sanitize:e.sanitize,noKatex:i,formatCopiedText:e.formatCopiedText,noHighlight:n,noImgZoomIn:e.noImgZoomIn,previewOnly:!0,sanitizeMermaid:e.sanitizeMermaid,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,onRemount:()=>{e.onRemount?.(),t.emit("onRemount")},noEcharts:e.noEcharts},null)])}});U.install=e=>(e.component(U.name,U),e);exports.CDN_IDS=S;exports.ContentPreview=Q;exports.MdPreview=U;exports.contentProps=Ze;exports.editorEmits=et;exports.editorProps=Qe;exports.useCatalog=ve;exports.useConfig=ge;exports.useEditorId=X;exports.useErrorCatcher=he;exports.useExpansion=fe;exports.useExpose=be;exports.useOnSave=me;exports.useProvide=pe;