md-editor-v3 7.1.0-1 → 7.1.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.
- package/README.md +5 -2
- package/lib/cjs/MdEditor.cjs +1 -1
- package/lib/cjs/chunks/dom.cjs +1 -1
- package/lib/cjs/chunks/index.cjs +1 -1
- package/lib/cjs/chunks/index2.cjs +1 -1
- package/lib/cjs/chunks/index3.cjs +1 -1
- package/lib/cjs/chunks/index4.cjs +16 -16
- package/lib/es/MdEditor.mjs +2 -3
- package/lib/es/chunks/dom.mjs +120 -110
- package/lib/es/chunks/index.mjs +180 -86
- package/lib/es/chunks/index2.mjs +182 -145
- package/lib/es/chunks/index3.mjs +1 -3
- package/lib/es/chunks/index4.mjs +87 -85
- package/lib/style.css +13 -2
- package/lib/types/index.d.ts +7 -7
- package/package.json +1 -1
|
@@ -1,38 +1,38 @@
|
|
|
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,
|
|
3
|
-
<${
|
|
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`
|
|
3
|
+
<${k} ${y.renderAttrs(X)}>
|
|
4
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
7
|
<span class="${p.prefix}-code-lang">${e.utils.escapeHtml(ee)}</span>
|
|
8
8
|
<span class="${p.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
|
-
</${
|
|
15
|
-
`}let
|
|
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+=`
|
|
16
16
|
<li>
|
|
17
17
|
<input
|
|
18
18
|
type="radio"
|
|
19
19
|
id="label-${p.prefix}-codetab-label-1-${d}-${g}-${T-g}"
|
|
20
20
|
name="${p.prefix}-codetab-label-${d}-${g}"
|
|
21
|
-
class="${
|
|
21
|
+
class="${k}"
|
|
22
22
|
${P}
|
|
23
23
|
>
|
|
24
24
|
<label
|
|
25
25
|
for="label-${p.prefix}-codetab-label-1-${d}-${g}-${T-g}"
|
|
26
|
-
onclick="this.getRootNode().querySelectorAll('.${
|
|
26
|
+
onclick="this.getRootNode().querySelectorAll('.${k}').forEach(e => e.click())"
|
|
27
27
|
>
|
|
28
|
-
${e.utils.escapeHtml(N||i(
|
|
28
|
+
${e.utils.escapeHtml(N||i(R))}
|
|
29
29
|
</label>
|
|
30
30
|
</li>`,D+=`
|
|
31
31
|
<div role="tabpanel">
|
|
32
32
|
<input
|
|
33
33
|
type="radio"
|
|
34
34
|
name="${p.prefix}-codetab-pre-${d}-${g}"
|
|
35
|
-
class="${
|
|
35
|
+
class="${k}"
|
|
36
36
|
${P}
|
|
37
37
|
role="presentation">
|
|
38
38
|
${a(m,T,b,v,y)}
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
<input
|
|
41
41
|
type="radio"
|
|
42
42
|
name="${p.prefix}-codetab-lang-${d}-${g}"
|
|
43
|
-
class="${
|
|
43
|
+
class="${k}"
|
|
44
44
|
${P}
|
|
45
45
|
role="presentation">
|
|
46
|
-
<span class=${p.prefix}-code-lang role="note">${e.utils.escapeHtml(i(
|
|
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`
|
|
47
47
|
<${H} ${y.renderAttrs(F)}>
|
|
48
48
|
<${L} class="${p.prefix}-code-head">
|
|
49
49
|
<div class="${p.prefix}-code-flag">
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<span class="${p.prefix}-codetab-lang">${z}</span>
|
|
54
54
|
<span class="${p.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
|
-
${H==="details"?
|
|
56
|
+
${H==="details"?A:""}
|
|
57
57
|
</div>
|
|
58
58
|
</${L}>
|
|
59
59
|
${D}
|
|
@@ -61,8 +61,8 @@
|
|
|
61
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
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],
|
|
65
|
-
`)})));let B=()=>{},D=()=>{};const z=()=>{const
|
|
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],(
|
|
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
67
|
`),g=m[Number(c)].replace(se[i].regexp,se[i].value);e.previewOnly?(m[Number(c)]=g,e.onChange(m.join(`
|
|
68
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;
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -591,13 +591,12 @@ $$`, "title")
|
|
|
591
591
|
onClick: m
|
|
592
592
|
}, [a(k, {
|
|
593
593
|
name: "delete"
|
|
594
|
-
}, null)])]) : a("
|
|
594
|
+
}, null)])]) : a("button", {
|
|
595
595
|
class: `${l}-clip-upload`,
|
|
596
|
+
type: "button",
|
|
596
597
|
onClick: () => {
|
|
597
598
|
s.value.click();
|
|
598
599
|
},
|
|
599
|
-
role: "button",
|
|
600
|
-
tabindex: "0",
|
|
601
600
|
"aria-label": t.value.imgTitleItem?.upload
|
|
602
601
|
}, [a(k, {
|
|
603
602
|
name: "upload"
|
package/lib/es/chunks/dom.mjs
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { p as
|
|
3
|
-
const
|
|
4
|
-
copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${
|
|
5
|
-
"collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${
|
|
6
|
-
pin: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin ${
|
|
7
|
-
"pin-off": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin-off ${
|
|
8
|
-
check: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check ${
|
|
9
|
-
}, p = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import X from "@vavt/copy2clipboard";
|
|
2
|
+
import { p as l } from "./config.mjs";
|
|
3
|
+
const A = {
|
|
4
|
+
copy: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy ${l}-icon"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,
|
|
5
|
+
"collapse-tips": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-chevron-left ${l}-icon"><circle cx="12" cy="12" r="10"/><path d="m14 16-4-4 4-4"/></svg>`,
|
|
6
|
+
pin: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin ${l}-icon"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg>`,
|
|
7
|
+
"pin-off": `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pin-off ${l}-icon"><path d="M12 17v5"/><path d="M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89"/><path d="m2 2 20 20"/><path d="M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11"/></svg>`,
|
|
8
|
+
check: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check ${l}-icon"><path d="M20 6 9 17l-5-5"/></svg>`
|
|
9
|
+
}, p = (r, e) => typeof e[r] == "string" ? e[r] : A[r], B = (r) => Array.from(
|
|
10
|
+
r.querySelectorAll(
|
|
11
|
+
'a[href], button, input, select, textarea, [tabindex], [contenteditable]:not([contenteditable="false"])'
|
|
12
|
+
)
|
|
13
|
+
).filter(
|
|
14
|
+
(e) => (
|
|
15
|
+
// contenteditable 未声明 tabindex 时仍可通过 Tab 访问,但其 tabIndex 为 -1。
|
|
16
|
+
(e.tabIndex >= 0 || e.isContentEditable && !e.hasAttribute("tabindex")) && !e.matches(':disabled, [aria-disabled="true"]') && !e.closest('[hidden], [inert], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility === "visible"
|
|
17
|
+
)
|
|
18
|
+
), z = (r, e) => {
|
|
19
|
+
const t = (c) => {
|
|
20
|
+
const o = r.parentElement || document.body, s = o.offsetWidth, i = o.offsetHeight, { clientWidth: a, clientHeight: u } = document.documentElement, d = c.offsetX, w = c.offsetY, g = (y) => {
|
|
21
|
+
let h = y.x + document.body.scrollLeft - document.body.clientLeft - d, m = y.y + document.body.scrollTop - document.body.clientTop - w;
|
|
22
|
+
h = h < 1 ? 1 : h < a - s - 1 ? h : a - s - 1, m = m < 1 ? 1 : m < u - i - 1 ? m : u - i - 1, e ? e(h, m) : (o.style.left = `${h}px`, o.style.top = `${m}px`);
|
|
14
23
|
};
|
|
15
24
|
document.addEventListener("mousemove", g);
|
|
16
25
|
const v = () => {
|
|
@@ -18,142 +27,143 @@ const j = {
|
|
|
18
27
|
};
|
|
19
28
|
document.addEventListener("mouseup", v);
|
|
20
29
|
};
|
|
21
|
-
return
|
|
22
|
-
|
|
30
|
+
return r.addEventListener("mousedown", t), () => {
|
|
31
|
+
r.removeEventListener("mousedown", t);
|
|
23
32
|
};
|
|
24
|
-
},
|
|
25
|
-
const c = document.getElementById(
|
|
33
|
+
}, I = (r, e, t = "") => {
|
|
34
|
+
const c = document.getElementById(e.id);
|
|
26
35
|
if (c)
|
|
27
|
-
|
|
36
|
+
t !== "" && (Reflect.get(window, t) ? e.onload?.call(c, new Event("load")) : e.onload && c.addEventListener("load", e.onload));
|
|
28
37
|
else {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
38
|
+
const o = { ...e };
|
|
39
|
+
o.onload = null;
|
|
40
|
+
const s = j(r, o);
|
|
41
|
+
e.onload && s.addEventListener("load", e.onload), document.head.appendChild(s);
|
|
33
42
|
}
|
|
34
|
-
},
|
|
35
|
-
document.getElementById(
|
|
36
|
-
},
|
|
37
|
-
const
|
|
38
|
-
return Object.keys(
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
},
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
let
|
|
45
|
-
|
|
43
|
+
}, V = (r, e) => {
|
|
44
|
+
document.getElementById(e.id)?.remove(), I(r, e);
|
|
45
|
+
}, j = (r, e) => {
|
|
46
|
+
const t = document.createElement(r);
|
|
47
|
+
return Object.keys(e).forEach((c) => {
|
|
48
|
+
e[c] !== void 0 && (t[c] = e[c]);
|
|
49
|
+
}), t;
|
|
50
|
+
}, R = (r, e) => {
|
|
51
|
+
const t = /* @__PURE__ */ new Map();
|
|
52
|
+
return r?.forEach((c) => {
|
|
53
|
+
let o = c.querySelector(`.${l}-mermaid-action`);
|
|
54
|
+
o ? o.querySelector(`.${l}-mermaid-copy`) || o.insertAdjacentHTML(
|
|
46
55
|
"beforeend",
|
|
47
|
-
`<span class="${
|
|
56
|
+
`<span class="${l}-mermaid-copy">${p("copy", e.customIcon)}</span>`
|
|
48
57
|
) : (c.insertAdjacentHTML(
|
|
49
58
|
"beforeend",
|
|
50
|
-
`<div class="${
|
|
51
|
-
),
|
|
52
|
-
const
|
|
53
|
-
let
|
|
54
|
-
const
|
|
55
|
-
clearTimeout(
|
|
56
|
-
|
|
59
|
+
`<div class="${l}-mermaid-action"><span class="${l}-mermaid-copy">${p("copy", e.customIcon)}</span></div>`
|
|
60
|
+
), o = c.querySelector(`.${l}-mermaid-action`));
|
|
61
|
+
const s = o.querySelector(`.${l}-mermaid-copy`);
|
|
62
|
+
let i = -1;
|
|
63
|
+
const a = () => {
|
|
64
|
+
clearTimeout(i), X(c.dataset.content || "").then(() => {
|
|
65
|
+
s.innerHTML = p("check", e.customIcon);
|
|
57
66
|
}).catch(() => {
|
|
58
|
-
|
|
67
|
+
s.innerHTML = p("copy", e.customIcon);
|
|
59
68
|
}).finally(() => {
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
i = window.setTimeout(() => {
|
|
70
|
+
s.innerHTML = p("copy", e.customIcon);
|
|
62
71
|
}, 1500);
|
|
63
72
|
});
|
|
64
73
|
};
|
|
65
|
-
|
|
74
|
+
s.addEventListener("click", a), t.set(c, {
|
|
66
75
|
removeClick: () => {
|
|
67
|
-
|
|
76
|
+
s.removeEventListener("click", a);
|
|
68
77
|
}
|
|
69
78
|
});
|
|
70
79
|
}), () => {
|
|
71
|
-
|
|
80
|
+
t.forEach(({ removeClick: c }) => {
|
|
72
81
|
c?.();
|
|
73
|
-
}),
|
|
82
|
+
}), t.clear();
|
|
74
83
|
};
|
|
75
|
-
},
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
84
|
+
}, W = /* @__PURE__ */ (() => {
|
|
85
|
+
const r = (t) => {
|
|
86
|
+
if (!t)
|
|
78
87
|
return () => {
|
|
79
88
|
};
|
|
80
|
-
const c =
|
|
81
|
-
let
|
|
89
|
+
const c = t.firstChild;
|
|
90
|
+
let o = 1, s = 0, i = 0, a = !1, u, d, w, g = 1;
|
|
82
91
|
const v = () => {
|
|
83
|
-
c.style.transform = `translate(${
|
|
84
|
-
}, y = (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
), g =
|
|
89
|
-
}, h = (
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
else if (
|
|
92
|
+
c.style.transform = `translate(${s}px, ${i}px) scale(${o})`;
|
|
93
|
+
}, y = (n) => {
|
|
94
|
+
n.touches.length === 1 ? (a = !0, u = n.touches[0].clientX - s, d = n.touches[0].clientY - i) : n.touches.length === 2 && (w = Math.hypot(
|
|
95
|
+
n.touches[0].clientX - n.touches[1].clientX,
|
|
96
|
+
n.touches[0].clientY - n.touches[1].clientY
|
|
97
|
+
), g = o);
|
|
98
|
+
}, h = (n) => {
|
|
99
|
+
if (n.preventDefault(), a && n.touches.length === 1)
|
|
100
|
+
s = n.touches[0].clientX - u, i = n.touches[0].clientY - d, v();
|
|
101
|
+
else if (n.touches.length === 2) {
|
|
93
102
|
const E = Math.hypot(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
) / w, f =
|
|
97
|
-
|
|
98
|
-
const M = (
|
|
99
|
-
|
|
103
|
+
n.touches[0].clientX - n.touches[1].clientX,
|
|
104
|
+
n.touches[0].clientY - n.touches[1].clientY
|
|
105
|
+
) / w, f = o;
|
|
106
|
+
o = g * (1 + (E - 1));
|
|
107
|
+
const M = (n.touches[0].clientX + n.touches[1].clientX) / 2, k = (n.touches[0].clientY + n.touches[1].clientY) / 2, S = c.getBoundingClientRect(), Y = (M - S.left) / f, H = (k - S.top) / f;
|
|
108
|
+
s -= Y * (o - f), i -= H * (o - f), v();
|
|
100
109
|
}
|
|
101
110
|
}, m = () => {
|
|
102
|
-
|
|
103
|
-
}, $ = (
|
|
104
|
-
|
|
105
|
-
const L = 0.02, E =
|
|
106
|
-
|
|
107
|
-
const f = c.getBoundingClientRect(), M =
|
|
108
|
-
|
|
109
|
-
}, x = (
|
|
110
|
-
|
|
111
|
-
}, C = (
|
|
112
|
-
|
|
111
|
+
a = !1;
|
|
112
|
+
}, $ = (n) => {
|
|
113
|
+
n.preventDefault();
|
|
114
|
+
const L = 0.02, E = o;
|
|
115
|
+
n.deltaY < 0 ? o += L : o = Math.max(0.1, o - L);
|
|
116
|
+
const f = c.getBoundingClientRect(), M = n.clientX - f.left, k = n.clientY - f.top;
|
|
117
|
+
s -= M / E * (o - E), i -= k / E * (o - E), v();
|
|
118
|
+
}, x = (n) => {
|
|
119
|
+
a = !0, u = n.clientX - s, d = n.clientY - i;
|
|
120
|
+
}, C = (n) => {
|
|
121
|
+
a && (s = n.clientX - u, i = n.clientY - d, v());
|
|
122
|
+
}, b = () => {
|
|
123
|
+
a = !1;
|
|
113
124
|
}, T = () => {
|
|
114
|
-
|
|
115
|
-
}, Y = () => {
|
|
116
|
-
l = !1;
|
|
125
|
+
a = !1;
|
|
117
126
|
};
|
|
118
|
-
return
|
|
119
|
-
|
|
127
|
+
return t.addEventListener("touchstart", y, { passive: !1 }), t.addEventListener("touchmove", h, { passive: !1 }), t.addEventListener("touchend", m), t.addEventListener("wheel", $, { passive: !1 }), t.addEventListener("mousedown", x), t.addEventListener("mousemove", C), t.addEventListener("mouseup", b), t.addEventListener("mouseleave", T), () => {
|
|
128
|
+
t.removeEventListener("touchstart", y), t.removeEventListener("touchmove", h), t.removeEventListener("touchend", m), t.removeEventListener("wheel", $), t.removeEventListener("mousedown", x), t.removeEventListener("mousemove", C), t.removeEventListener("mouseup", b), t.removeEventListener("mouseleave", T);
|
|
120
129
|
};
|
|
121
130
|
};
|
|
122
|
-
return (
|
|
123
|
-
const
|
|
124
|
-
return
|
|
125
|
-
let
|
|
126
|
-
|
|
131
|
+
return (t, c) => {
|
|
132
|
+
const o = /* @__PURE__ */ new Map();
|
|
133
|
+
return t?.forEach((s) => {
|
|
134
|
+
let i = s.querySelector(`.${l}-mermaid-action`);
|
|
135
|
+
i ? i.querySelector(`.${l}-mermaid-zoom`) || i.insertAdjacentHTML(
|
|
127
136
|
"beforeend",
|
|
128
|
-
`<span class="${
|
|
129
|
-
) : (
|
|
137
|
+
`<span class="${l}-mermaid-zoom">${p("pin-off", c.customIcon)}</span>`
|
|
138
|
+
) : (s.insertAdjacentHTML(
|
|
130
139
|
"beforeend",
|
|
131
|
-
`<div class="${
|
|
132
|
-
),
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
140
|
+
`<div class="${l}-mermaid-action"><span class="${l}-mermaid-zoom">${p("pin-off", c.customIcon)}</span></div>`
|
|
141
|
+
), i = s.querySelector(`.${l}-mermaid-action`));
|
|
142
|
+
const a = i.querySelector(`.${l}-mermaid-zoom`), u = () => {
|
|
143
|
+
const d = o.get(s);
|
|
144
|
+
if (d?.removeEvent)
|
|
145
|
+
d.removeEvent(), s.removeAttribute("data-grab"), o.set(s, { removeClick: d.removeClick }), a.innerHTML = p("pin-off", c.customIcon);
|
|
137
146
|
else {
|
|
138
|
-
const w =
|
|
139
|
-
|
|
147
|
+
const w = r(s);
|
|
148
|
+
s.setAttribute("data-grab", ""), o.set(s, { removeEvent: w, removeClick: d?.removeClick }), a.innerHTML = p("pin", c.customIcon);
|
|
140
149
|
}
|
|
141
150
|
};
|
|
142
|
-
|
|
143
|
-
removeClick: () =>
|
|
151
|
+
a.addEventListener("click", u), o.set(s, {
|
|
152
|
+
removeClick: () => a.removeEventListener("click", u)
|
|
144
153
|
});
|
|
145
154
|
}), () => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}),
|
|
155
|
+
o.forEach(({ removeEvent: s, removeClick: i }) => {
|
|
156
|
+
s?.(), i?.();
|
|
157
|
+
}), o.clear();
|
|
149
158
|
};
|
|
150
159
|
};
|
|
151
160
|
})();
|
|
152
161
|
export {
|
|
153
162
|
p as S,
|
|
154
|
-
|
|
155
|
-
|
|
163
|
+
I as a,
|
|
164
|
+
R as c,
|
|
165
|
+
B as g,
|
|
156
166
|
z as k,
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
V as u,
|
|
168
|
+
W as z
|
|
159
169
|
};
|