md-editor-v3 4.0.3 → 4.0.4-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,9 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 imzbf.cc
3
+ Copyright (c) 2021 imzbf.top
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
8
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1 +1 @@
1
- "use strict";const o=require("vue"),h=require("./chunks/config.cjs"),T=require("./chunks/index4.cjs"),y=require("./chunks/event-bus.cjs"),x={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},C=o.defineComponent({props:x,setup(l){return()=>{const{tocItem:c,mdHeadingId:d,scrollElement:n,onClick:u,scrollElementOffsetTop:p}=l;return o.createVNode("div",{class:[`${h.prefix}-catalog-link`,c.active&&`${h.prefix}-catalog-active`],onClick:r=>{u(r,c),r.stopPropagation();const E=d(c.text,c.level,c.index),m=document.getElementById(E),e=n instanceof Element?n:document.querySelector(n);if(m&&e){let t=m.offsetParent,s=m.offsetTop;if(e.contains(t))for(;t&&e!=t;)s+=t==null?void 0:t.offsetTop,t=t==null?void 0:t.offsetParent;e==null||e.scrollTo({top:s-p,behavior:"smooth"})}}},[o.createVNode("span",{title:c.text},[c.text]),o.createVNode("div",{class:`${h.prefix}-catalog-wrapper`},[c.children&&c.children.map(r=>o.createVNode(C,{mdHeadingId:d,key:`${c.text}-link-${r.level}-${r.text}`,tocItem:r,scrollElement:n,onClick:u,scrollElementOffsetTop:p},null))])])}}}),H=C,$={editorId:{type:String},class:{type:String,default:""},mdHeadingId:{type:Function,default:l=>l},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function}},b=o.defineComponent({name:"MdCatalog",props:$,emits:["onClick"],setup(l,c){const d=l.editorId,n=o.reactive({list:[],show:!1,scrollElement:l.scrollElement||`#${d}-preview-wrapper`}),u=o.shallowRef(),p=o.computed(()=>{const e=[];return n.list.forEach((t,s)=>{const{text:g,level:I}=t,i={level:I,text:g,index:s+1,active:u.value===t};if(e.length===0)e.push(i);else{let a=e[e.length-1];if(i.level>a.level)for(let f=a.level+1;f<=6;f++){const{children:v}=a;if(!v){a.children=[i];break}if(a=v[v.length-1],i.level<=a.level){v.push(i);break}}else e.push(i)}}),e}),r=()=>n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement),E=T.throttle(e=>{if(e.length===0)return n.list=[],!1;const{activeHead:t}=e.reduce((s,g,I)=>{const i=document.getElementById(l.mdHeadingId(g.text,g.level,I+1));if(i instanceof HTMLElement){const a=r(),f=T.getRelativeTop(i,a);if(f<l.offsetTop&&f>s.minTop)return{activeHead:g,minTop:f}}return s},{activeHead:e[0],minTop:Number.MIN_SAFE_INTEGER});u.value=t,n.list=e}),m=()=>{E(n.list)};return o.onMounted(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.addEventListener("scroll",m),y.bus.on(d,{name:"catalogChanged",callback:s=>{E(s)}}),y.bus.emit(d,"pushCatalog")}),o.onBeforeUnmount(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.removeEventListener("scroll",m)}),()=>o.createVNode("div",{class:`${h.prefix}-catalog${l.theme==="dark"?"-dark":""} ${l.class}`},[p.value.map(e=>o.createVNode(H,{mdHeadingId:l.mdHeadingId,tocItem:e,key:`link-${e.level}-${e.text}`,scrollElement:n.scrollElement,onClick:(t,s)=>{l.onClick?l.onClick(t,s):c.emit("onClick",t,s)},scrollElementOffsetTop:l.scrollElementOffsetTop},null))])}}),k=b;k.install=l=>(l.component(k.name,k),l);module.exports=k;
1
+ "use strict";const o=require("vue"),C=require("@vavt/util"),h=require("./chunks/config.cjs"),T=require("./chunks/index4.cjs"),x={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},scrollElement:{type:[String,Object],default:""},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},y=o.defineComponent({props:x,setup(l){return()=>{const{tocItem:c,mdHeadingId:d,scrollElement:n,onClick:u,scrollElementOffsetTop:p}=l;return o.createVNode("div",{class:[`${h.prefix}-catalog-link`,c.active&&`${h.prefix}-catalog-active`],onClick:r=>{u(r,c),r.stopPropagation();const E=d(c.text,c.level,c.index),m=document.getElementById(E),e=n instanceof Element?n:document.querySelector(n);if(m&&e){let t=m.offsetParent,s=m.offsetTop;if(e.contains(t))for(;t&&e!=t;)s+=t==null?void 0:t.offsetTop,t=t==null?void 0:t.offsetParent;e==null||e.scrollTo({top:s-p,behavior:"smooth"})}}},[o.createVNode("span",{title:c.text},[c.text]),o.createVNode("div",{class:`${h.prefix}-catalog-wrapper`},[c.children&&c.children.map(r=>o.createVNode(y,{mdHeadingId:d,key:`${c.text}-link-${r.level}-${r.text}`,tocItem:r,scrollElement:n,onClick:u,scrollElementOffsetTop:p},null))])])}}}),H=y,$={editorId:{type:String},class:{type:String,default:""},mdHeadingId:{type:Function,default:l=>l},scrollElement:{type:[String,Object]},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function}},b=o.defineComponent({name:"MdCatalog",props:$,emits:["onClick"],setup(l,c){const d=l.editorId,n=o.reactive({list:[],show:!1,scrollElement:l.scrollElement||`#${d}-preview-wrapper`}),u=o.shallowRef(),p=o.computed(()=>{const e=[];return n.list.forEach((t,s)=>{const{text:g,level:I}=t,i={level:I,text:g,index:s+1,active:u.value===t};if(e.length===0)e.push(i);else{let a=e[e.length-1];if(i.level>a.level)for(let f=a.level+1;f<=6;f++){const{children:v}=a;if(!v){a.children=[i];break}if(a=v[v.length-1],i.level<=a.level){v.push(i);break}}else e.push(i)}}),e}),r=()=>n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement),E=C.throttle(e=>{if(e.length===0)return n.list=[],!1;const{activeHead:t}=e.reduce((s,g,I)=>{const i=document.getElementById(l.mdHeadingId(g.text,g.level,I+1));if(i instanceof HTMLElement){const a=r(),f=T.getRelativeTop(i,a);if(f<l.offsetTop&&f>s.minTop)return{activeHead:g,minTop:f}}return s},{activeHead:e[0],minTop:Number.MIN_SAFE_INTEGER});u.value=t,n.list=e}),m=()=>{E(n.list)};return o.onMounted(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.addEventListener("scroll",m),T.bus.on(d,{name:"catalogChanged",callback:s=>{E(s)}}),T.bus.emit(d,"pushCatalog")}),o.onBeforeUnmount(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.removeEventListener("scroll",m)}),()=>o.createVNode("div",{class:`${h.prefix}-catalog${l.theme==="dark"?"-dark":""} ${l.class}`},[p.value.map(e=>o.createVNode(H,{mdHeadingId:l.mdHeadingId,tocItem:e,key:`link-${e.level}-${e.text}`,scrollElement:n.scrollElement,onClick:(t,s)=>{l.onClick?l.onClick(t,s):c.emit("onClick",t,s)},scrollElementOffsetTop:l.scrollElementOffsetTop},null))])}}),k=b;k.install=l=>(l.component(k.name,k),l);module.exports=k;
@@ -1,21 +1,21 @@
1
- "use strict";var qe=Object.defineProperty;var Re=(t,a,r)=>a in t?qe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r;var q=(t,a,r)=>(Re(t,typeof a!="symbol"?a+"":a,r),r);const e=require("vue"),l=require("./chunks/config.cjs"),K=require("./chunks/index2.cjs"),h=require("./chunks/event-bus.cjs"),ie=require("./chunks/index4.cjs"),w=require("./chunks/index.cjs"),Pe=require("./chunks/dom.cjs"),ne=require("./chunks/index3.cjs"),Y=require("codemirror"),X=require("@codemirror/view"),je=require("@codemirror/language-data"),Ge=require("@codemirror/lang-markdown"),oe=require("@codemirror/commands"),Q=require("@codemirror/language"),n=require("@lezer/highlight"),R=require("@codemirror/state"),Ne=require("./chunks/vue-tsx.cjs"),Oe=require("./MdCatalog.cjs"),Ue=require("./NormalToolbar.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");const Ke=e.defineComponent({setup(){return()=>e.createVNode("div",{class:`${l.prefix}-divider`},null)}}),_e={noPrettier:{type:Boolean},toolbars:{type:Array,default:()=>[]},toolbarsExclude:{type:Array,default:()=>[]},setting:{type:Object,default:()=>({})},screenfull:{type:Object,default:null},screenfullJs:{type:String,default:""},updateSetting:{type:Function,default:()=>{}},tableShape:{type:Array,default:()=>[6,4]},defToolbars:{type:Object},noUploadImg:{type:Boolean}},We=t=>{var g,d,u,v;const a=e.inject("editorId");let r=(d=(g=l.configOption.editorExtensions)==null?void 0:g.screenfull)==null?void 0:d.instance;const o=(v=(u=l.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:v.js,c=e.ref(!1),i=k=>{if(!r){h.bus.emit(a,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}r.isEnabled?(c.value=!0,(k===void 0?!r.isFullscreen:k)?r.request():r.exit()):console.error("browser does not support screenfull!")},s=()=>{r&&r.isEnabled&&r.on("change",()=>{(c.value||t.setting.fullscreen)&&(c.value=!1,t.updateSetting("fullscreen"))})},m=()=>{r=window.screenfull,s()};return e.onMounted(()=>{if(s(),!r){const k=document.createElement("script");k.src=o||l.screenfullUrl,k.onload=m,k.id=`${l.prefix}-screenfull`,Pe.appendHandler(k,"screenfull")}}),e.onMounted(()=>{h.bus.on(a,{name:w.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},ze={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},Ye=e.defineComponent({name:"TableShape",props:ze,setup(t){const a=e.reactive({x:-1,y:-1});return()=>e.createVNode("div",{class:`${l.prefix}-table-shape`,onMouseleave:()=>{a.x=-1,a.y=-1}},[new Array(t.tableShape[1]).fill("").map((r,o)=>e.createVNode("div",{class:`${l.prefix}-table-shape-row`,key:`table-shape-row-${o}`},[new Array(t.tableShape[0]).fill("").map((c,i)=>e.createVNode("div",{class:`${l.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{a.x=o,a.y=i},onClick:()=>{t.onSelected(a)}},[e.createVNode("div",{class:[`${l.prefix}-table-shape-col-default`,o<=a.x&&i<=a.y&&`${l.prefix}-table-shape-col-include`]},null)]))]))])}}),Ze=Ye,Je={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Xe=e.defineComponent({props:Je,setup(t){const a=e.inject("usedLanguageText"),r=e.inject("editorId"),o=e.computed(()=>{var i,s;switch(t.type){case"link":return(i=a.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(s=a.value.linkModalTips)==null?void 0:s.imageTitle;default:return""}}),c=e.reactive({desc:"",url:""});return e.watch(()=>t.visible,i=>{i||setTimeout(()=>{c.desc="",c.url=""},200)}),()=>e.createVNode(ne.Modal,{title:o.value,visible:t.visible,onClose:t.onCancel},{default:()=>{var i,s,m,g,d;return[e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("label",{class:`${l.prefix}-label`,for:`link-desc-${r}`},[(i=a.value.linkModalTips)==null?void 0:i.descLabel]),e.createVNode("input",{placeholder:(s=a.value.linkModalTips)==null?void 0:s.descLabelPlaceHolder,class:`${l.prefix}-input`,id:`link-desc-${r}`,type:"text",value:c.desc,onChange:u=>{c.desc=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("label",{class:`${l.prefix}-label`,for:`link-url-${r}`},[(m=a.value.linkModalTips)==null?void 0:m.urlLabel]),e.createVNode("input",{placeholder:(g=a.value.linkModalTips)==null?void 0:g.urlLabelPlaceHolder,class:`${l.prefix}-input`,id:`link-url-${r}`,type:"text",value:c.url,onChange:u=>{c.url=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("button",{class:[`${l.prefix}-btn`,`${l.prefix}-btn-row`],type:"button",onClick:()=>{t.onOk(c),c.desc="",c.url=""}},[(d=a.value.linkModalTips)==null?void 0:d.buttonOK])])]}})}}),Qe={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},et=e.defineComponent({props:Qe,setup(t){var u,v,k;const a=e.inject("usedLanguageText"),r=e.inject("editorId");let o=(k=(v=(u=l.configOption)==null?void 0:u.editorExtensions)==null?void 0:v.cropper)==null?void 0:k.instance;const c=e.ref(),i=e.ref(),s=e.ref(),m=e.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let g=null;e.watch(()=>t.visible,()=>{t.visible&&!m.cropperInited&&(o=o||window.Cropper,c.value.onchange=()=>{if(!o){h.bus.emit(r,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const b=c.value.files||[];if(m.imgSelected=!0,(b==null?void 0:b.length)>0){const p=new FileReader;p.onload=f=>{m.imgSrc=f.target.result,e.nextTick(()=>{g=new o(i.value,{viewMode:2,preview:`.${l.prefix}-clip-preview-target`})})},p.readAsDataURL(b[0])}})}),e.watch(()=>[m.imgSelected],()=>{s.value.style=""}),e.watch(()=>m.isFullscreen,()=>{e.nextTick(()=>{g==null||g.destroy(),s.value.style="",i.value&&(g=new o(i.value,{viewMode:2,preview:`.${l.prefix}-clip-preview-target`}))})});const d=()=>{g.clear(),g.destroy(),g=null,c.value.value="",m.imgSelected=!1};return()=>{var b;return e.createVNode(ne.Modal,{class:`${l.prefix}-modal-clip`,title:(b=a.value.clipModalTips)==null?void 0:b.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:m.isFullscreen,onAdjust:p=>{m.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,f;return[e.createVNode("div",{class:`${l.prefix}-form-item ${l.prefix}-clip`},[e.createVNode("div",{class:`${l.prefix}-clip-main`},[m.imgSelected?e.createVNode("div",{class:`${l.prefix}-clip-cropper`},[e.createVNode("img",{src:m.imgSrc,ref:i,style:{display:"none"},alt:""},null),e.createVNode("div",{class:`${l.prefix}-clip-delete`,onClick:d},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):e.createVNode("div",{class:`${l.prefix}-clip-upload`,onClick:()=>{c.value.click()}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),e.createVNode("div",{class:`${l.prefix}-clip-preview`},[e.createVNode("div",{class:`${l.prefix}-clip-preview-target`,ref:s},null)])]),e.createVNode("div",{class:`${l.prefix}-form-item`},[e.createVNode("button",{class:`${l.prefix}-btn`,type:"button",onClick:()=>{if(g){const x=g.getCroppedCanvas();h.bus.emit(r,"uploadImage",[ie.base642File(x.toDataURL("image/png"))],t.onOk),d()}}},[((p=a.value.clipModalTips)==null?void 0:p.buttonUpload)||((f=a.value.linkModalTips)==null?void 0:f.buttonOK)])]),e.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),tt={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},ot=e.defineComponent({props:tt,setup(t){return()=>e.createVNode(e.Fragment,null,[e.createVNode(Xe,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),e.createVNode(et,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),lt=e.defineComponent({name:"MDEditorToolbar",props:_e,setup(t){const a=e.inject("editorId"),r=e.inject("usedLanguageText"),{fullscreenHandler:o}=We(t),c=`${a}-toolbar-wrapper`,i=e.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),s=(b,p)=>{h.bus.emit(a,"replace",b,p)},m=e.reactive({type:"link",linkVisible:!1,clipVisible:!1}),g=e.ref();e.onMounted(()=>{h.bus.on(a,{name:"openModals",callback(b){m.type=b,m.linkVisible=!0}})});const d=e.computed(()=>{const b=t.toolbars.filter($=>!t.toolbarsExclude.includes($)),p=b.indexOf("="),f=p===-1?b:b.slice(0,p+1),x=p===-1?[]:b.slice(p,Number.MAX_SAFE_INTEGER);return[f,x]}),u=e.ref(),v=()=>{h.bus.emit(a,"uploadImage",Array.from(u.value.files||[])),u.value.value=""};e.onMounted(()=>{u.value.addEventListener("change",v)});const k=b=>{var p,f,x,$,y,N,T,C,S,B,M,A,L,H,E,P,I,ee,_,j,O,W,G,D,F,z,te,ce,se,de,ue,fe,ge,me,he,be,pe,ve,ke,xe,Ce,Ve,$e;if(l.allToolbar.includes(b))switch(b){case"-":return e.createVNode(Ke,null,null);case"bold":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(p=r.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{s("bold")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(f=r.value.toolbarTips)==null?void 0:f.underline,onClick:()=>{s("underline")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(x=r.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{s("italic")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:($=r.value.toolbarTips)==null?void 0:$.strikeThrough,onClick:()=>{s("strikeThrough")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.title,onChange:V=>{i.title=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h1")}},[(y=r.value.titleItem)==null?void 0:y.h1]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h2")}},[(N=r.value.titleItem)==null?void 0:N.h2]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h3")}},[(T=r.value.titleItem)==null?void 0:T.h3]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h4")}},[(C=r.value.titleItem)==null?void 0:C.h4]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h5")}},[(S=r.value.titleItem)==null?void 0:S.h5]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("h6")}},[(B=r.value.titleItem)==null?void 0:B.h6])])},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.title},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(M=r.value.toolbarTips)==null?void 0:M.sub,onClick:()=>{s("sub")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(A=r.value.toolbarTips)==null?void 0:A.sup,onClick:()=>{s("sup")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(L=r.value.toolbarTips)==null?void 0:L.quote,onClick:()=>{s("quote")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(H=r.value.toolbarTips)==null?void 0:H.unorderedList,onClick:()=>{s("unorderedList")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(E=r.value.toolbarTips)==null?void 0:E.orderedList,onClick:()=>{s("orderedList")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(P=r.value.toolbarTips)==null?void 0:P.task,onClick:()=>{s("task")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(I=r.value.toolbarTips)==null?void 0:I.codeRow,onClick:()=>{s("codeRow")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ee=r.value.toolbarTips)==null?void 0:ee.code,onClick:()=>{s("code")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(_=r.value.toolbarTips)==null?void 0:_.link,onClick:()=>{m.type="link",m.linkVisible=!0}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(j=r.value.toolbarTips)==null?void 0:j.image,onClick:()=>{m.type="image",m.linkVisible=!0}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.image,onChange:V=>{i.image=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{m.type="image",m.linkVisible=!0}},[(O=r.value.imgTitleItem)==null?void 0:O.link]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{u.value.click()}},[(W=r.value.imgTitleItem)==null?void 0:W.upload]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{m.clipVisible=!0}},[(G=r.value.imgTitleItem)==null?void 0:G.clip2upload])])},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.image},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.table,onChange:V=>{i.table=V},key:"bar-table",overlay:e.createVNode(Ze,{tableShape:t.tableShape,onSelected:V=>{s("table",{selectedShape:V})}},null)},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.table},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(D=r.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{h.bus.emit(a,"ctrlZ")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(F=r.value.toolbarTips)==null?void 0:F.next,onClick:()=>{h.bus.emit(a,"ctrlShiftZ")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(z=r.value.toolbarTips)==null?void 0:z.save,onClick:()=>{h.bus.emit(a,w.ON_SAVE)}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(te=r.value.toolbarTips)==null?void 0:te.prettier,onClick:()=>{s("prettier")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ce=r.value.toolbarTips)==null?void 0:ce.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(se=r.value.toolbarTips)==null?void 0:se.fullscreen,onClick:()=>{o()}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(de=r.value.toolbarTips)==null?void 0:de.preview,onClick:()=>{t.updateSetting("preview")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ue=r.value.toolbarTips)==null?void 0:ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(fe=r.value.toolbarTips)==null?void 0:fe.catalog,onClick:()=>{h.bus.emit(a,w.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(ge=r.value.toolbarTips)==null?void 0:ge.github,onClick:()=>ie.goto("https://github.com/imzbf/md-editor-v3")},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.mermaid,onChange:V=>{i.mermaid=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.mermaid=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("flow")}},[(me=r.value.mermaid)==null?void 0:me.flow]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("sequence")}},[(he=r.value.mermaid)==null?void 0:he.sequence]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("gantt")}},[(be=r.value.mermaid)==null?void 0:be.gantt]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("class")}},[(pe=r.value.mermaid)==null?void 0:pe.class]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("state")}},[(ve=r.value.mermaid)==null?void 0:ve.state]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("pie")}},[(ke=r.value.mermaid)==null?void 0:ke.pie]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("relationship")}},[(xe=r.value.mermaid)==null?void 0:xe.relationship]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("journey")}},[(Ce=r.value.mermaid)==null?void 0:Ce.journey])]),key:"bar-mermaid"},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.mermaid},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.katex,onChange:V=>{i.katex=V},overlay:e.createVNode("ul",{class:`${l.prefix}-menu`,onClick:()=>{i.katex=!1}},[e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("katexInline")}},[(Ve=r.value.katex)==null?void 0:Ve.inline]),e.createVNode("li",{class:`${l.prefix}-menu-item`,onClick:()=>{s("katexBlock")}},[($e=r.value.katex)==null?void 0:$e.block])]),key:"bar-katex"},{default:()=>{var V;return[e.createVNode("div",{class:`${l.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.katex},[e.createVNode("svg",{class:`${l.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[b]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[b]||""};return()=>{const b=d.value[0].map(f=>k(f)),p=d.value[1].map(f=>k(f));return e.createVNode(e.Fragment,null,[t.toolbars.length>0&&e.createVNode("div",{class:`${l.prefix}-toolbar-wrapper`,id:c},[e.createVNode("div",{class:`${l.prefix}-toolbar`},[e.createVNode("div",{class:`${l.prefix}-toolbar-left`,ref:g},[b]),e.createVNode("div",{class:`${l.prefix}-toolbar-right`},[p])])]),e.createVNode("input",{ref:u,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),e.createVNode(ot,{linkVisible:m.linkVisible,clipVisible:m.clipVisible,type:m.type,onCancel:()=>{m.linkVisible=!1,m.clipVisible=!1},onOk:f=>{f&&s(m.type,{desc:f.desc,url:f.url}),m.linkVisible=!1,m.clipVisible=!1}},null)])}}}),at=(t,a,r)=>{let o=t.scrollTop;const c=()=>{const i=a-o;o=o+i/5,Math.abs(i)<1?(t.scrollTo(0,a),r&&setTimeout(r,100)):(t.scrollTo(0,o),requestAnimationFrame(c))};c()},ye=at,rt=(t,a)=>{const r=ie.debounce(()=>{t.removeEventListener("scroll",o),t.addEventListener("scroll",o),a.removeEventListener("scroll",o),a.addEventListener("scroll",o)},50),o=c=>{const i=t.clientHeight,s=a.clientHeight,m=t.scrollHeight,g=a.scrollHeight,d=(m-i)/(g-s);c.target===t?(a.removeEventListener("scroll",o),a.scrollTo({top:t.scrollTop/d}),r()):(t.removeEventListener("scroll",o),t.scrollTo({top:a.scrollTop*d}),r())};return[()=>{r().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",o),a.removeEventListener("scroll",o)}]},it=(t,a,r)=>{const{view:o}=r,c=v=>o.lineBlockAt(o.state.doc.line(v).from).top,i=v=>o.lineBlockAt(o.state.doc.line(v).from).height;let s=[];const m=()=>{s=[];const v=Array.from(a.querySelectorAll("[data-line]")).map(f=>Number(f.dataset.line)+1),{lines:k}=o.state.doc;let b=1,p=v.shift()??k;for(let f=1;f<=k;f++)f===p&&(b=f,p=v.shift()||k+1),s.push({start:b,end:p-1})};let g=0,d=0;const u=v=>{var p,f,x,$,y,N,T;if(!((p=a.firstElementChild)!=null&&p.firstElementChild))return;const k=o.lineBlockAtHeight(o.scrollDOM.scrollTop),{number:b}=o.state.doc.lineAt(k.from);if(!(b>s.length)&&!(o.state.doc.lines<s[s.length-1].end))if(v.target===t){if(d!==0)return;g++;const C=s[b-1],S=c(C.end)+i(C.end);let B=0;const M=c(C.start),A=a.querySelector(`[data-line="${C.start-1}"]`)||((f=a.firstElementChild)==null?void 0:f.firstElementChild),L=a.querySelector(`[data-line="${C.end}"]`)||((x=a.lastElementChild)==null?void 0:x.lastElementChild);let H=0,E=0;M===0?(B=(o.scrollDOM.scrollTop-M)/(S-M),H=L.offsetTop):S>o.scrollDOM.scrollHeight-o.scrollDOM.clientHeight?(B=(o.scrollDOM.scrollTop-M)/(o.scrollDOM.scrollHeight-o.scrollDOM.clientHeight-M),E=A.offsetTop,H=a.scrollHeight-a.clientHeight-E+10):(B=(o.scrollDOM.scrollTop-M)/(S-M),E=A.offsetTop,H=L.offsetTop-E);const P=E-10+H*B;ye(a,P,()=>{g--})}else{if(g!==0)return;d++;const C=Array.from(a.querySelectorAll("[data-line]")),S=a.scrollTop,B=a.scrollHeight;let M=C.length===0?1:Math.ceil(Number(C[C.length-1].dataset.line)*(S/B)),A=($=a.firstElementChild)==null?void 0:$.firstElementChild;for(let D=M;D>=0;D--){const F=a.querySelector(`[data-line="${D}"]`);if(F){A=F,M=D;break}}let L=(y=a.firstElementChild)==null?void 0:y.firstElementChild,H=(N=a.firstElementChild)==null?void 0:N.lastElementChild;for(;C.length>0;){const D=C.indexOf(A);if(D+1>=C.length)break;const F=C[D+1],z=A.offsetTop;if(z>S){if(D===0){L=A,H=F;break}A=C[D-1];continue}const te=F.offsetTop;if(z<=S&&te>S){L=A,H=F;break}A=F}const E=L.offsetTop,P=H.offsetTop;let I=0;const{start:ee,end:_}=s[Number(L.dataset.line||0)],j=c(ee);let O=c(_);const W=i(_);let G=0;L===((T=a.firstElementChild)==null?void 0:T.firstElementChild)?(I=Math.max(S/P,0),G=O+W-j):O>o.scrollDOM.scrollHeight-o.scrollDOM.clientHeight?(I=Math.max((S-E)/(a.scrollHeight-E-a.clientHeight),0),O=c(o.state.doc.lines)+i(o.state.doc.lines),G=8+O-j-t.clientHeight):(I=Math.max((S-E)/(P-E),0),G=O+W-j),ye(t,j+G*I,()=>{d--})}};return[()=>{m(),t.addEventListener("scroll",u),a.addEventListener("scroll",u),t.dispatchEvent(new Event("scroll"))},()=>{s=[],t.removeEventListener("scroll",u),a.removeEventListener("scroll",u)}]},nt=(t,a,r)=>{const o=e.inject("editorId");let c=()=>{},i=()=>{};const s=()=>{c();const m=document.querySelector(".cm-scroller"),g=document.querySelector(`[id="${o}-preview-wrapper"][data-show="true"]`),d=document.querySelector(`[id="${o}-html-wrapper"][data-show="true"]`);(g||d)&&([i,c]=(g?it:rt)(m,g||d,r.value)),t.scrollAuto&&i()};e.watch([a,e.toRef(t.setting,"preview"),e.toRef(t.setting,"htmlPreview"),e.toRef(t.setting,"fullscreen"),e.toRef(t.setting,"pageFullscreen")],()=>{e.nextTick(s)}),e.watch(()=>t.scrollAuto,m=>{m?i():c()}),e.onMounted(s)},ct=nt,st=(t,a,r)=>{var u,v,k,b,p,f;let o="",c=0,i=0,s=!0,m=!1;const g=a.getSelectedText(),d=(u=l.configOption.editorConfig)==null?void 0:u.mermaidTemplate;if(/^h[1-6]{1}$/.test(t)){const x=t.replace(/^h(\d)/,($,y)=>new Array(Number(y)).fill("#",0,y).join(""));o=`${x} ${g}`,c=x.length+1}else if(t==="prettier"){const x=window.prettier||((k=(v=l.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:k.prettierInstance),$=[((b=window.prettierPlugins)==null?void 0:b.markdown)||((f=(p=l.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.parserMarkdownInstance)];!x||$[0]===void 0?(h.bus.emit(r.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),o=a.getValue()):o=x.format(a.getValue(),{parser:"markdown",plugins:$}),s=!1,m=!0}else switch(t){case"bold":{o=`**${g}**`,c=2,i=-2;break}case"underline":{o=`<u>${g}</u>`,c=3,i=-4;break}case"italic":{o=`*${g}*`,c=1,i=-1;break}case"strikeThrough":{o=`~~${g}~~`,c=2,i=-2;break}case"sub":{o=`<sub>${g}</sub>`,c=5,i=-6;break}case"sup":{o=`<sup>${g}</sup>`,c=5,i=-6;break}case"codeRow":{o="`"+g+"`",c=1,i=-1;break}case"quote":{o=`> ${g}`,c=2;break}case"orderedList":{o=`1. ${g}`,c=3;break}case"unorderedList":{o=`- ${g}`,c=2;break}case"task":{o=`- [ ] ${g}`,c=6;break}case"code":{const x=r.text||g||"",$=r.mode||"language";o=`\`\`\`${$}
1
+ "use strict";var Oe=Object.defineProperty;var Re=(t,a,r)=>a in t?Oe(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r;var R=(t,a,r)=>(Re(t,typeof a!="symbol"?a+"":a,r),r);const e=require("vue"),o=require("./chunks/config.cjs"),K=require("./chunks/index2.cjs"),h=require("./chunks/index4.cjs"),X=require("@vavt/util"),w=require("./chunks/index.cjs"),qe=require("./chunks/dom.cjs"),ne=require("./chunks/index3.cjs"),Y=require("codemirror"),Q=require("@codemirror/view"),Pe=require("@codemirror/language-data"),je=require("@codemirror/lang-markdown"),le=require("@codemirror/commands"),ee=require("@codemirror/language"),n=require("@lezer/highlight"),q=require("@codemirror/state"),$e=require("./chunks/vue-tsx.cjs"),Be=require("./MdCatalog.cjs"),Ge=require("./NormalToolbar.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");const Ue=e.defineComponent({setup(){return()=>e.createVNode("div",{class:`${o.prefix}-divider`},null)}}),Ke={noPrettier:{type:Boolean},toolbars:{type:Array,default:()=>[]},toolbarsExclude:{type:Array,default:()=>[]},setting:{type:Object,default:()=>({})},screenfull:{type:Object,default:null},screenfullJs:{type:String,default:""},updateSetting:{type:Function,default:()=>{}},tableShape:{type:Array,default:()=>[6,4]},defToolbars:{type:Object},noUploadImg:{type:Boolean}},_e=t=>{var g,d,u,v;const a=e.inject("editorId");let r=(d=(g=o.configOption.editorExtensions)==null?void 0:g.screenfull)==null?void 0:d.instance;const l=(v=(u=o.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:v.js,c=e.ref(!1),i=k=>{if(!r){h.bus.emit(a,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}r.isEnabled?(c.value=!0,(k===void 0?!r.isFullscreen:k)?r.request():r.exit()):console.error("browser does not support screenfull!")},s=()=>{r&&r.isEnabled&&r.on("change",()=>{(c.value||t.setting.fullscreen)&&(c.value=!1,t.updateSetting("fullscreen"))})},m=()=>{r=window.screenfull,s()};return e.onMounted(()=>{if(s(),!r){const k=document.createElement("script");k.src=l||o.screenfullUrl,k.onload=m,k.id=`${o.prefix}-screenfull`,qe.appendHandler(k,"screenfull")}}),e.onMounted(()=>{h.bus.on(a,{name:w.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},We={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},ze=e.defineComponent({name:"TableShape",props:We,setup(t){const a=e.reactive({x:-1,y:-1});return()=>e.createVNode("div",{class:`${o.prefix}-table-shape`,onMouseleave:()=>{a.x=-1,a.y=-1}},[new Array(t.tableShape[1]).fill("").map((r,l)=>e.createVNode("div",{class:`${o.prefix}-table-shape-row`,key:`table-shape-row-${l}`},[new Array(t.tableShape[0]).fill("").map((c,i)=>e.createVNode("div",{class:`${o.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{a.x=l,a.y=i},onClick:()=>{t.onSelected(a)}},[e.createVNode("div",{class:[`${o.prefix}-table-shape-col-default`,l<=a.x&&i<=a.y&&`${o.prefix}-table-shape-col-include`]},null)]))]))])}}),Ye=ze,Ze={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Je=e.defineComponent({props:Ze,setup(t){const a=e.inject("usedLanguageText"),r=e.inject("editorId"),l=e.computed(()=>{var i,s;switch(t.type){case"link":return(i=a.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(s=a.value.linkModalTips)==null?void 0:s.imageTitle;default:return""}}),c=e.reactive({desc:"",url:""});return e.watch(()=>t.visible,i=>{i||setTimeout(()=>{c.desc="",c.url=""},200)}),()=>e.createVNode(ne.Modal,{title:l.value,visible:t.visible,onClose:t.onCancel},{default:()=>{var i,s,m,g,d;return[e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("label",{class:`${o.prefix}-label`,for:`link-desc-${r}`},[(i=a.value.linkModalTips)==null?void 0:i.descLabel]),e.createVNode("input",{placeholder:(s=a.value.linkModalTips)==null?void 0:s.descLabelPlaceHolder,class:`${o.prefix}-input`,id:`link-desc-${r}`,type:"text",value:c.desc,onChange:u=>{c.desc=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("label",{class:`${o.prefix}-label`,for:`link-url-${r}`},[(m=a.value.linkModalTips)==null?void 0:m.urlLabel]),e.createVNode("input",{placeholder:(g=a.value.linkModalTips)==null?void 0:g.urlLabelPlaceHolder,class:`${o.prefix}-input`,id:`link-url-${r}`,type:"text",value:c.url,onChange:u=>{c.url=u.target.value},autocomplete:"off"},null)]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("button",{class:[`${o.prefix}-btn`,`${o.prefix}-btn-row`],type:"button",onClick:()=>{t.onOk(c),c.desc="",c.url=""}},[(d=a.value.linkModalTips)==null?void 0:d.buttonOK])])]}})}}),Xe={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Qe=e.defineComponent({props:Xe,setup(t){var u,v,k;const a=e.inject("usedLanguageText"),r=e.inject("editorId");let l=(k=(v=(u=o.configOption)==null?void 0:u.editorExtensions)==null?void 0:v.cropper)==null?void 0:k.instance;const c=e.ref(),i=e.ref(),s=e.ref(),m=e.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let g=null;e.watch(()=>t.visible,()=>{t.visible&&!m.cropperInited&&(l=l||window.Cropper,c.value.onchange=()=>{if(!l){h.bus.emit(r,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const b=c.value.files||[];if(m.imgSelected=!0,(b==null?void 0:b.length)>0){const p=new FileReader;p.onload=f=>{m.imgSrc=f.target.result,e.nextTick(()=>{g=new l(i.value,{viewMode:2,preview:`.${o.prefix}-clip-preview-target`})})},p.readAsDataURL(b[0])}})}),e.watch(()=>[m.imgSelected],()=>{s.value.style=""}),e.watch(()=>m.isFullscreen,()=>{e.nextTick(()=>{g==null||g.destroy(),s.value.style="",i.value&&(g=new l(i.value,{viewMode:2,preview:`.${o.prefix}-clip-preview-target`}))})});const d=()=>{g.clear(),g.destroy(),g=null,c.value.value="",m.imgSelected=!1};return()=>{var b;return e.createVNode(ne.Modal,{class:`${o.prefix}-modal-clip`,title:(b=a.value.clipModalTips)==null?void 0:b.title,visible:t.visible,onClose:t.onCancel,showAdjust:!0,isFullscreen:m.isFullscreen,onAdjust:p=>{m.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,f;return[e.createVNode("div",{class:`${o.prefix}-form-item ${o.prefix}-clip`},[e.createVNode("div",{class:`${o.prefix}-clip-main`},[m.imgSelected?e.createVNode("div",{class:`${o.prefix}-clip-cropper`},[e.createVNode("img",{src:m.imgSrc,ref:i,style:{display:"none"},alt:""},null),e.createVNode("div",{class:`${o.prefix}-clip-delete`,onClick:d},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-delete"},null)])])]):e.createVNode("div",{class:`${o.prefix}-clip-upload`,onClick:()=>{c.value.click()}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-upload"},null)])])]),e.createVNode("div",{class:`${o.prefix}-clip-preview`},[e.createVNode("div",{class:`${o.prefix}-clip-preview-target`,ref:s},null)])]),e.createVNode("div",{class:`${o.prefix}-form-item`},[e.createVNode("button",{class:`${o.prefix}-btn`,type:"button",onClick:()=>{if(g){const x=g.getCroppedCanvas();h.bus.emit(r,"uploadImage",[h.base642File(x.toDataURL("image/png"))],t.onOk),d()}}},[((p=a.value.clipModalTips)==null?void 0:p.buttonUpload)||((f=a.value.linkModalTips)==null?void 0:f.buttonOK)])]),e.createVNode("input",{ref:c,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),et={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},tt=e.defineComponent({props:et,setup(t){return()=>e.createVNode(e.Fragment,null,[e.createVNode(Je,{type:t.type,visible:t.linkVisible,onOk:t.onOk,onCancel:t.onCancel},null),e.createVNode(Qe,{visible:t.clipVisible,onOk:t.onOk,onCancel:t.onCancel},null)])}}),ot=e.defineComponent({name:"MDEditorToolbar",props:Ke,setup(t){const a=e.inject("editorId"),r=e.inject("usedLanguageText"),{fullscreenHandler:l}=_e(t),c=`${a}-toolbar-wrapper`,i=e.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),s=(b,p)=>{h.bus.emit(a,"replace",b,p)},m=e.reactive({type:"link",linkVisible:!1,clipVisible:!1}),g=e.ref();e.onMounted(()=>{h.bus.on(a,{name:"openModals",callback(b){m.type=b,m.linkVisible=!0}})});const d=e.computed(()=>{const b=t.toolbars.filter(N=>!t.toolbarsExclude.includes(N)),p=b.indexOf("="),f=p===-1?b:b.slice(0,p+1),x=p===-1?[]:b.slice(p,Number.MAX_SAFE_INTEGER);return[f,x]}),u=e.ref(),v=()=>{h.bus.emit(a,"uploadImage",Array.from(u.value.files||[])),u.value.value=""};e.onMounted(()=>{u.value.addEventListener("change",v)});const k=b=>{var p,f,x,N,y,$,T,C,S,I,M,A,H,L,E,P,B,te,_,j,O,W,G,D,F,z,oe,ce,se,de,ue,fe,ge,me,he,be,pe,ve,ke,xe,Ce,Ve,Ne;if(o.allToolbar.includes(b))switch(b){case"-":return e.createVNode(Ue,null,null);case"bold":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(p=r.value.toolbarTips)==null?void 0:p.bold,onClick:()=>{s("bold")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-bold"},null)])]);case"underline":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(f=r.value.toolbarTips)==null?void 0:f.underline,onClick:()=>{s("underline")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-underline"},null)])]);case"italic":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(x=r.value.toolbarTips)==null?void 0:x.italic,onClick:()=>{s("italic")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-italic"},null)])]);case"strikeThrough":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(N=r.value.toolbarTips)==null?void 0:N.strikeThrough,onClick:()=>{s("strikeThrough")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-strike-through"},null)])]);case"title":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.title,onChange:V=>{i.title=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h1")}},[(y=r.value.titleItem)==null?void 0:y.h1]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h2")}},[($=r.value.titleItem)==null?void 0:$.h2]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h3")}},[(T=r.value.titleItem)==null?void 0:T.h3]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h4")}},[(C=r.value.titleItem)==null?void 0:C.h4]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h5")}},[(S=r.value.titleItem)==null?void 0:S.h5]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("h6")}},[(I=r.value.titleItem)==null?void 0:I.h6])])},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.title},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-title"},null)])])]}});case"sub":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(M=r.value.toolbarTips)==null?void 0:M.sub,onClick:()=>{s("sub")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sub"},null)])]);case"sup":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(A=r.value.toolbarTips)==null?void 0:A.sup,onClick:()=>{s("sup")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-sup"},null)])]);case"quote":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(H=r.value.toolbarTips)==null?void 0:H.quote,onClick:()=>{s("quote")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-quote"},null)])]);case"unorderedList":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(L=r.value.toolbarTips)==null?void 0:L.unorderedList,onClick:()=>{s("unorderedList")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-unordered-list"},null)])]);case"orderedList":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(E=r.value.toolbarTips)==null?void 0:E.orderedList,onClick:()=>{s("orderedList")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-ordered-list"},null)])]);case"task":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(P=r.value.toolbarTips)==null?void 0:P.task,onClick:()=>{s("task")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-task"},null)])]);case"codeRow":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(B=r.value.toolbarTips)==null?void 0:B.codeRow,onClick:()=>{s("codeRow")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code-row"},null)])]);case"code":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(te=r.value.toolbarTips)==null?void 0:te.code,onClick:()=>{s("code")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-code"},null)])]);case"link":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(_=r.value.toolbarTips)==null?void 0:_.link,onClick:()=>{m.type="link",m.linkVisible=!0}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-link"},null)])]);case"image":return t.noUploadImg?e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(j=r.value.toolbarTips)==null?void 0:j.image,onClick:()=>{m.type="image",m.linkVisible=!0}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])]):e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.image,onChange:V=>{i.image=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.title=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{m.type="image",m.linkVisible=!0}},[(O=r.value.imgTitleItem)==null?void 0:O.link]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{u.value.click()}},[(W=r.value.imgTitleItem)==null?void 0:W.upload]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{m.clipVisible=!0}},[(G=r.value.imgTitleItem)==null?void 0:G.clip2upload])])},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.image},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-image"},null)])])]}});case"table":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.table,onChange:V=>{i.table=V},key:"bar-table",overlay:e.createVNode(Ye,{tableShape:t.tableShape,onSelected:V=>{s("table",{selectedShape:V})}},null)},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.table},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-table"},null)])])]}});case"revoke":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(D=r.value.toolbarTips)==null?void 0:D.revoke,onClick:()=>{h.bus.emit(a,"ctrlZ")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-revoke"},null)])]);case"next":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(F=r.value.toolbarTips)==null?void 0:F.next,onClick:()=>{h.bus.emit(a,"ctrlShiftZ")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-next"},null)])]);case"save":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(z=r.value.toolbarTips)==null?void 0:z.save,onClick:()=>{h.bus.emit(a,w.ON_SAVE)}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-baocun"},null)])]);case"prettier":return t.noPrettier?"":e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(oe=r.value.toolbarTips)==null?void 0:oe.prettier,onClick:()=>{s("prettier")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-prettier"},null)])]);case"pageFullscreen":return!t.setting.fullscreen&&e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ce=r.value.toolbarTips)==null?void 0:ce.pageFullscreen,onClick:()=>{t.updateSetting("pageFullscreen")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.pageFullscreen?"suoxiao":"fangda"}`},null)])]);case"fullscreen":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(se=r.value.toolbarTips)==null?void 0:se.fullscreen,onClick:()=>{l()}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#md-editor-icon-${t.setting.fullscreen?"fullscreen-exit":"fullscreen"}`},null)])]);case"preview":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(de=r.value.toolbarTips)==null?void 0:de.preview,onClick:()=>{t.updateSetting("preview")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-preview"},null)])]);case"htmlPreview":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ue=r.value.toolbarTips)==null?void 0:ue.htmlPreview,onClick:()=>{t.updateSetting("htmlPreview")}},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-coding"},null)])]);case"catalog":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(fe=r.value.toolbarTips)==null?void 0:fe.catalog,onClick:()=>{h.bus.emit(a,w.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-catalog"},null)])]);case"github":return e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(ge=r.value.toolbarTips)==null?void 0:ge.github,onClick:()=>X.linkTo("https://github.com/imzbf/md-editor-v3")},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-github"},null)])]);case"mermaid":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.mermaid,onChange:V=>{i.mermaid=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.mermaid=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("flow")}},[(me=r.value.mermaid)==null?void 0:me.flow]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("sequence")}},[(he=r.value.mermaid)==null?void 0:he.sequence]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("gantt")}},[(be=r.value.mermaid)==null?void 0:be.gantt]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("class")}},[(pe=r.value.mermaid)==null?void 0:pe.class]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("state")}},[(ve=r.value.mermaid)==null?void 0:ve.state]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("pie")}},[(ke=r.value.mermaid)==null?void 0:ke.pie]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("relationship")}},[(xe=r.value.mermaid)==null?void 0:xe.relationship]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("journey")}},[(Ce=r.value.mermaid)==null?void 0:Ce.journey])]),key:"bar-mermaid"},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.mermaid},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-mermaid"},null)])])]}});case"katex":return e.createVNode(K.Dropdown,{relative:`#${c}`,visible:i.katex,onChange:V=>{i.katex=V},overlay:e.createVNode("ul",{class:`${o.prefix}-menu`,onClick:()=>{i.katex=!1}},[e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("katexInline")}},[(Ve=r.value.katex)==null?void 0:Ve.inline]),e.createVNode("li",{class:`${o.prefix}-menu-item`,onClick:()=>{s("katexBlock")}},[(Ne=r.value.katex)==null?void 0:Ne.block])]),key:"bar-katex"},{default:()=>{var V;return[e.createVNode("div",{class:`${o.prefix}-toolbar-item`,title:(V=r.value.toolbarTips)==null?void 0:V.katex},[e.createVNode("svg",{class:`${o.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":"#md-editor-icon-formula"},null)])])]}})}else return t.defToolbars instanceof Array?t.defToolbars[b]||"":t.defToolbars&&t.defToolbars.children instanceof Array&&t.defToolbars.children[b]||""};return()=>{const b=d.value[0].map(f=>k(f)),p=d.value[1].map(f=>k(f));return e.createVNode(e.Fragment,null,[t.toolbars.length>0&&e.createVNode("div",{class:`${o.prefix}-toolbar-wrapper`,id:c},[e.createVNode("div",{class:`${o.prefix}-toolbar`},[e.createVNode("div",{class:`${o.prefix}-toolbar-left`,ref:g},[b]),e.createVNode("div",{class:`${o.prefix}-toolbar-right`},[p])])]),e.createVNode("input",{ref:u,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),e.createVNode(tt,{linkVisible:m.linkVisible,clipVisible:m.clipVisible,type:m.type,onCancel:()=>{m.linkVisible=!1,m.clipVisible=!1},onOk:f=>{f&&s(m.type,{desc:f.desc,url:f.url}),m.linkVisible=!1,m.clipVisible=!1}},null)])}}}),lt=(t,a)=>{const r=X.debounce(()=>{t.removeEventListener("scroll",l),t.addEventListener("scroll",l),a.removeEventListener("scroll",l),a.addEventListener("scroll",l)},50),l=c=>{const i=t.clientHeight,s=a.clientHeight,m=t.scrollHeight,g=a.scrollHeight,d=(m-i)/(g-s);c.target===t?(a.removeEventListener("scroll",l),a.scrollTo({top:t.scrollTop/d}),r()):(t.removeEventListener("scroll",l),t.scrollTo({top:a.scrollTop*d}),r())};return[()=>{r().finally(()=>{t.dispatchEvent(new Event("scroll"))})},()=>{t.removeEventListener("scroll",l),a.removeEventListener("scroll",l)}]},at=(t,a,r)=>{const{view:l}=r,c=v=>l.lineBlockAt(l.state.doc.line(v).from).top,i=v=>l.lineBlockAt(l.state.doc.line(v).from).height;let s=[];const m=()=>{s=[];const v=Array.from(a.querySelectorAll("[data-line]")).map(f=>Number(f.dataset.line)+1),{lines:k}=l.state.doc;let b=1,p=v.shift()??k;for(let f=1;f<=k;f++)f===p&&(b=f,p=v.shift()||k+1),s.push({start:b,end:p-1})};let g=0,d=0;const u=X.throttle(v=>{var p,f,x,N,y,$,T;if(!((p=a.firstElementChild)!=null&&p.firstElementChild))return;const k=l.lineBlockAtHeight(l.scrollDOM.scrollTop),{number:b}=l.state.doc.lineAt(k.from);if(!(b>s.length)&&!(l.state.doc.lines<s[s.length-1].end))if(v.target===t){if(d!==0)return;g++;const C=s[b-1],S=c(C.end)+i(C.end);let I=0;const M=c(C.start),A=a.querySelector(`[data-line="${C.start-1}"]`)||((f=a.firstElementChild)==null?void 0:f.firstElementChild),H=a.querySelector(`[data-line="${C.end}"]`)||((x=a.lastElementChild)==null?void 0:x.lastElementChild);let L=0,E=0;M===0?(I=(l.scrollDOM.scrollTop-M)/(S-M),L=H.offsetTop):S>l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight?(I=(l.scrollDOM.scrollTop-M)/(l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight-M),E=A.offsetTop,L=a.scrollHeight-a.clientHeight-E+10):(I=(l.scrollDOM.scrollTop-M)/(S-M),E=A.offsetTop,L=H.offsetTop-E);const P=E-10+L*I;X.smoothScroll(a,P,()=>{g--})}else{if(g!==0)return;d++;const C=Array.from(a.querySelectorAll("[data-line]")),S=a.scrollTop,I=a.scrollHeight;let M=C.length===0?1:Math.ceil(Number(C[C.length-1].dataset.line)*(S/I)),A=(N=a.firstElementChild)==null?void 0:N.firstElementChild;for(let D=M;D>=0;D--){const F=a.querySelector(`[data-line="${D}"]`);if(F){A=F,M=D;break}}let H=(y=a.firstElementChild)==null?void 0:y.firstElementChild,L=($=a.firstElementChild)==null?void 0:$.lastElementChild;for(;C.length>0;){const D=C.indexOf(A);if(D+1>=C.length)break;const F=C[D+1];if(D===-1){L=F;break}const z=A.offsetTop;if(z>S){if(D===0){H=A,L=F;break}A=C[D-1];continue}const oe=F.offsetTop;if(z<=S&&oe>S){H=A,L=F;break}A=F}const E=H.offsetTop,P=L.offsetTop;let B=0;const{start:te,end:_}=s[Number(H.dataset.line||0)],j=c(te);let O=c(_);const W=i(_);let G=0;H===((T=a.firstElementChild)==null?void 0:T.firstElementChild)?(B=Math.max(S/P,0),G=O+W-j):O>l.scrollDOM.scrollHeight-l.scrollDOM.clientHeight?(B=Math.max((S-E)/(a.scrollHeight-E-a.clientHeight),0),O=c(l.state.doc.lines)+i(l.state.doc.lines),G=8+O-j-t.clientHeight):(B=Math.max((S-E)/(P-E),0),G=O+W-j),X.smoothScroll(t,j+G*B,()=>{d--})}},10);return[()=>{m(),t.addEventListener("scroll",u),a.addEventListener("scroll",u),t.dispatchEvent(new Event("scroll"))},()=>{s=[],t.removeEventListener("scroll",u),a.removeEventListener("scroll",u)}]},rt=(t,a,r)=>{const l=e.inject("editorId");let c=()=>{},i=()=>{};const s=()=>{c();const m=document.querySelector(".cm-scroller"),g=document.querySelector(`[id="${l}-preview-wrapper"][data-show="true"]`),d=document.querySelector(`[id="${l}-html-wrapper"][data-show="true"]`);(g||d)&&([i,c]=(g?at:lt)(m,g||d,r.value)),t.scrollAuto&&i()};e.watch([a,e.toRef(t.setting,"preview"),e.toRef(t.setting,"htmlPreview"),e.toRef(t.setting,"fullscreen"),e.toRef(t.setting,"pageFullscreen")],()=>{e.nextTick(s)}),e.watch(()=>t.scrollAuto,m=>{m?i():c()}),e.onMounted(s)},it=rt,nt=(t,a,r)=>{var u,v,k,b,p,f;let l="",c=0,i=0,s=!0,m=!1;const g=a.getSelectedText(),d=(u=o.configOption.editorConfig)==null?void 0:u.mermaidTemplate;if(/^h[1-6]{1}$/.test(t)){const x=t.replace(/^h(\d)/,(N,y)=>new Array(Number(y)).fill("#",0,y).join(""));l=`${x} ${g}`,c=x.length+1}else if(t==="prettier"){const x=window.prettier||((k=(v=o.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:k.prettierInstance),N=[((b=window.prettierPlugins)==null?void 0:b.markdown)||((f=(p=o.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:f.parserMarkdownInstance)];!x||N[0]===void 0?(h.bus.emit(r.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),l=a.getValue()):l=x.format(a.getValue(),{parser:"markdown",plugins:N}),s=!1,m=!0}else switch(t){case"bold":{l=`**${g}**`,c=2,i=-2;break}case"underline":{l=`<u>${g}</u>`,c=3,i=-4;break}case"italic":{l=`*${g}*`,c=1,i=-1;break}case"strikeThrough":{l=`~~${g}~~`,c=2,i=-2;break}case"sub":{l=`<sub>${g}</sub>`,c=5,i=-6;break}case"sup":{l=`<sup>${g}</sup>`,c=5,i=-6;break}case"codeRow":{l="`"+g+"`",c=1,i=-1;break}case"quote":{l=`> ${g}`,c=2;break}case"orderedList":{l=`1. ${g}`,c=3;break}case"unorderedList":{l=`- ${g}`,c=2;break}case"task":{l=`- [ ] ${g}`,c=6;break}case"code":{const x=r.text||g||"",N=r.mode||"language";l=`\`\`\`${N}
2
2
  ${x}
3
3
  \`\`\`
4
- `,c=3,i=3+$.length-o.length;break}case"table":{o="|";const{selectedShape:x={x:1,y:1}}=r,{x:$,y}=x;for(let N=0;N<=y;N++)o+=" col |";o+=`
5
- |`;for(let N=0;N<=y;N++)o+=" - |";for(let N=0;N<=$;N++){o+=`
6
- |`;for(let T=0;T<=y;T++)o+=" content |"}c=2,i=5-o.length;break}case"link":{const{desc:x,url:$}=r;o=`[${x}](${$})`,s=!1;break}case"image":{const{desc:x,url:$,urls:y}=r;y instanceof Array?o=y.reduce((N,T)=>N+`![${x}](${T})
7
- `,""):o=`![${x}](${$})
8
- `,s=!1;break}case"flow":{o=`\`\`\`mermaid
4
+ `,c=3,i=3+N.length-l.length;break}case"table":{l="|";const{selectedShape:x={x:1,y:1}}=r,{x:N,y}=x;for(let $=0;$<=y;$++)l+=" col |";l+=`
5
+ |`;for(let $=0;$<=y;$++)l+=" - |";for(let $=0;$<=N;$++){l+=`
6
+ |`;for(let T=0;T<=y;T++)l+=" content |"}c=2,i=5-l.length;break}case"link":{const{desc:x,url:N}=r;l=`[${x}](${N})`,s=!1;break}case"image":{const{desc:x,url:N,urls:y}=r;y instanceof Array?l=y.reduce(($,T)=>$+`![${x}](${T})
7
+ `,""):l=`![${x}](${N})
8
+ `,s=!1;break}case"flow":{l=`\`\`\`mermaid
9
9
  ${(d==null?void 0:d.flow)||`flowchart TD
10
10
  Start --> Stop`}
11
11
  \`\`\`
12
- `,c=3,i=10-o.length;break}case"sequence":{o=`\`\`\`mermaid
12
+ `,c=3,i=10-l.length;break}case"sequence":{l=`\`\`\`mermaid
13
13
  ${(d==null?void 0:d.sequence)||`sequenceDiagram
14
14
  A->>B: hello!
15
15
  B-->>A: hi!
16
16
  A-)B: bye!`}
17
17
  \`\`\`
18
- `,c=3,i=10-o.length;break}case"gantt":{o=`\`\`\`mermaid
18
+ `,c=3,i=10-l.length;break}case"gantt":{l=`\`\`\`mermaid
19
19
  ${(d==null?void 0:d.gantt)||`gantt
20
20
  title A Gantt Diagram
21
21
  dateFormat YYYY-MM-DD
@@ -23,27 +23,27 @@ section Section
23
23
  A task :a1, 2014-01-01, 30d
24
24
  Another task :after a1, 20d`}
25
25
  \`\`\`
26
- `,c=3,i=10-o.length;break}case"class":{o=`\`\`\`mermaid
26
+ `,c=3,i=10-l.length;break}case"class":{l=`\`\`\`mermaid
27
27
  ${(d==null?void 0:d.class)||`classDiagram
28
28
  class Animal
29
29
  Vehicle <|-- Car`}
30
30
  \`\`\`
31
- `,c=3,i=10-o.length;break}case"state":{o=`\`\`\`mermaid
31
+ `,c=3,i=10-l.length;break}case"state":{l=`\`\`\`mermaid
32
32
  ${(d==null?void 0:d.state)||`stateDiagram-v2
33
33
  s1 --> s2`}
34
34
  \`\`\`
35
- `,c=3,i=10-o.length;break}case"pie":{o=`\`\`\`mermaid
35
+ `,c=3,i=10-l.length;break}case"pie":{l=`\`\`\`mermaid
36
36
  ${(d==null?void 0:d.pie)||`pie title Pets adopted by volunteers
37
37
  "Dogs" : 386
38
38
  "Cats" : 85
39
39
  "Rats" : 15`}
40
40
  \`\`\`
41
- `,c=3,i=10-o.length;break}case"relationship":{o=`\`\`\`mermaid
41
+ `,c=3,i=10-l.length;break}case"relationship":{l=`\`\`\`mermaid
42
42
  ${(d==null?void 0:d.relationship)||`erDiagram
43
43
  CAR ||--o{ NAMED-DRIVER : allows
44
44
  PERSON ||--o{ NAMED-DRIVER : is`}
45
45
  \`\`\`
46
- `,c=3,i=10-o.length;break}case"journey":{o=`\`\`\`mermaid
46
+ `,c=3,i=10-l.length;break}case"journey":{l=`\`\`\`mermaid
47
47
  ${(d==null?void 0:d.journey)||`journey
48
48
  title My working day
49
49
  section Go to work
@@ -54,7 +54,7 @@ ${(d==null?void 0:d.journey)||`journey
54
54
  Go downstairs: 5: Me
55
55
  Sit down: 5: Me`}
56
56
  \`\`\`
57
- `,c=3,i=10-o.length;break}case"katexInline":{o="$$",c=1,i=-1;break}case"katexBlock":{o=`$$
57
+ `,c=3,i=10-l.length;break}case"katexInline":{l="$$",c=1,i=-1;break}case"katexBlock":{l=`$$
58
58
 
59
59
  $$
60
- `,c=3,i=-4;break}case"universal":{const{generate:x}=r,$=x(g);o=$.targetValue,s=$.select,c=$.deviationStart,i=$.deviationEnd}}return{text:o,options:{select:s,deviationStart:c,deviationEnd:i,replaceAll:m}}},dt="#e5c07b",we="var(--md-color)",ut="#56b6c2",ft="#ffffff",Z="var(--md-color)",Te="#e5c07b",gt="#e5c07b",mt="var(--md-color)",Se="#d19a66",ht="#c678dd",bt="#21252b",Me="#2c313a",Ae="var(--md-bk-color)",ae="#353a42",pt="#ceedfa33",Ee="#528bff",vt=X.EditorView.theme({"&":{color:Z,backgroundColor:Ae},".cm-content":{caretColor:Ee},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ee},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:pt},".cm-panels":{backgroundColor:bt,color:Z},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ae,color:Z,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Me},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ae},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ae,borderBottomColor:ae},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Me,color:Z}}},{dark:!0}),kt=Q.HighlightStyle.define([{tag:n.tags.keyword,color:ht},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:we},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:gt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Se},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:Z},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:dt},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:ut},{tag:[n.tags.meta,n.tags.comment],color:Te},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:Te,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:we},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Se},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:mt},{tag:n.tags.invalid,color:ft}]),xt=[vt,Q.syntaxHighlighting(kt)],Ct="#e5c07b",De="#3f4a54",Vt="#56b6c2",$t="#fff",J="#3f4a54",Le="#2d8cf0",Nt="#2d8cf0",yt="#3f4a54",He="#d19a66",wt="#c678dd",Tt="#21252b",Fe="#ceedfa33",Be="var(--md-bk-color)",re="#353a42",St="#bad5fa",Ie="#3f4a54",Mt=X.EditorView.theme({"&":{color:J,backgroundColor:Be},".cm-content":{caretColor:Ie},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ie},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:St},".cm-panels":{backgroundColor:Tt,color:J},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Be,color:J,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Fe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:re},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:re,borderBottomColor:re},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Fe,color:J}}},{dark:!0}),At=Q.HighlightStyle.define([{tag:n.tags.keyword,color:wt},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:De},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:Nt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:He},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:J},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:Ct},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:Vt},{tag:[n.tags.meta,n.tags.comment],color:Le},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:Le,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:De},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:He},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:yt},{tag:n.tags.invalid,color:$t}]),Et=[Mt,Q.syntaxHighlighting(At)],U=t=>{const a=new R.Compartment;return o=>(a.get(t.state)?t.dispatch({effects:a.reconfigure(o)}):t.dispatch({effects:R.StateEffect.appendConfig.of(a.of(o))}),!0)};class Dt{constructor(a){q(this,"view");q(this,"toggleTabSize");q(this,"togglePlaceholder");q(this,"setExtensions");q(this,"toggleDisabled");q(this,"toggleReadOnly");q(this,"toggleMaxlength");this.view=a,this.toggleTabSize=U(this.view),this.togglePlaceholder=U(this.view),this.setExtensions=U(this.view),this.toggleDisabled=U(this.view),this.toggleReadOnly=U(this.view),this.toggleMaxlength=U(this.view)}getValue(){return this.view.state.doc.toString()}setValue(a,r=0,o=this.view.state.doc.length){this.view.dispatch({changes:{from:r,to:o,insert:a}})}getSelectedText(){const{from:a,to:r}=this.view.state.selection.main;return this.view.state.sliceDoc(a,r)}replaceSelectedText(a,r={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1}){if(r.replaceAll){this.setValue(a);return}const{from:o}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(a)),r.select){const c=o+a.length+r.deviationEnd;this.view.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(o+r.deviationStart,c),R.EditorSelection.cursor(c)],1)}),this.view.focus()}}setTabSize(a){this.toggleTabSize([R.EditorState.tabSize.of(a),Q.indentUnit.of(" ".repeat(a))])}setPlaceholder(a){this.togglePlaceholder(X.placeholder(a))}focus(){this.view.focus()}setDisabled(a){this.toggleDisabled([X.EditorView.editable.of(!a)])}setReadOnly(a){this.toggleReadOnly([R.EditorState.readOnly.of(a)])}setMaxLength(a){this.toggleMaxlength([R.EditorState.changeFilter.of(r=>r.newDoc.length<=a)])}}const Lt=t=>{const a=e.inject("editorId");return o=>{if(o.clipboardData){if(o.clipboardData.files.length>0){const{files:c}=o.clipboardData;h.bus.emit(a,"uploadImage",Array.from(c).filter(i=>/image\/.*/.test(i.type))),o.preventDefault()}if(t.autoDetectCode&&o.clipboardData.types.includes("vscode-editor-data")){const c=JSON.parse(o.clipboardData.getData("vscode-editor-data"));h.bus.emit(a,"replace","code",{mode:c.mode,text:o.clipboardData.getData("text/plain")}),o.preventDefault()}}}},Ht=Lt,Ft=t=>{const a=e.inject("editorId");e.onMounted(()=>{h.bus.on(a,{name:w.TEXTAREA_FOCUS,callback(){var r;(r=t.value)==null||r.focus()}})})},Bt=Ft,It=(t,a)=>{const r={key:"Ctrl-b",mac:"Cmd-b",run:()=>(h.bus.emit(t,"replace","bold"),!0)},o={key:"Ctrl-s",mac:"Cmd-s",run:T=>(h.bus.emit(t,w.ON_SAVE,T.state.doc.toString()),!0),shift:()=>(h.bus.emit(t,"replace","strikeThrough"),!0)},c={key:"Ctrl-u",mac:"Cmd-u",run:()=>(h.bus.emit(t,"replace","underline"),!0),shift:()=>(h.bus.emit(t,"replace","unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(h.bus.emit(t,"replace","italic"),!0),shift:()=>(h.bus.emit(t,"openModals","image"),!0)},s={key:"Ctrl-1",mac:"Cmd-1",run:()=>(h.bus.emit(t,"replace","h1"),!0)},m={key:"Ctrl-2",mac:"Cmd-2",run:()=>(h.bus.emit(t,"replace","h2"),!0)},g={key:"Ctrl-3",mac:"Cmd-3",run:()=>(h.bus.emit(t,"replace","h3"),!0)},d={key:"Ctrl-4",mac:"Cmd-4",run:()=>(h.bus.emit(t,"replace","h4"),!0)},u={key:"Ctrl-5",mac:"Cmd-5",run:()=>(h.bus.emit(t,"replace","h5"),!0)},v={key:"Ctrl-6",mac:"Cmd-6",run:()=>(h.bus.emit(t,"replace","h6"),!0)},k={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(h.bus.emit(t,"replace","sup"),!0)},b={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(h.bus.emit(t,"replace","sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(h.bus.emit(t,"replace","orderedList"),!0)},f={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(h.bus.emit(t,"replace","code"),!0),any(T,C){return(C.ctrlKey||C.metaKey)&&C.altKey&&C.code==="KeyC"?(h.bus.emit(t,"replace","codeRow"),!0):!1}},x={key:"Ctrl-l",mac:"Cmd-l",run:()=>(h.bus.emit(t,"openModals","link"),!0)},$={key:"Ctrl-f",mac:"Cmd-f",shift:()=>a.noPrettier?!1:(h.bus.emit(t,"replace","prettier"),!0)},y={any:(T,C)=>(C.ctrlKey||C.metaKey)&&C.altKey&&C.shiftKey&&C.code==="KeyT"?(h.bus.emit(t,"replace","table"),!0):!1},N={key:"Ctrl-d",mac:"Cmd-d",run:oe.deleteLine,preventDefault:!0};return[r,N,o,c,i,s,m,g,d,u,v,k,b,p,f,x,$,y]},Ot=It,qt=t=>{const a=e.inject("tabWidth"),r=e.inject("editorId"),o=e.inject("theme"),c=e.ref(),i=e.shallowRef(),s=Ot(r,t),m=Ht(t),g=[X.keymap.of([...s,oe.indentWithTab]),Y.minimalSetup,Ge.markdown({codeLanguages:je.languages}),Y.EditorView.lineWrapping,Y.EditorView.updateListener.of(u=>{u.docChanged&&t.onChange(u.state.doc.toString())}),Y.EditorView.domEventHandlers({paste:m,blur:t.onBlur,focus:t.onFocus})],d=()=>o.value==="light"?l.configOption.codeMirrorExtensions(o.value,[...g,Et],[...s]):l.configOption.codeMirrorExtensions(o.value,[...g,xt],[...s]);return e.onMounted(()=>{const u=new Y.EditorView({doc:t.value,parent:c.value});i.value=new Dt(u),i.value.setTabSize(a),i.value.setExtensions(d()),i.value.setDisabled(t.disabled),i.value.setReadOnly(t.readonly),t.placeholder&&i.value.setPlaceholder(t.placeholder),t.autofocus&&u.focus(),t.maxlength&&i.value.setMaxLength(t.maxlength),h.bus.on(r,{name:"ctrlZ",callback(){oe.undo(u)}}),h.bus.on(r,{name:"ctrlShiftZ",callback(){oe.redo(u)}}),h.bus.on(r,{name:"replace",callback(v,k={}){var f;const{text:b,options:p}=st(v,i.value,k);(f=i.value)==null||f.replaceSelectedText(b,p)}})}),e.watch(()=>o.value,()=>{var u,v;o.value==="dark"?(u=i.value)==null||u.setExtensions(d()):(v=i.value)==null||v.setExtensions(d())}),e.watch(()=>t.value,()=>{var u,v;((u=i.value)==null?void 0:u.getValue())!==t.value&&((v=i.value)==null||v.setValue(t.value))}),e.watch(()=>t.placeholder,()=>{var u;(u=i.value)==null||u.setPlaceholder(t.placeholder)}),e.watch(()=>t.disabled,()=>{var u;(u=i.value)==null||u.setDisabled(t.disabled)}),e.watch(()=>t.readonly,()=>{var u;(u=i.value)==null||u.setDisabled(t.readonly)}),e.watch(()=>t.maxlength,()=>{var u;t.maxlength&&((u=i.value)==null||u.setMaxLength(t.maxlength))}),Bt(i),{inputWrapperRef:c,codeMirrorUt:i}},Rt=qt,Pt={value:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:t=>t},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:t=>t},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},noHighlight:{type:Boolean,default:!1}},jt=e.defineComponent({name:"MDEditorContent",props:Pt,setup(t){const a=e.ref(""),{inputWrapperRef:r,codeMirrorUt:o}=Rt(t);return ct(t,a,o),()=>e.createVNode("div",{class:`${l.prefix}-content`},[e.createVNode("div",{class:`${l.prefix}-input-wrapper`,ref:r},null),e.createVNode(w.ContentPreview,{modelValue:t.value,setting:t.setting,onHtmlChanged:c=>{a.value=c,t.onHtmlChanged(c)},onGetCatalog:t.onGetCatalog,mdHeadingId:t.mdHeadingId,noMermaid:t.noMermaid,sanitize:t.sanitize,noKatex:t.noKatex,formatCopiedText:t.formatCopiedText,noHighlight:t.noHighlight},null)])}}),Gt=e.defineComponent({props:{modelValue:{type:String,default:""}},setup(t){const a=e.inject("usedLanguageText");return()=>{var r,o;return e.createVNode("div",{class:`${l.prefix}-footer-item`},[e.createVNode("label",{class:`${l.prefix}-footer-label`},[`${(r=a.value.footer)==null?void 0:r.markdownTotal}:`]),e.createVNode("span",null,[((o=t.modelValue)==null?void 0:o.length)||0])])}}}),Ut={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Kt=e.defineComponent({props:Ut,setup(t){return()=>e.createVNode("div",{class:[`${l.prefix}-checkbox`,t.checked&&`${l.prefix}-checkbox-checked`],onClick:()=>{t.onChange(!t.checked)}},null)}}),_t={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},Wt=e.defineComponent({props:_t,setup(t){const a=e.inject("usedLanguageText");return()=>{var r;return e.createVNode("div",{class:`${l.prefix}-footer-item`},[e.createVNode("label",{class:`${l.prefix}-footer-label`,onClick:()=>{t.onScrollAutoChange(!t.scrollAuto)}},[(r=a.value.footer)==null?void 0:r.scrollAuto]),e.createVNode(Kt,{checked:t.scrollAuto,onChange:t.onScrollAutoChange},null)])}}}),zt={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},Yt=e.defineComponent({name:"MDEditorFooter",props:zt,setup(t){const a=e.computed(()=>{const o=t.footers.indexOf("="),c=o===-1?t.footers:t.footers.slice(0,o),i=o===-1?[]:t.footers.slice(o,Number.MAX_SAFE_INTEGER);return[c,i]}),r=o=>{if(l.allFooter.includes(o))switch(o){case"markdownTotal":return e.createVNode(Gt,{modelValue:t.modelValue},null);case"scrollSwitch":return e.createVNode(Wt,{scrollAuto:t.scrollAuto,onScrollAutoChange:t.onScrollAutoChange},null)}else return t.defFooters instanceof Array?t.defFooters[o]||"":t.defFooters&&t.defFooters.children instanceof Array&&t.defFooters.children[o]||""};return()=>{const o=a.value[0].map(i=>r(i)),c=a.value[1].map(i=>r(i));return e.createVNode("div",{class:`${l.prefix}-footer`},[e.createVNode("div",{class:`${l.prefix}-footer-left`},[o]),e.createVNode("div",{class:`${l.prefix}-footer-right`},[c])])}}}),Zt=e.defineComponent({name:"MdEditorV3",props:w.editorProps,emits:w.editorEmits,setup(t,a){const{editorId:r,noKatex:o,noMermaid:c,noPrettier:i,noUploadImg:s,noHighlight:m}=t,g=e.reactive({scrollAuto:t.scrollAuto});w.useOnSave(t,a),w.useProvide(t),w.useExpansion(t);const[d,u]=w.useConfig(t,a),v=w.useCatalog(t);return e.onBeforeUnmount(()=>{h.bus.clear(r)}),w.useExpose(t,a,v,d,u),()=>{var p;const k=Ne.getSlot({props:t,ctx:a},"defToolbars"),b=Ne.getSlot({props:t,ctx:a},"defFooters");return e.createVNode("div",{id:r,class:[l.prefix,t.class,t.theme==="dark"&&`${l.prefix}-dark`,d.fullscreen||d.pageFullscreen?`${l.prefix}-fullscreen`:""],style:t.style},[e.createVNode(lt,{noPrettier:i,toolbars:t.toolbars,toolbarsExclude:t.toolbarsExclude,setting:d,updateSetting:u,tableShape:t.tableShape,defToolbars:k,noUploadImg:s},null),e.createVNode(jt,{value:t.modelValue,setting:d,mdHeadingId:t.mdHeadingId,noMermaid:c,noPrettier:i,sanitize:t.sanitize,placeholder:t.placeholder,noKatex:o,scrollAuto:g.scrollAuto,formatCopiedText:t.formatCopiedText,autofocus:t.autoFocus,disabled:t.disabled,readonly:t.readOnly,maxlength:t.maxLength,autoDetectCode:t.autoDetectCode,noHighlight:m,onChange:f=>{t.onChange?t.onChange(f):(a.emit("update:modelValue",f),a.emit("onChange",f))},onHtmlChanged:f=>{t.onHtmlChanged?t.onHtmlChanged(f):a.emit("onHtmlChanged",f)},onGetCatalog:f=>{t.onGetCatalog?t.onGetCatalog(f):a.emit("onGetCatalog",f)},onBlur:f=>{t.onBlur?t.onBlur(f):a.emit("onBlur",f)},onFocus:f=>{t.onFocus?t.onFocus(f):a.emit("onFocus",f)}},null),((p=t.footers)==null?void 0:p.length)>0&&e.createVNode(Yt,{modelValue:t.modelValue,footers:t.footers,defFooters:b,scrollAuto:g.scrollAuto,onScrollAutoChange:f=>g.scrollAuto=f},null),v.value&&e.createVNode(Oe,{theme:t.theme,class:`${l.prefix}-catalog-editor`,editorId:r,mdHeadingId:t.mdHeadingId,key:"internal-catalog"},null)])}}}),le=Zt;le.install=t=>(t.component(le.name,le),t.use(Ue).use(K.DropdownToolbar).use(ne.ModalToolbar).use(Oe).use(w.MdPreview),t);module.exports=le;
60
+ `,c=3,i=-4;break}case"universal":{const{generate:x}=r,N=x(g);l=N.targetValue,s=N.select,c=N.deviationStart,i=N.deviationEnd}}return{text:l,options:{select:s,deviationStart:c,deviationEnd:i,replaceAll:m}}},ct="#e5c07b",ye="var(--md-color)",st="#56b6c2",dt="#ffffff",Z="var(--md-color)",we="#e5c07b",ut="#e5c07b",ft="var(--md-color)",Te="#d19a66",gt="#c678dd",mt="#21252b",Se="#2c313a",Me="var(--md-bk-color)",re="#353a42",ht="#ceedfa33",Ae="#528bff",bt=Q.EditorView.theme({"&":{color:Z,backgroundColor:Me},".cm-content":{caretColor:Ae},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ae},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ht},".cm-panels":{backgroundColor:mt,color:Z},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Me,color:Z,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Se},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:re},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:re,borderBottomColor:re},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Se,color:Z}}},{dark:!0}),pt=ee.HighlightStyle.define([{tag:n.tags.keyword,color:gt},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:ye},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:ut},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Te},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:Z},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:ct},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:st},{tag:[n.tags.meta,n.tags.comment],color:we},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:we,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:ye},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Te},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:ft},{tag:n.tags.invalid,color:dt}]),vt=[bt,ee.syntaxHighlighting(pt)],kt="#e5c07b",Ee="#3f4a54",xt="#56b6c2",Ct="#fff",J="#3f4a54",De="#2d8cf0",Vt="#2d8cf0",Nt="#3f4a54",Le="#d19a66",$t="#c678dd",yt="#21252b",He="#ceedfa33",Fe="var(--md-bk-color)",ie="#353a42",wt="#bad5fa",Ie="#3f4a54",Tt=Q.EditorView.theme({"&":{color:J,backgroundColor:Fe},".cm-content":{caretColor:Ie},".cm-cursor, .cm-dropCursor":{borderLeftColor:Ie},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:wt},".cm-panels":{backgroundColor:yt,color:J},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#ceedfa33"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Fe,color:J,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:He},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:ie},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ie,borderBottomColor:ie},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:He,color:J}}},{dark:!0}),St=ee.HighlightStyle.define([{tag:n.tags.keyword,color:$t},{tag:[n.tags.name,n.tags.deleted,n.tags.character,n.tags.propertyName,n.tags.macroName],color:Ee},{tag:[n.tags.function(n.tags.variableName),n.tags.labelName],color:Vt},{tag:[n.tags.color,n.tags.constant(n.tags.name),n.tags.standard(n.tags.name)],color:Le},{tag:[n.tags.definition(n.tags.name),n.tags.separator],color:J},{tag:[n.tags.typeName,n.tags.className,n.tags.number,n.tags.changed,n.tags.annotation,n.tags.modifier,n.tags.self,n.tags.namespace],color:kt},{tag:[n.tags.operator,n.tags.operatorKeyword,n.tags.url,n.tags.escape,n.tags.regexp,n.tags.link,n.tags.special(n.tags.string)],color:xt},{tag:[n.tags.meta,n.tags.comment],color:De},{tag:n.tags.strong,fontWeight:"bold"},{tag:n.tags.emphasis,fontStyle:"italic"},{tag:n.tags.strikethrough,textDecoration:"line-through"},{tag:n.tags.link,color:De,textDecoration:"underline"},{tag:n.tags.heading,fontWeight:"bold",color:Ee},{tag:[n.tags.atom,n.tags.bool,n.tags.special(n.tags.variableName)],color:Le},{tag:[n.tags.processingInstruction,n.tags.string,n.tags.inserted],color:Nt},{tag:n.tags.invalid,color:Ct}]),Mt=[Tt,ee.syntaxHighlighting(St)],U=t=>{const a=new q.Compartment;return l=>(a.get(t.state)?t.dispatch({effects:a.reconfigure(l)}):t.dispatch({effects:q.StateEffect.appendConfig.of(a.of(l))}),!0)};class At{constructor(a){R(this,"view");R(this,"toggleTabSize");R(this,"togglePlaceholder");R(this,"setExtensions");R(this,"toggleDisabled");R(this,"toggleReadOnly");R(this,"toggleMaxlength");this.view=a,this.toggleTabSize=U(this.view),this.togglePlaceholder=U(this.view),this.setExtensions=U(this.view),this.toggleDisabled=U(this.view),this.toggleReadOnly=U(this.view),this.toggleMaxlength=U(this.view)}getValue(){return this.view.state.doc.toString()}setValue(a,r=0,l=this.view.state.doc.length){this.view.dispatch({changes:{from:r,to:l,insert:a}})}getSelectedText(){const{from:a,to:r}=this.view.state.selection.main;return this.view.state.sliceDoc(a,r)}replaceSelectedText(a,r={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1}){if(r.replaceAll){this.setValue(a);return}const{from:l}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(a)),r.select){const c=l+a.length+r.deviationEnd;this.view.dispatch({selection:q.EditorSelection.create([q.EditorSelection.range(l+r.deviationStart,c),q.EditorSelection.cursor(c)],1)}),this.view.focus()}}setTabSize(a){this.toggleTabSize([q.EditorState.tabSize.of(a),ee.indentUnit.of(" ".repeat(a))])}setPlaceholder(a){this.togglePlaceholder(Q.placeholder(a))}focus(){this.view.focus()}setDisabled(a){this.toggleDisabled([Q.EditorView.editable.of(!a)])}setReadOnly(a){this.toggleReadOnly([q.EditorState.readOnly.of(a)])}setMaxLength(a){this.toggleMaxlength([q.EditorState.changeFilter.of(r=>r.newDoc.length<=a)])}}const Et=t=>{const a=e.inject("editorId");return l=>{if(l.clipboardData){if(l.clipboardData.files.length>0){const{files:c}=l.clipboardData;h.bus.emit(a,"uploadImage",Array.from(c).filter(i=>/image\/.*/.test(i.type))),l.preventDefault()}if(t.autoDetectCode&&l.clipboardData.types.includes("vscode-editor-data")){const c=JSON.parse(l.clipboardData.getData("vscode-editor-data"));h.bus.emit(a,"replace","code",{mode:c.mode,text:l.clipboardData.getData("text/plain")}),l.preventDefault()}}}},Dt=Et,Lt=t=>{const a=e.inject("editorId");e.onMounted(()=>{h.bus.on(a,{name:w.TEXTAREA_FOCUS,callback(){var r;(r=t.value)==null||r.focus()}})})},Ht=Lt,Ft=(t,a)=>{const r={key:"Ctrl-b",mac:"Cmd-b",run:()=>(h.bus.emit(t,"replace","bold"),!0)},l={key:"Ctrl-s",mac:"Cmd-s",run:T=>(h.bus.emit(t,w.ON_SAVE,T.state.doc.toString()),!0),shift:()=>(h.bus.emit(t,"replace","strikeThrough"),!0)},c={key:"Ctrl-u",mac:"Cmd-u",run:()=>(h.bus.emit(t,"replace","underline"),!0),shift:()=>(h.bus.emit(t,"replace","unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(h.bus.emit(t,"replace","italic"),!0),shift:()=>(h.bus.emit(t,"openModals","image"),!0)},s={key:"Ctrl-1",mac:"Cmd-1",run:()=>(h.bus.emit(t,"replace","h1"),!0)},m={key:"Ctrl-2",mac:"Cmd-2",run:()=>(h.bus.emit(t,"replace","h2"),!0)},g={key:"Ctrl-3",mac:"Cmd-3",run:()=>(h.bus.emit(t,"replace","h3"),!0)},d={key:"Ctrl-4",mac:"Cmd-4",run:()=>(h.bus.emit(t,"replace","h4"),!0)},u={key:"Ctrl-5",mac:"Cmd-5",run:()=>(h.bus.emit(t,"replace","h5"),!0)},v={key:"Ctrl-6",mac:"Cmd-6",run:()=>(h.bus.emit(t,"replace","h6"),!0)},k={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(h.bus.emit(t,"replace","sup"),!0)},b={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(h.bus.emit(t,"replace","sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(h.bus.emit(t,"replace","orderedList"),!0)},f={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(h.bus.emit(t,"replace","code"),!0),any(T,C){return(C.ctrlKey||C.metaKey)&&C.altKey&&C.code==="KeyC"?(h.bus.emit(t,"replace","codeRow"),!0):!1}},x={key:"Ctrl-l",mac:"Cmd-l",run:()=>(h.bus.emit(t,"openModals","link"),!0)},N={key:"Ctrl-f",mac:"Cmd-f",shift:()=>a.noPrettier?!1:(h.bus.emit(t,"replace","prettier"),!0)},y={any:(T,C)=>(C.ctrlKey||C.metaKey)&&C.altKey&&C.shiftKey&&C.code==="KeyT"?(h.bus.emit(t,"replace","table"),!0):!1},$={key:"Ctrl-d",mac:"Cmd-d",run:le.deleteLine,preventDefault:!0};return[r,$,l,c,i,s,m,g,d,u,v,k,b,p,f,x,N,y]},It=Ft,Bt=t=>{const a=e.inject("tabWidth"),r=e.inject("editorId"),l=e.inject("theme"),c=e.ref(),i=e.shallowRef(),s=It(r,t),m=Dt(t),g=[Q.keymap.of([...s,le.indentWithTab]),Y.minimalSetup,je.markdown({codeLanguages:Pe.languages}),Y.EditorView.lineWrapping,Y.EditorView.updateListener.of(u=>{u.docChanged&&t.onChange(u.state.doc.toString())}),Y.EditorView.domEventHandlers({paste:m,blur:t.onBlur,focus:t.onFocus})],d=()=>l.value==="light"?o.configOption.codeMirrorExtensions(l.value,[...g,Mt],[...s]):o.configOption.codeMirrorExtensions(l.value,[...g,vt],[...s]);return e.onMounted(()=>{const u=new Y.EditorView({doc:t.value,parent:c.value});i.value=new At(u),i.value.setTabSize(a),i.value.setExtensions(d()),i.value.setDisabled(t.disabled),i.value.setReadOnly(t.readonly),t.placeholder&&i.value.setPlaceholder(t.placeholder),t.autofocus&&u.focus(),t.maxlength&&i.value.setMaxLength(t.maxlength),h.bus.on(r,{name:"ctrlZ",callback(){le.undo(u)}}),h.bus.on(r,{name:"ctrlShiftZ",callback(){le.redo(u)}}),h.bus.on(r,{name:"replace",callback(v,k={}){var f;const{text:b,options:p}=nt(v,i.value,k);(f=i.value)==null||f.replaceSelectedText(b,p)}})}),e.watch(()=>l.value,()=>{var u,v;l.value==="dark"?(u=i.value)==null||u.setExtensions(d()):(v=i.value)==null||v.setExtensions(d())}),e.watch(()=>t.value,()=>{var u,v;((u=i.value)==null?void 0:u.getValue())!==t.value&&((v=i.value)==null||v.setValue(t.value))}),e.watch(()=>t.placeholder,()=>{var u;(u=i.value)==null||u.setPlaceholder(t.placeholder)}),e.watch(()=>t.disabled,()=>{var u;(u=i.value)==null||u.setDisabled(t.disabled)}),e.watch(()=>t.readonly,()=>{var u;(u=i.value)==null||u.setDisabled(t.readonly)}),e.watch(()=>t.maxlength,()=>{var u;t.maxlength&&((u=i.value)==null||u.setMaxLength(t.maxlength))}),Ht(i),{inputWrapperRef:c,codeMirrorUt:i}},Ot=Bt,Rt={value:{type:String,default:""},onChange:{type:Function,default:()=>{}},setting:{type:Object,default:()=>({})},onHtmlChanged:{type:Function,default:()=>{}},onGetCatalog:{type:Function,default:()=>{}},mdHeadingId:{type:Function,default:()=>""},noMermaid:{type:Boolean,default:!1},sanitize:{type:Function,default:t=>t},placeholder:{type:String,default:""},noKatex:{type:Boolean,default:!1},scrollAuto:{type:Boolean},formatCopiedText:{type:Function,default:t=>t},autofocus:{type:Boolean},disabled:{type:Boolean},readonly:{type:Boolean},maxlength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function,default:()=>{}},onFocus:{type:Function,default:()=>{}},noPrettier:{type:Boolean},noHighlight:{type:Boolean,default:!1}},qt=e.defineComponent({name:"MDEditorContent",props:Rt,setup(t){const a=e.ref(""),{inputWrapperRef:r,codeMirrorUt:l}=Ot(t);return it(t,a,l),()=>e.createVNode("div",{class:`${o.prefix}-content`},[e.createVNode("div",{class:`${o.prefix}-input-wrapper`,ref:r},null),e.createVNode(w.ContentPreview,{modelValue:t.value,setting:t.setting,onHtmlChanged:c=>{a.value=c,t.onHtmlChanged(c)},onGetCatalog:t.onGetCatalog,mdHeadingId:t.mdHeadingId,noMermaid:t.noMermaid,sanitize:t.sanitize,noKatex:t.noKatex,formatCopiedText:t.formatCopiedText,noHighlight:t.noHighlight},null)])}}),Pt=e.defineComponent({props:{modelValue:{type:String,default:""}},setup(t){const a=e.inject("usedLanguageText");return()=>{var r,l;return e.createVNode("div",{class:`${o.prefix}-footer-item`},[e.createVNode("label",{class:`${o.prefix}-footer-label`},[`${(r=a.value.footer)==null?void 0:r.markdownTotal}:`]),e.createVNode("span",null,[((l=t.modelValue)==null?void 0:l.length)||0])])}}}),jt={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Gt=e.defineComponent({props:jt,setup(t){return()=>e.createVNode("div",{class:[`${o.prefix}-checkbox`,t.checked&&`${o.prefix}-checkbox-checked`],onClick:()=>{t.onChange(!t.checked)}},null)}}),Ut={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},Kt=e.defineComponent({props:Ut,setup(t){const a=e.inject("usedLanguageText");return()=>{var r;return e.createVNode("div",{class:`${o.prefix}-footer-item`},[e.createVNode("label",{class:`${o.prefix}-footer-label`,onClick:()=>{t.onScrollAutoChange(!t.scrollAuto)}},[(r=a.value.footer)==null?void 0:r.scrollAuto]),e.createVNode(Gt,{checked:t.scrollAuto,onChange:t.onScrollAutoChange},null)])}}}),_t={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},Wt=e.defineComponent({name:"MDEditorFooter",props:_t,setup(t){const a=e.computed(()=>{const l=t.footers.indexOf("="),c=l===-1?t.footers:t.footers.slice(0,l),i=l===-1?[]:t.footers.slice(l,Number.MAX_SAFE_INTEGER);return[c,i]}),r=l=>{if(o.allFooter.includes(l))switch(l){case"markdownTotal":return e.createVNode(Pt,{modelValue:t.modelValue},null);case"scrollSwitch":return e.createVNode(Kt,{scrollAuto:t.scrollAuto,onScrollAutoChange:t.onScrollAutoChange},null)}else return t.defFooters instanceof Array?t.defFooters[l]||"":t.defFooters&&t.defFooters.children instanceof Array&&t.defFooters.children[l]||""};return()=>{const l=a.value[0].map(i=>r(i)),c=a.value[1].map(i=>r(i));return e.createVNode("div",{class:`${o.prefix}-footer`},[e.createVNode("div",{class:`${o.prefix}-footer-left`},[l]),e.createVNode("div",{class:`${o.prefix}-footer-right`},[c])])}}}),zt=e.defineComponent({name:"MdEditorV3",props:w.editorProps,emits:w.editorEmits,setup(t,a){const{editorId:r,noKatex:l,noMermaid:c,noPrettier:i,noUploadImg:s,noHighlight:m}=t,g=e.reactive({scrollAuto:t.scrollAuto});w.useOnSave(t,a),w.useProvide(t),w.useExpansion(t);const[d,u]=w.useConfig(t,a),v=w.useCatalog(t);return e.onBeforeUnmount(()=>{h.bus.clear(r)}),w.useExpose(t,a,v,d,u),()=>{var p;const k=$e.getSlot({props:t,ctx:a},"defToolbars"),b=$e.getSlot({props:t,ctx:a},"defFooters");return e.createVNode("div",{id:r,class:[o.prefix,t.class,t.theme==="dark"&&`${o.prefix}-dark`,d.fullscreen||d.pageFullscreen?`${o.prefix}-fullscreen`:""],style:t.style},[e.createVNode(ot,{noPrettier:i,toolbars:t.toolbars,toolbarsExclude:t.toolbarsExclude,setting:d,updateSetting:u,tableShape:t.tableShape,defToolbars:k,noUploadImg:s},null),e.createVNode(qt,{value:t.modelValue,setting:d,mdHeadingId:t.mdHeadingId,noMermaid:c,noPrettier:i,sanitize:t.sanitize,placeholder:t.placeholder,noKatex:l,scrollAuto:g.scrollAuto,formatCopiedText:t.formatCopiedText,autofocus:t.autoFocus,disabled:t.disabled,readonly:t.readOnly,maxlength:t.maxLength,autoDetectCode:t.autoDetectCode,noHighlight:m,onChange:f=>{t.onChange?t.onChange(f):(a.emit("update:modelValue",f),a.emit("onChange",f))},onHtmlChanged:f=>{t.onHtmlChanged?t.onHtmlChanged(f):a.emit("onHtmlChanged",f)},onGetCatalog:f=>{t.onGetCatalog?t.onGetCatalog(f):a.emit("onGetCatalog",f)},onBlur:f=>{t.onBlur?t.onBlur(f):a.emit("onBlur",f)},onFocus:f=>{t.onFocus?t.onFocus(f):a.emit("onFocus",f)}},null),((p=t.footers)==null?void 0:p.length)>0&&e.createVNode(Wt,{modelValue:t.modelValue,footers:t.footers,defFooters:b,scrollAuto:g.scrollAuto,onScrollAutoChange:f=>g.scrollAuto=f},null),v.value&&e.createVNode(Be,{theme:t.theme,class:`${o.prefix}-catalog-editor`,editorId:r,mdHeadingId:t.mdHeadingId,key:"internal-catalog"},null)])}}}),ae=zt;ae.install=t=>(t.component(ae.name,ae),t.use(Ge).use(K.DropdownToolbar).use(ne.ModalToolbar).use(Be).use(w.MdPreview),t);module.exports=ae;
@@ -1 +1 @@
1
- "use strict";const e=require("./chunks/index.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/event-bus.cjs");require("./chunks/dom.cjs");require("./chunks/index4.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");module.exports=e.MdPreview;
1
+ "use strict";const e=require("./chunks/index.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/index4.cjs");require("./chunks/dom.cjs");require("@vavt/util");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");module.exports=e.MdPreview;
@@ -1 +1 @@
1
- "use strict";const r=require("./chunks/index3.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/vue-tsx.cjs");require("./chunks/dom.cjs");require("./chunks/index4.cjs");module.exports=r.ModalToolbar;
1
+ "use strict";const r=require("./chunks/index3.cjs");require("vue");require("./chunks/config.cjs");require("./chunks/vue-tsx.cjs");require("./chunks/dom.cjs");require("@vavt/util");module.exports=r.ModalToolbar;
@@ -1 +1 @@
1
- "use strict";const E=require("./index4.cjs"),y=(e,d)=>{const t=n=>{const o=e.parentElement||document.body,i=o.offsetWidth,u=o.offsetHeight,{clientWidth:l}=document.documentElement,{clientHeight:m}=document.documentElement,p=n.offsetX,v=n.offsetY,a=f=>{let s=f.x+document.body.scrollLeft-document.body.clientLeft-p,c=f.y+document.body.scrollTop-document.body.clientTop-v;s=s<1?1:s<l-i-1?s:l-i-1,c=c<1?1:c<m-u-1?c:m-u-1,d?d(s,c):(o.style.left=`${s}px`,o.style.top=`${c}px`)};document.addEventListener("mousemove",a);const r=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)};document.addEventListener("mouseup",r)};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},L=(e,d="")=>{const t=document.getElementById(e.id),n=e.onload;e.onload=null;const o=function(i){typeof n=="function"&&n.bind(this)(i),e.removeEventListener("load",o)};t?d!==""&&(t.addEventListener("load",o),Reflect.get(window,d)&&t.dispatchEvent(new Event("load"))):(e.addEventListener("load",o),document.head.appendChild(e))},h=E.debounce((e,d,t)=>{const n=document.getElementById(e);n&&n.setAttribute(d,t)},10);exports.appendHandler=L;exports.keyMove=y;exports.updateHandler=h;
1
+ "use strict";const E=require("@vavt/util"),y=(e,d)=>{const t=n=>{const o=e.parentElement||document.body,u=o.offsetWidth,i=o.offsetHeight,{clientWidth:l}=document.documentElement,{clientHeight:m}=document.documentElement,p=n.offsetX,v=n.offsetY,a=f=>{let s=f.x+document.body.scrollLeft-document.body.clientLeft-p,c=f.y+document.body.scrollTop-document.body.clientTop-v;s=s<1?1:s<l-u-1?s:l-u-1,c=c<1?1:c<m-i-1?c:m-i-1,d?d(s,c):(o.style.left=`${s}px`,o.style.top=`${c}px`)};document.addEventListener("mousemove",a);const r=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",r)};document.addEventListener("mouseup",r)};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},L=(e,d="")=>{const t=document.getElementById(e.id),n=e.onload;e.onload=null;const o=function(u){typeof n=="function"&&n.bind(this)(u),e.removeEventListener("load",o)};t?d!==""&&(t.addEventListener("load",o),Reflect.get(window,d)&&t.dispatchEvent(new Event("load"))):(e.addEventListener("load",o),document.head.appendChild(e))},h=E.debounce((e,d,t)=>{const n=document.getElementById(e);n&&n.setAttribute(d,t)},10);exports.appendHandler=L;exports.keyMove=y;exports.updateHandler=h;
@@ -1,8 +1,8 @@
1
- "use strict";const s=require("vue"),d=require("./config.cjs"),w=require("./event-bus.cjs"),C=require("./dom.cjs"),z=require("medium-zoom"),I=require("./index4.cjs"),K=require("copy-to-clipboard"),W=require("markdown-it"),Z=require("markdown-it-image-figures"),J=require("markdown-it-task-lists"),X=require("lru-cache"),P="onSave",_="changeCatalogVisible",O="changeFullscreen",H="pageFullscreenChanged",M="fullscreenChanged",F="previewChanged",R="htmlPreviewChanged",A="catalogVisibleChanged",N="textareaFocus",Q=(e,o)=>{const a=s.inject("editorId"),n=I.debounce(()=>{const t=document.querySelectorAll(`#${a}-preview img`);t.length!==0&&z(t,{background:"#00000073"})});s.onMounted(n),s.watch([o,s.toRef(e.setting,"preview")],n)},Y=Q,ee=(e,o)=>{const a=s.inject("editorId"),n=s.inject("usedLanguageText"),t=()=>{document.querySelectorAll(`#${a}-preview pre`).forEach(l=>{var f,h;let m=-1;(f=l.querySelector(".copy-button"))==null||f.remove();const u=((h=n.value.copyCode)==null?void 0:h.text)||"复制代码",r=document.createElement("span");r.setAttribute("class","copy-button"),r.dataset.tips=u,r.innerHTML=`<svg class="${d.prefix}-icon" aria-hidden="true"><use xlink:href="#${d.prefix}-icon-copy"></use></svg>`,r.addEventListener("click",()=>{var $,b;clearTimeout(m);const k=l.querySelector("code").innerText,p=K(e.formatCopiedText(k)),v=(($=n.value.copyCode)==null?void 0:$.successTips)||"已复制!",g=((b=n.value.copyCode)==null?void 0:b.failTips)||"已复制!";r.dataset.tips=p?v:g,m=window.setTimeout(()=>{r.dataset.tips=u},1500)}),l.appendChild(r)})},i=()=>{s.nextTick(t)},c=l=>{l&&s.nextTick(t)};s.watch(()=>o.value,i),s.watch(()=>e.setting.preview,c),s.watch(()=>e.setting.htmlPreview,c),s.watch(()=>n.value,t),s.onMounted(t)},ne=ee,te=e=>{var i;const o=(i=d.configOption.editorExtensions)==null?void 0:i.highlight,a=o==null?void 0:o.instance,n=s.inject("highlight"),t=s.shallowRef(a);return s.onMounted(()=>{if(!e.noHighlight&&!t.value){const c=document.createElement("script");c.src=n.value.js,c.onload=()=>{t.value=window.hljs},c.id=`${d.prefix}-hljs`,C.appendHandler(c,"hljs");const l=document.createElement("link");l.rel="stylesheet",l.href=n.value.css,l.id=`${d.prefix}-hlCss`,C.appendHandler(l)}}),s.watch(()=>n.value.css,c=>{C.updateHandler(`${d.prefix}-hlCss`,"href",c)}),t},re=te,oe=e=>{const o=s.inject("theme"),{editorExtensions:a}=d.configOption,n=a==null?void 0:a.mermaid,t=s.shallowRef(n==null?void 0:n.instance),i=s.shallowRef(!1),c=new X({max:1e3,ttl:6e5}),l=()=>{const u=t.value;!e.noMermaid&&u&&(u.initialize({startOnLoad:!1,theme:o.value==="dark"?"dark":"default"}),i.value=!i.value)};return s.watch(()=>o.value,()=>{c.clear(),l()}),s.onMounted(()=>{if(!e.noMermaid&&!(n!=null&&n.instance)){const u=(n==null?void 0:n.js)||d.mermaidUrl;if(/\.mjs/.test(u))import(u).then(r=>{t.value=r.default,l()});else{const r=document.createElement("script");r.id=`${d.prefix}-mermaid`,r.src=u,r.onload=()=>{t.value=window.mermaid,l()},C.appendHandler(r,"mermaid")}}}),{mermaidRef:t,reRenderRef:i,replaceMermaid:()=>{s.nextTick(()=>{!e.noMermaid&&t.value&&document.querySelectorAll(`div.${d.prefix}-mermaid`).forEach(async r=>{let f=c.get(r.innerText);if(!f){const k=I.uuid(),v=await(t.value.renderAsync||t.value.render)(k,r.innerText);f=typeof v=="string"?v:v.svg,c.set(r.innerText,f)}const h=document.createElement("p");h.className=`${d.prefix}-mermaid`,h.setAttribute("data-processed",""),h.innerHTML=f,r.dataset.line!==void 0&&(h.dataset.line=r.dataset.line),r.replaceWith(h)})})}}},ie=oe,ae=e=>{var t;const o=(t=d.configOption.editorExtensions)==null?void 0:t.katex,a=o==null?void 0:o.instance,n=s.shallowRef(a);return s.onMounted(()=>{if(!e.noKatex&&!n.value){const i=document.createElement("script");i.src=(o==null?void 0:o.js)||d.katexUrl.js,i.onload=()=>{n.value=window.katex},i.id=`${d.prefix}-katex`;const c=document.createElement("link");c.rel="stylesheet",c.href=(o==null?void 0:o.css)||d.katexUrl.css,c.id=`${d.prefix}-katexCss`,C.appendHandler(i,"katex"),C.appendHandler(c)}}),n},le=ae,ce=(e,o)=>{const a=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(n,t,i,c,l)=>{const m=n[t],u=m.content.trim();if(m.info==="mermaid"){let r;return n[t].map&&n[t].level===0&&(r=n[t].map[0],n[t].attrSet("data-line",String(r))),`<div class="${d.prefix}-mermaid" ${r!==void 0?"data-line="+r:""} data-mermaid-theme=${o.themeRef.value}>${u}</div>`}return a(n,t,i,c,l)}},se=ce,L=(e,o)=>{let a=!0,n=!0;const t=e.posMax,i=o>0?e.src.charCodeAt(o-1):-1,c=o+1<=t?e.src.charCodeAt(o+1):-1;return(i===32||i===9||c>=48&&c<=57)&&(n=!1),(c===32||c===9)&&(a=!1),{can_open:a,can_close:n}},ue=(e,o)=>{let a,n,t,i;if(e.src[e.pos]!=="$")return!1;if(t=L(e,e.pos),!t.can_open)return o||(e.pending+="$"),e.pos+=1,!0;const c=e.pos+1;for(a=c;(a=e.src.indexOf("$",a))!==-1;){for(i=a-1;e.src[i]==="\\";)i-=1;if((a-i)%2==1)break;a+=1}return a===-1?(o||(e.pending+="$"),e.pos=c,!0):a-c===0?(o||(e.pending+="$$"),e.pos=c+1,!0):(t=L(e,a),t.can_close?(o||(n=e.push("math_inline","math",0),n.markup="$",n.content=e.src.slice(c,a)),e.pos=a+1,!0):(o||(e.pending+="$"),e.pos=c,!0))},de=(e,o,a,n)=>{let t,i,c,l,m=!1,u=e.bMarks[o]+e.tShift[o],r=e.eMarks[o];if(u+2>r||e.src.slice(u,u+2)!=="$$")return!1;if(u+=2,t=e.src.slice(u,r),n)return!0;for(t.trim().slice(-2)==="$$"&&(t=t.trim().slice(0,-2),m=!0),c=o;!m&&(c++,!(c>=a||(u=e.bMarks[c]+e.tShift[c],r=e.eMarks[c],u<r&&e.tShift[c]<e.blkIndent)));)e.src.slice(u,r).trim().slice(-2)==="$$"&&(l=e.src.slice(0,r).lastIndexOf("$$"),i=e.src.slice(u,l),m=!0);e.line=c+1;const f=e.push("math_block","math",0);return f.block=!0,f.content=(t&&t.trim()?t+`
1
+ "use strict";const s=require("vue"),d=require("./config.cjs"),b=require("./index4.cjs"),C=require("./dom.cjs"),z=require("medium-zoom"),L=require("@vavt/util"),K=require("copy-to-clipboard"),W=require("markdown-it"),Z=require("markdown-it-image-figures"),J=require("markdown-it-task-lists"),X=require("lru-cache"),I="onSave",P="changeCatalogVisible",O="changeFullscreen",_="pageFullscreenChanged",H="fullscreenChanged",M="previewChanged",F="htmlPreviewChanged",R="catalogVisibleChanged",N="textareaFocus",Q=(e,o)=>{const a=s.inject("editorId"),n=L.debounce(()=>{const t=document.querySelectorAll(`#${a}-preview img`);t.length!==0&&z(t,{background:"#00000073"})});s.onMounted(n),s.watch([o,s.toRef(e.setting,"preview")],n)},Y=Q,ee=(e,o)=>{const a=s.inject("editorId"),n=s.inject("usedLanguageText"),t=()=>{document.querySelectorAll(`#${a}-preview pre`).forEach(l=>{var f,h;let m=-1;(f=l.querySelector(".copy-button"))==null||f.remove();const u=((h=n.value.copyCode)==null?void 0:h.text)||"复制代码",r=document.createElement("span");r.setAttribute("class","copy-button"),r.dataset.tips=u,r.innerHTML=`<svg class="${d.prefix}-icon" aria-hidden="true"><use xlink:href="#${d.prefix}-icon-copy"></use></svg>`,r.addEventListener("click",()=>{var $,w;clearTimeout(m);const k=l.querySelector("code").innerText,p=K(e.formatCopiedText(k)),v=(($=n.value.copyCode)==null?void 0:$.successTips)||"已复制!",g=((w=n.value.copyCode)==null?void 0:w.failTips)||"已复制!";r.dataset.tips=p?v:g,m=window.setTimeout(()=>{r.dataset.tips=u},1500)}),l.appendChild(r)})},i=()=>{s.nextTick(t)},c=l=>{l&&s.nextTick(t)};s.watch(()=>o.value,i),s.watch(()=>e.setting.preview,c),s.watch(()=>e.setting.htmlPreview,c),s.watch(()=>n.value,t),s.onMounted(t)},ne=ee,te=e=>{var i;const o=(i=d.configOption.editorExtensions)==null?void 0:i.highlight,a=o==null?void 0:o.instance,n=s.inject("highlight"),t=s.shallowRef(a);return s.onMounted(()=>{if(!e.noHighlight&&!t.value){const c=document.createElement("script");c.src=n.value.js,c.onload=()=>{t.value=window.hljs},c.id=`${d.prefix}-hljs`,C.appendHandler(c,"hljs");const l=document.createElement("link");l.rel="stylesheet",l.href=n.value.css,l.id=`${d.prefix}-hlCss`,C.appendHandler(l)}}),s.watch(()=>n.value.css,c=>{C.updateHandler(`${d.prefix}-hlCss`,"href",c)}),t},re=te,oe=e=>{const o=s.inject("theme"),{editorExtensions:a}=d.configOption,n=a==null?void 0:a.mermaid,t=s.shallowRef(n==null?void 0:n.instance),i=s.shallowRef(!1),c=new X({max:1e3,ttl:6e5}),l=()=>{const u=t.value;!e.noMermaid&&u&&(u.initialize({startOnLoad:!1,theme:o.value==="dark"?"dark":"default"}),i.value=!i.value)};return s.watch(()=>o.value,()=>{c.clear(),l()}),s.onMounted(()=>{if(!e.noMermaid&&!(n!=null&&n.instance)){const u=(n==null?void 0:n.js)||d.mermaidUrl;if(/\.mjs/.test(u))import(u).then(r=>{t.value=r.default,l()});else{const r=document.createElement("script");r.id=`${d.prefix}-mermaid`,r.src=u,r.onload=()=>{t.value=window.mermaid,l()},C.appendHandler(r,"mermaid")}}}),{mermaidRef:t,reRenderRef:i,replaceMermaid:()=>{s.nextTick(()=>{!e.noMermaid&&t.value&&document.querySelectorAll(`div.${d.prefix}-mermaid`).forEach(async r=>{let f=c.get(r.innerText);if(!f){const k=b.uuid(),v=await(t.value.renderAsync||t.value.render)(k,r.innerText);f=typeof v=="string"?v:v.svg,c.set(r.innerText,f)}const h=document.createElement("p");h.className=`${d.prefix}-mermaid`,h.setAttribute("data-processed",""),h.innerHTML=f,r.dataset.line!==void 0&&(h.dataset.line=r.dataset.line),r.replaceWith(h)})})}}},ie=oe,ae=e=>{var t;const o=(t=d.configOption.editorExtensions)==null?void 0:t.katex,a=o==null?void 0:o.instance,n=s.shallowRef(a);return s.onMounted(()=>{if(!e.noKatex&&!n.value){const i=document.createElement("script");i.src=(o==null?void 0:o.js)||d.katexUrl.js,i.onload=()=>{n.value=window.katex},i.id=`${d.prefix}-katex`;const c=document.createElement("link");c.rel="stylesheet",c.href=(o==null?void 0:o.css)||d.katexUrl.css,c.id=`${d.prefix}-katexCss`,C.appendHandler(i,"katex"),C.appendHandler(c)}}),n},le=ae,ce=(e,o)=>{const a=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(n,t,i,c,l)=>{const m=n[t],u=m.content.trim();if(m.info==="mermaid"){let r;return n[t].map&&n[t].level===0&&(r=n[t].map[0],n[t].attrSet("data-line",String(r))),`<div class="${d.prefix}-mermaid" ${r!==void 0?"data-line="+r:""} data-mermaid-theme=${o.themeRef.value}>${u}</div>`}return a(n,t,i,c,l)}},se=ce,A=(e,o)=>{let a=!0,n=!0;const t=e.posMax,i=o>0?e.src.charCodeAt(o-1):-1,c=o+1<=t?e.src.charCodeAt(o+1):-1;return(i===32||i===9||c>=48&&c<=57)&&(n=!1),(c===32||c===9)&&(a=!1),{can_open:a,can_close:n}},ue=(e,o)=>{let a,n,t,i;if(e.src[e.pos]!=="$")return!1;if(t=A(e,e.pos),!t.can_open)return o||(e.pending+="$"),e.pos+=1,!0;const c=e.pos+1;for(a=c;(a=e.src.indexOf("$",a))!==-1;){for(i=a-1;e.src[i]==="\\";)i-=1;if((a-i)%2==1)break;a+=1}return a===-1?(o||(e.pending+="$"),e.pos=c,!0):a-c===0?(o||(e.pending+="$$"),e.pos=c+1,!0):(t=A(e,a),t.can_close?(o||(n=e.push("math_inline","math",0),n.markup="$",n.content=e.src.slice(c,a)),e.pos=a+1,!0):(o||(e.pending+="$"),e.pos=c,!0))},de=(e,o,a,n)=>{let t,i,c,l,m=!1,u=e.bMarks[o]+e.tShift[o],r=e.eMarks[o];if(u+2>r||e.src.slice(u,u+2)!=="$$")return!1;if(u+=2,t=e.src.slice(u,r),n)return!0;for(t.trim().slice(-2)==="$$"&&(t=t.trim().slice(0,-2),m=!0),c=o;!m&&(c++,!(c>=a||(u=e.bMarks[c]+e.tShift[c],r=e.eMarks[c],u<r&&e.tShift[c]<e.blkIndent)));)e.src.slice(u,r).trim().slice(-2)==="$$"&&(l=e.src.slice(0,r).lastIndexOf("$$"),i=e.src.slice(u,l),m=!0);e.line=c+1;const f=e.push("math_block","math",0);return f.block=!0,f.content=(t&&t.trim()?t+`
2
2
  `:"")+e.getLines(o+1,c,e.tShift[o],!0)+(i&&i.trim()?i:""),f.map=[o,e.line],f.markup="$$",!0},me=(e,o)=>{const a=t=>{if(o.katexRef.value){const i=o.katexRef.value.renderToString(t,{throwOnError:!1});return`<span class="${d.prefix}-katex-inline" data-processed>${i}</span>`}else return`<span class="${d.prefix}-katex-inline">${t}</span>`},n=(t,i)=>{if(o.katexRef.value){const c=o.katexRef.value.renderToString(t,{throwOnError:!1,displayMode:!0});return`<p class="${d.prefix}-katex-block" data-line=${i} data-processed>${c}</p>`}else return`<p class="${d.prefix}-katex-block" data-line=${i}>${t}</p>`};e.inline.ruler.after("escape","math_inline",ue),e.block.ruler.after("blockquote","math_block",de,{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=(t,i)=>a(t[i].content),e.renderer.rules.math_block=(t,i)=>n(t[i].content,t[i].map[0])+`
3
- `},fe=me,pe=(e,o)=>{o=o||{};const a=3,n=o.marker||"!",t=n.charCodeAt(0),i=n.length;let c="",l="";const m=(r,f,h,k,p)=>{const v=r[f];return v.type==="admonition_open"?(r[f].attrPush(["class",`${d.prefix}-admonition ${d.prefix}-admonition-${v.info}`]),r[f].attrSet("data-line",String(r[f].map[0]))):v.type==="admonition_title_open"&&r[f].attrPush(["class",`${d.prefix}-admonition-title`]),p.renderToken(r,f,h)},u=r=>{const f=r.trim().split(" ",2);l="",c=f[0],f.length>1&&(l=r.substring(c.length+2)),(l===""||!l)&&(l=c)};e.block.ruler.before("code","admonition",(r,f,h,k)=>{let p,v,g,$=!1,b=r.bMarks[f]+r.tShift[f],y=r.eMarks[f];if(t!==r.src.charCodeAt(b))return!1;for(p=b+1;p<=y&&n[(p-b)%i]===r.src[p];p++);const x=Math.floor((p-b)/i);if(x!==a)return!1;p-=(p-b)%i;const E=r.src.slice(b,p),S=r.src.slice(p,y);if(u(S),k)return!0;for(v=f;v++,!(v>=h||(b=r.bMarks[v]+r.tShift[v],y=r.eMarks[v],b<y&&r.sCount[v]<r.blkIndent));)if(t===r.src.charCodeAt(b)&&!(r.sCount[v]-r.blkIndent>=4)){for(p=b+1;p<=y&&n[(p-b)%i]===r.src[p];p++);if(!(Math.floor((p-b)/i)<x)&&(p-=(p-b)%i,p=r.skipSpaces(p),!(p<y))){$=!0;break}}const q=r.parentType,D=r.lineMax;return r.parentType="root",r.lineMax=v,g=r.push("admonition_open","div",1),g.markup=E,g.block=!0,g.info=c,g.map=[f,v],g=r.push("admonition_title_open","p",1),g.markup=E+" "+c,g.map=[f,v],g=r.push("inline","",0),g.content=l,g.map=[f,r.line-1],g.children=[],g=r.push("admonition_title_close","p",-1),g.markup=E+" "+c,r.md.block.tokenize(r,f+1,v),g=r.push("admonition_close","div",-1),g.markup=r.src.slice(b,p),g.block=!0,r.parentType=q,r.lineMax=D,r.line=v+($?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=m,e.renderer.rules.admonition_title_open=m,e.renderer.rules.admonition_title_close=m,e.renderer.rules.admonition_close=m},he=pe,ge=(e,o)=>{let a;e.core.ruler.push("headingLinks",n=>{a||(a=n.Token)}),e.renderer.rules.heading_open=(n,t)=>{const i=n[t],c=n[t+1].content,l=i.markup.length;return o.headsRef.value.push({text:c,level:l}),i.map&&i.level===0&&(i.attrSet("data-line",String(i.map[0])),i.attrSet("id",o.mdHeadingId(c,l,o.headsRef.value.length))),e.renderer.renderToken(n,t,o)},e.renderer.rules.heading_close=(n,t,i,c,l)=>l.renderToken(n,t,i)},ve=ge,be=(e,o)=>{const a=e.renderer.rules.fence,n=e.utils.unescapeAll,t=/\[(\w*)(?::([\w ]*))?\]/;function i(u){return u.info?n(u.info).trim():""}function c(u){const r=i(u),[f=null,h=""]=(t.exec(r)||[]).slice(1);return[f,h]}function l(u){const r=i(u);return r?r.split(/(\s+)/g)[0]:""}const m=(u,r,f,h,k)=>{if(u[r].hidden)return"";const[p,v]=c(u[r]);if(p===null)return a(u,r,f,h,k);let g,$,b,y,x="",E="";for(let S=r;S<u.length&&(g=u[S],[$,b]=c(g),$===p);S++)g.info=g.info.replace(t,""),g.hidden=!0,y=S-r>0?"":" checked",x+=`<li><input type="radio" name="label-group-${o.editorId}-${r}"${y}><label for="group-${o.editorId}-${r}-tab-${S-r}" onclick="this.previousElementSibling.click()">${b||l(g)}</label></li>
3
+ `},fe=me,pe=(e,o)=>{o=o||{};const a=3,n=o.marker||"!",t=n.charCodeAt(0),i=n.length;let c="",l="";const m=(r,f,h,k,p)=>{const v=r[f];return v.type==="admonition_open"?(r[f].attrPush(["class",`${d.prefix}-admonition ${d.prefix}-admonition-${v.info}`]),r[f].attrSet("data-line",String(r[f].map[0]))):v.type==="admonition_title_open"&&r[f].attrPush(["class",`${d.prefix}-admonition-title`]),p.renderToken(r,f,h)},u=r=>{const f=r.trim().split(" ",2);l="",c=f[0],f.length>1&&(l=r.substring(c.length+2)),(l===""||!l)&&(l=c)};e.block.ruler.before("code","admonition",(r,f,h,k)=>{let p,v,g,$=!1,w=r.bMarks[f]+r.tShift[f],y=r.eMarks[f];if(t!==r.src.charCodeAt(w))return!1;for(p=w+1;p<=y&&n[(p-w)%i]===r.src[p];p++);const x=Math.floor((p-w)/i);if(x!==a)return!1;p-=(p-w)%i;const E=r.src.slice(w,p),S=r.src.slice(p,y);if(u(S),k)return!0;for(v=f;v++,!(v>=h||(w=r.bMarks[v]+r.tShift[v],y=r.eMarks[v],w<y&&r.sCount[v]<r.blkIndent));)if(t===r.src.charCodeAt(w)&&!(r.sCount[v]-r.blkIndent>=4)){for(p=w+1;p<=y&&n[(p-w)%i]===r.src[p];p++);if(!(Math.floor((p-w)/i)<x)&&(p-=(p-w)%i,p=r.skipSpaces(p),!(p<y))){$=!0;break}}const q=r.parentType,D=r.lineMax;return r.parentType="root",r.lineMax=v,g=r.push("admonition_open","div",1),g.markup=E,g.block=!0,g.info=c,g.map=[f,v],g=r.push("admonition_title_open","p",1),g.markup=E+" "+c,g.map=[f,v],g=r.push("inline","",0),g.content=l,g.map=[f,r.line-1],g.children=[],g=r.push("admonition_title_close","p",-1),g.markup=E+" "+c,r.md.block.tokenize(r,f+1,v),g=r.push("admonition_close","div",-1),g.markup=r.src.slice(w,p),g.block=!0,r.parentType=q,r.lineMax=D,r.line=v+($?1:0),!0},{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.admonition_open=m,e.renderer.rules.admonition_title_open=m,e.renderer.rules.admonition_title_close=m,e.renderer.rules.admonition_close=m},he=pe,ge=(e,o)=>{let a;e.core.ruler.push("headingLinks",n=>{a||(a=n.Token)}),e.renderer.rules.heading_open=(n,t)=>{const i=n[t],c=n[t+1].content,l=i.markup.length;return o.headsRef.value.push({text:c,level:l}),i.map&&i.level===0&&(i.attrSet("data-line",String(i.map[0])),i.attrSet("id",o.mdHeadingId(c,l,o.headsRef.value.length))),e.renderer.renderToken(n,t,o)},e.renderer.rules.heading_close=(n,t,i,c,l)=>l.renderToken(n,t,i)},ve=ge,be=(e,o)=>{const a=e.renderer.rules.fence,n=e.utils.unescapeAll,t=/\[(\w*)(?::([\w ]*))?\]/;function i(u){return u.info?n(u.info).trim():""}function c(u){const r=i(u),[f=null,h=""]=(t.exec(r)||[]).slice(1);return[f,h]}function l(u){const r=i(u);return r?r.split(/(\s+)/g)[0]:""}const m=(u,r,f,h,k)=>{if(u[r].hidden)return"";const[p,v]=c(u[r]);if(p===null)return a(u,r,f,h,k);let g,$,w,y,x="",E="";for(let S=r;S<u.length&&(g=u[S],[$,w]=c(g),$===p);S++)g.info=g.info.replace(t,""),g.hidden=!0,y=S-r>0?"":" checked",x+=`<li><input type="radio" name="label-group-${o.editorId}-${r}"${y}><label for="group-${o.editorId}-${r}-tab-${S-r}" onclick="this.previousElementSibling.click()">${w||l(g)}</label></li>
4
4
  `,E+=`<input type="radio" id="group-${o.editorId}-${r}-tab-${S-r}" name="group-${o.editorId}-${r}"${y}>
5
5
  `+a(u,S,f,h,k);return`<div class="code-tabs">
6
6
  <ul>
7
7
  `+x+`</ul>
8
- `+E+"</div>"};e.renderer.rules.fence=m},we=be,ye=e=>{["paragraph_open","table_open","ordered_list_open","bullet_list_open","blockquote_open","hr"].forEach(o=>{e.renderer.rules[o]=(a,n,t,i,c)=>{let l;return a[n].map&&a[n].level===0&&(l=a[n].map[0],a[n].attrSet("data-line",String(l))),c.renderToken(a,n,t)}}),["html_block","fence"].forEach(o=>{const a=e.renderer.rules[o];e.renderer.rules[o]=(n,t,i,c,l)=>{let m;const u=a(n,t,i,c,l);return n[t].map&&n[t].level===0?(m=n[t].map[0],u.replace(/^(<[^>]*)/,`$1 data-line="${m}"`)):u}})},ke=(e,o)=>{const{editorConfig:a,markdownItConfig:n}=d.configOption,t=s.inject("editorId"),i=s.inject("showCodeRowNumber"),c=s.inject("theme"),l=s.ref([]),m=re(e),u=le(e),{reRenderRef:r,replaceMermaid:f}=ie(e),h=W({html:!0,breaks:!0});n(h),h.use(fe,{katexRef:u}),h.use(Z,{figcaption:!0}),h.use(he),h.use(J),h.use(ve,{mdHeadingId:e.mdHeadingId,headsRef:l}),h.use(we,{editorId:t}),e.noMermaid||h.use(se,{themeRef:c}),h.set({highlight:($,b)=>{let y;!e.noHighlight&&m.value?m.value.getLanguage(b)?y=m.value.highlight($,{language:b,ignoreIllegals:!0}).value:y=m.value.highlightAuto($).value:y=h.utils.escapeHtml($);const x=i?I.generateCodeRowNumber(y.trim()):`<span class="code-block">${y.trim()}</span>`;return`<pre><code class="language-${b}" language=${b}>${x}</code></pre>`}}),ye(h);const k=s.ref(e.sanitize(h.render(e.modelValue))),p=()=>{w.bus.emit(t,"buildFinished",k.value),e.onHtmlChanged(k.value),e.onGetCatalog(l.value),w.bus.emit(t,"catalogChanged",l.value),f()};s.onMounted(p);const v=I.debounce(async()=>{l.value=[],k.value=e.sanitize(h.render(e.modelValue)),p()},(a==null?void 0:a.renderDelay)!==void 0?a==null?void 0:a.renderDelay:o?0:500),g=s.computed(()=>(e.noKatex||u.value)&&(e.noHighlight||m.value));return s.watch([s.toRef(e,"modelValue"),g,r],v),s.onMounted(()=>{w.bus.on(t,{name:"pushCatalog",callback(){w.bus.emit(t,"catalogChanged",l.value)}})}),{html:k}},$e=ke,Ce={modelValue:{type:String,default:""},setting:{type:Object,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}},j=s.defineComponent({name:"ContentPreview",props:Ce,setup(e){const o=s.inject("editorId"),a=s.inject("previewTheme"),n=s.inject("showCodeRowNumber"),{html:t}=$e(e,e.previewOnly);return ne(e,t),Y(e,t),()=>s.createVNode(s.Fragment,null,[s.createVNode("div",{id:`${o}-preview-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.preview,key:"content-preview-wrapper"},[s.createVNode("article",{id:`${o}-preview`,class:[`${d.prefix}-preview`,`${a==null?void 0:a.value}-theme`,n&&`${d.prefix}-scrn`],innerHTML:t.value},null)]),!e.previewOnly&&s.createVNode("div",{id:`${o}-html-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.htmlPreview,key:"html-preview-wrapper"},[s.createVNode("div",{class:`${d.prefix}-html`},[t.value])])])}}),xe=(e,o)=>{const{editorId:a}=e,n=s.reactive({buildFinished:!1,html:""});s.watch(()=>e.modelValue,()=>{n.buildFinished=!1}),s.onMounted(()=>{w.bus.on(a,{name:"buildFinished",callback(t){n.buildFinished=!0,n.html=t}}),w.bus.on(a,{name:P,callback(){const t=new Promise(i=>{if(n.buildFinished)i(n.html);else{const c=l=>{i(l),w.bus.remove(a,"buildFinished",c)};w.bus.on(a,{name:"buildFinished",callback:c})}});e.onSave?e.onSave(e.modelValue,t):o.emit("onSave",e.modelValue,t)}})})},V=e=>{var t,i;const{editorId:o}=e,a=(i=(t=d.configOption)==null?void 0:t.editorExtensions)==null?void 0:i.highlight;s.provide("editorId",o),s.provide("theme",s.computed(()=>e.theme)),s.provide("highlight",s.computed(()=>{const c={...d.codeCss,...a==null?void 0:a.css},l=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(a==null?void 0:a.js)||d.highlightUrl,css:c[e.codeTheme]?c[e.codeTheme][l]:d.codeCss.atom[l]}})),s.provide("showCodeRowNumber",e.showCodeRowNumber);const n=s.computed(()=>{var l,m;const c={...d.staticTextDefault,...(m=(l=d.configOption)==null?void 0:l.editorConfig)==null?void 0:m.languageUserDefined};return c[e.language]?c[e.language]:d.staticTextDefault["zh-CN"]});s.provide("usedLanguageText",n),s.provide("previewTheme",s.computed(()=>e.previewTheme))},Se=e=>{V(e),s.provide("tabWidth",e.tabWidth)},B=e=>{s.onMounted(()=>{var a;const o=document.createElement("script");o.src=((a=d.configOption.editorExtensions)==null?void 0:a.iconfont)||d.iconfontUrl,o.id=`${d.prefix}-icon`,e.noIconfont||C.appendHandler(o)})},Ee=e=>{var l,m,u,r,f,h;const{noPrettier:o,noUploadImg:a}=e,{editorExtensions:n}=d.configOption,t=o||!!((m=(l=d.configOption.editorExtensions)==null?void 0:l.prettier)!=null&&m.prettierInstance),i=o||!!((r=(u=d.configOption.editorExtensions)==null?void 0:u.prettier)!=null&&r.parserMarkdownInstance),c=a||!!((h=(f=d.configOption.editorExtensions)==null?void 0:f.cropper)!=null&&h.instance);s.onMounted(()=>{var $,b,y,x;const k=document.createElement("script"),p=document.createElement("script");k.src=(($=n==null?void 0:n.prettier)==null?void 0:$.standaloneJs)||d.prettierUrl.main,k.id=`${d.prefix}-prettier`,p.src=((b=n==null?void 0:n.prettier)==null?void 0:b.parserMarkdownJs)||d.prettierUrl.markdown,p.id=`${d.prefix}-prettierMD`;const v=document.createElement("link");v.rel="stylesheet",v.href=((y=n==null?void 0:n.cropper)==null?void 0:y.css)||d.cropperUrl.css,v.id=`${d.prefix}-cropperCss`;const g=document.createElement("script");g.src=((x=n==null?void 0:n.cropper)==null?void 0:x.js)||d.cropperUrl.js,g.id=`${d.prefix}-cropper`,c||(C.appendHandler(v),C.appendHandler(g)),t||C.appendHandler(k),i||C.appendHandler(p)}),B(e)},Te=(e,o)=>{const{editorId:a}=e,n=s.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),t=(l,m)=>{n[l]=m===void 0?!n[l]:m,l==="preview"&&n.preview?n.htmlPreview=!1:l==="htmlPreview"&&n.htmlPreview&&(n.preview=!1)};let i="";const c=()=>{n.pageFullscreen||n.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=i};return s.watch(()=>[n.pageFullscreen,n.fullscreen],c),s.onMounted(()=>{w.bus.on(a,{name:"uploadImage",callback(l,m){const u=r=>{w.bus.emit(a,"replace","image",{desc:"",urls:r}),m&&m()};e.onUploadImg?e.onUploadImg(l,u):o.emit("onUploadImg",l,u)}}),i=document.body.style.overflow,c()}),[n,t]},Ie=e=>{const{editorId:o}=e,a=s.ref(!1);return s.onMounted(()=>{w.bus.on(o,{name:_,callback:t=>{t===void 0?a.value=!a.value:a.value=t}})}),s.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog")&&a.value)},Pe=(e,o,a,n,t)=>{const{editorId:i}=e;s.watch(()=>n.pageFullscreen,l=>{w.bus.emit(i,H,l)}),s.watch(()=>n.fullscreen,l=>{w.bus.emit(i,M,l)}),s.watch(()=>n.preview,l=>{w.bus.emit(i,F,l)}),s.watch(()=>n.htmlPreview,l=>{w.bus.emit(i,R,l)}),s.watch(a,l=>{w.bus.emit(i,A,l)});const c={on(l,m){switch(l){case"pageFullscreen":{w.bus.on(i,{name:H,callback(u){m(u)}});break}case"fullscreen":{w.bus.on(i,{name:M,callback(u){m(u)}});break}case"preview":{w.bus.on(i,{name:F,callback(u){m(u)}});break}case"htmlPreview":{w.bus.on(i,{name:R,callback(u){m(u)}});break}case"catalog":{w.bus.on(i,{name:A,callback(u){m(u)}});break}}},togglePageFullscreen(l){t("pageFullscreen",l)},toggleFullscreen(l){w.bus.emit(i,O,l)},togglePreview(l){t("preview",l)},toggleHtmlPreview(l){t("htmlPreview",l)},toggleCatalog(l){w.bus.emit(i,_,l)},triggerSave(){w.bus.emit(i,P)},insert(l){w.bus.emit(i,"replace","universal",{generate:l})},focus(){w.bus.emit(i,N)}};o.expose(c)},_e=e=>e,U={modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},language:{type:String,default:"zh-CN"},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:d.defaultEditorId},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:_e},sanitize:{type:Function,default:e=>e},noMermaid:{type:Boolean,default:!1},noKatex:{type:Boolean,default:!1},codeTheme:{type:String,default:"atom"},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:e=>e},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},noHighlight:{type:Boolean,default:!1}},He={...U,onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},toolbars:{type:Array,default:d.allToolbar},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]},onError:{type:Function},footers:{type:Array,default:d.allFooter},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noUploadImg:{type:Boolean},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function},onFocus:{type:Function}},G=["onHtmlChanged","onGetCatalog"],Me=[...G,"onChange","onSave","onUploadImg","onError","update:modelValue","onBlur","onFocus"],Fe=s.defineComponent({name:"MdPreview",props:U,emits:G,setup(e,o){const{editorId:a,noKatex:n,noMermaid:t,noHighlight:i}=e;return V(e),B(e),s.onBeforeUnmount(()=>{w.bus.clear(a)}),()=>s.createVNode("div",{id:a,class:[d.prefix,e.class,e.theme==="dark"&&`${d.prefix}-dark`,`${d.prefix}-previewOnly`],style:e.style},[s.createVNode(j,{modelValue:e.modelValue,onHtmlChanged:c=>{e.onHtmlChanged?e.onHtmlChanged(c):o.emit("onHtmlChanged",c)},onGetCatalog:c=>{e.onGetCatalog?e.onGetCatalog(c):o.emit("onGetCatalog",c)},mdHeadingId:e.mdHeadingId,noMermaid:t,sanitize:e.sanitize,noKatex:n,formatCopiedText:e.formatCopiedText,noHighlight:i,previewOnly:!0},null)])}}),T=Fe;T.install=e=>(e.component(T.name,T),e);exports.CHANGE_CATALOG_VISIBLE=_;exports.CHANGE_FULL_SCREEN=O;exports.ContentPreview=j;exports.MdPreview=T;exports.ON_SAVE=P;exports.TEXTAREA_FOCUS=N;exports.editorEmits=Me;exports.editorProps=He;exports.useCatalog=Ie;exports.useConfig=Te;exports.useExpansion=Ee;exports.useExpose=Pe;exports.useOnSave=xe;exports.useProvide=Se;
8
+ `+E+"</div>"};e.renderer.rules.fence=m},we=be,ye=e=>{["paragraph_open","table_open","ordered_list_open","bullet_list_open","blockquote_open","hr"].forEach(o=>{e.renderer.rules[o]=(a,n,t,i,c)=>{let l;return a[n].map&&a[n].level===0&&(l=a[n].map[0],a[n].attrSet("data-line",String(l))),c.renderToken(a,n,t)}}),["html_block","fence"].forEach(o=>{const a=e.renderer.rules[o];e.renderer.rules[o]=(n,t,i,c,l)=>{let m;const u=a(n,t,i,c,l);return n[t].map&&n[t].level===0?(m=n[t].map[0],u.replace(/^(<[^>]*)/,`$1 data-line="${m}"`)):u}})},ke=(e,o)=>{const{editorConfig:a,markdownItConfig:n}=d.configOption,t=s.inject("editorId"),i=s.inject("showCodeRowNumber"),c=s.inject("theme"),l=s.ref([]),m=re(e),u=le(e),{reRenderRef:r,replaceMermaid:f}=ie(e),h=W({html:!0,breaks:!0});n(h),h.use(fe,{katexRef:u}),h.use(Z,{figcaption:!0}),h.use(he),h.use(J),h.use(ve,{mdHeadingId:e.mdHeadingId,headsRef:l}),h.use(we,{editorId:t}),e.noMermaid||h.use(se,{themeRef:c}),h.set({highlight:($,w)=>{let y;!e.noHighlight&&m.value?m.value.getLanguage(w)?y=m.value.highlight($,{language:w,ignoreIllegals:!0}).value:y=m.value.highlightAuto($).value:y=h.utils.escapeHtml($);const x=i?b.generateCodeRowNumber(y.trim()):`<span class="code-block">${y.trim()}</span>`;return`<pre><code class="language-${w}" language=${w}>${x}</code></pre>`}}),ye(h);const k=s.ref(e.sanitize(h.render(e.modelValue))),p=()=>{b.bus.emit(t,"buildFinished",k.value),e.onHtmlChanged(k.value),e.onGetCatalog(l.value),b.bus.emit(t,"catalogChanged",l.value),f()};s.onMounted(p);const v=L.debounce(async()=>{l.value=[],k.value=e.sanitize(h.render(e.modelValue)),p()},(a==null?void 0:a.renderDelay)!==void 0?a==null?void 0:a.renderDelay:o?0:500),g=s.computed(()=>(e.noKatex||u.value)&&(e.noHighlight||m.value));return s.watch([s.toRef(e,"modelValue"),g,r],v),s.onMounted(()=>{b.bus.on(t,{name:"pushCatalog",callback(){b.bus.emit(t,"catalogChanged",l.value)}})}),{html:k}},$e=ke,Ce={modelValue:{type:String,default:""},setting:{type:Object,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}},j=s.defineComponent({name:"ContentPreview",props:Ce,setup(e){const o=s.inject("editorId"),a=s.inject("previewTheme"),n=s.inject("showCodeRowNumber"),{html:t}=$e(e,e.previewOnly);return ne(e,t),Y(e,t),()=>s.createVNode(s.Fragment,null,[s.createVNode("div",{id:`${o}-preview-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.preview,key:"content-preview-wrapper"},[s.createVNode("article",{id:`${o}-preview`,class:[`${d.prefix}-preview`,`${a==null?void 0:a.value}-theme`,n&&`${d.prefix}-scrn`],innerHTML:t.value},null)]),!e.previewOnly&&s.createVNode("div",{id:`${o}-html-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.htmlPreview,key:"html-preview-wrapper"},[s.createVNode("div",{class:`${d.prefix}-html`},[t.value])])])}}),xe=(e,o)=>{const{editorId:a}=e,n=s.reactive({buildFinished:!1,html:""});s.watch(()=>e.modelValue,()=>{n.buildFinished=!1}),s.onMounted(()=>{b.bus.on(a,{name:"buildFinished",callback(t){n.buildFinished=!0,n.html=t}}),b.bus.on(a,{name:I,callback(){const t=new Promise(i=>{if(n.buildFinished)i(n.html);else{const c=l=>{i(l),b.bus.remove(a,"buildFinished",c)};b.bus.on(a,{name:"buildFinished",callback:c})}});e.onSave?e.onSave(e.modelValue,t):o.emit("onSave",e.modelValue,t)}})})},V=e=>{var t,i;const{editorId:o}=e,a=(i=(t=d.configOption)==null?void 0:t.editorExtensions)==null?void 0:i.highlight;s.provide("editorId",o),s.provide("theme",s.computed(()=>e.theme)),s.provide("highlight",s.computed(()=>{const c={...d.codeCss,...a==null?void 0:a.css},l=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(a==null?void 0:a.js)||d.highlightUrl,css:c[e.codeTheme]?c[e.codeTheme][l]:d.codeCss.atom[l]}})),s.provide("showCodeRowNumber",e.showCodeRowNumber);const n=s.computed(()=>{var l,m;const c={...d.staticTextDefault,...(m=(l=d.configOption)==null?void 0:l.editorConfig)==null?void 0:m.languageUserDefined};return c[e.language]?c[e.language]:d.staticTextDefault["zh-CN"]});s.provide("usedLanguageText",n),s.provide("previewTheme",s.computed(()=>e.previewTheme))},Se=e=>{V(e),s.provide("tabWidth",e.tabWidth)},U=e=>{s.onMounted(()=>{var a;const o=document.createElement("script");o.src=((a=d.configOption.editorExtensions)==null?void 0:a.iconfont)||d.iconfontUrl,o.id=`${d.prefix}-icon`,e.noIconfont||C.appendHandler(o)})},Ee=e=>{var l,m,u,r,f,h;const{noPrettier:o,noUploadImg:a}=e,{editorExtensions:n}=d.configOption,t=o||!!((m=(l=d.configOption.editorExtensions)==null?void 0:l.prettier)!=null&&m.prettierInstance),i=o||!!((r=(u=d.configOption.editorExtensions)==null?void 0:u.prettier)!=null&&r.parserMarkdownInstance),c=a||!!((h=(f=d.configOption.editorExtensions)==null?void 0:f.cropper)!=null&&h.instance);s.onMounted(()=>{var $,w,y,x;const k=document.createElement("script"),p=document.createElement("script");k.src=(($=n==null?void 0:n.prettier)==null?void 0:$.standaloneJs)||d.prettierUrl.main,k.id=`${d.prefix}-prettier`,p.src=((w=n==null?void 0:n.prettier)==null?void 0:w.parserMarkdownJs)||d.prettierUrl.markdown,p.id=`${d.prefix}-prettierMD`;const v=document.createElement("link");v.rel="stylesheet",v.href=((y=n==null?void 0:n.cropper)==null?void 0:y.css)||d.cropperUrl.css,v.id=`${d.prefix}-cropperCss`;const g=document.createElement("script");g.src=((x=n==null?void 0:n.cropper)==null?void 0:x.js)||d.cropperUrl.js,g.id=`${d.prefix}-cropper`,c||(C.appendHandler(v),C.appendHandler(g)),t||C.appendHandler(k),i||C.appendHandler(p)}),U(e)},Te=(e,o)=>{const{editorId:a}=e,n=s.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),t=(l,m)=>{n[l]=m===void 0?!n[l]:m,l==="preview"&&n.preview?n.htmlPreview=!1:l==="htmlPreview"&&n.htmlPreview&&(n.preview=!1)};let i="";const c=()=>{n.pageFullscreen||n.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=i};return s.watch(()=>[n.pageFullscreen,n.fullscreen],c),s.onMounted(()=>{b.bus.on(a,{name:"uploadImage",callback(l,m){const u=r=>{b.bus.emit(a,"replace","image",{desc:"",urls:r}),m&&m()};e.onUploadImg?e.onUploadImg(l,u):o.emit("onUploadImg",l,u)}}),i=document.body.style.overflow,c()}),[n,t]},Ie=e=>{const{editorId:o}=e,a=s.ref(!1);return s.onMounted(()=>{b.bus.on(o,{name:P,callback:t=>{t===void 0?a.value=!a.value:a.value=t}})}),s.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog")&&a.value)},Pe=(e,o,a,n,t)=>{const{editorId:i}=e;s.watch(()=>n.pageFullscreen,l=>{b.bus.emit(i,_,l)}),s.watch(()=>n.fullscreen,l=>{b.bus.emit(i,H,l)}),s.watch(()=>n.preview,l=>{b.bus.emit(i,M,l)}),s.watch(()=>n.htmlPreview,l=>{b.bus.emit(i,F,l)}),s.watch(a,l=>{b.bus.emit(i,R,l)});const c={on(l,m){switch(l){case"pageFullscreen":{b.bus.on(i,{name:_,callback(u){m(u)}});break}case"fullscreen":{b.bus.on(i,{name:H,callback(u){m(u)}});break}case"preview":{b.bus.on(i,{name:M,callback(u){m(u)}});break}case"htmlPreview":{b.bus.on(i,{name:F,callback(u){m(u)}});break}case"catalog":{b.bus.on(i,{name:R,callback(u){m(u)}});break}}},togglePageFullscreen(l){t("pageFullscreen",l)},toggleFullscreen(l){b.bus.emit(i,O,l)},togglePreview(l){t("preview",l)},toggleHtmlPreview(l){t("htmlPreview",l)},toggleCatalog(l){b.bus.emit(i,P,l)},triggerSave(){b.bus.emit(i,I)},insert(l){b.bus.emit(i,"replace","universal",{generate:l})},focus(){b.bus.emit(i,N)}};o.expose(c)},_e=e=>e,B={modelValue:{type:String,default:""},theme:{type:String,default:"light"},class:{type:String,default:""},language:{type:String,default:"zh-CN"},onHtmlChanged:{type:Function},onGetCatalog:{type:Function},editorId:{type:String,default:d.defaultEditorId},showCodeRowNumber:{type:Boolean,default:!1},previewTheme:{type:String,default:"default"},style:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:_e},sanitize:{type:Function,default:e=>e},noMermaid:{type:Boolean,default:!1},noKatex:{type:Boolean,default:!1},codeTheme:{type:String,default:"atom"},noIconfont:{type:Boolean},formatCopiedText:{type:Function,default:e=>e},codeStyleReverse:{type:Boolean,default:!0},codeStyleReverseList:{type:Array,default:["default","mk-cute"]},noHighlight:{type:Boolean,default:!1}},He={...B,onChange:{type:Function},onSave:{type:Function},onUploadImg:{type:Function},pageFullscreen:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},htmlPreview:{type:Boolean,default:!1},toolbars:{type:Array,default:d.allToolbar},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]},onError:{type:Function},footers:{type:Array,default:d.allFooter},scrollAuto:{type:Boolean,default:!0},defFooters:{type:[String,Object]},noUploadImg:{type:Boolean},autoFocus:{type:Boolean},disabled:{type:Boolean},readOnly:{type:Boolean},maxLength:{type:Number},autoDetectCode:{type:Boolean},onBlur:{type:Function},onFocus:{type:Function}},G=["onHtmlChanged","onGetCatalog"],Me=[...G,"onChange","onSave","onUploadImg","onError","update:modelValue","onBlur","onFocus"],Fe=s.defineComponent({name:"MdPreview",props:B,emits:G,setup(e,o){const{editorId:a,noKatex:n,noMermaid:t,noHighlight:i}=e;return V(e),U(e),s.onBeforeUnmount(()=>{b.bus.clear(a)}),()=>s.createVNode("div",{id:a,class:[d.prefix,e.class,e.theme==="dark"&&`${d.prefix}-dark`,`${d.prefix}-previewOnly`],style:e.style},[s.createVNode(j,{modelValue:e.modelValue,onHtmlChanged:c=>{e.onHtmlChanged?e.onHtmlChanged(c):o.emit("onHtmlChanged",c)},onGetCatalog:c=>{e.onGetCatalog?e.onGetCatalog(c):o.emit("onGetCatalog",c)},mdHeadingId:e.mdHeadingId,noMermaid:t,sanitize:e.sanitize,noKatex:n,formatCopiedText:e.formatCopiedText,noHighlight:i,previewOnly:!0},null)])}}),T=Fe;T.install=e=>(e.component(T.name,T),e);exports.CHANGE_CATALOG_VISIBLE=P;exports.CHANGE_FULL_SCREEN=O;exports.ContentPreview=j;exports.MdPreview=T;exports.ON_SAVE=I;exports.TEXTAREA_FOCUS=N;exports.editorEmits=Me;exports.editorProps=He;exports.useCatalog=Ie;exports.useConfig=Te;exports.useExpansion=Ee;exports.useExpose=Pe;exports.useOnSave=xe;exports.useProvide=Se;
@@ -1,2 +1,2 @@
1
- "use strict";const u=(t,n={newWindow:!0,nofollow:!0})=>{t||console.error("error link!");const e=document.createElement("a");e.href=t,e.style.display="none",n.newWindow&&(e.target="_blank"),n.nofollow&&(e.rel="noopener noreferrer"),document.body.appendChild(e),e.click(),document.body.removeChild(e)},a=(t,n="image.png")=>{const e=t.split(","),o=e[0].match(/:(.*?);/);if(o){const s=o[1],i=atob(e[1]);let r=i.length;const l=new Uint8Array(r);for(;r--;)l[r]=i.charCodeAt(r);return new File([l],n,{type:s})}return null},c=t=>{if(!t)return t;const n=t.split(`
2
- `),e=['<span rn-wrapper aria-hidden="true">'];return n.forEach(()=>{e.push("<span></span>")}),e.push("</span>"),`<span class="code-block">${t}</span>${e.join("")}`},d=(t,n=200)=>{let e=0;return(...o)=>new Promise(s=>{e&&(clearTimeout(e),s("cancel")),e=window.setTimeout(()=>{t.apply(void 0,o),e=0,s("done")},n)})},p=(t,n=200)=>{let e=0,o=null;return(...s)=>{const i=r=>{e===0&&(e=r),r-e>=n?(t.apply(void 0,o),o=null,e=0):window.requestAnimationFrame(i)};o===null&&window.requestAnimationFrame(i),o=s}},w=(t,n)=>{const e=t==null?void 0:t.getBoundingClientRect();if(n===document.documentElement)return e.top-n.clientTop;const o=n==null?void 0:n.getBoundingClientRect();return e.top-o.top},m=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;exports.base642File=a;exports.debounce=d;exports.generateCodeRowNumber=c;exports.getRelativeTop=w;exports.goto=u;exports.throttle=p;exports.uuid=m;
1
+ "use strict";var c=Object.defineProperty;var u=(o,t,s)=>t in o?c(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var p=(o,t,s)=>(u(o,typeof t!="symbol"?t+"":t,s),s);class a{constructor(){p(this,"pools",{})}remove(t,s,n){const e=this.pools[t]&&this.pools[t][s];e&&(this.pools[t][s]=e.filter(i=>i!==n))}clear(t){this.pools[t]={}}on(t,s){return this.pools[t]||(this.pools[t]={}),this.pools[t][s.name]||(this.pools[t][s.name]=[]),this.pools[t][s.name].push(s.callback),this.pools[t][s.name].includes(s.callback)}emit(t,s,...n){this.pools[t]||(this.pools[t]={});const e=this.pools[t][s];e&&e.forEach(i=>{try{i(...n)}catch(r){console.error(`${s} monitor event exception!`,r)}})}}const h=new a,g=(o,t="image.png")=>{const s=o.split(","),n=s[0].match(/:(.*?);/);if(n){const l=n[1],e=atob(s[1]);let i=e.length;const r=new Uint8Array(i);for(;i--;)r[i]=e.charCodeAt(i);return new File([r],t,{type:l})}return null},b=o=>{if(!o)return o;const t=o.split(`
2
+ `),s=['<span rn-wrapper aria-hidden="true">'];return t.forEach(()=>{s.push("<span></span>")}),s.push("</span>"),`<span class="code-block">${o}</span>${s.join("")}`},R=(o,t)=>{const s=o==null?void 0:o.getBoundingClientRect();if(t===document.documentElement)return s.top-t.clientTop;const n=t==null?void 0:t.getBoundingClientRect();return s.top-n.top},m=()=>`${Date.now().toString(36)}${Math.random().toString(36).substring(2)}`;exports.base642File=g;exports.bus=h;exports.generateCodeRowNumber=b;exports.getRelativeTop=R;exports.uuid=m;
package/lib/cjs/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./MdEditor.cjs"),e=require("./chunks/index.cjs"),o=require("./NormalToolbar.cjs"),i=require("./chunks/index2.cjs"),u=require("./chunks/index3.cjs"),q=require("./MdCatalog.cjs"),a=require("./chunks/config.cjs");require("vue");require("./chunks/event-bus.cjs");require("./chunks/index4.cjs");require("./chunks/dom.cjs");require("codemirror");require("@codemirror/view");require("@codemirror/language-data");require("@codemirror/lang-markdown");require("@codemirror/commands");require("@codemirror/language");require("@lezer/highlight");require("@codemirror/state");require("./chunks/vue-tsx.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");exports.MdEditor=r;exports.MdPreview=e.MdPreview;exports.NormalToolbar=o;exports.DropdownToolbar=i.DropdownToolbar;exports.ModalToolbar=u.ModalToolbar;exports.MdCatalog=q;exports.config=a.config;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./MdEditor.cjs"),e=require("./chunks/index.cjs"),o=require("./NormalToolbar.cjs"),i=require("./chunks/index2.cjs"),u=require("./chunks/index3.cjs"),q=require("./MdCatalog.cjs"),a=require("./chunks/config.cjs");require("vue");require("./chunks/index4.cjs");require("@vavt/util");require("./chunks/dom.cjs");require("codemirror");require("@codemirror/view");require("@codemirror/language-data");require("@codemirror/lang-markdown");require("@codemirror/commands");require("@codemirror/language");require("@lezer/highlight");require("@codemirror/state");require("./chunks/vue-tsx.cjs");require("medium-zoom");require("copy-to-clipboard");require("markdown-it");require("markdown-it-image-figures");require("markdown-it-task-lists");require("lru-cache");exports.MdEditor=r;exports.MdPreview=e.MdPreview;exports.NormalToolbar=o;exports.DropdownToolbar=i.DropdownToolbar;exports.ModalToolbar=u.ModalToolbar;exports.MdCatalog=q;exports.config=a.config;
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as y, createVNode as f, reactive as H, shallowRef as $, computed as b, onMounted as x, onBeforeUnmount as w } from "vue";
2
+ import { throttle as O } from "@vavt/util";
2
3
  import { p as h } from "./chunks/config.mjs";
3
- import { t as O, c as S } from "./chunks/index4.mjs";
4
- import { b as T } from "./chunks/event-bus.mjs";
4
+ import { c as S, b as T } from "./chunks/index4.mjs";
5
5
  const M = {
6
6
  tocItem: {
7
7
  type: Object,