md-editor-v3 6.5.5 → 7.0.0-0

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