md-editor-v3 7.1.1 → 7.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,28 @@
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],A=m[w];if(v||!x||!x.isConnected||(r?.value?!r.value.contains(x):!1)){I?.dispose?.(),A?.disconnect?.();return}y.push(x),I&&E.push(I),A&&C.push(A)}),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},A=n.echarts.parseOption(C,I),S=n.echarts.sanitizeOption(d(A),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 R=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===R&&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 k=document.createElement("div");k.style.cssText="position:fixed;z-index:-10000;top:-10000px;left:-10000px;",k.style.width=Math.max(document.body.offsetWidth,1366)+"px",k.style.height=Math.max(document.body.offsetHeight,768)+"px",document.body.appendChild(k);try{return await C.render(q.randomId(),N,k)}finally{k.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 $={...H,svg:L.innerHTML};w.replaceWith(L);try{H.bindFunctions?.(L),l.add(L)}catch(F){throw L.replaceWith(w),F}i.set(B,$)}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),A=l.src.slice(b,x);if(i(A),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,R=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=R,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,A=`<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:k,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`
1
+ "use strict";const o=require("vue"),h=require("./event-bus.cjs"),q=require("@vavt/util"),m=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:`${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`},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=m.globalConfig.editorExtensions.highlight,s=m.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={...m.codeCss,...n.css},{js:i,css:l={}}=s||{},c=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme,p=u[e.codeTheme]?u[e.codeTheme][c]:m.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:p,...g}}})),o.provide("showCodeRowNumber",e.showCodeRowNumber);const d=o.computed(()=>{const f={...m.staticTextDefault,...m.globalConfig.editorConfig.languageUserDefined};return q.deepMerge(q.deepClone(m.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}=m.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=p=>{Q(r,{direct:"image",params:{desc:"",urls:p}}),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||`${m.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} .${m.prefix}-preview .${m.prefix}-code`).forEach(l=>{let c=-1;const p=l.querySelector(`.${m.prefix}-copy-button:not([data-processed])`);p&&(p.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(()=>{p.dataset.isIcon?p.dataset.tips=x:p.textContent=x,c=window.setTimeout(()=>{p.dataset.isIcon?p.dataset.tips=y:p.textContent=y},1500)})},p.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}=m.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=[],p=[];const g=(v=!1)=>{if(!l.length){v&&(c.forEach(x=>{x.dispose?.()}),p.forEach(x=>{x.disconnect?.()}),c=[],p=[]);return}const y=[],E=[],C=[];l.forEach((x,w)=>{const I=c[w],A=p[w];if(v||!x||!x.isConnected||(r?.value?!r.value.contains(x):!1)){I?.dispose?.(),A?.disconnect?.();return}y.push(x),I&&E.push(I),A&&C.push(A)}),l=y,c=E,p=C},b=()=>{if(g(),!e.noEcharts&&f){const v=r.value;if(!v)return;Array.from(v.querySelectorAll(`div.${m.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},A=n.echarts.parseOption(C,I),S=n.echarts.sanitizeOption(d(A),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),p.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(m.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||m.globalConfig.editorExtensions.highlight.instance||M.updateHandler("link",{...t.value.css,rel:"stylesheet",id:_.hlcss})}),a},Me=e=>{const t=o.shallowRef(m.globalConfig.editorExtensions.katex.instance);return o.onMounted(()=>{if(e.noKatex||t.value)return;const{editorExtensions:a,editorExtensionsAttrs:r}=m.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}=m.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 p=0,g=!1;const b=(E,C)=>i.get(JSON.stringify([u.value,E,C])),v=()=>{p+=1,i.clear(),u.value+=1};o.watch([a,()=>e.sanitizeMermaid],v,{flush:"sync"}),o.watch(()=>e.modelValue,()=>{p+=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.${m.prefix}-mermaid, p.${m.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===p)return I.promise;const S=(async()=>{const R=p,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&&p===R&&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 k=document.createElement("div");k.style.cssText="position:fixed;z-index:-10000;top:-10000px;left:-10000px;",k.style.width=Math.max(document.body.offsetWidth,1366)+"px",k.style.height=Math.max(document.body.offsetHeight,768)+"px",document.body.appendChild(k);try{return await C.render(q.randomId(),N,k)}finally{k.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 $={...H,svg:L.innerHTML};w.replaceWith(L);try{H.bindFunctions?.(L),l.add(L)}catch(F){throw L.replaceWith(w),F}i.set(B,$)}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:p,promise:S}),S}))};return o.onBeforeUnmount(()=>{g=!0,p+=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,p,g,b)=>{const v=l[c];return v.type==="admonition_open"?l[c].attrPush(["class",`${m.prefix}-admonition ${m.prefix}-admonition-${v.info}`]):v.type==="admonition_title_open"&&l[c].attrPush(["class",`${m.prefix}-admonition-title`]),b.renderToken(l,c,p)},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,p,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),A=l.src.slice(b,x);if(i(A),g)return!0;for(v=c;v++,!(v>=p||(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,R=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=R,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=p=>p.info?r(p.info).trim():"",u=p=>{const g=f(p),[b=null,v=""]=(n.exec(g)||[]).slice(1);return[b,v]},i=p=>m.parseCodeBlockInfo(f(p)).language,l=p=>{const g=p.info.match(s)||[],b=g[1]==="open"||g[1]!=="close"&&t.codeFoldable&&p.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=(p,g,b,v,y)=>{if(p[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,A=`<span class="${m.prefix}-collapse-tips">${M.StrIcon("collapse-tips",t.customIconRef.value)}</span>`,[S]=u(p[g]);if(S===null){const{open:T,tagContainer:k,tagHeader:j}=l(p[g]),K=[["class",`${m.prefix}-code`]];T&&K.push(["open",""]);const X={attrs:m.mergeAttrs(p[g],K)};p[g].info=p[g].info.replace(s,"");const{attrs:Z,language:J}=m.parseCodeBlockInfo(f(p[g])),ee=[J,Z].filter(Boolean).join(" "),he=a(p,g,b,v,y);return`
3
3
  <${k} ${y.renderAttrs(X)}>
4
- <${j} 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(ee)}</span>
8
- <span class="${p.prefix}-copy-button" data-tips="${x}"${I?" data-is-icon=true":""}>${w}</span>
4
+ <${j} 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(ee)}</span>
8
+ <span class="${m.prefix}-copy-button" data-tips="${x}"${I?" data-is-icon=true":""}>${w}</span>
9
9
  ${t.extraTools instanceof Function?t.extraTools({lang:ee}):t.extraTools||""}
10
10
  ${k==="details"?A:""}
11
11
  </div>
12
12
  </${j}>
13
13
  ${he}
14
14
  </${k}>
15
- `}let R,U,N,P,B="",D="",z="";const{open:O,tagContainer:H,tagHeader:L}=l(m[g]),$=[["class",`${p.prefix}-code`]];O&&$.push(["open",""]);const F={attrs:p.mergeAttrs(m[g],$)};for(let T=g;T<m.length&&(R=m[T],[U,N]=u(R),U===S);T++){R.info=R.info.replace(n,"").replace(s,""),R.hidden=!0;const k=`${p.prefix}-codetab-${d}-${g}-${T-g}`;P=T-g>0?"":"checked",B+=`
15
+ `}let R,U,N,P,B="",D="",z="";const{open:O,tagContainer:H,tagHeader:L}=l(p[g]),$=[["class",`${m.prefix}-code`]];O&&$.push(["open",""]);const F={attrs:m.mergeAttrs(p[g],$)};for(let T=g;T<p.length&&(R=p[T],[U,N]=u(R),U===S);T++){R.info=R.info.replace(n,"").replace(s,""),R.hidden=!0;const k=`${m.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-${d}-${g}-${T-g}"
20
- name="${p.prefix}-codetab-label-${d}-${g}"
19
+ id="label-${m.prefix}-codetab-label-1-${d}-${g}-${T-g}"
20
+ name="${m.prefix}-codetab-label-${d}-${g}"
21
21
  class="${k}"
22
22
  ${P}
23
23
  >
24
24
  <label
25
- for="label-${p.prefix}-codetab-label-1-${d}-${g}-${T-g}"
25
+ for="label-${m.prefix}-codetab-label-1-${d}-${g}-${T-g}"
26
26
  onclick="this.getRootNode().querySelectorAll('.${k}').forEach(e => e.click())"
27
27
  >
28
28
  ${e.utils.escapeHtml(N||i(R))}
@@ -31,38 +31,38 @@
31
31
  <div role="tabpanel">
32
32
  <input
33
33
  type="radio"
34
- name="${p.prefix}-codetab-pre-${d}-${g}"
34
+ name="${m.prefix}-codetab-pre-${d}-${g}"
35
35
  class="${k}"
36
36
  ${P}
37
37
  role="presentation">
38
- ${a(m,T,b,v,y)}
38
+ ${a(p,T,b,v,y)}
39
39
  </div>`,z+=`
40
40
  <input
41
41
  type="radio"
42
- name="${p.prefix}-codetab-lang-${d}-${g}"
42
+ name="${m.prefix}-codetab-lang-${d}-${g}"
43
43
  class="${k}"
44
44
  ${P}
45
45
  role="presentation">
46
- <span class=${p.prefix}-code-lang role="note">${e.utils.escapeHtml(i(R))}</span>`}const{attrs:V,language:G}=p.parseCodeBlockInfo(f(m[g])),W=[G,V].filter(Boolean).join(" ");return`
46
+ <span class=${m.prefix}-code-lang role="note">${e.utils.escapeHtml(i(R))}</span>`}const{attrs:V,language:G}=m.parseCodeBlockInfo(f(p[g])),W=[G,V].filter(Boolean).join(" ");return`
47
47
  <${H} ${y.renderAttrs(F)}>
48
- <${L} class="${p.prefix}-code-head">
49
- <div class="${p.prefix}-code-flag">
50
- <ul class="${p.prefix}-codetab-label" role="tablist">${B}</ul>
48
+ <${L} class="${m.prefix}-code-head">
49
+ <div class="${m.prefix}-code-flag">
50
+ <ul class="${m.prefix}-codetab-label" role="tablist">${B}</ul>
51
51
  </div>
52
- <div class="${p.prefix}-code-action">
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>
52
+ <div class="${m.prefix}-code-action">
53
+ <span class="${m.prefix}-codetab-lang">${z}</span>
54
+ <span class="${m.prefix}-copy-button" data-tips="${x}"${I?" data-is-icon=true":""}>${w}</span>
55
55
  ${t.extraTools instanceof Function?t.extraTools({lang:W}):t.extraTools||""}
56
56
  ${H==="details"?A:""}
57
57
  </div>
58
58
  </${L}>
59
59
  ${D}
60
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(`
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",`${m.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
62
  `);const d=s.content?s.content.split(`
63
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],A=t.eMarks[y];if(I<A&&t.tShift[y]<t.blkIndent)break;if(t.src.slice(I,A).trim().endsWith(i.close)){const R=t.src.slice(0,A).lastIndexOf(i.close);C=t.src.slice(I,R),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:A}=He(e),S=ve({html:!1,breaks:!0,linkify:!0});r(S,{editorId:d});const R=[{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||R.push({type:"katex",plugin:Ue,options:{katexRef:y}}),e.noMermaid||R.push({type:"mermaid",plugin:ze,options:{themeRef:l,revision:E,getCached:w}}),e.noEcharts||R.push({type:"echarts",plugin:Be,options:{themeRef:l}}),n(R,{editorId:d}).forEach($=>{S.use($.plugin,$.options)});const U=S.options.highlight;S.set({highlight:($,F,V)=>{const G=p.parseCodeBlockInfo(F,V),{attrs:W,language:T,lineHighlightRanges:k}=G;let j="";if(U){const Z=U($,T,W);if(Z){const J=te.prepareCustomCodeHighlight(Z,$,{lineHighlightRanges:k,showLineNumber:i});if(J.shouldReturnDirectly)return J.html;j=J.html}}j||(!e.noHighlight&&v.value?v.value.getLanguage(T)?j=v.value.highlight($,{language:T,ignoreIllegals:!0}).value:T?j=S.utils.escapeHtml($):j=v.value.highlightAuto($).value:j=S.utils.escapeHtml($));const K=S.utils.escapeHtml(T);let X=`<span class="${p.prefix}-code-block">${j.replace(/^\n+|\n+$/g,"")}</span>`;return(i||k.length)&&(X=te.generateCodeBlock(j,$,{lineHighlightRanges:k,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 $=m.value?.querySelectorAll(`#${d} p.${p.prefix}-mermaid:not([data-closed=false])`);D(),D=M.copyMermaid($,{customIcon:c.value}),s.mermaid?.enableZoom&&(B(),B=M.zoomMermaid($,{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),A()})},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],($,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),A(),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:/\[[xX]\]/,value:"[ ]"},unChecked:{regexp:/\[ \]/,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 .task-list-item-checkbox"),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;
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"?m.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=Number(n.tag.slice(1));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 p=t.push("math_block",e.tag,0);return p.attrSet("class",e.className),p.block=!0,p.content=i,p.map=[a,t.line],p.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,p=t.src.slice(c,f).trim(),g=p==="",b=p===i.close,v=p.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=p.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],A=t.eMarks[y];if(I<A&&t.tShift[y]<t.blkIndent)break;if(t.src.slice(I,A).trim().endsWith(i.close)){const R=t.src.slice(0,A).lastIndexOf(i.close);C=t.src.slice(I,R),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 m.renderTokenContent(f,e.utils.escapeHtml(f.content),u);const l={throwOnError:!1,displayMode:i,trust:!1},c=m.globalConfig.katexConfig(l),p=t.value.renderToString(f.content,{...l,...c,trust:c?.trust??!1});return f.attrSet("data-processed",""),m.renderTokenContent(f,String(p),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:`${m.prefix}-katex-inline`,tag:"span"})),e.block.ruler.after("blockquote","math_block",Ge({delimiters:r||oe.block,className:`${m.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",`${m.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),m.renderTokenContent(u,l.svg,f)):m.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}=m.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"),p=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:A}=He(e),S=ve({html:!1,breaks:!0,linkify:!0});r(S,{editorId:d});const R=[{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||R.push({type:"katex",plugin:Ue,options:{katexRef:y}}),e.noMermaid||R.push({type:"mermaid",plugin:ze,options:{themeRef:l,revision:E,getCached:w}}),e.noEcharts||R.push({type:"echarts",plugin:Be,options:{themeRef:l}}),n(R,{editorId:d}).forEach($=>{S.use($.plugin,$.options)});const U=S.options.highlight;S.set({highlight:($,F,V)=>{const G=m.parseCodeBlockInfo(F,V),{attrs:W,language:T,lineHighlightRanges:k}=G;let j="";if(U){const Z=U($,T,W);if(Z){const J=te.prepareCustomCodeHighlight(Z,$,{lineHighlightRanges:k,showLineNumber:i});if(J.shouldReturnDirectly)return J.html;j=J.html}}j||(!e.noHighlight&&v.value?v.value.getLanguage(T)?j=v.value.highlight($,{language:T,ignoreIllegals:!0}).value:T?j=S.utils.escapeHtml($):j=v.value.highlightAuto($).value:j=S.utils.escapeHtml($));const K=S.utils.escapeHtml(T);let X=`<span class="${m.prefix}-code-block">${j.replace(/^\n+|\n+$/g,"")}</span>`;return(i||k.length)&&(X=te.generateCodeBlock(j,$,{lineHighlightRanges:k,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 $=p.value?.querySelectorAll(`#${d} p.${m.prefix}-mermaid:not([data-closed=false])`);D(),D=M.copyMermaid($,{customIcon:c.value}),s.mermaid?.enableZoom&&(B(),B=M.zoomMermaid($,{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),A()})},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],($,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),A(),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:/\[[xX]\]/,value:"[ ]"},unChecked:{regexp:/\[ \]/,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 .task-list-item-checkbox"),f=u=>{u.preventDefault();const i=u.target.checked?"unChecked":"checked",l=u.target.parentElement?.dataset.line;if(!l)return;const c=Number(l),p=e.modelValue.split(`
67
+ `),g=p[Number(c)].replace(se[i].regexp,se[i].value);e.previewOnly?(p[Number(c)]=g,e.onChange(p.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(()=>[`${m.prefix}-preview`,`${r?.value}-theme`,n&&`${m.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:`${m.prefix}-preview-wrapper`,key:"content-preview-wrapper"},[u()])),a.value.htmlPreview&&o.createVNode("div",{id:`${t}-html-wrapper`,class:`${m.prefix}-preview-wrapper`,key:"html-preview-wrapper"},[o.createVNode("div",{class:`${m.prefix}-html`},[s.value])])])}}),ct=({text:e})=>e,me={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={...me,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}},pe=["onHtmlChanged","onGetCatalog","onChange","onRemount","update:modelValue"],ut=[...pe,"onSave","onUploadImg","onError","onBlur","onFocus","onInput","onDrop","onInputBoxWidthChange"],Y=o.defineComponent({name:"MdPreview",props:me,emits:pe,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:[m.prefix,e.class,`${m.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;
@@ -929,7 +929,7 @@ const Ae = /* @__PURE__ */ new WeakMap(), $t = (e, t) => {
929
929
  };
930
930
  }, kt = (e, t) => {
931
931
  e.renderer.rules.heading_open = (a, o) => {
932
- const n = a[o], s = a[o + 1].children?.reduce((u, d) => u + (["text", "code_inline", "math_inline"].includes(d.type) && d.content || ""), "") || "", c = n.markup.length;
932
+ const n = a[o], s = a[o + 1].children?.reduce((u, d) => u + (["text", "code_inline", "math_inline"].includes(d.type) && d.content || ""), "") || "", c = Number(n.tag.slice(1));
933
933
  return t.headsRef.value.push({
934
934
  text: s,
935
935
  level: c,
@@ -1861,10 +1861,18 @@ declare const Editor: vue.DefineComponent<vue.ExtractPropTypes<{
1861
1861
  onOnInputBoxWidthChange?: ((...args: any[]) => any) | undefined;
1862
1862
  onOnRemount?: ((...args: any[]) => any) | undefined;
1863
1863
  }>, {
1864
+ language: string;
1865
+ theme: Themes;
1866
+ previewTheme: string;
1867
+ codeTheme: string;
1868
+ disabled: boolean;
1869
+ showToolbarName: boolean;
1870
+ class: string;
1871
+ style: string | vue.CSSProperties;
1872
+ onChange: ChangeEvent;
1864
1873
  preview: boolean;
1865
1874
  pageFullscreen: boolean;
1866
1875
  htmlPreview: boolean;
1867
- onChange: ChangeEvent;
1868
1876
  onSave: SaveEvent;
1869
1877
  onUploadImg: UploadImgEvent;
1870
1878
  onHtmlChanged: HtmlChangedEvent;
@@ -1893,30 +1901,22 @@ declare const Editor: vue.DefineComponent<vue.ExtractPropTypes<{
1893
1901
  }>;
1894
1902
  noUploadImg: boolean;
1895
1903
  autoFocus: boolean;
1896
- disabled: boolean;
1897
1904
  readOnly: boolean;
1898
1905
  maxLength: number;
1899
1906
  autoDetectCode: boolean;
1900
1907
  completions: _codemirror_autocomplete.CompletionSource[];
1901
- showToolbarName: boolean;
1902
1908
  inputBoxWidth: string;
1903
1909
  transformImgUrl: (t: string) => string | Promise<string>;
1904
- catalogLayout: "fixed" | "flat";
1910
+ catalogLayout: "flat" | "fixed";
1905
1911
  catalogMaxDepth: number;
1906
1912
  modelValue: string;
1907
- theme: Themes;
1908
- class: string;
1909
- language: string;
1910
1913
  editorId: string;
1911
1914
  id: string;
1912
1915
  showCodeRowNumber: boolean;
1913
- previewTheme: string;
1914
- style: string | vue.CSSProperties;
1915
1916
  mdHeadingId: MdHeadingId;
1916
1917
  sanitize: (html: string) => string;
1917
1918
  noMermaid: boolean;
1918
1919
  noKatex: boolean;
1919
- codeTheme: string;
1920
1920
  formatCopiedText: (text: string) => string;
1921
1921
  codeStyleReverse: boolean;
1922
1922
  codeStyleReverseList: string[];
@@ -2035,18 +2035,18 @@ declare const _default$b: vue.DefineComponent<vue.ExtractPropTypes<{
2035
2035
  }>> & Readonly<{
2036
2036
  onOnClick?: ((...args: any[]) => any) | undefined;
2037
2037
  }>, {
2038
+ onClick: (e: MouseEvent) => void;
2038
2039
  title: string;
2039
- disabled: boolean;
2040
- showToolbarName: boolean;
2041
- theme: Themes;
2042
- language: string;
2043
- previewTheme: string;
2044
- codeTheme: string;
2045
2040
  trigger: string | VNode<vue.RendererNode, vue.RendererElement, {
2046
2041
  [key: string]: any;
2047
2042
  }>;
2048
2043
  insert: () => void;
2049
- onClick: (e: MouseEvent) => void;
2044
+ language: string;
2045
+ theme: Themes;
2046
+ previewTheme: string;
2047
+ codeTheme: string;
2048
+ disabled: boolean;
2049
+ showToolbarName: boolean;
2050
2050
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2051
2051
 
2052
2052
  declare const _default$a: typeof _default$b & {
@@ -2171,21 +2171,21 @@ declare const _default$9: vue.DefineComponent<vue.ExtractPropTypes<{
2171
2171
  onOnChange?: ((...args: any[]) => any) | undefined;
2172
2172
  }>, {
2173
2173
  title: string;
2174
- onChange: (visible: boolean) => void;
2175
- disabled: boolean;
2176
- showToolbarName: boolean;
2177
- theme: Themes;
2174
+ trigger: string | VNode<vue.RendererNode, vue.RendererElement, {
2175
+ [key: string]: any;
2176
+ }>;
2177
+ insert: () => void;
2178
2178
  language: string;
2179
+ theme: Themes;
2179
2180
  previewTheme: string;
2180
2181
  codeTheme: string;
2182
+ disabled: boolean;
2183
+ showToolbarName: boolean;
2181
2184
  visible: boolean;
2182
- trigger: string | VNode<vue.RendererNode, vue.RendererElement, {
2183
- [key: string]: any;
2184
- }>;
2185
+ onChange: (visible: boolean) => void;
2185
2186
  overlay: string | VNode<vue.RendererNode, vue.RendererElement, {
2186
2187
  [key: string]: any;
2187
2188
  }>;
2188
- insert: () => void;
2189
2189
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2190
2190
 
2191
2191
  declare const _default$8: typeof _default$9 & {
@@ -2283,7 +2283,7 @@ declare const _default$7: vue.DefineComponent<vue.ExtractPropTypes<{
2283
2283
  type: PropType<boolean>;
2284
2284
  default: undefined;
2285
2285
  };
2286
- }>, () => vue_jsx_runtime.JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("onClose" | "onAdjust" | "onClick")[], "onClose" | "onAdjust" | "onClick", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
2286
+ }>, () => vue_jsx_runtime.JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("onClick" | "onClose" | "onAdjust")[], "onClick" | "onClose" | "onAdjust", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
2287
2287
  title: {
2288
2288
  type: PropType<string>;
2289
2289
  default: string;
@@ -2375,35 +2375,35 @@ declare const _default$7: vue.DefineComponent<vue.ExtractPropTypes<{
2375
2375
  default: undefined;
2376
2376
  };
2377
2377
  }>> & Readonly<{
2378
+ onOnClick?: ((...args: any[]) => any) | undefined;
2378
2379
  onOnClose?: ((...args: any[]) => any) | undefined;
2379
2380
  onOnAdjust?: ((...args: any[]) => any) | undefined;
2380
- onOnClick?: ((...args: any[]) => any) | undefined;
2381
2381
  }>, {
2382
+ onClick: () => void;
2382
2383
  title: string;
2383
- disabled: boolean;
2384
- showToolbarName: boolean;
2385
- theme: Themes;
2386
- class: string;
2387
- language: string;
2388
- previewTheme: string;
2389
- style: string | CSSProperties;
2390
- codeTheme: string;
2391
- visible: boolean;
2392
2384
  trigger: string | VNode<vue.RendererNode, vue.RendererElement, {
2393
2385
  [key: string]: any;
2394
2386
  }>;
2395
2387
  insert: () => void;
2388
+ language: string;
2389
+ theme: Themes;
2390
+ previewTheme: string;
2391
+ codeTheme: string;
2392
+ disabled: boolean;
2393
+ showToolbarName: boolean;
2396
2394
  onClose: () => void;
2395
+ onAdjust: (val: boolean) => void;
2396
+ modalTitle: string | VNode<vue.RendererNode, vue.RendererElement, {
2397
+ [key: string]: any;
2398
+ }>;
2399
+ visible: boolean;
2397
2400
  width: string;
2398
2401
  height: string;
2399
2402
  showAdjust: boolean;
2400
2403
  isFullscreen: boolean;
2401
- onAdjust: (val: boolean) => void;
2404
+ class: string;
2405
+ style: string | CSSProperties;
2402
2406
  showMask: boolean;
2403
- onClick: () => void;
2404
- modalTitle: string | VNode<vue.RendererNode, vue.RendererElement, {
2405
- [key: string]: any;
2406
- }>;
2407
2407
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2408
2408
 
2409
2409
  declare const _default$6: typeof _default$7 & {
@@ -2506,14 +2506,14 @@ declare const _default$5: vue.DefineComponent<vue.ExtractPropTypes<{
2506
2506
  }> | VNode<vue.RendererNode, vue.RendererElement, {
2507
2507
  [key: string]: any;
2508
2508
  }>[];
2509
- class: string;
2510
- style: string | CSSProperties;
2509
+ onAdjust: (val: boolean) => void;
2511
2510
  visible: boolean;
2512
2511
  width: string;
2513
2512
  height: string;
2514
2513
  showAdjust: boolean;
2515
2514
  isFullscreen: boolean;
2516
- onAdjust: (val: boolean) => void;
2515
+ class: string;
2516
+ style: string | CSSProperties;
2517
2517
  showMask: boolean;
2518
2518
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2519
2519
 
@@ -2566,10 +2566,10 @@ declare const _default$3: vue.DefineComponent<vue.ExtractPropTypes<{
2566
2566
  }>> & Readonly<{
2567
2567
  onOnClick?: ((...args: any[]) => any) | undefined;
2568
2568
  }>, {
2569
- disabled: boolean;
2570
- theme: Themes;
2571
- language: string;
2572
2569
  onClick: (e: MouseEvent) => void;
2570
+ language: string;
2571
+ theme: Themes;
2572
+ disabled: boolean;
2573
2573
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2574
2574
 
2575
2575
  declare const _default$2: typeof _default$3 & {
@@ -2577,49 +2577,49 @@ declare const _default$2: typeof _default$3 & {
2577
2577
  };
2578
2578
 
2579
2579
  declare const MdPreview: vue.DefineComponent<{
2580
- readonly modelValue: string;
2581
- readonly theme: Themes;
2582
- readonly class: string;
2583
2580
  readonly language: string;
2584
- readonly showCodeRowNumber: boolean;
2581
+ readonly theme: Themes;
2585
2582
  readonly previewTheme: string;
2583
+ readonly codeTheme: string;
2584
+ readonly class: string;
2586
2585
  readonly style: string | vue.CSSProperties;
2586
+ readonly modelValue: string;
2587
+ readonly showCodeRowNumber: boolean;
2587
2588
  readonly mdHeadingId: MdHeadingId;
2588
2589
  readonly sanitize: (html: string) => string;
2589
2590
  readonly noMermaid: boolean;
2590
2591
  readonly noKatex: boolean;
2591
- readonly codeTheme: string;
2592
2592
  readonly formatCopiedText: (text: string) => string;
2593
2593
  readonly codeStyleReverse: boolean;
2594
2594
  readonly codeStyleReverseList: string[];
2595
2595
  readonly noHighlight: boolean;
2596
2596
  readonly noImgZoomIn: boolean;
2597
2597
  readonly customIcon: {
2598
- bold?: {
2598
+ title?: {
2599
2599
  component: vue.Component | vue.VNode | string;
2600
2600
  props?: {
2601
2601
  [key: string | number | symbol]: any;
2602
2602
  };
2603
2603
  } | undefined;
2604
- underline?: {
2604
+ bold?: {
2605
2605
  component: vue.Component | vue.VNode | string;
2606
2606
  props?: {
2607
2607
  [key: string | number | symbol]: any;
2608
2608
  };
2609
2609
  } | undefined;
2610
- italic?: {
2610
+ underline?: {
2611
2611
  component: vue.Component | vue.VNode | string;
2612
2612
  props?: {
2613
2613
  [key: string | number | symbol]: any;
2614
2614
  };
2615
2615
  } | undefined;
2616
- "strike-through"?: {
2616
+ italic?: {
2617
2617
  component: vue.Component | vue.VNode | string;
2618
2618
  props?: {
2619
2619
  [key: string | number | symbol]: any;
2620
2620
  };
2621
2621
  } | undefined;
2622
- title?: {
2622
+ "strike-through"?: {
2623
2623
  component: vue.Component | vue.VNode | string;
2624
2624
  props?: {
2625
2625
  [key: string | number | symbol]: any;
@@ -2812,49 +2812,49 @@ declare const MdPreview: vue.DefineComponent<{
2812
2812
  readonly id: string | undefined;
2813
2813
  readonly previewComponent: vue.Component | undefined;
2814
2814
  }, () => vue_jsx_runtime.JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, EditorEmits, "onChange" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "onError" | "update:modelValue" | "onBlur" | "onFocus" | "onInput" | "onDrop" | "onInputBoxWidthChange" | "onRemount", vue.PublicProps, Readonly<{
2815
- readonly modelValue: string;
2816
- readonly theme: Themes;
2817
- readonly class: string;
2818
2815
  readonly language: string;
2819
- readonly showCodeRowNumber: boolean;
2816
+ readonly theme: Themes;
2820
2817
  readonly previewTheme: string;
2818
+ readonly codeTheme: string;
2819
+ readonly class: string;
2821
2820
  readonly style: string | vue.CSSProperties;
2821
+ readonly modelValue: string;
2822
+ readonly showCodeRowNumber: boolean;
2822
2823
  readonly mdHeadingId: MdHeadingId;
2823
2824
  readonly sanitize: (html: string) => string;
2824
2825
  readonly noMermaid: boolean;
2825
2826
  readonly noKatex: boolean;
2826
- readonly codeTheme: string;
2827
2827
  readonly formatCopiedText: (text: string) => string;
2828
2828
  readonly codeStyleReverse: boolean;
2829
2829
  readonly codeStyleReverseList: string[];
2830
2830
  readonly noHighlight: boolean;
2831
2831
  readonly noImgZoomIn: boolean;
2832
2832
  readonly customIcon: {
2833
- bold?: {
2833
+ title?: {
2834
2834
  component: vue.Component | vue.VNode | string;
2835
2835
  props?: {
2836
2836
  [key: string | number | symbol]: any;
2837
2837
  };
2838
2838
  } | undefined;
2839
- underline?: {
2839
+ bold?: {
2840
2840
  component: vue.Component | vue.VNode | string;
2841
2841
  props?: {
2842
2842
  [key: string | number | symbol]: any;
2843
2843
  };
2844
2844
  } | undefined;
2845
- italic?: {
2845
+ underline?: {
2846
2846
  component: vue.Component | vue.VNode | string;
2847
2847
  props?: {
2848
2848
  [key: string | number | symbol]: any;
2849
2849
  };
2850
2850
  } | undefined;
2851
- "strike-through"?: {
2851
+ italic?: {
2852
2852
  component: vue.Component | vue.VNode | string;
2853
2853
  props?: {
2854
2854
  [key: string | number | symbol]: any;
2855
2855
  };
2856
2856
  } | undefined;
2857
- title?: {
2857
+ "strike-through"?: {
2858
2858
  component: vue.Component | vue.VNode | string;
2859
2859
  props?: {
2860
2860
  [key: string | number | symbol]: any;
@@ -3061,24 +3061,24 @@ declare const MdPreview: vue.DefineComponent<{
3061
3061
  onOnInputBoxWidthChange?: ((...args: any[]) => any) | undefined;
3062
3062
  onOnRemount?: ((...args: any[]) => any) | undefined;
3063
3063
  }>, {
3064
+ language: string;
3065
+ theme: Themes;
3066
+ previewTheme: string;
3067
+ codeTheme: string;
3068
+ class: string;
3069
+ style: string | vue.CSSProperties;
3064
3070
  onChange: ChangeEvent;
3065
3071
  onHtmlChanged: HtmlChangedEvent;
3066
3072
  onGetCatalog: GetCatalogEvent;
3067
3073
  onRemount: () => void;
3068
3074
  modelValue: string;
3069
- theme: Themes;
3070
- class: string;
3071
- language: string;
3072
3075
  editorId: string;
3073
3076
  id: string;
3074
3077
  showCodeRowNumber: boolean;
3075
- previewTheme: string;
3076
- style: string | vue.CSSProperties;
3077
3078
  mdHeadingId: MdHeadingId;
3078
3079
  sanitize: (html: string) => string;
3079
3080
  noMermaid: boolean;
3080
3081
  noKatex: boolean;
3081
- codeTheme: string;
3082
3082
  formatCopiedText: (text: string) => string;
3083
3083
  codeStyleReverse: boolean;
3084
3084
  codeStyleReverseList: string[];
@@ -3266,12 +3266,12 @@ declare const MdCatalog: vue.DefineComponent<vue.ExtractPropTypes<{
3266
3266
  onOnClick?: ((...args: any[]) => any) | undefined;
3267
3267
  onOnActive?: ((...args: any[]) => any) | undefined;
3268
3268
  }>, {
3269
- catalogMaxDepth: number;
3269
+ onClick: (e: MouseEvent, t: TocItem) => void;
3270
3270
  theme: Themes;
3271
3271
  class: string;
3272
+ catalogMaxDepth: number;
3272
3273
  editorId: string;
3273
3274
  mdHeadingId: MdHeadingId;
3274
- onClick: (e: MouseEvent, t: TocItem) => void;
3275
3275
  onActive: (heading: HeadList | undefined, activeElement: HTMLDivElement) => void;
3276
3276
  scrollElement: string | HTMLElement;
3277
3277
  offsetTop: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",