md-editor-v3 7.0.0 → 7.1.0-1

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