md-editor-v3 6.4.0 → 6.4.2

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,5 +1,5 @@
1
- "use strict";const n=require("vue"),j=require("@vavt/util"),h=require("./config.cjs"),p=require("./event-bus.cjs"),S=require("./dom.cjs"),re=require("@vavt/copy2clipboard"),ie=require("markdown-it"),ae=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"),A={hljs:`${h.prefix}-hljs`,hlcss:`${h.prefix}-hlCss`,prettier:`${h.prefix}-prettier`,prettierMD:`${h.prefix}-prettierMD`,cropperjs:`${h.prefix}-cropper`,croppercss:`${h.prefix}-cropperCss`,screenfull:`${h.prefix}-screenfull`,mermaidM:`${h.prefix}-mermaid-m`,mermaid:`${h.prefix}-mermaid`,katexjs:`${h.prefix}-katex`,katexcss:`${h.prefix}-katexCss`,echarts:`${h.prefix}-echarts`},fe=(e,t,a)=>{const{editorId:o}=a,r=n.reactive({buildFinished:!1,html:""});n.watch(()=>e.modelValue,()=>{r.buildFinished=!1}),n.onMounted(()=>{p.bus.on(o,{name:p.BUILD_FINISHED,callback(f){r.buildFinished=!0,r.html=f}}),p.bus.on(o,{name:p.ON_SAVE,callback(){const f=new Promise(d=>{if(r.buildFinished)d(r.html);else{const m=c=>{d(c),p.bus.remove(o,p.BUILD_FINISHED,m)};p.bus.on(o,{name:p.BUILD_FINISHED,callback:m})}});e.onSave?e.onSave(e.modelValue,f):t.emit("onSave",e.modelValue,f)}})})},Y=(e,{editorId:t,rootRef:a,setting:o})=>{const r=h.globalConfig.editorExtensions.highlight,f=h.globalConfig.editorExtensionsAttrs.highlight;n.provide("editorId",t),n.provide("rootRef",a),n.provide("theme",n.computed(()=>e.theme)),n.provide("language",n.computed(()=>e.language)),n.provide("highlight",n.computed(()=>{const{js:m}=r,c={...h.codeCss,...r.css},{js:l,css:s={}}=f||{},i=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme,u=c[e.codeTheme]?c[e.codeTheme][i]:h.codeCss.atom[i],w=c[e.codeTheme]&&s[e.codeTheme]?s[e.codeTheme][i]:s.atom?s.atom[i]:{};return{js:{src:m,...l},css:{href:u,...w}}})),n.provide("showCodeRowNumber",e.showCodeRowNumber);const d=n.computed(()=>{const m={...h.staticTextDefault,...h.globalConfig.editorConfig.languageUserDefined};return j.deepMerge(j.deepClone(h.staticTextDefault["en-US"]),m[e.language]||{})});return n.provide("usedLanguageText",d),n.provide("previewTheme",n.computed(()=>e.previewTheme)),n.provide("customIcon",n.computed(()=>e.customIcon)),n.provide("setting",n.computed(()=>o?{...o}:{preview:!0,htmlPreview:!1,previewOnly:!1,pageFullscreen:!1,fullscreen:!1})),{editorId:t}},me=(e,t)=>(n.provide("tabWidth",e.tabWidth),n.provide("disabled",n.computed(()=>e.disabled)),n.provide("showToolbarName",n.computed(()=>e.showToolbarName)),n.provide("noUploadImg",e.noUploadImg),n.provide("tableShape",n.computed(()=>e.tableShape)),n.provide("noPrettier",e.noPrettier),n.provide("codeTheme",n.computed(()=>e.codeTheme)),n.provide("updateSetting",t.updateSetting),n.provide("catalogVisible",n.computed(()=>t.catalogVisible.value)),n.provide("defToolbars",t.defToolbars),n.provide("floatingToolbars",n.computed(()=>e.floatingToolbars)),Y(e,t)),pe=e=>{const{noPrettier:t,noUploadImg:a}=e,{editorExtensions:o,editorExtensionsAttrs:r}=h.globalConfig,f=t||o.prettier.prettierInstance,d=t||o.prettier.parserMarkdownInstance,m=a||o.cropper.instance;n.onMounted(()=>{if(!m){const{js:c={},css:l={}}=r.cropper||{};S.appendHandler("link",{...l,rel:"stylesheet",href:o.cropper.css,id:A.croppercss}),S.appendHandler("script",{...c,src:o.cropper.js,id:A.cropperjs})}if(!f){const{standaloneJs:c={}}=r.prettier||{};S.appendHandler("script",{...c,src:o.prettier.standaloneJs,id:A.prettier})}if(!d){const{parserMarkdownJs:c={}}=r.prettier||{};S.appendHandler("script",{...c,src:o.prettier.parserMarkdownJs,id:A.prettierMD})}})},he=(e,t,a)=>{const{editorId:o}=a;n.onMounted(()=>{p.bus.on(o,{name:p.ERROR_CATCHER,callback:r=>{e.onError?.(r),t.emit("onError",r)}})})},ge=(e,t,a)=>{const{editorId:o}=a,r=n.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview,previewOnly:!1}),f=n.reactive({...r}),d=(l,s)=>{const i=s===void 0?!r[l]:s;switch(l){case"preview":{r.htmlPreview=!1,r.previewOnly=!1;break}case"htmlPreview":{r.preview=!1,r.previewOnly=!1;break}case"previewOnly":{i?!r.preview&&!r.htmlPreview&&(r.preview=!0):(f.preview||(r.preview=!1),f.htmlPreview||(r.htmlPreview=!1));break}}f[l]=i,r[l]=i};let m="";const c=()=>{r.pageFullscreen||r.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=m};return n.watch(()=>[r.pageFullscreen,r.fullscreen],c),n.onMounted(()=>{p.bus.on(o,{name:p.UPLOAD_IMAGE,callback(l,s){const i=u=>{p.bus.emit(o,p.REPLACE,"image",{desc:"",urls:u}),s?.()};e.onUploadImg?e.onUploadImg(l,i):t.emit("onUploadImg",l,i)}}),m=document.body.style.overflow,c()}),[r,d]},ve=(e,t)=>{const{editorId:a}=t,o=n.ref(!1);return n.onMounted(()=>{p.bus.on(a,{name:p.CHANGE_CATALOG_VISIBLE,callback:r=>{r===void 0?o.value=!o.value:o.value=r}})}),o},be=(e,t,a)=>{const{editorId:o,catalogVisible:r,setting:f,updateSetting:d,codeRef:m}=a;n.watch(()=>f.pageFullscreen,l=>{p.bus.emit(o,p.PAGE_FULL_SCREEN_CHANGED,l)}),n.watch(()=>f.fullscreen,l=>{p.bus.emit(o,p.FULL_SCREEN_CHANGED,l)}),n.watch(()=>f.preview,l=>{p.bus.emit(o,p.PREVIEW_CHANGED,l)}),n.watch(()=>f.previewOnly,l=>{p.bus.emit(o,p.PREVIEW_ONLY_CHANGED,l)}),n.watch(()=>f.htmlPreview,l=>{p.bus.emit(o,p.HTML_PREVIEW_CHANGED,l)}),n.watch(r,l=>{p.bus.emit(o,p.CATALOG_VISIBLE_CHANGED,l)});const c={on(l,s){switch(l){case"pageFullscreen":{p.bus.on(o,{name:p.PAGE_FULL_SCREEN_CHANGED,callback(i){s(i)}});break}case"fullscreen":{p.bus.on(o,{name:p.FULL_SCREEN_CHANGED,callback(i){s(i)}});break}case"preview":{p.bus.on(o,{name:p.PREVIEW_CHANGED,callback(i){s(i)}});break}case"previewOnly":{p.bus.on(o,{name:p.PREVIEW_ONLY_CHANGED,callback(i){s(i)}});break}case"htmlPreview":{p.bus.on(o,{name:p.HTML_PREVIEW_CHANGED,callback(i){s(i)}});break}case"catalog":{p.bus.on(o,{name:p.CATALOG_VISIBLE_CHANGED,callback(i){s(i)}});break}}},togglePageFullscreen(l){d("pageFullscreen",l)},toggleFullscreen(l){p.bus.emit(o,p.CHANGE_FULL_SCREEN,l)},togglePreview(l){d("preview",l)},togglePreviewOnly(l){d("previewOnly",l)},toggleHtmlPreview(l){d("htmlPreview",l)},toggleCatalog(l){p.bus.emit(o,p.CHANGE_CATALOG_VISIBLE,l)},triggerSave(){p.bus.emit(o,p.ON_SAVE)},insert(l){p.bus.emit(o,p.REPLACE,"universal",{generate:l})},focus(l){m.value?.focus(l)},rerender(){p.bus.emit(o,p.RERENDER)},getSelectedText(){return m.value?.getSelectedText()},resetHistory(){m.value?.resetHistory()},domEventHandlers(l){p.bus.emit(o,p.EVENT_LISTENER,l)},execCommand(l){p.bus.emit(o,p.REPLACE,l)},getEditorView(){return m.value?.getEditorView()}};t.expose(c)},Q=e=>{const t=n.useId();return e.id||e.editorId||`${h.prefix}-${t}`},ye=(e,t,a)=>{const o=n.inject("editorId"),r=n.inject("rootRef"),f=n.inject("usedLanguageText"),d=n.inject("setting"),m=()=>{r.value.querySelectorAll(`#${o} .${h.prefix}-preview .${h.prefix}-code`).forEach(s=>{let i=-1;const u=s.querySelector(`.${h.prefix}-copy-button:not([data-processed])`);u&&(u.onclick=w=>{w.preventDefault(),clearTimeout(i);const v=(s.querySelector("input:checked + pre code")||s.querySelector("pre code")).textContent,{text:b,successTips:$,failTips:y}=f.value.copyCode;let x=$;re(e.formatCopiedText(v||"")).catch(()=>{x=y}).finally(()=>{u.dataset.isIcon?u.dataset.tips=x:u.innerHTML=x,i=window.setTimeout(()=>{u.dataset.isIcon?u.dataset.tips=b:u.innerHTML=b},1500)})},u.setAttribute("data-processed","true"))})},c=()=>{n.nextTick(m)},l=s=>{s&&n.nextTick(m)};n.watch([t,a],c),n.watch(()=>d.value.preview,l),n.watch(()=>d.value.htmlPreview,l),n.onMounted(m)},Ce=e=>{const t=n.inject("editorId"),a=n.inject("theme"),o=n.inject("rootRef"),{editorExtensions:r,editorExtensionsAttrs:f}=h.globalConfig;let d=r.echarts.instance;const m=n.shallowRef(-1),c=()=>{!e.noEcharts&&d&&(m.value=m.value+1)};n.watch(()=>a.value,()=>{c()}),n.onMounted(()=>{if(e.noEcharts||d)return;const g=r.echarts.js;S.appendHandler("script",{...f.echarts?.js,src:g,id:A.echarts,onload(){d=window.echarts,c()}},"echarts")});let l=[],s=[],i=[];const u=(g=!1)=>{if(!l.length){g&&(s.forEach(y=>{y.dispose?.()}),i.forEach(y=>{y.disconnect?.()}),s=[],i=[]);return}const v=[],b=[],$=[];l.forEach((y,x)=>{const T=s[x],C=i[x];if(g||!y||!y.isConnected||(o?.value?!o.value.contains(y):!1)){T?.dispose?.(),C?.disconnect?.();return}v.push(y),T&&b.push(T),C&&$.push(C)}),l=v,s=b,i=$},w=()=>{u(),!e.noEcharts&&d&&Array.from(o.value.querySelectorAll(`#${t} div.${h.prefix}-echarts:not([data-processed])`)).forEach(v=>{if(v.dataset.closed==="false")return!1;try{const b=new Function(`return ${v.innerText}`)(),$=d.init(v,a.value);$.setOption(b),v.setAttribute("data-processed",""),l.push(v),s.push($);const y=new ResizeObserver(()=>{$.resize()});y.observe(v),i.push(y)}catch(b){p.bus.emit(t,p.ERROR_CATCHER,{name:"echarts",message:b?.message,error:b})}})};return n.onBeforeUnmount(()=>{u(!0)}),{reRenderEcharts:m,replaceEcharts:w}},we=e=>{const t=n.inject("highlight"),a=n.shallowRef(h.globalConfig.editorExtensions.highlight.instance);return n.onMounted(()=>{e.noHighlight||a.value||(S.appendHandler("link",{...t.value.css,rel:"stylesheet",id:A.hlcss}),S.appendHandler("script",{...t.value.js,id:A.hljs,onload(){a.value=window.hljs}},"hljs"))}),n.watch(()=>t.value.css,()=>{e.noHighlight||h.globalConfig.editorExtensions.highlight.instance||S.updateHandler("link",{...t.value.css,rel:"stylesheet",id:A.hlcss})}),a},xe=e=>{const t=n.shallowRef(h.globalConfig.editorExtensions.katex.instance);return n.onMounted(()=>{if(e.noKatex||t.value)return;const{editorExtensions:a,editorExtensionsAttrs:o}=h.globalConfig;S.appendHandler("script",{...o.katex?.js,src:a.katex.js,id:A.katexjs,onload(){t.value=window.katex}},"katex"),S.appendHandler("link",{...o.katex?.css,rel:"stylesheet",href:a.katex.css,id:A.katexcss})}),t},U=new de.LRUCache({max:1e3,ttl:6e5}),Ee=e=>{const t=n.inject("editorId"),a=n.inject("theme"),o=n.inject("rootRef"),{editorExtensions:r,editorExtensionsAttrs:f,mermaidConfig:d}=h.globalConfig;let m=r.mermaid.instance;const c=n.shallowRef(-1),l=()=>{if(!e.noMermaid&&m){const i=a.value==="dark"?{startOnLoad:!1,theme:"dark"}:{startOnLoad:!1,theme:"base",themeVariables:{background:"#ffffff",primaryColor:"#ffffff",primaryTextColor:"#1f2329",primaryBorderColor:"#b7c0cc",secondaryColor:"#f7f8fa",tertiaryColor:"#f7f8fa",lineColor:"#596273",edgeLabelBackground:"#ffffff",clusterBkg:"#ffffff",clusterBorder:"#b7c0cc"}};m.initialize(d(i)),c.value=c.value+1}};return n.watch(()=>a.value,()=>{U.clear(),l()}),n.onMounted(()=>{if(e.noMermaid||m)return;const i=r.mermaid.js;/\.mjs/.test(i)?(S.appendHandler("link",{...f.mermaid?.js,rel:"modulepreload",href:i,id:A.mermaidM}),import(i).then(u=>{m=u.default,l()}).catch(u=>{p.bus.emit(t,p.ERROR_CATCHER,{name:"mermaid",message:`Failed to load mermaid module: ${u.message}`,error:u})})):S.appendHandler("script",{...f.mermaid?.js,src:i,id:A.mermaid,onload(){m=window.mermaid,l()}},"mermaid")}),{reRenderRef:c,replaceMermaid:async()=>{if(!e.noMermaid&&m){const i=o.value.querySelectorAll(`div.${h.prefix}-mermaid`),u=document.createElement("div"),w=document.body.offsetWidth>1366?document.body.offsetWidth:1366,g=document.body.offsetHeight>768?document.body.offsetHeight:768;u.style.width=w+"px",u.style.height=g+"px",u.style.position="fixed",u.style.zIndex="-10000",u.style.top="-10000";let v=i.length;v>0&&document.body.appendChild(u),await Promise.allSettled(Array.from(i).map(b=>(async y=>{if(y.dataset.closed==="false")return!1;const x=y.innerText;let T=U.get(x);if(!T){const C=j.randomId();let k={svg:""};try{k=await m.render(C,x,u),T=await e.sanitizeMermaid(k.svg);const I=document.createElement("p");I.className=`${h.prefix}-mermaid`,I.setAttribute("data-processed",""),I.setAttribute("data-content",x),I.innerHTML=T,I.children[0]?.removeAttribute("height"),U.set(x,I.innerHTML),y.dataset.line!==void 0&&(I.dataset.line=y.dataset.line),y.replaceWith(I)}catch(I){p.bus.emit(t,p.ERROR_CATCHER,{name:"mermaid",message:I.message,error:I})}--v===0&&u.remove()}})(b)))}}}},$e=(e,t)=>{t=t||{};const a=3,o=t.marker||"!",r=o.charCodeAt(0),f=o.length;let d="",m="";const c=(s,i,u,w,g)=>{const v=s[i];return v.type==="admonition_open"?s[i].attrPush(["class",`${h.prefix}-admonition ${h.prefix}-admonition-${v.info}`]):v.type==="admonition_title_open"&&s[i].attrPush(["class",`${h.prefix}-admonition-title`]),g.renderToken(s,i,u)},l=s=>{const i=s.trim().split(" ",2);m="",d=i[0],i.length>1&&(m=s.substring(d.length+2))};e.block.ruler.before("code","admonition",(s,i,u,w)=>{let g,v,b,$=!1,y=s.bMarks[i]+s.tShift[i],x=s.eMarks[i];if(r!==s.src.charCodeAt(y))return!1;for(g=y+1;g<=x&&o[(g-y)%f]===s.src[g];g++);const T=Math.floor((g-y)/f);if(T!==a)return!1;g-=(g-y)%f;const C=s.src.slice(y,g),k=s.src.slice(g,x);if(l(k),w)return!0;for(v=i;v++,!(v>=u||(y=s.bMarks[v]+s.tShift[v],x=s.eMarks[v],y<x&&s.sCount[v]<s.blkIndent));)if(r===s.src.charCodeAt(y)&&!(s.sCount[v]-s.blkIndent>=4)){for(g=y+1;g<=x&&o[(g-y)%f]===s.src[g];g++);if(!(Math.floor((g-y)/f)<T)&&(g-=(g-y)%f,g=s.skipSpaces(g),!(g<x))){$=!0;break}}const I=s.parentType,H=s.lineMax;return s.parentType="root",s.lineMax=v,b=s.push("admonition_open","div",1),b.markup=C,b.block=!0,b.info=d,b.map=[i,v],m&&(b=s.push("admonition_title_open","p",1),b.markup=C+" "+d,b.map=[i,v],b=s.push("inline","",0),b.content=m,b.map=[i,s.line-1],b.children=[],b=s.push("admonition_title_close","p",-1),b.markup=C+" "+d),s.md.block.tokenize(s,i+1,v),b=s.push("admonition_close","div",-1),b.markup=s.src.slice(y,g),b.block=!0,s.parentType=I,s.lineMax=H,s.line=v+($?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=c,e.renderer.rules.admonition_title_open=c,e.renderer.rules.admonition_title_close=c,e.renderer.rules.admonition_close=c},z=(e,t)=>{const a=e.attrs?e.attrs.slice():[];return t.forEach(o=>{const r=e.attrIndex(o[0]);r<0?a.push(o):(a[r]=a[r].slice(),a[r][1]+=` ${o[1]}`)}),a},Ie=(e,t)=>{const a=e.renderer.rules.fence,o=e.utils.unescapeAll,r=/\[(\w*)(?::([\w ]*))?\]/,f=/::(open|close)/,d=i=>i.info?o(i.info).trim():"",m=i=>{const u=d(i),[w=null,g=""]=(r.exec(u)||[]).slice(1);return[w,g]},c=i=>{const u=d(i);return u?u.split(/(\s+)/g)[0]:""},l=i=>{const u=i.info.match(f)||[],w=u[1]==="open"||u[1]!=="close"&&t.codeFoldable&&i.content.trim().split(`
2
- `).length<t.autoFoldThreshold,g=u[1]||t.codeFoldable?"details":"div",v=u[1]||t.codeFoldable?"summary":"div";return{open:w,tagContainer:g,tagHeader:v}},s=(i,u,w,g,v)=>{if(i[u].hidden)return"";const b=t.usedLanguageTextRef.value?.copyCode.text,$=t.customIconRef.value.copy||b,y=!!t.customIconRef.value.copy,x=`<span class="${h.prefix}-collapse-tips">${S.StrIcon("collapse-tips",t.customIconRef.value)}</span>`,[T]=m(i[u]);if(T===null){const{open:E,tagContainer:R,tagHeader:G}=l(i[u]),L=[["class",`${h.prefix}-code`]];E&&L.push(["open",""]);const W={attrs:z(i[u],L)};i[u].info=i[u].info.replace(f,"");const O=a(i,u,w,g,v);return`
1
+ "use strict";const n=require("vue"),j=require("@vavt/util"),h=require("./config.cjs"),p=require("./event-bus.cjs"),S=require("./dom.cjs"),re=require("@vavt/copy2clipboard"),ie=require("markdown-it"),ae=require("markdown-it-image-figures"),le=require("markdown-it-sub"),se=require("markdown-it-sup"),ce=require("./index5.cjs"),de=require("medium-zoom"),A={hljs:`${h.prefix}-hljs`,hlcss:`${h.prefix}-hlCss`,prettier:`${h.prefix}-prettier`,prettierMD:`${h.prefix}-prettierMD`,cropperjs:`${h.prefix}-cropper`,croppercss:`${h.prefix}-cropperCss`,screenfull:`${h.prefix}-screenfull`,mermaidM:`${h.prefix}-mermaid-m`,mermaid:`${h.prefix}-mermaid`,katexjs:`${h.prefix}-katex`,katexcss:`${h.prefix}-katexCss`,echarts:`${h.prefix}-echarts`},ue=(e,t,a)=>{const{editorId:o}=a,r=n.reactive({buildFinished:!1,html:""});n.watch(()=>e.modelValue,()=>{r.buildFinished=!1}),n.onMounted(()=>{p.bus.on(o,{name:p.BUILD_FINISHED,callback(f){r.buildFinished=!0,r.html=f}}),p.bus.on(o,{name:p.ON_SAVE,callback(){const f=new Promise(d=>{if(r.buildFinished)d(r.html);else{const m=c=>{d(c),p.bus.remove(o,p.BUILD_FINISHED,m)};p.bus.on(o,{name:p.BUILD_FINISHED,callback:m})}});e.onSave?e.onSave(e.modelValue,f):t.emit("onSave",e.modelValue,f)}})})},Y=(e,{editorId:t,rootRef:a,setting:o})=>{const r=h.globalConfig.editorExtensions.highlight,f=h.globalConfig.editorExtensionsAttrs.highlight;n.provide("editorId",t),n.provide("rootRef",a),n.provide("theme",n.computed(()=>e.theme)),n.provide("language",n.computed(()=>e.language)),n.provide("highlight",n.computed(()=>{const{js:m}=r,c={...h.codeCss,...r.css},{js:l,css:s={}}=f||{},i=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme,u=c[e.codeTheme]?c[e.codeTheme][i]:h.codeCss.atom[i],x=c[e.codeTheme]&&s[e.codeTheme]?s[e.codeTheme][i]:s.atom?s.atom[i]:{};return{js:{src:m,...l},css:{href:u,...x}}})),n.provide("showCodeRowNumber",e.showCodeRowNumber);const d=n.computed(()=>{const m={...h.staticTextDefault,...h.globalConfig.editorConfig.languageUserDefined};return j.deepMerge(j.deepClone(h.staticTextDefault["en-US"]),m[e.language]||{})});return n.provide("usedLanguageText",d),n.provide("previewTheme",n.computed(()=>e.previewTheme)),n.provide("customIcon",n.computed(()=>e.customIcon)),n.provide("setting",n.computed(()=>o?{...o}:{preview:!0,htmlPreview:!1,previewOnly:!1,pageFullscreen:!1,fullscreen:!1})),{editorId:t}},fe=(e,t)=>(n.provide("tabWidth",e.tabWidth),n.provide("disabled",n.computed(()=>e.disabled)),n.provide("showToolbarName",n.computed(()=>e.showToolbarName)),n.provide("noUploadImg",e.noUploadImg),n.provide("tableShape",n.computed(()=>e.tableShape)),n.provide("noPrettier",e.noPrettier),n.provide("codeTheme",n.computed(()=>e.codeTheme)),n.provide("updateSetting",t.updateSetting),n.provide("catalogVisible",n.computed(()=>t.catalogVisible.value)),n.provide("defToolbars",t.defToolbars),n.provide("floatingToolbars",n.computed(()=>e.floatingToolbars)),Y(e,t)),me=e=>{const{noPrettier:t,noUploadImg:a}=e,{editorExtensions:o,editorExtensionsAttrs:r}=h.globalConfig,f=t||o.prettier.prettierInstance,d=t||o.prettier.parserMarkdownInstance,m=a||o.cropper.instance;n.onMounted(()=>{if(!m){const{js:c={},css:l={}}=r.cropper||{};S.appendHandler("link",{...l,rel:"stylesheet",href:o.cropper.css,id:A.croppercss}),S.appendHandler("script",{...c,src:o.cropper.js,id:A.cropperjs})}if(!f){const{standaloneJs:c={}}=r.prettier||{};S.appendHandler("script",{...c,src:o.prettier.standaloneJs,id:A.prettier})}if(!d){const{parserMarkdownJs:c={}}=r.prettier||{};S.appendHandler("script",{...c,src:o.prettier.parserMarkdownJs,id:A.prettierMD})}})},pe=(e,t,a)=>{const{editorId:o}=a;n.onMounted(()=>{p.bus.on(o,{name:p.ERROR_CATCHER,callback:r=>{e.onError?.(r),t.emit("onError",r)}})})},he=(e,t,a)=>{const{editorId:o}=a,r=n.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview,previewOnly:!1}),f=n.reactive({...r}),d=(l,s)=>{const i=s===void 0?!r[l]:s;switch(l){case"preview":{r.htmlPreview=!1,r.previewOnly=!1;break}case"htmlPreview":{r.preview=!1,r.previewOnly=!1;break}case"previewOnly":{i?!r.preview&&!r.htmlPreview&&(r.preview=!0):(f.preview||(r.preview=!1),f.htmlPreview||(r.htmlPreview=!1));break}}f[l]=i,r[l]=i};let m="";const c=()=>{r.pageFullscreen||r.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=m};return n.watch(()=>[r.pageFullscreen,r.fullscreen],c),n.onMounted(()=>{p.bus.on(o,{name:p.UPLOAD_IMAGE,callback(l,s){const i=u=>{p.bus.emit(o,p.REPLACE,"image",{desc:"",urls:u}),s?.()};e.onUploadImg?e.onUploadImg(l,i):t.emit("onUploadImg",l,i)}}),m=document.body.style.overflow,c()}),[r,d]},ge=(e,t)=>{const{editorId:a}=t,o=n.ref(!1);return n.onMounted(()=>{p.bus.on(a,{name:p.CHANGE_CATALOG_VISIBLE,callback:r=>{r===void 0?o.value=!o.value:o.value=r}})}),o},ve=(e,t,a)=>{const{editorId:o,catalogVisible:r,setting:f,updateSetting:d,codeRef:m}=a;n.watch(()=>f.pageFullscreen,l=>{p.bus.emit(o,p.PAGE_FULL_SCREEN_CHANGED,l)}),n.watch(()=>f.fullscreen,l=>{p.bus.emit(o,p.FULL_SCREEN_CHANGED,l)}),n.watch(()=>f.preview,l=>{p.bus.emit(o,p.PREVIEW_CHANGED,l)}),n.watch(()=>f.previewOnly,l=>{p.bus.emit(o,p.PREVIEW_ONLY_CHANGED,l)}),n.watch(()=>f.htmlPreview,l=>{p.bus.emit(o,p.HTML_PREVIEW_CHANGED,l)}),n.watch(r,l=>{p.bus.emit(o,p.CATALOG_VISIBLE_CHANGED,l)});const c={on(l,s){switch(l){case"pageFullscreen":{p.bus.on(o,{name:p.PAGE_FULL_SCREEN_CHANGED,callback(i){s(i)}});break}case"fullscreen":{p.bus.on(o,{name:p.FULL_SCREEN_CHANGED,callback(i){s(i)}});break}case"preview":{p.bus.on(o,{name:p.PREVIEW_CHANGED,callback(i){s(i)}});break}case"previewOnly":{p.bus.on(o,{name:p.PREVIEW_ONLY_CHANGED,callback(i){s(i)}});break}case"htmlPreview":{p.bus.on(o,{name:p.HTML_PREVIEW_CHANGED,callback(i){s(i)}});break}case"catalog":{p.bus.on(o,{name:p.CATALOG_VISIBLE_CHANGED,callback(i){s(i)}});break}}},togglePageFullscreen(l){d("pageFullscreen",l)},toggleFullscreen(l){p.bus.emit(o,p.CHANGE_FULL_SCREEN,l)},togglePreview(l){d("preview",l)},togglePreviewOnly(l){d("previewOnly",l)},toggleHtmlPreview(l){d("htmlPreview",l)},toggleCatalog(l){p.bus.emit(o,p.CHANGE_CATALOG_VISIBLE,l)},triggerSave(){p.bus.emit(o,p.ON_SAVE)},insert(l){p.bus.emit(o,p.REPLACE,"universal",{generate:l})},focus(l){m.value?.focus(l)},rerender(){p.bus.emit(o,p.RERENDER)},getSelectedText(){return m.value?.getSelectedText()},resetHistory(){m.value?.resetHistory()},domEventHandlers(l){p.bus.emit(o,p.EVENT_LISTENER,l)},execCommand(l){p.bus.emit(o,p.REPLACE,l)},getEditorView(){return m.value?.getEditorView()}};t.expose(c)},Q=e=>{const t=n.useId();return e.id||e.editorId||`${h.prefix}-${t}`},be=(e,t,a)=>{const o=n.inject("editorId"),r=n.inject("rootRef"),f=n.inject("usedLanguageText"),d=n.inject("setting"),m=()=>{r.value.querySelectorAll(`#${o} .${h.prefix}-preview .${h.prefix}-code`).forEach(s=>{let i=-1;const u=s.querySelector(`.${h.prefix}-copy-button:not([data-processed])`);u&&(u.onclick=x=>{x.preventDefault(),clearTimeout(i);const v=(s.querySelector("input:checked + pre code")||s.querySelector("pre code")).textContent,{text:b,successTips:$,failTips:y}=f.value.copyCode;let w=$;re(e.formatCopiedText(v||"")).catch(()=>{w=y}).finally(()=>{u.dataset.isIcon?u.dataset.tips=w:u.innerHTML=w,i=window.setTimeout(()=>{u.dataset.isIcon?u.dataset.tips=b:u.innerHTML=b},1500)})},u.setAttribute("data-processed","true"))})},c=()=>{n.nextTick(m)},l=s=>{s&&n.nextTick(m)};n.watch([t,a],c),n.watch(()=>d.value.preview,l),n.watch(()=>d.value.htmlPreview,l),n.onMounted(m)},ye=e=>{const t=n.inject("editorId"),a=n.inject("theme"),o=n.inject("rootRef"),{editorExtensions:r,editorExtensionsAttrs:f}=h.globalConfig;let d=r.echarts.instance;const m=n.shallowRef(-1),c=()=>{!e.noEcharts&&d&&(m.value=m.value+1)};n.watch(()=>a.value,()=>{c()}),n.onMounted(()=>{if(e.noEcharts||d)return;const g=r.echarts.js;S.appendHandler("script",{...f.echarts?.js,src:g,id:A.echarts,onload(){d=window.echarts,c()}},"echarts")});let l=[],s=[],i=[];const u=(g=!1)=>{if(!l.length){g&&(s.forEach(y=>{y.dispose?.()}),i.forEach(y=>{y.disconnect?.()}),s=[],i=[]);return}const v=[],b=[],$=[];l.forEach((y,w)=>{const T=s[w],C=i[w];if(g||!y||!y.isConnected||(o?.value?!o.value.contains(y):!1)){T?.dispose?.(),C?.disconnect?.();return}v.push(y),T&&b.push(T),C&&$.push(C)}),l=v,s=b,i=$},x=()=>{u(),!e.noEcharts&&d&&Array.from(o.value.querySelectorAll(`#${t} div.${h.prefix}-echarts:not([data-processed])`)).forEach(v=>{if(v.dataset.closed==="false")return!1;try{const b=new Function(`return ${v.innerText}`)(),$=d.init(v,a.value);$.setOption(b),v.setAttribute("data-processed",""),l.push(v),s.push($);const y=new ResizeObserver(()=>{$.resize()});y.observe(v),i.push(y)}catch(b){p.bus.emit(t,p.ERROR_CATCHER,{name:"echarts",message:b?.message,error:b})}})};return n.onBeforeUnmount(()=>{u(!0)}),{reRenderEcharts:m,replaceEcharts:x}},Ce=e=>{const t=n.inject("highlight"),a=n.shallowRef(h.globalConfig.editorExtensions.highlight.instance);return n.onMounted(()=>{e.noHighlight||a.value||(S.appendHandler("link",{...t.value.css,rel:"stylesheet",id:A.hlcss}),S.appendHandler("script",{...t.value.js,id:A.hljs,onload(){a.value=window.hljs}},"hljs"))}),n.watch(()=>t.value.css,()=>{e.noHighlight||h.globalConfig.editorExtensions.highlight.instance||S.updateHandler("link",{...t.value.css,rel:"stylesheet",id:A.hlcss})}),a},xe=e=>{const t=n.shallowRef(h.globalConfig.editorExtensions.katex.instance);return n.onMounted(()=>{if(e.noKatex||t.value)return;const{editorExtensions:a,editorExtensionsAttrs:o}=h.globalConfig;S.appendHandler("script",{...o.katex?.js,src:a.katex.js,id:A.katexjs,onload(){t.value=window.katex}},"katex"),S.appendHandler("link",{...o.katex?.css,rel:"stylesheet",href:a.katex.css,id:A.katexcss})}),t};class we{constructor(t){this.options=t}cache=new Map;isExpired(t){return t.expiresAt<=Date.now()}deleteExpired(t,a){const o=a??this.cache.get(t);return!o||!this.isExpired(o)?!1:(this.cache.delete(t),!0)}trim(){for(const[t,a]of this.cache)if(!this.deleteExpired(t,a))break;for(;this.cache.size>this.options.max;){const t=this.cache.keys().next().value;if(t===void 0)break;this.cache.delete(t)}}get(t){const a=this.cache.get(t);if(!(!a||this.deleteExpired(t,a)))return this.cache.delete(t),this.cache.set(t,a),a.value}set(t,a){this.cache.delete(t),this.cache.set(t,{value:a,expiresAt:Date.now()+this.options.ttl}),this.trim()}clear(){this.cache.clear()}}const U=new we({max:1e3,ttl:6e5}),Ee=e=>{const t=n.inject("editorId"),a=n.inject("theme"),o=n.inject("rootRef"),{editorExtensions:r,editorExtensionsAttrs:f,mermaidConfig:d}=h.globalConfig;let m=r.mermaid.instance;const c=n.shallowRef(-1),l=()=>{if(!e.noMermaid&&m){const i=a.value==="dark"?{startOnLoad:!1,theme:"dark"}:{startOnLoad:!1,theme:"base",themeVariables:{background:"#ffffff",primaryColor:"#ffffff",primaryTextColor:"#1f2329",primaryBorderColor:"#b7c0cc",secondaryColor:"#f7f8fa",tertiaryColor:"#f7f8fa",lineColor:"#596273",edgeLabelBackground:"#ffffff",clusterBkg:"#ffffff",clusterBorder:"#b7c0cc"}};m.initialize(d(i)),c.value=c.value+1}};return n.watch(()=>a.value,()=>{U.clear(),l()}),n.onMounted(()=>{if(e.noMermaid||m)return;const i=r.mermaid.js;/\.mjs/.test(i)?(S.appendHandler("link",{...f.mermaid?.js,rel:"modulepreload",href:i,id:A.mermaidM}),import(i).then(u=>{m=u.default,l()}).catch(u=>{p.bus.emit(t,p.ERROR_CATCHER,{name:"mermaid",message:`Failed to load mermaid module: ${u.message}`,error:u})})):S.appendHandler("script",{...f.mermaid?.js,src:i,id:A.mermaid,onload(){m=window.mermaid,l()}},"mermaid")}),{reRenderRef:c,replaceMermaid:async()=>{if(!e.noMermaid&&m){const i=o.value.querySelectorAll(`div.${h.prefix}-mermaid`),u=document.createElement("div"),x=document.body.offsetWidth>1366?document.body.offsetWidth:1366,g=document.body.offsetHeight>768?document.body.offsetHeight:768;u.style.width=x+"px",u.style.height=g+"px",u.style.position="fixed",u.style.zIndex="-10000",u.style.top="-10000";let v=i.length;v>0&&document.body.appendChild(u),await Promise.allSettled(Array.from(i).map(b=>(async y=>{if(y.dataset.closed==="false")return!1;const w=y.innerText;let T=U.get(w);if(!T){const C=j.randomId();let k={svg:""};try{k=await m.render(C,w,u),T=await e.sanitizeMermaid(k.svg);const I=document.createElement("p");I.className=`${h.prefix}-mermaid`,I.setAttribute("data-processed",""),I.setAttribute("data-content",w),I.innerHTML=T,I.children[0]?.removeAttribute("height"),U.set(w,I.innerHTML),y.dataset.line!==void 0&&(I.dataset.line=y.dataset.line),y.replaceWith(I)}catch(I){p.bus.emit(t,p.ERROR_CATCHER,{name:"mermaid",message:I.message,error:I})}--v===0&&u.remove()}})(b)))}}}},$e=(e,t)=>{t=t||{};const a=3,o=t.marker||"!",r=o.charCodeAt(0),f=o.length;let d="",m="";const c=(s,i,u,x,g)=>{const v=s[i];return v.type==="admonition_open"?s[i].attrPush(["class",`${h.prefix}-admonition ${h.prefix}-admonition-${v.info}`]):v.type==="admonition_title_open"&&s[i].attrPush(["class",`${h.prefix}-admonition-title`]),g.renderToken(s,i,u)},l=s=>{const i=s.trim().split(" ",2);m="",d=i[0],i.length>1&&(m=s.substring(d.length+2))};e.block.ruler.before("code","admonition",(s,i,u,x)=>{let g,v,b,$=!1,y=s.bMarks[i]+s.tShift[i],w=s.eMarks[i];if(r!==s.src.charCodeAt(y))return!1;for(g=y+1;g<=w&&o[(g-y)%f]===s.src[g];g++);const T=Math.floor((g-y)/f);if(T!==a)return!1;g-=(g-y)%f;const C=s.src.slice(y,g),k=s.src.slice(g,w);if(l(k),x)return!0;for(v=i;v++,!(v>=u||(y=s.bMarks[v]+s.tShift[v],w=s.eMarks[v],y<w&&s.sCount[v]<s.blkIndent));)if(r===s.src.charCodeAt(y)&&!(s.sCount[v]-s.blkIndent>=4)){for(g=y+1;g<=w&&o[(g-y)%f]===s.src[g];g++);if(!(Math.floor((g-y)/f)<T)&&(g-=(g-y)%f,g=s.skipSpaces(g),!(g<w))){$=!0;break}}const I=s.parentType,H=s.lineMax;return s.parentType="root",s.lineMax=v,b=s.push("admonition_open","div",1),b.markup=C,b.block=!0,b.info=d,b.map=[i,v],m&&(b=s.push("admonition_title_open","p",1),b.markup=C+" "+d,b.map=[i,v],b=s.push("inline","",0),b.content=m,b.map=[i,s.line-1],b.children=[],b=s.push("admonition_title_close","p",-1),b.markup=C+" "+d),s.md.block.tokenize(s,i+1,v),b=s.push("admonition_close","div",-1),b.markup=s.src.slice(y,g),b.block=!0,s.parentType=I,s.lineMax=H,s.line=v+($?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=c,e.renderer.rules.admonition_title_open=c,e.renderer.rules.admonition_title_close=c,e.renderer.rules.admonition_close=c},z=(e,t)=>{const a=e.attrs?e.attrs.slice():[];return t.forEach(o=>{const r=e.attrIndex(o[0]);r<0?a.push(o):(a[r]=a[r].slice(),a[r][1]+=` ${o[1]}`)}),a},Ie=(e,t)=>{const a=e.renderer.rules.fence,o=e.utils.unescapeAll,r=/\[(\w*)(?::([\w ]*))?\]/,f=/::(open|close)/,d=i=>i.info?o(i.info).trim():"",m=i=>{const u=d(i),[x=null,g=""]=(r.exec(u)||[]).slice(1);return[x,g]},c=i=>{const u=d(i);return u?u.split(/(\s+)/g)[0]:""},l=i=>{const u=i.info.match(f)||[],x=u[1]==="open"||u[1]!=="close"&&t.codeFoldable&&i.content.trim().split(`
2
+ `).length<t.autoFoldThreshold,g=u[1]||t.codeFoldable?"details":"div",v=u[1]||t.codeFoldable?"summary":"div";return{open:x,tagContainer:g,tagHeader:v}},s=(i,u,x,g,v)=>{if(i[u].hidden)return"";const b=t.usedLanguageTextRef.value?.copyCode.text,$=t.customIconRef.value.copy||b,y=!!t.customIconRef.value.copy,w=`<span class="${h.prefix}-collapse-tips">${S.StrIcon("collapse-tips",t.customIconRef.value)}</span>`,[T]=m(i[u]);if(T===null){const{open:E,tagContainer:R,tagHeader:G}=l(i[u]),F=[["class",`${h.prefix}-code`]];E&&F.push(["open",""]);const W={attrs:z(i[u],F)};i[u].info=i[u].info.replace(f,"");const O=a(i,u,x,g,v);return`
3
3
  <${R} ${v.renderAttrs(W)}>
4
4
  <${G} class="${h.prefix}-code-head">
5
5
  <div class="${h.prefix}-code-flag"><span></span><span></span><span></span></div>
@@ -7,12 +7,12 @@
7
7
  <span class="${h.prefix}-code-lang">${e.utils.escapeHtml(i[u].info.trim())}</span>
8
8
  <span class="${h.prefix}-copy-button" data-tips="${b}"${y?" data-is-icon=true":""}>${$}</span>
9
9
  ${t.extraTools instanceof Function?t.extraTools({lang:i[u].info.trim()}):t.extraTools||""}
10
- ${R==="details"?x:""}
10
+ ${R==="details"?w:""}
11
11
  </div>
12
12
  </${G}>
13
13
  ${O}
14
14
  </${R}>
15
- `}let C,k,I,H,F="",M="",P="";const{open:D,tagContainer:_,tagHeader:N}=l(i[u]),B=[["class",`${h.prefix}-code`]];D&&B.push(["open",""]);const V={attrs:z(i[u],B)};for(let E=u;E<i.length&&(C=i[E],[k,I]=m(C),k===T);E++){C.info=C.info.replace(r,"").replace(f,""),C.hidden=!0;const R=`${h.prefix}-codetab-${t.editorId}-${u}-${E-u}`;H=E-u>0?"":"checked",F+=`
15
+ `}let C,k,I,H,M="",L="",P="";const{open:D,tagContainer:_,tagHeader:N}=l(i[u]),B=[["class",`${h.prefix}-code`]];D&&B.push(["open",""]);const V={attrs:z(i[u],B)};for(let E=u;E<i.length&&(C=i[E],[k,I]=m(C),k===T);E++){C.info=C.info.replace(r,"").replace(f,""),C.hidden=!0;const R=`${h.prefix}-codetab-${t.editorId}-${u}-${E-u}`;H=E-u>0?"":"checked",M+=`
16
16
  <li>
17
17
  <input
18
18
  type="radio"
@@ -27,7 +27,7 @@
27
27
  >
28
28
  ${e.utils.escapeHtml(I||c(C))}
29
29
  </label>
30
- </li>`,M+=`
30
+ </li>`,L+=`
31
31
  <div role="tabpanel">
32
32
  <input
33
33
  type="radio"
@@ -35,7 +35,7 @@
35
35
  class="${R}"
36
36
  ${H}
37
37
  role="presentation">
38
- ${a(i,E,w,g,v)}
38
+ ${a(i,E,x,g,v)}
39
39
  </div>`,P+=`
40
40
  <input
41
41
  type="radio"
@@ -47,19 +47,19 @@
47
47
  <${_} ${v.renderAttrs(V)}>
48
48
  <${N} class="${h.prefix}-code-head">
49
49
  <div class="${h.prefix}-code-flag">
50
- <ul class="${h.prefix}-codetab-label" role="tablist">${F}</ul>
50
+ <ul class="${h.prefix}-codetab-label" role="tablist">${M}</ul>
51
51
  </div>
52
52
  <div class="${h.prefix}-code-action">
53
53
  <span class="${h.prefix}-codetab-lang">${P}</span>
54
54
  <span class="${h.prefix}-copy-button" data-tips="${b}"${y?" data-is-icon=true":""}>${$}</span>
55
55
  ${t.extraTools instanceof Function?t.extraTools({lang:i[u].info.trim()}):t.extraTools||""}
56
- ${_==="details"?x:""}
56
+ ${_==="details"?w:""}
57
57
  </div>
58
58
  </${N}>
59
- ${M}
59
+ ${L}
60
60
  </${_}>
61
- `};e.renderer.rules.fence=s,e.renderer.rules.code_block=s},Te=(e,t)=>{const a=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(o,r,f,d,m)=>{const c=o[r],l=c.content.trim();if(c.info==="echarts"){if(c.attrSet("class",`${h.prefix}-echarts`),c.attrSet("data-echarts-theme",t.themeRef.value),c.map&&c.level===0){const s=c.map[1]-1,u=!!d.srcLines[s]?.trim()?.startsWith("```");c.attrSet("data-closed",`${u}`),c.attrSet("data-line",String(c.map[0]))}return`<div ${m.renderAttrs(c)} style="width: 100%; aspect-ratio: 4 / 3;">${e.utils.escapeHtml(l)}</div>`}return a(o,r,f,d,m)}},ke=(e,t)=>{e.renderer.rules.heading_open=(a,o)=>{const r=a[o],f=a[o+1].children?.reduce((m,c)=>m+(["text","code_inline","math_inline"].includes(c.type)&&c.content||""),"")||"",d=r.markup.length;return t.headsRef.value.push({text:f,level:d,line:r.map[0],currentToken:r,nextToken:a[o+1]}),r.map&&r.level===0&&r.attrSet("id",t.mdHeadingId({text:f,level:d,index:t.headsRef.value.length,currentToken:r,nextToken:a[o+1]})),e.renderer.renderToken(a,o,t)},e.renderer.rules.heading_close=(a,o,r,f,d)=>d.renderToken(a,o,r)},K={block:[{open:"$$",close:"$$"},{open:"\\[",close:"\\]"}],inline:[{open:"$$",close:"$$"},{open:"$",close:"$"},{open:"\\[",close:"\\]"},{open:"\\(",close:"\\)"}]},Se=e=>(t,a)=>{const o=e.delimiters;for(const r of o){if(!t.src.startsWith(r.open,t.pos))continue;const f=t.pos+r.open.length;let d=f;for(;(d=t.src.indexOf(r.close,d))!==-1;){let m=0,c=d-1;for(;c>=0&&t.src[c]==="\\";)m++,c--;if(m%2===0)break;d+=r.close.length}if(d!==-1){if(d-f===0)return a||(t.pending+=r.open+r.close),t.pos=d+r.close.length,!0;if(!a){const m=t.push("math_inline","math",0);m.markup=r.open,m.content=t.src.slice(f,d)}return t.pos=d+r.close.length,!0}}return!1},Re=e=>(t,a,o,r)=>{const f=e.delimiters,d=t.bMarks[a]+t.tShift[a],m=t.eMarks[a],c=(l,s,i)=>{t.line=s;const u=t.push("math_block","math",0);return u.block=!0,u.content=l,u.map=[a,t.line],u.markup=i,!0};for(const l of f){const s=d;if(t.src.slice(s,s+l.open.length)!==l.open)continue;const i=s+l.open.length,u=t.src.slice(i,m).trim(),w=u==="",g=u===l.close,v=u.endsWith(l.close);if(!w&&!g&&!v)continue;if(r)return!0;if(g)return c("",a+1,l.open);if(!w&&v){const C=u.slice(0,-l.close.length);return c(C,a+1,l.open)}let b=a+1,$=!1,y="";for(;b<o;b++){const C=t.bMarks[b]+t.tShift[b],k=t.eMarks[b];if(C<k&&t.tShift[b]<t.blkIndent)break;if(t.src.slice(C,k).trim().endsWith(l.close)){const H=t.src.slice(0,k).lastIndexOf(l.close);y=t.src.slice(C,H),$=!0;break}}if(!$)continue;const T=t.getLines(a+1,b,t.tShift[a],!0)+(y.trim()?y:"");return c(T,b+1,l.open)}return!1},Ae=(e,{katexRef:t,inlineDelimiters:a,blockDelimiters:o})=>{const r=(m,c,l,s,i=!1)=>{const u={attrs:z(m,[["class",c]])},w=s.renderAttrs(u);if(!t.value)return`<${l} ${w}>${m.content}</${l}>`;const g=t.value.renderToString(m.content,h.globalConfig.katexConfig({throwOnError:!1,displayMode:i}));return`<${l} ${w} data-processed>${g}</${l}>`},f=(m,c,l,s,i)=>r(m[c],`${h.prefix}-katex-inline`,"span",i),d=(m,c,l,s,i)=>r(m[c],`${h.prefix}-katex-block`,"p",i,!0);e.inline.ruler.before("escape","math_inline",Se({delimiters:a||K.inline})),e.block.ruler.after("blockquote","math_block",Re({delimiters:o||K.block}),{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=f,e.renderer.rules.math_block=d},He=(e,t)=>{const a=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(o,r,f,d,m)=>{const c=o[r],l=c.content.trim();if(c.info==="mermaid"){if(c.attrSet("class",`${h.prefix}-mermaid`),c.attrSet("data-mermaid-theme",t.themeRef.value),c.map&&c.level===0){const i=c.map[1]-1,w=!!d.srcLines[i]?.trim()?.startsWith("```");c.attrSet("data-closed",`${w}`),c.attrSet("data-line",String(c.map[0]))}const s=U.get(l);return s?(c.attrSet("data-processed",""),c.attrSet("data-content",l),`<p ${m.renderAttrs(c)}>${s}</p>`):`<div ${m.renderAttrs(c)}>${e.utils.escapeHtml(l)}</div>`}return a(o,r,f,d,m)}},Z=(e,t,a)=>{const o=e.attrIndex(t),r=[t,a];o<0?e.attrPush(r):(e.attrs=e.attrs||[],e.attrs[o]=r)},Fe=e=>e.type==="inline",Le=e=>e.type==="paragraph_open",Me=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])&&Le(e[t-1])&&Me(e[t-2])&&Pe(e[t]),je=(e,t)=>{const a=e[t].level-1;for(let o=t-1;o>=0;o--)if(e[o].level===a)return o;return-1},Ne=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,a)=>{const o=new a("html_inline","",0);return o.content='<label class="task-list-item-label" for="'+t+'">'+e+"</label>",o.attrs=[["for",t]],o},Be=(e,t,a)=>{const o=new t("html_inline","",0),r=a.enabled?" ":' disabled="" ';return e.content.indexOf("[ ] ")===0?o.content='<input class="task-list-item-checkbox"'+r+'type="checkbox">':(e.content.indexOf("[x] ")===0||e.content.indexOf("[X] ")===0)&&(o.content='<input class="task-list-item-checkbox" checked=""'+r+'type="checkbox">'),o},Ve=(e,t,a)=>{if(e.children=e.children||[],e.children.unshift(Be(e,t,a)),e.children[1].content=e.children[1].content.slice(3),e.content=e.content.slice(3),a.label)if(a.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(Ne(t)),e.children.push(Oe(t))},Ge=(e,t={})=>{e.core.ruler.after("inline","github-task-lists",a=>{const o=a.tokens;for(let r=2;r<o.length;r++)_e(o,r)&&(Ve(o[r],a.Token,t),Z(o[r-2],"class","task-list-item"+(t.enabled?" enabled":" ")),Z(o[je(o,r-2)],"class","contains-task-list"))})},Ue=e=>{e.core.ruler.push("init-line-number",t=>(t.tokens.forEach(a=>{a.map&&(a.attrs||(a.attrs=[]),a.attrs.push(["data-line",a.map[0].toString()]))}),!0))},qe=(e,t)=>{const{editorConfig:a,markdownItConfig:o,markdownItPlugins:r,editorExtensions:f}=h.globalConfig,d=n.inject("editorId"),m=n.inject("language"),c=n.inject("usedLanguageText"),l=n.inject("showCodeRowNumber"),s=n.inject("theme"),i=n.inject("customIcon"),u=n.inject("rootRef"),w=n.inject("setting"),g=n.ref([]),v=we(e),b=xe(e),{reRenderRef:$,replaceMermaid:y}=Ee(e),{reRenderEcharts:x,replaceEcharts:T}=Ce(e),C=ie({html:!0,breaks:!0,linkify:!0});o(C,{editorId:d});const k=[{type:"image",plugin:ae,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:$e,options:{}},{type:"taskList",plugin:Ge,options:{}},{type:"heading",plugin:ke,options:{mdHeadingId:e.mdHeadingId,headsRef:g}},{type:"code",plugin:Ie,options:{editorId:d,usedLanguageTextRef:c,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,customIconRef:i}},{type:"sub",plugin:le,options:{}},{type:"sup",plugin:se,options:{}}];e.noKatex||k.push({type:"katex",plugin:Ae,options:{katexRef:b}}),e.noMermaid||k.push({type:"mermaid",plugin:He,options:{themeRef:s}}),e.noEcharts||k.push({type:"echarts",plugin:Te,options:{themeRef:s}}),r(k,{editorId:d}).forEach(E=>{C.use(E.plugin,E.options)});const I=C.options.highlight;C.set({highlight:(E,R,G)=>{if(I){const O=I(E,R,G);if(O)return O}let L;!e.noHighlight&&v.value?v.value.getLanguage(R)?L=v.value.highlight(E,{language:R,ignoreIllegals:!0}).value:L=v.value.highlightAuto(E).value:L=C.utils.escapeHtml(E);const W=l?ce.generateCodeRowNumber(L.replace(/^\n+|\n+$/g,""),E.replace(/^\n+|\n+$/g,"")):`<span class="${h.prefix}-code-block">${L.replace(/^\n+|\n+$/g,"")}</span>`;return`<pre><code class="language-${R}" language=${R}>${W}</code></pre>`}}),Ue(C);const H=n.ref(`_article-key_${j.randomId()}`),F=n.ref(e.sanitize(C.render(e.modelValue,{srcLines:e.modelValue.split(`
62
- `)})));let M=()=>{},P=()=>{};const D=()=>{const E=u.value?.querySelectorAll(`#${d} p.${h.prefix}-mermaid:not([data-closed=false])`);P(),P=S.copyMermaid(E,{customIcon:i.value}),f.mermaid?.enableZoom&&(M(),M=S.zoomMermaid(E,{customIcon:i.value}))},_=()=>{p.bus.emit(d,p.BUILD_FINISHED,F.value),e.onHtmlChanged(F.value),e.onGetCatalog(g.value),p.bus.emit(d,p.CATALOG_CHANGED,g.value),n.nextTick(()=>{y().then(D),T()})},N=()=>{g.value=[],F.value=e.sanitize(C.render(e.modelValue,{srcLines:e.modelValue.split(`
63
- `)}))},B=n.computed(()=>(e.noKatex||!!b.value)&&(e.noHighlight||!!v.value));let V=-1;return n.watch([n.toRef(e,"modelValue"),B,$,m],()=>{V=window.setTimeout(()=>{N()},t?0:a.renderDelay)}),n.watch(()=>w.value.preview,()=>{w.value.preview&&n.nextTick(()=>{y().then(D),T(),p.bus.emit(d,p.CATALOG_CHANGED,g.value)})}),n.watch([F,x],()=>{_()}),n.onMounted(_),n.onMounted(()=>{p.bus.on(d,{name:p.PUSH_CATALOG,callback(){p.bus.emit(d,p.CATALOG_CHANGED,g.value)}}),p.bus.on(d,{name:p.RERENDER,callback:()=>{H.value=`_article-key_${j.randomId()}`,N()}})}),n.onBeforeUnmount(()=>{M(),P(),clearTimeout(V)}),{html:F,key:H}},We=(e,t)=>{const a=n.inject("editorId"),o=n.inject("setting"),{noImgZoomIn:r}=e,f=j.debounce(()=>{const d=document.querySelectorAll(`#${a}-preview img:not(.not-zoom):not(.medium-zoom-image)`);d.length!==0&&ue(d,{background:"#00000073"})});n.onMounted(async()=>{!r&&o.value.preview&&await f()}),n.watch([t,()=>o.value.preview],async()=>{!r&&o.value.preview&&await f()})},J={checked:{regexp:/- \[x\]/,value:"- [ ]"},unChecked:{regexp:/- \[\s\]/,value:"- [x]"}},ze=(e,t)=>{const a=n.inject("editorId"),o=n.inject("rootRef");let r=()=>{};const f=()=>{if(!o.value)return!1;const d=o.value.querySelectorAll(".task-list-item.enabled"),m=c=>{c.preventDefault();const l=c.target.checked?"unChecked":"checked",s=c.target.parentElement?.dataset.line;if(!s)return;const i=Number(s),u=e.modelValue.split(`
64
- `),w=u[Number(i)].replace(J[l].regexp,J[l].value);e.previewOnly?(u[Number(i)]=w,e.onChange(u.join(`
65
- `))):p.bus.emit(a,p.TASK_STATE_CHANGED,i+1,w)};d.forEach(c=>{c.addEventListener("click",m)}),r=()=>{d.forEach(c=>{c.removeEventListener("click",m)})}};n.onBeforeUnmount(()=>{r()}),n.watch([t],()=>{r(),n.nextTick(f)},{immediate:!0})},Ke=(e,t,a)=>{const o=n.inject("setting"),r=()=>{n.nextTick(()=>{e.onRemount?.()})},f=d=>{d&&r()};n.watch([t,a],r),n.watch(()=>o.value.preview,f),n.watch(()=>o.value.htmlPreview,f),n.onMounted(r)},ee={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},previewComponent:{type:[Object,Function],default:void 0}},Ze={...ee,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}},X=e=>{const a=new DOMParser().parseFromString(e,"text/html");return Array.from(a.body.childNodes)},Je=(e,t)=>e.nodeType!==t.nodeType?!1:e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE?e.textContent===t.textContent:e.nodeType===Node.ELEMENT_NODE?e.outerHTML===t.outerHTML:e.isEqualNode?e.isEqualNode(t):!1,Xe=n.defineComponent({name:"UpdateOnDemand",props:{id:{type:String,required:!0},class:{type:[String,Array,Object],required:!0},html:{type:String,required:!0}},setup(e){const t=n.ref(),a=e.html,o=(r,f)=>{if(!t.value)return;const d=t.value,m=Array.from(d.childNodes),c=Math.min(r.length,f.length);let l=-1;for(let i=0;i<c;i++)if(!Je(r[i],f[i])){l=i;break}if(l===-1)if(f.length>r.length)l=r.length;else if(r.length>f.length)l=f.length;else return;const s=Math.min(l,m.length);for(let i=m.length-1;i>=s;i--)m[i].remove();for(let i=l;i<r.length;i++)d.appendChild(r[i].cloneNode(!0))};return n.watch(()=>e.html,(r,f)=>{const d=X(r),m=X(f||"");o(d,m)}),()=>n.createVNode("div",{id:e.id,class:e.class,innerHTML:a,ref:t},null)}}),te=n.defineComponent({name:"ContentPreview",props:ee,setup(e){const t=n.inject("editorId"),a=n.inject("setting"),o=n.inject("previewTheme"),r=n.inject("showCodeRowNumber"),{html:f,key:d}=qe(e,e.previewOnly);ye(e,f,d),We(e,f),ze(e,f),Ke(e,f,d);const m=n.computed(()=>[`${h.prefix}-preview`,`${o?.value}-theme`,r&&`${h.prefix}-scrn`].filter(Boolean)),c=()=>{const l=`${t}-preview`;return e.previewComponent?n.h(e.previewComponent,{key:d.value,html:f.value,id:l,class:m.value}):n.createVNode(Xe,{key:d.value,html:f.value,id:l,class:m.value},null)};return()=>n.createVNode(n.Fragment,null,[a.value.preview&&(e.previewOnly?c():n.createVNode("div",{id:`${t}-preview-wrapper`,class:`${h.prefix}-preview-wrapper`,key:"content-preview-wrapper"},[c()])),a.value.htmlPreview&&n.createVNode("div",{id:`${t}-html-wrapper`,class:`${h.prefix}-preview-wrapper`,key:"html-preview-wrapper"},[n.createVNode("div",{class:`${h.prefix}-html`},[f.value])])])}}),Ye=({text:e})=>e,ne={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},previewComponent:{type:[Object,Function],default:void 0}},Qe={...ne,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:h.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:h.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}},oe=["onHtmlChanged","onGetCatalog","onChange","onRemount","update:modelValue"],et=[...oe,"onSave","onUploadImg","onError","onBlur","onFocus","onInput","onDrop","oninputBoxWidthChange"],tt=(e,t,a)=>{const{editorId:o}=a,r={rerender(){p.bus.emit(o,p.RERENDER)}};t.expose(r)},q=n.defineComponent({name:"MdPreview",props:ne,emits:oe,setup(e,t){const{noKatex:a,noMermaid:o,noHighlight:r}=e,f=n.ref(),d=Q(e);Y(e,{rootRef:f,editorId:d}),tt(e,t,{editorId:d}),n.onBeforeUnmount(()=>{p.bus.clear(d)});const m=i=>{e.onChange?.(i),t.emit("onChange",i),t.emit("update:modelValue",i)},c=i=>{e.onHtmlChanged?.(i),t.emit("onHtmlChanged",i)},l=i=>{e.onGetCatalog?.(i),t.emit("onGetCatalog",i)},s=()=>{e.onRemount?.(),t.emit("onRemount")};return()=>n.createVNode("div",{id:d,class:[h.prefix,e.class,e.theme==="dark"&&`${h.prefix}-dark`,`${h.prefix}-previewOnly`],style:e.style,ref:f},[n.createVNode(te,{modelValue:e.modelValue,onChange:m,onHtmlChanged:c,onGetCatalog:l,mdHeadingId:e.mdHeadingId,noMermaid:o,sanitize:e.sanitize,noKatex:a,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0,sanitizeMermaid:e.sanitizeMermaid,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,onRemount:s,noEcharts:e.noEcharts,previewComponent:e.previewComponent},null)])}});q.install=e=>(e.component(q.name,q),e);exports.CDN_IDS=A;exports.ContentPreview=te;exports.MdPreview=q;exports.contentProps=Ze;exports.editorEmits=et;exports.editorProps=Qe;exports.useCatalog=ve;exports.useConfig=ge;exports.useEditorId=Q;exports.useErrorCatcher=he;exports.useExpansion=pe;exports.useExpose=be;exports.useOnSave=fe;exports.useProvide=me;
61
+ `};e.renderer.rules.fence=s,e.renderer.rules.code_block=s},Te=(e,t)=>{const a=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(o,r,f,d,m)=>{const c=o[r],l=c.content.trim();if(c.info==="echarts"){if(c.attrSet("class",`${h.prefix}-echarts`),c.attrSet("data-echarts-theme",t.themeRef.value),c.map&&c.level===0){const s=c.map[1]-1,u=!!d.srcLines[s]?.trim()?.startsWith("```");c.attrSet("data-closed",`${u}`),c.attrSet("data-line",String(c.map[0]))}return`<div ${m.renderAttrs(c)} style="width: 100%; aspect-ratio: 4 / 3;">${e.utils.escapeHtml(l)}</div>`}return a(o,r,f,d,m)}},ke=(e,t)=>{e.renderer.rules.heading_open=(a,o)=>{const r=a[o],f=a[o+1].children?.reduce((m,c)=>m+(["text","code_inline","math_inline"].includes(c.type)&&c.content||""),"")||"",d=r.markup.length;return t.headsRef.value.push({text:f,level:d,line:r.map[0],currentToken:r,nextToken:a[o+1]}),r.map&&r.level===0&&r.attrSet("id",t.mdHeadingId({text:f,level:d,index:t.headsRef.value.length,currentToken:r,nextToken:a[o+1]})),e.renderer.renderToken(a,o,t)},e.renderer.rules.heading_close=(a,o,r,f,d)=>d.renderToken(a,o,r)},K={block:[{open:"$$",close:"$$"},{open:"\\[",close:"\\]"}],inline:[{open:"$$",close:"$$"},{open:"$",close:"$"},{open:"\\[",close:"\\]"},{open:"\\(",close:"\\)"}]},Se=e=>(t,a)=>{const o=e.delimiters;for(const r of o){if(!t.src.startsWith(r.open,t.pos))continue;const f=t.pos+r.open.length;let d=f;for(;(d=t.src.indexOf(r.close,d))!==-1;){let m=0,c=d-1;for(;c>=0&&t.src[c]==="\\";)m++,c--;if(m%2===0)break;d+=r.close.length}if(d!==-1){if(d-f===0)return a||(t.pending+=r.open+r.close),t.pos=d+r.close.length,!0;if(!a){const m=t.push("math_inline","math",0);m.markup=r.open,m.content=t.src.slice(f,d)}return t.pos=d+r.close.length,!0}}return!1},Re=e=>(t,a,o,r)=>{const f=e.delimiters,d=t.bMarks[a]+t.tShift[a],m=t.eMarks[a],c=(l,s,i)=>{t.line=s;const u=t.push("math_block","math",0);return u.block=!0,u.content=l,u.map=[a,t.line],u.markup=i,!0};for(const l of f){const s=d;if(t.src.slice(s,s+l.open.length)!==l.open)continue;const i=s+l.open.length,u=t.src.slice(i,m).trim(),x=u==="",g=u===l.close,v=u.endsWith(l.close);if(!x&&!g&&!v)continue;if(r)return!0;if(g)return c("",a+1,l.open);if(!x&&v){const C=u.slice(0,-l.close.length);return c(C,a+1,l.open)}let b=a+1,$=!1,y="";for(;b<o;b++){const C=t.bMarks[b]+t.tShift[b],k=t.eMarks[b];if(C<k&&t.tShift[b]<t.blkIndent)break;if(t.src.slice(C,k).trim().endsWith(l.close)){const H=t.src.slice(0,k).lastIndexOf(l.close);y=t.src.slice(C,H),$=!0;break}}if(!$)continue;const T=t.getLines(a+1,b,t.tShift[a],!0)+(y.trim()?y:"");return c(T,b+1,l.open)}return!1},Ae=(e,{katexRef:t,inlineDelimiters:a,blockDelimiters:o})=>{const r=(m,c,l,s,i=!1)=>{const u={attrs:z(m,[["class",c]])},x=s.renderAttrs(u);if(!t.value)return`<${l} ${x}>${m.content}</${l}>`;const g=t.value.renderToString(m.content,h.globalConfig.katexConfig({throwOnError:!1,displayMode:i}));return`<${l} ${x} data-processed>${g}</${l}>`},f=(m,c,l,s,i)=>r(m[c],`${h.prefix}-katex-inline`,"span",i),d=(m,c,l,s,i)=>r(m[c],`${h.prefix}-katex-block`,"p",i,!0);e.inline.ruler.before("escape","math_inline",Se({delimiters:a||K.inline})),e.block.ruler.after("blockquote","math_block",Re({delimiters:o||K.block}),{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=f,e.renderer.rules.math_block=d},He=(e,t)=>{const a=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(o,r,f,d,m)=>{const c=o[r],l=c.content.trim();if(c.info==="mermaid"){if(c.attrSet("class",`${h.prefix}-mermaid`),c.attrSet("data-mermaid-theme",t.themeRef.value),c.map&&c.level===0){const i=c.map[1]-1,x=!!d.srcLines[i]?.trim()?.startsWith("```");c.attrSet("data-closed",`${x}`),c.attrSet("data-line",String(c.map[0]))}const s=U.get(l);return s?(c.attrSet("data-processed",""),c.attrSet("data-content",l),`<p ${m.renderAttrs(c)}>${s}</p>`):`<div ${m.renderAttrs(c)}>${e.utils.escapeHtml(l)}</div>`}return a(o,r,f,d,m)}},Z=(e,t,a)=>{const o=e.attrIndex(t),r=[t,a];o<0?e.attrPush(r):(e.attrs=e.attrs||[],e.attrs[o]=r)},Me=e=>e.type==="inline",Fe=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)=>Me(e[t])&&Fe(e[t-1])&&Le(e[t-2])&&Pe(e[t]),je=(e,t)=>{const a=e[t].level-1;for(let o=t-1;o>=0;o--)if(e[o].level===a)return o;return-1},Ne=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,a)=>{const o=new a("html_inline","",0);return o.content='<label class="task-list-item-label" for="'+t+'">'+e+"</label>",o.attrs=[["for",t]],o},Be=(e,t,a)=>{const o=new t("html_inline","",0),r=a.enabled?" ":' disabled="" ';return e.content.indexOf("[ ] ")===0?o.content='<input class="task-list-item-checkbox"'+r+'type="checkbox">':(e.content.indexOf("[x] ")===0||e.content.indexOf("[X] ")===0)&&(o.content='<input class="task-list-item-checkbox" checked=""'+r+'type="checkbox">'),o},Ve=(e,t,a)=>{if(e.children=e.children||[],e.children.unshift(Be(e,t,a)),e.children[1].content=e.children[1].content.slice(3),e.content=e.content.slice(3),a.label)if(a.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(Ne(t)),e.children.push(Oe(t))},Ge=(e,t={})=>{e.core.ruler.after("inline","github-task-lists",a=>{const o=a.tokens;for(let r=2;r<o.length;r++)_e(o,r)&&(Ve(o[r],a.Token,t),Z(o[r-2],"class","task-list-item"+(t.enabled?" enabled":" ")),Z(o[je(o,r-2)],"class","contains-task-list"))})},Ue=e=>{e.core.ruler.push("init-line-number",t=>(t.tokens.forEach(a=>{a.map&&(a.attrs||(a.attrs=[]),a.attrs.push(["data-line",a.map[0].toString()]))}),!0))},qe=(e,t)=>{const{editorConfig:a,markdownItConfig:o,markdownItPlugins:r,editorExtensions:f}=h.globalConfig,d=n.inject("editorId"),m=n.inject("language"),c=n.inject("usedLanguageText"),l=n.inject("showCodeRowNumber"),s=n.inject("theme"),i=n.inject("customIcon"),u=n.inject("rootRef"),x=n.inject("setting"),g=n.ref([]),v=Ce(e),b=xe(e),{reRenderRef:$,replaceMermaid:y}=Ee(e),{reRenderEcharts:w,replaceEcharts:T}=ye(e),C=ie({html:!0,breaks:!0,linkify:!0});o(C,{editorId:d});const k=[{type:"image",plugin:ae,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:$e,options:{}},{type:"taskList",plugin:Ge,options:{}},{type:"heading",plugin:ke,options:{mdHeadingId:e.mdHeadingId,headsRef:g}},{type:"code",plugin:Ie,options:{editorId:d,usedLanguageTextRef:c,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,customIconRef:i}},{type:"sub",plugin:le,options:{}},{type:"sup",plugin:se,options:{}}];e.noKatex||k.push({type:"katex",plugin:Ae,options:{katexRef:b}}),e.noMermaid||k.push({type:"mermaid",plugin:He,options:{themeRef:s}}),e.noEcharts||k.push({type:"echarts",plugin:Te,options:{themeRef:s}}),r(k,{editorId:d}).forEach(E=>{C.use(E.plugin,E.options)});const I=C.options.highlight;C.set({highlight:(E,R,G)=>{if(I){const O=I(E,R,G);if(O)return O}let F;!e.noHighlight&&v.value?v.value.getLanguage(R)?F=v.value.highlight(E,{language:R,ignoreIllegals:!0}).value:F=v.value.highlightAuto(E).value:F=C.utils.escapeHtml(E);const W=l?ce.generateCodeRowNumber(F.replace(/^\n+|\n+$/g,""),E.replace(/^\n+|\n+$/g,"")):`<span class="${h.prefix}-code-block">${F.replace(/^\n+|\n+$/g,"")}</span>`;return`<pre><code class="language-${R}" language=${R}>${W}</code></pre>`}}),Ue(C);const H=n.ref(`_article-key_${j.randomId()}`),M=n.ref(e.sanitize(C.render(e.modelValue,{srcLines:e.modelValue.split(`
62
+ `)})));let L=()=>{},P=()=>{};const D=()=>{const E=u.value?.querySelectorAll(`#${d} p.${h.prefix}-mermaid:not([data-closed=false])`);P(),P=S.copyMermaid(E,{customIcon:i.value}),f.mermaid?.enableZoom&&(L(),L=S.zoomMermaid(E,{customIcon:i.value}))},_=()=>{p.bus.emit(d,p.BUILD_FINISHED,M.value),e.onHtmlChanged(M.value),e.onGetCatalog(g.value),p.bus.emit(d,p.CATALOG_CHANGED,g.value),n.nextTick(()=>{y().then(D),T()})},N=()=>{g.value=[],M.value=e.sanitize(C.render(e.modelValue,{srcLines:e.modelValue.split(`
63
+ `)}))},B=n.computed(()=>(e.noKatex||!!b.value)&&(e.noHighlight||!!v.value));let V=-1;return n.watch([n.toRef(e,"modelValue"),B,$,m],()=>{V=window.setTimeout(()=>{N()},t?0:a.renderDelay)}),n.watch(()=>x.value.preview,()=>{x.value.preview&&n.nextTick(()=>{y().then(D),T(),p.bus.emit(d,p.CATALOG_CHANGED,g.value)})}),n.watch([M,w],()=>{_()}),n.onMounted(_),n.onMounted(()=>{p.bus.on(d,{name:p.PUSH_CATALOG,callback(){p.bus.emit(d,p.CATALOG_CHANGED,g.value)}}),p.bus.on(d,{name:p.RERENDER,callback:()=>{H.value=`_article-key_${j.randomId()}`,N()}})}),n.onBeforeUnmount(()=>{L(),P(),clearTimeout(V)}),{html:M,key:H}},We=(e,t)=>{const a=n.inject("editorId"),o=n.inject("setting"),{noImgZoomIn:r}=e,f=j.debounce(()=>{const d=document.querySelectorAll(`#${a}-preview img:not(.not-zoom):not(.medium-zoom-image)`);d.length!==0&&de(d,{background:"#00000073"})});n.onMounted(async()=>{!r&&o.value.preview&&await f()}),n.watch([t,()=>o.value.preview],async()=>{!r&&o.value.preview&&await f()})},J={checked:{regexp:/- \[x\]/,value:"- [ ]"},unChecked:{regexp:/- \[\s\]/,value:"- [x]"}},ze=(e,t)=>{const a=n.inject("editorId"),o=n.inject("rootRef");let r=()=>{};const f=()=>{if(!o.value)return!1;const d=o.value.querySelectorAll(".task-list-item.enabled"),m=c=>{c.preventDefault();const l=c.target.checked?"unChecked":"checked",s=c.target.parentElement?.dataset.line;if(!s)return;const i=Number(s),u=e.modelValue.split(`
64
+ `),x=u[Number(i)].replace(J[l].regexp,J[l].value);e.previewOnly?(u[Number(i)]=x,e.onChange(u.join(`
65
+ `))):p.bus.emit(a,p.TASK_STATE_CHANGED,i+1,x)};d.forEach(c=>{c.addEventListener("click",m)}),r=()=>{d.forEach(c=>{c.removeEventListener("click",m)})}};n.onBeforeUnmount(()=>{r()}),n.watch([t],()=>{r(),n.nextTick(f)},{immediate:!0})},Ke=(e,t,a)=>{const o=n.inject("setting"),r=()=>{n.nextTick(()=>{e.onRemount?.()})},f=d=>{d&&r()};n.watch([t,a],r),n.watch(()=>o.value.preview,f),n.watch(()=>o.value.htmlPreview,f),n.onMounted(r)},ee={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},previewComponent:{type:[Object,Function],default:void 0}},Ze={...ee,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}},X=e=>{const a=new DOMParser().parseFromString(e,"text/html");return Array.from(a.body.childNodes)},Je=(e,t)=>e.nodeType!==t.nodeType?!1:e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE?e.textContent===t.textContent:e.nodeType===Node.ELEMENT_NODE?e.outerHTML===t.outerHTML:e.isEqualNode?e.isEqualNode(t):!1,Xe=n.defineComponent({name:"UpdateOnDemand",props:{id:{type:String,required:!0},class:{type:[String,Array,Object],required:!0},html:{type:String,required:!0}},setup(e){const t=n.ref(),a=e.html,o=(r,f)=>{if(!t.value)return;const d=t.value,m=Array.from(d.childNodes),c=Math.min(r.length,f.length);let l=-1;for(let i=0;i<c;i++)if(!Je(r[i],f[i])){l=i;break}if(l===-1)if(f.length>r.length)l=r.length;else if(r.length>f.length)l=f.length;else return;const s=Math.min(l,m.length);for(let i=m.length-1;i>=s;i--)m[i].remove();for(let i=l;i<r.length;i++)d.appendChild(r[i].cloneNode(!0))};return n.watch(()=>e.html,(r,f)=>{const d=X(r),m=X(f||"");o(d,m)}),()=>n.createVNode("div",{id:e.id,class:e.class,innerHTML:a,ref:t},null)}}),te=n.defineComponent({name:"ContentPreview",props:ee,setup(e){const t=n.inject("editorId"),a=n.inject("setting"),o=n.inject("previewTheme"),r=n.inject("showCodeRowNumber"),{html:f,key:d}=qe(e,e.previewOnly);be(e,f,d),We(e,f),ze(e,f),Ke(e,f,d);const m=n.computed(()=>[`${h.prefix}-preview`,`${o?.value}-theme`,r&&`${h.prefix}-scrn`].filter(Boolean)),c=()=>{const l=`${t}-preview`;return e.previewComponent?n.h(e.previewComponent,{key:d.value,html:f.value,id:l,class:m.value}):n.createVNode(Xe,{key:d.value,html:f.value,id:l,class:m.value},null)};return()=>n.createVNode(n.Fragment,null,[a.value.preview&&(e.previewOnly?c():n.createVNode("div",{id:`${t}-preview-wrapper`,class:`${h.prefix}-preview-wrapper`,key:"content-preview-wrapper"},[c()])),a.value.htmlPreview&&n.createVNode("div",{id:`${t}-html-wrapper`,class:`${h.prefix}-preview-wrapper`,key:"html-preview-wrapper"},[n.createVNode("div",{class:`${h.prefix}-html`},[f.value])])])}}),Ye=({text:e})=>e,ne={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},previewComponent:{type:[Object,Function],default:void 0}},Qe={...ne,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:h.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:h.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}},oe=["onHtmlChanged","onGetCatalog","onChange","onRemount","update:modelValue"],et=[...oe,"onSave","onUploadImg","onError","onBlur","onFocus","onInput","onDrop","oninputBoxWidthChange"],tt=(e,t,a)=>{const{editorId:o}=a,r={rerender(){p.bus.emit(o,p.RERENDER)}};t.expose(r)},q=n.defineComponent({name:"MdPreview",props:ne,emits:oe,setup(e,t){const{noKatex:a,noMermaid:o,noHighlight:r}=e,f=n.ref(),d=Q(e);Y(e,{rootRef:f,editorId:d}),tt(e,t,{editorId:d}),n.onBeforeUnmount(()=>{p.bus.clear(d)});const m=i=>{e.onChange?.(i),t.emit("onChange",i),t.emit("update:modelValue",i)},c=i=>{e.onHtmlChanged?.(i),t.emit("onHtmlChanged",i)},l=i=>{e.onGetCatalog?.(i),t.emit("onGetCatalog",i)},s=()=>{e.onRemount?.(),t.emit("onRemount")};return()=>n.createVNode("div",{id:d,class:[h.prefix,e.class,e.theme==="dark"&&`${h.prefix}-dark`,`${h.prefix}-previewOnly`],style:e.style,ref:f},[n.createVNode(te,{modelValue:e.modelValue,onChange:m,onHtmlChanged:c,onGetCatalog:l,mdHeadingId:e.mdHeadingId,noMermaid:o,sanitize:e.sanitize,noKatex:a,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0,sanitizeMermaid:e.sanitizeMermaid,codeFoldable:e.codeFoldable,autoFoldThreshold:e.autoFoldThreshold,onRemount:s,noEcharts:e.noEcharts,previewComponent:e.previewComponent},null)])}});q.install=e=>(e.component(q.name,q),e);exports.CDN_IDS=A;exports.ContentPreview=te;exports.MdPreview=q;exports.contentProps=Ze;exports.editorEmits=et;exports.editorProps=Qe;exports.useCatalog=ge;exports.useConfig=he;exports.useEditorId=Q;exports.useErrorCatcher=pe;exports.useExpansion=me;exports.useExpose=ve;exports.useOnSave=ue;exports.useProvide=fe;
@@ -1,7 +1,7 @@
1
- import { useId as Fe, provide as T, computed as R, reactive as re, watch as k, onMounted as H, ref as G, inject as w, nextTick as U, shallowRef as ee, onBeforeUnmount as te, toRef as Re, defineComponent as ce, createVNode as j, Fragment as Ae, h as He } from "vue";
1
+ import { useId as Fe, provide as T, computed as A, reactive as re, watch as E, onMounted as H, ref as G, inject as w, nextTick as U, shallowRef as ee, onBeforeUnmount as te, toRef as Ae, defineComponent as ce, createVNode as j, Fragment as Re, h as He } from "vue";
2
2
  import { deepMerge as Me, deepClone as Pe, randomId as le, debounce as Le } from "@vavt/util";
3
3
  import { p as f, g as P, f as ue, s as me, b as Oe, a as _e } from "./config.mjs";
4
- import { b as y, U as Be, C as ke, B as X, O as Ee, E as Q, P as fe, F as he, f as pe, g as ge, H as ve, h as ye, R as ie, e as je, i as de, d as Ne, j as oe, k as De, T as Ve } from "./event-bus.mjs";
4
+ import { b as y, U as Be, C as Ee, B as X, O as ke, E as Q, P as fe, F as he, f as pe, g as ge, H as ve, h as ye, R as ie, e as je, i as de, d as Ne, j as oe, k as De, T as Ve } from "./event-bus.mjs";
5
5
  import { a as O, u as Ge, S as Ue, c as ze, z as We } from "./dom.mjs";
6
6
  import qe from "@vavt/copy2clipboard";
7
7
  import Ke from "markdown-it";
@@ -9,8 +9,7 @@ import Ze from "markdown-it-image-figures";
9
9
  import Je from "markdown-it-sub";
10
10
  import Xe from "markdown-it-sup";
11
11
  import { g as Ye } from "./index5.mjs";
12
- import { LRUCache as Qe } from "lru-cache";
13
- import et from "medium-zoom";
12
+ import Qe from "medium-zoom";
14
13
  const M = {
15
14
  hljs: `${f}-hljs`,
16
15
  hlcss: `${f}-hlCss`,
@@ -24,14 +23,14 @@ const M = {
24
23
  katexjs: `${f}-katex`,
25
24
  katexcss: `${f}-katexCss`,
26
25
  echarts: `${f}-echarts`
27
- }, Jt = (e, t, r) => {
26
+ }, Zt = (e, t, r) => {
28
27
  const { editorId: n } = r, o = re({
29
28
  // 是否已编译成html
30
29
  buildFinished: !1,
31
30
  // 存储当前最新的html
32
31
  html: ""
33
32
  });
34
- k(
33
+ E(
35
34
  () => e.modelValue,
36
35
  () => {
37
36
  o.buildFinished = !1;
@@ -43,7 +42,7 @@ const M = {
43
42
  o.buildFinished = !0, o.html = u;
44
43
  }
45
44
  }), y.on(n, {
46
- name: Ee,
45
+ name: ke,
47
46
  callback() {
48
47
  const u = new Promise((c) => {
49
48
  if (o.buildFinished)
@@ -70,13 +69,13 @@ const M = {
70
69
  const o = P.editorExtensions.highlight, u = P.editorExtensionsAttrs.highlight;
71
70
  T("editorId", t), T("rootRef", r), T(
72
71
  "theme",
73
- R(() => e.theme)
72
+ A(() => e.theme)
74
73
  ), T(
75
74
  "language",
76
- R(() => e.language)
75
+ A(() => e.language)
77
76
  ), T(
78
77
  "highlight",
79
- R(() => {
78
+ A(() => {
80
79
  const { js: m } = o, s = {
81
80
  ...ue,
82
81
  ...o.css
@@ -93,7 +92,7 @@ const M = {
93
92
  };
94
93
  })
95
94
  ), T("showCodeRowNumber", e.showCodeRowNumber);
96
- const c = R(() => {
95
+ const c = A(() => {
97
96
  const m = {
98
97
  ...me,
99
98
  ...P.editorConfig.languageUserDefined
@@ -105,13 +104,13 @@ const M = {
105
104
  });
106
105
  return T("usedLanguageText", c), T(
107
106
  "previewTheme",
108
- R(() => e.previewTheme)
107
+ A(() => e.previewTheme)
109
108
  ), T(
110
109
  "customIcon",
111
- R(() => e.customIcon)
110
+ A(() => e.customIcon)
112
111
  ), T(
113
112
  "setting",
114
- R(() => n ? {
113
+ A(() => n ? {
115
114
  // setting是reactive,不转化是可以直接赋值的
116
115
  ...n
117
116
  } : {
@@ -122,25 +121,25 @@ const M = {
122
121
  fullscreen: !1
123
122
  })
124
123
  ), { editorId: t };
125
- }, Xt = (e, t) => (T("tabWidth", e.tabWidth), T(
124
+ }, Jt = (e, t) => (T("tabWidth", e.tabWidth), T(
126
125
  "disabled",
127
- R(() => e.disabled)
126
+ A(() => e.disabled)
128
127
  ), T(
129
128
  "showToolbarName",
130
- R(() => e.showToolbarName)
129
+ A(() => e.showToolbarName)
131
130
  ), T("noUploadImg", e.noUploadImg), T(
132
131
  "tableShape",
133
- R(() => e.tableShape)
132
+ A(() => e.tableShape)
134
133
  ), T("noPrettier", e.noPrettier), T(
135
134
  "codeTheme",
136
- R(() => e.codeTheme)
135
+ A(() => e.codeTheme)
137
136
  ), T("updateSetting", t.updateSetting), T(
138
137
  "catalogVisible",
139
- R(() => t.catalogVisible.value)
138
+ A(() => t.catalogVisible.value)
140
139
  ), T("defToolbars", t.defToolbars), T(
141
140
  "floatingToolbars",
142
- R(() => e.floatingToolbars)
143
- ), Te(e, t)), Yt = (e) => {
141
+ A(() => e.floatingToolbars)
142
+ ), Te(e, t)), Xt = (e) => {
144
143
  const { noPrettier: t, noUploadImg: r } = e, { editorExtensions: n, editorExtensionsAttrs: o } = P, u = t || n.prettier.prettierInstance, c = t || n.prettier.parserMarkdownInstance, m = r || n.cropper.instance;
145
144
  H(() => {
146
145
  if (!m) {
@@ -173,7 +172,7 @@ const M = {
173
172
  });
174
173
  }
175
174
  });
176
- }, Qt = (e, t, r) => {
175
+ }, Yt = (e, t, r) => {
177
176
  const { editorId: n } = r;
178
177
  H(() => {
179
178
  y.on(n, {
@@ -183,7 +182,7 @@ const M = {
183
182
  }
184
183
  });
185
184
  });
186
- }, en = (e, t, r) => {
185
+ }, Qt = (e, t, r) => {
187
186
  const { editorId: n } = r, o = re({
188
187
  pageFullscreen: e.pageFullscreen,
189
188
  fullscreen: !1,
@@ -212,7 +211,7 @@ const M = {
212
211
  const s = () => {
213
212
  o.pageFullscreen || o.fullscreen ? document.body.style.overflow = "hidden" : document.body.style.overflow = m;
214
213
  };
215
- return k(() => [o.pageFullscreen, o.fullscreen], s), H(() => {
214
+ return E(() => [o.pageFullscreen, o.fullscreen], s), H(() => {
216
215
  y.on(n, {
217
216
  name: Be,
218
217
  callback(l, i) {
@@ -226,44 +225,44 @@ const M = {
226
225
  }
227
226
  }), m = document.body.style.overflow, s();
228
227
  }), [o, c];
229
- }, tn = (e, t) => {
228
+ }, en = (e, t) => {
230
229
  const { editorId: r } = t, n = G(!1);
231
230
  return H(() => {
232
231
  y.on(r, {
233
- name: ke,
232
+ name: Ee,
234
233
  callback: (o) => {
235
234
  o === void 0 ? n.value = !n.value : n.value = o;
236
235
  }
237
236
  });
238
237
  }), n;
239
- }, nn = (e, t, r) => {
238
+ }, tn = (e, t, r) => {
240
239
  const { editorId: n, catalogVisible: o, setting: u, updateSetting: c, codeRef: m } = r;
241
- k(
240
+ E(
242
241
  () => u.pageFullscreen,
243
242
  (l) => {
244
243
  y.emit(n, fe, l);
245
244
  }
246
- ), k(
245
+ ), E(
247
246
  () => u.fullscreen,
248
247
  (l) => {
249
248
  y.emit(n, he, l);
250
249
  }
251
- ), k(
250
+ ), E(
252
251
  () => u.preview,
253
252
  (l) => {
254
253
  y.emit(n, pe, l);
255
254
  }
256
- ), k(
255
+ ), E(
257
256
  () => u.previewOnly,
258
257
  (l) => {
259
258
  y.emit(n, ge, l);
260
259
  }
261
- ), k(
260
+ ), E(
262
261
  () => u.htmlPreview,
263
262
  (l) => {
264
263
  y.emit(n, ve, l);
265
264
  }
266
- ), k(o, (l) => {
265
+ ), E(o, (l) => {
267
266
  y.emit(n, ye, l);
268
267
  });
269
268
  const s = {
@@ -341,10 +340,10 @@ const M = {
341
340
  c("htmlPreview", l);
342
341
  },
343
342
  toggleCatalog(l) {
344
- y.emit(n, ke, l);
343
+ y.emit(n, Ee, l);
345
344
  },
346
345
  triggerSave() {
347
- y.emit(n, Ee);
346
+ y.emit(n, ke);
348
347
  },
349
348
  insert(l) {
350
349
  y.emit(n, ie, "universal", { generate: l });
@@ -372,10 +371,10 @@ const M = {
372
371
  }
373
372
  };
374
373
  t.expose(s);
375
- }, tt = (e) => {
374
+ }, et = (e) => {
376
375
  const t = Fe();
377
376
  return e.id || e.editorId || `${f}-${t}`;
378
- }, nt = (e, t, r) => {
377
+ }, tt = (e, t, r) => {
379
378
  const n = w("editorId"), o = w("rootRef"), u = w("usedLanguageText"), c = w("setting"), m = () => {
380
379
  o.value.querySelectorAll(`#${n} .${f}-preview .${f}-code`).forEach((i) => {
381
380
  let a = -1;
@@ -384,8 +383,8 @@ const M = {
384
383
  );
385
384
  d && (d.onclick = ($) => {
386
385
  $.preventDefault(), clearTimeout(a);
387
- const p = (i.querySelector("input:checked + pre code") || i.querySelector("pre code")).textContent, { text: g, successTips: I, failTips: v } = u.value.copyCode;
388
- let C = I;
386
+ const p = (i.querySelector("input:checked + pre code") || i.querySelector("pre code")).textContent, { text: g, successTips: x, failTips: v } = u.value.copyCode;
387
+ let C = x;
389
388
  qe(e.formatCopiedText(p || "")).catch(() => {
390
389
  C = v;
391
390
  }).finally(() => {
@@ -400,14 +399,14 @@ const M = {
400
399
  }, l = (i) => {
401
400
  i && U(m);
402
401
  };
403
- k([t, r], s), k(() => c.value.preview, l), k(() => c.value.htmlPreview, l), H(m);
404
- }, ot = (e) => {
402
+ E([t, r], s), E(() => c.value.preview, l), E(() => c.value.htmlPreview, l), H(m);
403
+ }, nt = (e) => {
405
404
  const t = w("editorId"), r = w("theme"), n = w("rootRef"), { editorExtensions: o, editorExtensionsAttrs: u } = P;
406
405
  let c = o.echarts.instance;
407
406
  const m = ee(-1), s = () => {
408
407
  !e.noEcharts && c && (m.value = m.value + 1);
409
408
  };
410
- k(
409
+ E(
411
410
  () => r.value,
412
411
  () => {
413
412
  s();
@@ -439,15 +438,15 @@ const M = {
439
438
  }), i = [], a = []);
440
439
  return;
441
440
  }
442
- const p = [], g = [], I = [];
441
+ const p = [], g = [], x = [];
443
442
  l.forEach((v, C) => {
444
- const x = i[C], b = a[C];
443
+ const S = i[C], b = a[C];
445
444
  if (h || !v || !v.isConnected || (n?.value ? !n.value.contains(v) : !1)) {
446
- x?.dispose?.(), b?.disconnect?.();
445
+ S?.dispose?.(), b?.disconnect?.();
447
446
  return;
448
447
  }
449
- p.push(v), x && g.push(x), b && I.push(b);
450
- }), l = p, i = g, a = I;
448
+ p.push(v), S && g.push(S), b && x.push(b);
449
+ }), l = p, i = g, a = x;
451
450
  }, $ = () => {
452
451
  d(), !e.noEcharts && c && Array.from(
453
452
  n.value.querySelectorAll(
@@ -457,10 +456,10 @@ const M = {
457
456
  if (p.dataset.closed === "false")
458
457
  return !1;
459
458
  try {
460
- const g = new Function(`return ${p.innerText}`)(), I = c.init(p, r.value);
461
- I.setOption(g), p.setAttribute("data-processed", ""), l.push(p), i.push(I);
459
+ const g = new Function(`return ${p.innerText}`)(), x = c.init(p, r.value);
460
+ x.setOption(g), p.setAttribute("data-processed", ""), l.push(p), i.push(x);
462
461
  const v = new ResizeObserver(() => {
463
- I.resize();
462
+ x.resize();
464
463
  });
465
464
  v.observe(p), a.push(v);
466
465
  } catch (g) {
@@ -475,7 +474,7 @@ const M = {
475
474
  return te(() => {
476
475
  d(!0);
477
476
  }), { reRenderEcharts: m, replaceEcharts: $ };
478
- }, at = (e) => {
477
+ }, ot = (e) => {
479
478
  const t = w("highlight"), r = ee(P.editorExtensions.highlight.instance);
480
479
  return H(() => {
481
480
  e.noHighlight || r.value || (O("link", {
@@ -493,7 +492,7 @@ const M = {
493
492
  },
494
493
  "hljs"
495
494
  ));
496
- }), k(
495
+ }), E(
497
496
  () => t.value.css,
498
497
  () => {
499
498
  e.noHighlight || P.editorExtensions.highlight.instance || Ge("link", {
@@ -503,7 +502,7 @@ const M = {
503
502
  });
504
503
  }
505
504
  ), r;
506
- }, rt = (e) => {
505
+ }, at = (e) => {
507
506
  const t = ee(P.editorExtensions.katex.instance);
508
507
  return H(() => {
509
508
  if (e.noKatex || t.value)
@@ -527,7 +526,46 @@ const M = {
527
526
  id: M.katexcss
528
527
  });
529
528
  }), t;
530
- }, Y = new Qe({
529
+ };
530
+ class rt {
531
+ constructor(t) {
532
+ this.options = t;
533
+ }
534
+ cache = /* @__PURE__ */ new Map();
535
+ isExpired(t) {
536
+ return t.expiresAt <= Date.now();
537
+ }
538
+ deleteExpired(t, r) {
539
+ const n = r ?? this.cache.get(t);
540
+ return !n || !this.isExpired(n) ? !1 : (this.cache.delete(t), !0);
541
+ }
542
+ trim() {
543
+ for (const [t, r] of this.cache)
544
+ if (!this.deleteExpired(t, r))
545
+ break;
546
+ for (; this.cache.size > this.options.max; ) {
547
+ const t = this.cache.keys().next().value;
548
+ if (t === void 0)
549
+ break;
550
+ this.cache.delete(t);
551
+ }
552
+ }
553
+ get(t) {
554
+ const r = this.cache.get(t);
555
+ if (!(!r || this.deleteExpired(t, r)))
556
+ return this.cache.delete(t), this.cache.set(t, r), r.value;
557
+ }
558
+ set(t, r) {
559
+ this.cache.delete(t), this.cache.set(t, {
560
+ value: r,
561
+ expiresAt: Date.now() + this.options.ttl
562
+ }), this.trim();
563
+ }
564
+ clear() {
565
+ this.cache.clear();
566
+ }
567
+ }
568
+ const Y = new rt({
531
569
  max: 1e3,
532
570
  // 缓存10分钟
533
571
  ttl: 6e5
@@ -558,7 +596,7 @@ const M = {
558
596
  m.initialize(c(a)), s.value = s.value + 1;
559
597
  }
560
598
  };
561
- return k(
599
+ return E(
562
600
  () => r.value,
563
601
  () => {
564
602
  Y.clear(), l();
@@ -608,19 +646,19 @@ const M = {
608
646
  if (v.dataset.closed === "false")
609
647
  return !1;
610
648
  const C = v.innerText;
611
- let x = Y.get(C);
612
- if (!x) {
649
+ let S = Y.get(C);
650
+ if (!S) {
613
651
  const b = le();
614
652
  let F = { svg: "" };
615
653
  try {
616
- F = await m.render(b, C, d), x = await e.sanitizeMermaid(F.svg);
617
- const S = document.createElement("p");
618
- S.className = `${f}-mermaid`, S.setAttribute("data-processed", ""), S.setAttribute("data-content", C), S.innerHTML = x, S.children[0]?.removeAttribute("height"), Y.set(C, S.innerHTML), v.dataset.line !== void 0 && (S.dataset.line = v.dataset.line), v.replaceWith(S);
619
- } catch (S) {
654
+ F = await m.render(b, C, d), S = await e.sanitizeMermaid(F.svg);
655
+ const I = document.createElement("p");
656
+ I.className = `${f}-mermaid`, I.setAttribute("data-processed", ""), I.setAttribute("data-content", C), I.innerHTML = S, I.children[0]?.removeAttribute("height"), Y.set(C, I.innerHTML), v.dataset.line !== void 0 && (I.dataset.line = v.dataset.line), v.replaceWith(I);
657
+ } catch (I) {
620
658
  y.emit(t, Q, {
621
659
  name: "mermaid",
622
- message: S.message,
623
- error: S
660
+ message: I.message,
661
+ error: I
624
662
  });
625
663
  }
626
664
  --p === 0 && d.remove();
@@ -647,13 +685,13 @@ const M = {
647
685
  "code",
648
686
  "admonition",
649
687
  (i, a, d, $) => {
650
- let h, p, g, I = !1, v = i.bMarks[a] + i.tShift[a], C = i.eMarks[a];
688
+ let h, p, g, x = !1, v = i.bMarks[a] + i.tShift[a], C = i.eMarks[a];
651
689
  if (o !== i.src.charCodeAt(v))
652
690
  return !1;
653
691
  for (h = v + 1; h <= C && n[(h - v) % u] === i.src[h]; h++)
654
692
  ;
655
- const x = Math.floor((h - v) / u);
656
- if (x !== r)
693
+ const S = Math.floor((h - v) / u);
694
+ if (S !== r)
657
695
  return !1;
658
696
  h -= (h - v) % u;
659
697
  const b = i.src.slice(v, h), F = i.src.slice(h, C);
@@ -663,13 +701,13 @@ const M = {
663
701
  if (o === i.src.charCodeAt(v) && !(i.sCount[p] - i.blkIndent >= 4)) {
664
702
  for (h = v + 1; h <= C && n[(h - v) % u] === i.src[h]; h++)
665
703
  ;
666
- if (!(Math.floor((h - v) / u) < x) && (h -= (h - v) % u, h = i.skipSpaces(h), !(h < C))) {
667
- I = !0;
704
+ if (!(Math.floor((h - v) / u) < S) && (h -= (h - v) % u, h = i.skipSpaces(h), !(h < C))) {
705
+ x = !0;
668
706
  break;
669
707
  }
670
708
  }
671
- const S = i.parentType, L = i.lineMax;
672
- return i.parentType = "root", i.lineMax = p, g = i.push("admonition_open", "div", 1), g.markup = b, g.block = !0, g.info = c, g.map = [a, p], m && (g = i.push("admonition_title_open", "p", 1), g.markup = b + " " + c, g.map = [a, p], g = i.push("inline", "", 0), g.content = m, g.map = [a, i.line - 1], g.children = [], g = i.push("admonition_title_close", "p", -1), g.markup = b + " " + c), i.md.block.tokenize(i, a + 1, p), g = i.push("admonition_close", "div", -1), g.markup = i.src.slice(v, h), g.block = !0, i.parentType = S, i.lineMax = L, i.line = p + (I ? 1 : 0), !0;
709
+ const I = i.parentType, L = i.lineMax;
710
+ return i.parentType = "root", i.lineMax = p, g = i.push("admonition_open", "div", 1), g.markup = b, g.block = !0, g.info = c, g.map = [a, p], m && (g = i.push("admonition_title_open", "p", 1), g.markup = b + " " + c, g.map = [a, p], g = i.push("inline", "", 0), g.content = m, g.map = [a, i.line - 1], g.children = [], g = i.push("admonition_title_close", "p", -1), g.markup = b + " " + c), i.md.block.tokenize(i, a + 1, p), g = i.push("admonition_close", "div", -1), g.markup = i.src.slice(v, h), g.block = !0, i.parentType = I, i.lineMax = L, i.line = p + (x ? 1 : 0), !0;
673
711
  },
674
712
  {
675
713
  alt: ["paragraph", "reference", "blockquote", "list"]
@@ -695,68 +733,68 @@ const M = {
695
733
  }, i = (a, d, $, h, p) => {
696
734
  if (a[d].hidden)
697
735
  return "";
698
- const g = t.usedLanguageTextRef.value?.copyCode.text, I = t.customIconRef.value.copy || g, v = !!t.customIconRef.value.copy, C = `<span class="${f}-collapse-tips">${Ue("collapse-tips", t.customIconRef.value)}</span>`, [x] = m(a[d]);
699
- if (x === null) {
700
- const { open: E, tagContainer: A, tagHeader: J } = l(a[d]), B = [["class", `${f}-code`]];
701
- E && B.push(["open", ""]);
736
+ const g = t.usedLanguageTextRef.value?.copyCode.text, x = t.customIconRef.value.copy || g, v = !!t.customIconRef.value.copy, C = `<span class="${f}-collapse-tips">${Ue("collapse-tips", t.customIconRef.value)}</span>`, [S] = m(a[d]);
737
+ if (S === null) {
738
+ const { open: k, tagContainer: R, tagHeader: J } = l(a[d]), B = [["class", `${f}-code`]];
739
+ k && B.push(["open", ""]);
702
740
  const ne = {
703
741
  attrs: se(a[d], B)
704
742
  };
705
743
  a[d].info = a[d].info.replace(u, "");
706
744
  const W = r(a, d, $, h, p);
707
745
  return `
708
- <${A} ${p.renderAttrs(ne)}>
746
+ <${R} ${p.renderAttrs(ne)}>
709
747
  <${J} class="${f}-code-head">
710
748
  <div class="${f}-code-flag"><span></span><span></span><span></span></div>
711
749
  <div class="${f}-code-action">
712
750
  <span class="${f}-code-lang">${e.utils.escapeHtml(a[d].info.trim())}</span>
713
- <span class="${f}-copy-button" data-tips="${g}"${v ? " data-is-icon=true" : ""}>${I}</span>
751
+ <span class="${f}-copy-button" data-tips="${g}"${v ? " data-is-icon=true" : ""}>${x}</span>
714
752
  ${t.extraTools instanceof Function ? t.extraTools({ lang: a[d].info.trim() }) : t.extraTools || ""}
715
- ${A === "details" ? C : ""}
753
+ ${R === "details" ? C : ""}
716
754
  </div>
717
755
  </${J}>
718
756
  ${W}
719
- </${A}>
757
+ </${R}>
720
758
  `;
721
759
  }
722
- let b, F, S, L, _ = "", N = "", D = "";
760
+ let b, F, I, L, _ = "", N = "", D = "";
723
761
  const { open: q, tagContainer: V, tagHeader: z } = l(a[d]), K = [["class", `${f}-code`]];
724
762
  q && K.push(["open", ""]);
725
763
  const Z = {
726
764
  attrs: se(a[d], K)
727
765
  };
728
- for (let E = d; E < a.length && (b = a[E], [F, S] = m(b), F === x); E++) {
766
+ for (let k = d; k < a.length && (b = a[k], [F, I] = m(b), F === S); k++) {
729
767
  b.info = b.info.replace(o, "").replace(u, ""), b.hidden = !0;
730
- const A = `${f}-codetab-${t.editorId}-${d}-${E - d}`;
731
- L = E - d > 0 ? "" : "checked", _ += `
768
+ const R = `${f}-codetab-${t.editorId}-${d}-${k - d}`;
769
+ L = k - d > 0 ? "" : "checked", _ += `
732
770
  <li>
733
771
  <input
734
772
  type="radio"
735
- id="label-${f}-codetab-label-1-${t.editorId}-${d}-${E - d}"
773
+ id="label-${f}-codetab-label-1-${t.editorId}-${d}-${k - d}"
736
774
  name="${f}-codetab-label-${t.editorId}-${d}"
737
- class="${A}"
775
+ class="${R}"
738
776
  ${L}
739
777
  >
740
778
  <label
741
- for="label-${f}-codetab-label-1-${t.editorId}-${d}-${E - d}"
742
- onclick="this.getRootNode().querySelectorAll('.${A}').forEach(e => e.click())"
779
+ for="label-${f}-codetab-label-1-${t.editorId}-${d}-${k - d}"
780
+ onclick="this.getRootNode().querySelectorAll('.${R}').forEach(e => e.click())"
743
781
  >
744
- ${e.utils.escapeHtml(S || s(b))}
782
+ ${e.utils.escapeHtml(I || s(b))}
745
783
  </label>
746
784
  </li>`, N += `
747
785
  <div role="tabpanel">
748
786
  <input
749
787
  type="radio"
750
788
  name="${f}-codetab-pre-${t.editorId}-${d}"
751
- class="${A}"
789
+ class="${R}"
752
790
  ${L}
753
791
  role="presentation">
754
- ${r(a, E, $, h, p)}
792
+ ${r(a, k, $, h, p)}
755
793
  </div>`, D += `
756
794
  <input
757
795
  type="radio"
758
796
  name="${f}-codetab-lang-${t.editorId}-${d}"
759
- class="${A}"
797
+ class="${R}"
760
798
  ${L}
761
799
  role="presentation">
762
800
  <span class=${f}-code-lang role="note">${e.utils.escapeHtml(s(b))}</span>`;
@@ -769,7 +807,7 @@ const M = {
769
807
  </div>
770
808
  <div class="${f}-code-action">
771
809
  <span class="${f}-codetab-lang">${D}</span>
772
- <span class="${f}-copy-button" data-tips="${g}"${v ? " data-is-icon=true" : ""}>${I}</span>
810
+ <span class="${f}-copy-button" data-tips="${g}"${v ? " data-is-icon=true" : ""}>${x}</span>
773
811
  ${t.extraTools instanceof Function ? t.extraTools({ lang: a[d].info.trim() }) : t.extraTools || ""}
774
812
  ${V === "details" ? C : ""}
775
813
  </div>
@@ -870,21 +908,21 @@ const M = {
870
908
  const b = d.slice(0, -l.close.length);
871
909
  return s(b, r + 1, l.open);
872
910
  }
873
- let g = r + 1, I = !1, v = "";
911
+ let g = r + 1, x = !1, v = "";
874
912
  for (; g < n; g++) {
875
913
  const b = t.bMarks[g] + t.tShift[g], F = t.eMarks[g];
876
914
  if (b < F && t.tShift[g] < t.blkIndent)
877
915
  break;
878
916
  if (t.src.slice(b, F).trim().endsWith(l.close)) {
879
917
  const L = t.src.slice(0, F).lastIndexOf(l.close);
880
- v = t.src.slice(b, L), I = !0;
918
+ v = t.src.slice(b, L), x = !0;
881
919
  break;
882
920
  }
883
921
  }
884
- if (!I)
922
+ if (!x)
885
923
  continue;
886
- const x = t.getLines(r + 1, g, t.tShift[r], !0) + (v.trim() ? v : "");
887
- return s(x, g + 1, l.open);
924
+ const S = t.getLines(r + 1, g, t.tShift[r], !0) + (v.trim() ? v : "");
925
+ return s(S, g + 1, l.open);
888
926
  }
889
927
  return !1;
890
928
  }, ft = (e, { katexRef: t, inlineDelimiters: r, blockDelimiters: n }) => {
@@ -948,21 +986,21 @@ const M = {
948
986
  }, Ct = (e) => {
949
987
  const t = new e("html_inline", "", 0);
950
988
  return t.content = "</label>", t;
951
- }, kt = (e, t, r) => {
989
+ }, Et = (e, t, r) => {
952
990
  const n = new r("html_inline", "", 0);
953
991
  return n.content = '<label class="task-list-item-label" for="' + t + '">' + e + "</label>", n.attrs = [["for", t]], n;
954
- }, Et = (e, t, r) => {
992
+ }, kt = (e, t, r) => {
955
993
  const n = new t("html_inline", "", 0), o = r.enabled ? " " : ' disabled="" ';
956
994
  return e.content.indexOf("[ ] ") === 0 ? n.content = '<input class="task-list-item-checkbox"' + o + 'type="checkbox">' : (e.content.indexOf("[x] ") === 0 || e.content.indexOf("[X] ") === 0) && (n.content = '<input class="task-list-item-checkbox" checked=""' + o + 'type="checkbox">'), n;
957
995
  }, Tt = (e, t, r) => {
958
- if (e.children = e.children || [], e.children.unshift(Et(e, t, r)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), r.label)
996
+ if (e.children = e.children || [], e.children.unshift(kt(e, t, r)), e.children[1].content = e.children[1].content.slice(3), e.content = e.content.slice(3), r.label)
959
997
  if (r.labelAfter) {
960
998
  e.children.pop();
961
999
  const n = "task-item-" + Math.ceil(Math.random() * (1e4 * 1e3) - 1e3);
962
- e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + n + '">', e.children.push(kt(e.content, n, t));
1000
+ e.children[0].content = e.children[0].content.slice(0, -1) + ' id="' + n + '">', e.children.push(Et(e.content, n, t));
963
1001
  } else
964
1002
  e.children.unshift(wt(t)), e.children.push(Ct(t));
965
- }, It = (e, t = {}) => {
1003
+ }, xt = (e, t = {}) => {
966
1004
  e.core.ruler.after("inline", "github-task-lists", (r) => {
967
1005
  const n = r.tokens;
968
1006
  for (let o = 2; o < n.length; o++)
@@ -972,14 +1010,14 @@ const M = {
972
1010
  "task-list-item" + (t.enabled ? " enabled" : " ")
973
1011
  ), $e(n[$t(n, o - 2)], "class", "contains-task-list"));
974
1012
  });
975
- }, St = (e) => {
1013
+ }, It = (e) => {
976
1014
  e.core.ruler.push("init-line-number", (t) => (t.tokens.forEach((r) => {
977
1015
  r.map && (r.attrs || (r.attrs = []), r.attrs.push(["data-line", r.map[0].toString()]));
978
1016
  }), !0));
979
- }, xt = (e, t) => {
1017
+ }, St = (e, t) => {
980
1018
  const { editorConfig: r, markdownItConfig: n, markdownItPlugins: o, editorExtensions: u } = P, c = w("editorId"), m = w("language"), s = w(
981
1019
  "usedLanguageText"
982
- ), l = w("showCodeRowNumber"), i = w("theme"), a = w("customIcon"), d = w("rootRef"), $ = w("setting"), h = G([]), p = at(e), g = rt(e), { reRenderRef: I, replaceMermaid: v } = lt(e), { reRenderEcharts: C, replaceEcharts: x } = ot(e), b = Ke({
1020
+ ), l = w("showCodeRowNumber"), i = w("theme"), a = w("customIcon"), d = w("rootRef"), $ = w("setting"), h = G([]), p = ot(e), g = at(e), { reRenderRef: x, replaceMermaid: v } = lt(e), { reRenderEcharts: C, replaceEcharts: S } = nt(e), b = Ke({
983
1021
  html: !0,
984
1022
  breaks: !0,
985
1023
  linkify: !0
@@ -1000,7 +1038,7 @@ const M = {
1000
1038
  },
1001
1039
  {
1002
1040
  type: "taskList",
1003
- plugin: It,
1041
+ plugin: xt,
1004
1042
  options: {}
1005
1043
  },
1006
1044
  {
@@ -1045,29 +1083,29 @@ const M = {
1045
1083
  options: { themeRef: i }
1046
1084
  }), o(F, {
1047
1085
  editorId: c
1048
- }).forEach((E) => {
1049
- b.use(E.plugin, E.options);
1086
+ }).forEach((k) => {
1087
+ b.use(k.plugin, k.options);
1050
1088
  });
1051
- const S = b.options.highlight;
1089
+ const I = b.options.highlight;
1052
1090
  b.set({
1053
- highlight: (E, A, J) => {
1054
- if (S) {
1055
- const W = S(E, A, J);
1091
+ highlight: (k, R, J) => {
1092
+ if (I) {
1093
+ const W = I(k, R, J);
1056
1094
  if (W)
1057
1095
  return W;
1058
1096
  }
1059
1097
  let B;
1060
- !e.noHighlight && p.value ? p.value.getLanguage(A) ? B = p.value.highlight(E, {
1061
- language: A,
1098
+ !e.noHighlight && p.value ? p.value.getLanguage(R) ? B = p.value.highlight(k, {
1099
+ language: R,
1062
1100
  ignoreIllegals: !0
1063
- }).value : B = p.value.highlightAuto(E).value : B = b.utils.escapeHtml(E);
1101
+ }).value : B = p.value.highlightAuto(k).value : B = b.utils.escapeHtml(k);
1064
1102
  const ne = l ? Ye(
1065
1103
  B.replace(/^\n+|\n+$/g, ""),
1066
- E.replace(/^\n+|\n+$/g, "")
1104
+ k.replace(/^\n+|\n+$/g, "")
1067
1105
  ) : `<span class="${f}-code-block">${B.replace(/^\n+|\n+$/g, "")}</span>`;
1068
- return `<pre><code class="language-${A}" language=${A}>${ne}</code></pre>`;
1106
+ return `<pre><code class="language-${R}" language=${R}>${ne}</code></pre>`;
1069
1107
  }
1070
- }), St(b);
1108
+ }), It(b);
1071
1109
  const L = G(`_article-key_${le()}`), _ = G(
1072
1110
  e.sanitize(
1073
1111
  b.render(e.modelValue, {
@@ -1080,17 +1118,17 @@ const M = {
1080
1118
  }, D = () => {
1081
1119
  };
1082
1120
  const q = () => {
1083
- const E = d.value?.querySelectorAll(
1121
+ const k = d.value?.querySelectorAll(
1084
1122
  `#${c} p.${f}-mermaid:not([data-closed=false])`
1085
1123
  );
1086
- D(), D = ze(E, {
1124
+ D(), D = ze(k, {
1087
1125
  customIcon: a.value
1088
- }), u.mermaid?.enableZoom && (N(), N = We(E, {
1126
+ }), u.mermaid?.enableZoom && (N(), N = We(k, {
1089
1127
  customIcon: a.value
1090
1128
  }));
1091
1129
  }, V = () => {
1092
1130
  y.emit(c, X, _.value), e.onHtmlChanged(_.value), e.onGetCatalog(h.value), y.emit(c, oe, h.value), U(() => {
1093
- v().then(q), x();
1131
+ v().then(q), S();
1094
1132
  });
1095
1133
  }, z = () => {
1096
1134
  h.value = [], _.value = e.sanitize(
@@ -1099,23 +1137,23 @@ const M = {
1099
1137
  `)
1100
1138
  })
1101
1139
  );
1102
- }, K = R(() => (e.noKatex || !!g.value) && (e.noHighlight || !!p.value));
1140
+ }, K = A(() => (e.noKatex || !!g.value) && (e.noHighlight || !!p.value));
1103
1141
  let Z = -1;
1104
- return k([Re(e, "modelValue"), K, I, m], () => {
1142
+ return E([Ae(e, "modelValue"), K, x, m], () => {
1105
1143
  Z = window.setTimeout(
1106
1144
  () => {
1107
1145
  z();
1108
1146
  },
1109
1147
  t ? 0 : r.renderDelay
1110
1148
  );
1111
- }), k(
1149
+ }), E(
1112
1150
  () => $.value.preview,
1113
1151
  () => {
1114
1152
  $.value.preview && U(() => {
1115
- v().then(q), x(), y.emit(c, oe, h.value);
1153
+ v().then(q), S(), y.emit(c, oe, h.value);
1116
1154
  });
1117
1155
  }
1118
- ), k([_, C], () => {
1156
+ ), E([_, C], () => {
1119
1157
  V();
1120
1158
  }), H(V), H(() => {
1121
1159
  y.on(c, {
@@ -1137,13 +1175,13 @@ const M = {
1137
1175
  const c = document.querySelectorAll(
1138
1176
  `#${r}-preview img:not(.not-zoom):not(.medium-zoom-image)`
1139
1177
  );
1140
- c.length !== 0 && et(c, {
1178
+ c.length !== 0 && Qe(c, {
1141
1179
  background: "#00000073"
1142
1180
  });
1143
1181
  });
1144
1182
  H(async () => {
1145
1183
  !o && n.value.preview && await u();
1146
- }), k([t, () => n.value.preview], async () => {
1184
+ }), E([t, () => n.value.preview], async () => {
1147
1185
  !o && n.value.preview && await u();
1148
1186
  });
1149
1187
  }, we = {
@@ -1155,7 +1193,7 @@ const M = {
1155
1193
  regexp: /- \[\s\]/,
1156
1194
  value: "- [x]"
1157
1195
  }
1158
- }, Rt = (e, t) => {
1196
+ }, At = (e, t) => {
1159
1197
  const r = w("editorId"), n = w("rootRef");
1160
1198
  let o = () => {
1161
1199
  };
@@ -1185,7 +1223,7 @@ const M = {
1185
1223
  };
1186
1224
  te(() => {
1187
1225
  o();
1188
- }), k(
1226
+ }), E(
1189
1227
  [t],
1190
1228
  () => {
1191
1229
  o(), U(u);
@@ -1194,7 +1232,7 @@ const M = {
1194
1232
  immediate: !0
1195
1233
  }
1196
1234
  );
1197
- }, At = (e, t, r) => {
1235
+ }, Rt = (e, t, r) => {
1198
1236
  const n = w("setting"), o = () => {
1199
1237
  U(() => {
1200
1238
  e.onRemount?.();
@@ -1202,8 +1240,8 @@ const M = {
1202
1240
  }, u = (c) => {
1203
1241
  c && o();
1204
1242
  };
1205
- k([t, r], o), k(() => n.value.preview, u), k(() => n.value.htmlPreview, u), H(o);
1206
- }, Ie = {
1243
+ E([t, r], o), E(() => n.value.preview, u), E(() => n.value.htmlPreview, u), H(o);
1244
+ }, xe = {
1207
1245
  modelValue: {
1208
1246
  type: String,
1209
1247
  default: ""
@@ -1274,8 +1312,8 @@ const M = {
1274
1312
  type: [Object, Function],
1275
1313
  default: void 0
1276
1314
  }
1277
- }, on = {
1278
- ...Ie,
1315
+ }, nn = {
1316
+ ...xe,
1279
1317
  updateModelValue: {
1280
1318
  type: Function,
1281
1319
  default: () => {
@@ -1385,7 +1423,7 @@ const M = {
1385
1423
  for (let a = l; a < o.length; a++)
1386
1424
  c.appendChild(o[a].cloneNode(!0));
1387
1425
  };
1388
- return k(() => e.html, (o, u) => {
1426
+ return E(() => e.html, (o, u) => {
1389
1427
  const c = Ce(o), m = Ce(u || "");
1390
1428
  n(c, m);
1391
1429
  }), () => j("div", {
@@ -1397,14 +1435,14 @@ const M = {
1397
1435
  }
1398
1436
  }), Pt = /* @__PURE__ */ ce({
1399
1437
  name: "ContentPreview",
1400
- props: Ie,
1438
+ props: xe,
1401
1439
  setup(e) {
1402
1440
  const t = w("editorId"), r = w("setting"), n = w("previewTheme"), o = w("showCodeRowNumber"), {
1403
1441
  html: u,
1404
1442
  key: c
1405
- } = xt(e, e.previewOnly);
1406
- nt(e, u, c), Ft(e, u), Rt(e, u), At(e, u, c);
1407
- const m = R(() => [`${f}-preview`, `${n?.value}-theme`, o && `${f}-scrn`].filter(Boolean)), s = () => {
1443
+ } = St(e, e.previewOnly);
1444
+ tt(e, u, c), Ft(e, u), At(e, u), Rt(e, u, c);
1445
+ const m = A(() => [`${f}-preview`, `${n?.value}-theme`, o && `${f}-scrn`].filter(Boolean)), s = () => {
1408
1446
  const l = `${t}-preview`;
1409
1447
  return e.previewComponent ? He(e.previewComponent, {
1410
1448
  key: c.value,
@@ -1418,7 +1456,7 @@ const M = {
1418
1456
  class: m.value
1419
1457
  }, null);
1420
1458
  };
1421
- return () => j(Ae, null, [r.value.preview && (e.previewOnly ? s() : j("div", {
1459
+ return () => j(Re, null, [r.value.preview && (e.previewOnly ? s() : j("div", {
1422
1460
  id: `${t}-preview-wrapper`,
1423
1461
  class: `${f}-preview-wrapper`,
1424
1462
  key: "content-preview-wrapper"
@@ -1430,7 +1468,7 @@ const M = {
1430
1468
  class: `${f}-html`
1431
1469
  }, [u.value])])]);
1432
1470
  }
1433
- }), Lt = ({ text: e }) => e, Se = {
1471
+ }), Lt = ({ text: e }) => e, Ie = {
1434
1472
  /**
1435
1473
  * markdown content.
1436
1474
  *
@@ -1668,8 +1706,8 @@ const M = {
1668
1706
  type: [Object, Function],
1669
1707
  default: void 0
1670
1708
  }
1671
- }, an = {
1672
- ...Se,
1709
+ }, on = {
1710
+ ...Ie,
1673
1711
  /**
1674
1712
  * input回调事件
1675
1713
  */
@@ -1974,14 +2012,14 @@ const M = {
1974
2012
  type: Number,
1975
2013
  default: void 0
1976
2014
  }
1977
- }, xe = [
2015
+ }, Se = [
1978
2016
  "onHtmlChanged",
1979
2017
  "onGetCatalog",
1980
2018
  "onChange",
1981
2019
  "onRemount",
1982
2020
  "update:modelValue"
1983
- ], rn = [
1984
- ...xe,
2021
+ ], an = [
2022
+ ...Se,
1985
2023
  "onSave",
1986
2024
  "onUploadImg",
1987
2025
  "onError",
@@ -1999,14 +2037,14 @@ const M = {
1999
2037
  t.expose(o);
2000
2038
  }, ae = /* @__PURE__ */ ce({
2001
2039
  name: "MdPreview",
2002
- props: Se,
2003
- emits: xe,
2040
+ props: Ie,
2041
+ emits: Se,
2004
2042
  setup(e, t) {
2005
2043
  const {
2006
2044
  noKatex: r,
2007
2045
  noMermaid: n,
2008
2046
  noHighlight: o
2009
- } = e, u = G(), c = tt(e);
2047
+ } = e, u = G(), c = et(e);
2010
2048
  Te(e, {
2011
2049
  rootRef: u,
2012
2050
  editorId: c
@@ -2056,15 +2094,15 @@ export {
2056
2094
  M as C,
2057
2095
  ae as M,
2058
2096
  Pt as a,
2059
- an as b,
2060
- on as c,
2061
- en as d,
2062
- rn as e,
2063
- tn as f,
2064
- Jt as g,
2065
- Yt as h,
2066
- Qt as i,
2067
- nn as j,
2068
- Xt as k,
2069
- tt as u
2097
+ on as b,
2098
+ nn as c,
2099
+ Qt as d,
2100
+ an as e,
2101
+ en as f,
2102
+ Zt as g,
2103
+ Xt as h,
2104
+ Yt as i,
2105
+ tn as j,
2106
+ Jt as k,
2107
+ et as u
2070
2108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "6.4.0",
3
+ "version": "6.4.2",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",
@@ -56,9 +56,8 @@
56
56
  "@lezer/highlight": "^1.2.1",
57
57
  "@types/markdown-it": "^14.0.1",
58
58
  "@vavt/copy2clipboard": "^1.0.1",
59
- "@vavt/util": "^2.1.0",
59
+ "@vavt/util": "^2.1.2",
60
60
  "codemirror": "^6.0.2",
61
- "lru-cache": "^11.2.1",
62
61
  "lucide-vue-next": "^0.543.0",
63
62
  "markdown-it": "^14.0.0",
64
63
  "markdown-it-image-figures": "^2.1.1",