md-editor-v3 4.5.0 → 4.6.0-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/README.md +1 -0
- package/lib/cjs/MdCatalog.cjs +1 -1
- package/lib/cjs/MdEditor.cjs +11 -11
- package/lib/cjs/chunks/index.cjs +6 -6
- package/lib/cjs/chunks/index4.cjs +2 -2
- package/lib/cjs/index.cjs +1 -1
- package/lib/es/MdCatalog.mjs +28 -28
- package/lib/es/MdEditor.mjs +711 -703
- package/lib/es/chunks/index.mjs +206 -201
- package/lib/es/chunks/index4.mjs +64 -46
- package/lib/es/index.mjs +17 -16
- package/lib/types/MdEditor/Editor.d.ts +8 -1
- package/lib/types/MdEditor/index.d.ts +18 -2
- package/lib/types/MdEditor/layouts/Content/index.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +4 -0
- package/lib/types/MdEditor/props.d.ts +3 -0
- package/lib/types/MdEditor/static/event-name.d.ts +9 -0
- package/lib/types/MdEditor/type.d.ts +4 -2
- package/lib/types/MdPreview/MdPreview.d.ts +2 -1
- package/lib/types/MdPreview/index.d.ts +6 -2
- package/lib/umd/index.js +41 -41
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -310,6 +310,7 @@ Except for the same as `MdPreview`:
|
|
|
310
310
|
| onBlur | `event: FocusEvent` | Textarea has lost focus |
|
|
311
311
|
| onFocus | `event: FocusEvent` | Textarea has received focus |
|
|
312
312
|
| onInput | `event: Event` | Element gets input |
|
|
313
|
+
| onDrop | `event: DragEvent` | The event occurs when a selection is being dragged |
|
|
313
314
|
|
|
314
315
|
### 🎍 Slots
|
|
315
316
|
|
package/lib/cjs/MdCatalog.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("vue"),C=require("@vavt/util"),h=require("./chunks/config.cjs"),
|
|
1
|
+
"use strict";const o=require("vue"),C=require("@vavt/util"),h=require("./chunks/config.cjs"),p=require("./chunks/index4.cjs"),H={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:H,setup(l){return()=>{const{tocItem:c,mdHeadingId:d,scrollElement:n,onClick:u,scrollElementOffsetTop:g}=l;return o.createVNode("div",{class:[`${h.prefix}-catalog-link`,c.active&&`${h.prefix}-catalog-active`],onClick:r=>{u(r,c),r.stopPropagation();const v=d(c.text,c.level,c.index),m=document.getElementById(v),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-g,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:g},null))])])}}}),x=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(),g=o.computed(()=>{const e=[];return n.list.forEach((t,s)=>{const{text:E,level:I}=t,i={level:I,text:E,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:T}=a;if(!T){a.children=[i];break}if(a=T[T.length-1],i.level<=a.level){T.push(i);break}}else e.push(i)}}),e}),r=()=>n.scrollElement instanceof HTMLElement?n.scrollElement:document.querySelector(n.scrollElement),v=C.throttle(e=>{if(e.length===0)return n.list=[],!1;const{activeHead:t}=e.reduce((s,E,I)=>{const i=document.getElementById(l.mdHeadingId(E.text,E.level,I+1));if(i instanceof HTMLElement){const a=r(),f=p.getRelativeTop(i,a);if(f<l.offsetTop&&f>s.minTop)return{activeHead:E,minTop:f}}return s},{activeHead:e[0],minTop:Number.MIN_SAFE_INTEGER});u.value=t,n.list=e}),m=()=>{v(n.list)};return o.onMounted(()=>{var t;const e=r();(t=e===document.documentElement?window:e)==null||t.addEventListener("scroll",m),p.bus.on(d,{name:p.CATALOG_CHANGED,callback:s=>{v(s)}}),p.bus.emit(d,p.PUSH_CATALOG)}),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}`},[g.value.map(e=>o.createVNode(x,{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;
|
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var ut=Object.defineProperty;var mt=(e,l,o)=>l in e?ut(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o;var P=(e,l,o)=>(mt(e,typeof l!="symbol"?l+"":l,o),o);const t=require("vue"),r=require("./chunks/config.cjs"),Z=require("@vavt/util"),z=require("./chunks/index2.cjs"),b=require("./chunks/index4.cjs"),S=require("./chunks/index.cjs"),ft=require("./chunks/dom.cjs"),k=require("./chunks/index3.cjs"),ee=require("codemirror"),le=require("@codemirror/view"),gt=require("@codemirror/language-data"),bt=require("@codemirror/lang-markdown"),ce=require("@codemirror/commands"),ae=require("@codemirror/language"),c=require("@lezer/highlight"),H=require("@codemirror/state"),ht=require("@codemirror/autocomplete"),dt=require("./MdCatalog.cjs"),Je=require("./chunks/vue-tsx.cjs"),pt=require("./NormalToolbar.cjs"),vt=require("./ModalToolbar.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 kt=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${r.prefix}-divider`},null)}}),Ct={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},showToolbarName:{type:Boolean}},xt=e=>{var s,f,m,h;const l=t.inject("editorId");let o=(f=(s=r.configOption.editorExtensions)==null?void 0:s.screenfull)==null?void 0:f.instance;const a=(h=(m=r.configOption.editorExtensions)==null?void 0:m.screenfull)==null?void 0:h.js,n=t.ref(!1),i=x=>{if(!o){b.bus.emit(l,"errorCatcher",{name:"fullscreen",message:"fullscreen is undefined"});return}o.isEnabled?(n.value=!0,(x===void 0?!o.isFullscreen:x)?o.request():o.exit()):console.error("browser does not support screenfull!")},u=()=>{o&&o.isEnabled&&o.on("change",()=>{(n.value||e.setting.fullscreen)&&(n.value=!1,e.updateSetting("fullscreen"))})},d=()=>{o=window.screenfull,u()};return t.onMounted(()=>{if(u(),!o){const x=document.createElement("script");x.src=a||r.screenfullUrl,x.onload=d,x.id=`${r.prefix}-screenfull`,ft.appendHandler(x,"screenfull")}}),t.onMounted(()=>{b.bus.on(l,{name:S.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},Nt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},Vt=t.defineComponent({name:"TableShape",props:Nt,setup(e){const l=t.reactive({x:-1,y:-1});return()=>t.createVNode("div",{class:`${r.prefix}-table-shape`,onMouseleave:()=>{l.x=-1,l.y=-1}},[new Array(e.tableShape[1]).fill("").map((o,a)=>t.createVNode("div",{class:`${r.prefix}-table-shape-row`,key:`table-shape-row-${a}`},[new Array(e.tableShape[0]).fill("").map((n,i)=>t.createVNode("div",{class:`${r.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{l.x=a,l.y=i},onClick:()=>{e.onSelected(l)}},[t.createVNode("div",{class:[`${r.prefix}-table-shape-col-default`,a<=l.x&&i<=l.y&&`${r.prefix}-table-shape-col-include`]},null)]))]))])}}),$t=Vt,yt={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Tt=t.defineComponent({props:yt,setup(e){const l=t.inject("usedLanguageText"),o=t.inject("editorId"),a=t.computed(()=>{var i,u;switch(e.type){case"link":return(i=l.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(u=l.value.linkModalTips)==null?void 0:u.imageTitle;default:return""}}),n=t.reactive({desc:"",url:""});return t.watch(()=>e.visible,i=>{i||setTimeout(()=>{n.desc="",n.url=""},200)}),()=>t.createVNode(k.MdModal,{title:a.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var i,u,d,s,f;return[t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-desc-${o}`},[(i=l.value.linkModalTips)==null?void 0:i.descLabel]),t.createVNode("input",{placeholder:(u=l.value.linkModalTips)==null?void 0:u.descLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-desc-${o}`,type:"text",value:n.desc,onChange:m=>{n.desc=m.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-url-${o}`},[(d=l.value.linkModalTips)==null?void 0:d.urlLabel]),t.createVNode("input",{placeholder:(s=l.value.linkModalTips)==null?void 0:s.urlLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-url-${o}`,type:"text",value:n.url,onChange:m=>{n.url=m.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:[`${r.prefix}-btn`,`${r.prefix}-btn-row`],type:"button",onClick:()=>{e.onOk(n),n.desc="",n.url=""}},[(f=l.value.linkModalTips)==null?void 0:f.buttonOK])])]}})}}),wt={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},St=t.defineComponent({props:wt,setup(e){var m,h,x;const l=t.inject("usedLanguageText"),o=t.inject("editorId");let a=(x=(h=(m=r.configOption)==null?void 0:m.editorExtensions)==null?void 0:h.cropper)==null?void 0:x.instance;const n=t.ref(),i=t.ref(),u=t.ref(),d=t.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let s=null;t.watch(()=>e.visible,()=>{e.visible&&!d.cropperInited&&(a=a||window.Cropper,n.value.onchange=()=>{if(!a){b.bus.emit(o,"errorCatcher",{name:"Cropper",message:"Cropper is undefined"});return}const V=n.value.files||[];if(d.imgSelected=!0,(V==null?void 0:V.length)>0){const p=new FileReader;p.onload=g=>{d.imgSrc=g.target.result,t.nextTick(()=>{s=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`})})},p.readAsDataURL(V[0])}})}),t.watch(()=>[d.imgSelected],()=>{u.value.style=""}),t.watch(()=>d.isFullscreen,()=>{t.nextTick(()=>{s==null||s.destroy(),u.value.style="",i.value&&(s=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`}))})});const f=()=>{s.clear(),s.destroy(),s=null,n.value.value="",d.imgSelected=!1};return()=>{var V;return t.createVNode(k.MdModal,{class:`${r.prefix}-modal-clip`,title:(V=l.value.clipModalTips)==null?void 0:V.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:d.isFullscreen,onAdjust:p=>{d.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,g;return[t.createVNode("div",{class:`${r.prefix}-form-item ${r.prefix}-clip`},[t.createVNode("div",{class:`${r.prefix}-clip-main`},[d.imgSelected?t.createVNode("div",{class:`${r.prefix}-clip-cropper`},[t.createVNode("img",{src:d.imgSrc,ref:i,style:{display:"none"},alt:""},null),t.createVNode("div",{class:`${r.prefix}-clip-delete`,onClick:f},[t.createVNode(k.Icon,{name:"delete"},null)])]):t.createVNode("div",{class:`${r.prefix}-clip-upload`,onClick:()=>{n.value.click()}},[t.createVNode(k.Icon,{name:"upload"},null)])]),t.createVNode("div",{class:`${r.prefix}-clip-preview`},[t.createVNode("div",{class:`${r.prefix}-clip-preview-target`,ref:u},null)])]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:`${r.prefix}-btn`,type:"button",onClick:()=>{if(s){const v=s.getCroppedCanvas();b.bus.emit(o,"uploadImage",[b.base642File(v.toDataURL("image/png"))],e.onOk),f()}}},[((p=l.value.clipModalTips)==null?void 0:p.buttonUpload)||((g=l.value.linkModalTips)==null?void 0:g.buttonOK)])]),t.createVNode("input",{ref:n,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),It={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},Mt=t.defineComponent({props:It,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(Tt,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(St,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),At=t.defineComponent({name:"MDEditorToolbar",props:Ct,setup(e){const l=t.inject("editorId"),o=t.inject("usedLanguageText"),{fullscreenHandler:a}=xt(e),n=`${l}-toolbar-wrapper`,i=t.ref(),u=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),d=(p,g)=>{b.bus.emit(l,"replace",p,g)},s=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),f=t.ref();t.onMounted(()=>{b.bus.on(l,{name:"openModals",callback(p){s.type=p,s.linkVisible=!0}})});const m=t.computed(()=>{const p=e.toolbars.filter($=>!e.toolbarsExclude.includes($)),g=p.indexOf("="),v=g===-1?p:p.slice(0,g+1),N=g===-1?[]:p.slice(g,Number.MAX_SAFE_INTEGER);return[v,N]}),h=t.ref(),x=()=>{b.bus.emit(l,"uploadImage",Array.from(h.value.files||[])),h.value.value=""};t.onMounted(()=>{h.value.addEventListener("change",x)});const V=p=>{var g,v,N,$,y,D,I,X,T,w,R,q,L,A,E,O,j,G,re,Y,K,U,J,_,F,B,Q,ne,fe,ge,be,he,pe,ve,ke,Ce,xe,Ne,Ve,$e,ye,Te,we,Se,Ie,Me,Ae,Ee,De,Le,He,Oe,Fe,Be,qe,Re,Pe,je,Ge,Ue,_e,Ke,We,ze,Ze,Xe,Ye;if(r.allToolbar.includes(p))switch(p){case"-":return t.createVNode(kt,null,null);case"bold":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(g=o.value.toolbarTips)==null?void 0:g.bold,onClick:()=>{d("bold")}},[t.createVNode(k.Icon,{name:"bold"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(v=o.value.toolbarTips)==null?void 0:v.bold])]);case"underline":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(N=o.value.toolbarTips)==null?void 0:N.underline,onClick:()=>{d("underline")}},[t.createVNode(k.Icon,{name:"underline"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[($=o.value.toolbarTips)==null?void 0:$.underline])]);case"italic":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(y=o.value.toolbarTips)==null?void 0:y.italic,onClick:()=>{d("italic")}},[t.createVNode(k.Icon,{name:"italic"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(D=o.value.toolbarTips)==null?void 0:D.italic])]);case"strikeThrough":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(I=o.value.toolbarTips)==null?void 0:I.strikeThrough,onClick:()=>{d("strikeThrough")}},[t.createVNode(k.Icon,{name:"strike-through"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(X=o.value.toolbarTips)==null?void 0:X.strikeThrough])]);case"title":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:u.title,onChange:C=>{u.title=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h1")}},[(T=o.value.titleItem)==null?void 0:T.h1]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h2")}},[(w=o.value.titleItem)==null?void 0:w.h2]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h3")}},[(R=o.value.titleItem)==null?void 0:R.h3]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h4")}},[(q=o.value.titleItem)==null?void 0:q.h4]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h5")}},[(L=o.value.titleItem)==null?void 0:L.h5]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h6")}},[(A=o.value.titleItem)==null?void 0:A.h6])])},{default:()=>{var C,M;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.title},[t.createVNode(k.Icon,{name:"title"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(M=o.value.toolbarTips)==null?void 0:M.title])])]}});case"sub":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(E=o.value.toolbarTips)==null?void 0:E.sub,onClick:()=>{d("sub")}},[t.createVNode(k.Icon,{name:"sub"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(O=o.value.toolbarTips)==null?void 0:O.sub])]);case"sup":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(j=o.value.toolbarTips)==null?void 0:j.sup,onClick:()=>{d("sup")}},[t.createVNode(k.Icon,{name:"sup"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(G=o.value.toolbarTips)==null?void 0:G.sup])]);case"quote":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(re=o.value.toolbarTips)==null?void 0:re.quote,onClick:()=>{d("quote")}},[t.createVNode(k.Icon,{name:"quote"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Y=o.value.toolbarTips)==null?void 0:Y.quote])]);case"unorderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(K=o.value.toolbarTips)==null?void 0:K.unorderedList,onClick:()=>{d("unorderedList")}},[t.createVNode(k.Icon,{name:"unordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(U=o.value.toolbarTips)==null?void 0:U.unorderedList])]);case"orderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(J=o.value.toolbarTips)==null?void 0:J.orderedList,onClick:()=>{d("orderedList")}},[t.createVNode(k.Icon,{name:"ordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(_=o.value.toolbarTips)==null?void 0:_.orderedList])]);case"task":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(F=o.value.toolbarTips)==null?void 0:F.task,onClick:()=>{d("task")}},[t.createVNode(k.Icon,{name:"task"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(B=o.value.toolbarTips)==null?void 0:B.task])]);case"codeRow":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Q=o.value.toolbarTips)==null?void 0:Q.codeRow,onClick:()=>{d("codeRow")}},[t.createVNode(k.Icon,{name:"code-row"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ne=o.value.toolbarTips)==null?void 0:ne.codeRow])]);case"code":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(fe=o.value.toolbarTips)==null?void 0:fe.code,onClick:()=>{d("code")}},[t.createVNode(k.Icon,{name:"code"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ge=o.value.toolbarTips)==null?void 0:ge.code])]);case"link":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(be=o.value.toolbarTips)==null?void 0:be.link,onClick:()=>{s.type="link",s.linkVisible=!0}},[t.createVNode(k.Icon,{name:"link"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(he=o.value.toolbarTips)==null?void 0:he.link])]);case"image":return e.noUploadImg?t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(pe=o.value.toolbarTips)==null?void 0:pe.image,onClick:()=>{s.type="image",s.linkVisible=!0}},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ve=o.value.toolbarTips)==null?void 0:ve.image])]):t.createVNode(z.Dropdown,{relative:`#${n}`,visible:u.image,onChange:C=>{u.image=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{s.type="image",s.linkVisible=!0}},[(ke=o.value.imgTitleItem)==null?void 0:ke.link]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{h.value.click()}},[(Ce=o.value.imgTitleItem)==null?void 0:Ce.upload]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{s.clipVisible=!0}},[(xe=o.value.imgTitleItem)==null?void 0:xe.clip2upload])])},{default:()=>{var C,M;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.image},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(M=o.value.toolbarTips)==null?void 0:M.image])])]}});case"table":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:u.table,onChange:C=>{u.table=C},key:"bar-table",overlay:t.createVNode($t,{tableShape:e.tableShape,onSelected:C=>{d("table",{selectedShape:C})}},null)},{default:()=>{var C,M;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.table},[t.createVNode(k.Icon,{name:"table"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(M=o.value.toolbarTips)==null?void 0:M.table])])]}});case"revoke":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ne=o.value.toolbarTips)==null?void 0:Ne.revoke,onClick:()=>{b.bus.emit(l,"ctrlZ")}},[t.createVNode(k.Icon,{name:"revoke"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ve=o.value.toolbarTips)==null?void 0:Ve.revoke])]);case"next":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:($e=o.value.toolbarTips)==null?void 0:$e.next,onClick:()=>{b.bus.emit(l,"ctrlShiftZ")}},[t.createVNode(k.Icon,{name:"next"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ye=o.value.toolbarTips)==null?void 0:ye.next])]);case"save":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Te=o.value.toolbarTips)==null?void 0:Te.save,onClick:()=>{b.bus.emit(l,S.ON_SAVE)}},[t.createVNode(k.Icon,{name:"baocun"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(we=o.value.toolbarTips)==null?void 0:we.save])]);case"prettier":return e.noPrettier?"":t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Se=o.value.toolbarTips)==null?void 0:Se.prettier,onClick:()=>{d("prettier")}},[t.createVNode(k.Icon,{name:"prettier"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ie=o.value.toolbarTips)==null?void 0:Ie.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Me=o.value.toolbarTips)==null?void 0:Me.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[t.createVNode(k.Icon,{name:e.setting.pageFullscreen?"suoxiao":"fangda"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ae=o.value.toolbarTips)==null?void 0:Ae.pageFullscreen])]);case"fullscreen":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ee=o.value.toolbarTips)==null?void 0:Ee.fullscreen,onClick:()=>{a()}},[t.createVNode(k.Icon,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(De=o.value.toolbarTips)==null?void 0:De.fullscreen])]);case"preview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Le=o.value.toolbarTips)==null?void 0:Le.preview,onClick:()=>{e.updateSetting("preview")}},[t.createVNode(k.Icon,{name:"preview"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(He=o.value.toolbarTips)==null?void 0:He.preview])]);case"htmlPreview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Oe=o.value.toolbarTips)==null?void 0:Oe.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[t.createVNode(k.Icon,{name:"coding"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Fe=o.value.toolbarTips)==null?void 0:Fe.htmlPreview])]);case"catalog":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Be=o.value.toolbarTips)==null?void 0:Be.catalog,onClick:()=>{b.bus.emit(l,S.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[t.createVNode(k.Icon,{name:"catalog"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(qe=o.value.toolbarTips)==null?void 0:qe.catalog])]);case"github":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Re=o.value.toolbarTips)==null?void 0:Re.github,onClick:()=>Z.linkTo("https://github.com/imzbf/md-editor-v3")},[t.createVNode(k.Icon,{name:"github"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Pe=o.value.toolbarTips)==null?void 0:Pe.github])]);case"mermaid":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:u.mermaid,onChange:C=>{u.mermaid=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.mermaid=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("flow")}},[(je=o.value.mermaid)==null?void 0:je.flow]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("sequence")}},[(Ge=o.value.mermaid)==null?void 0:Ge.sequence]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("gantt")}},[(Ue=o.value.mermaid)==null?void 0:Ue.gantt]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("class")}},[(_e=o.value.mermaid)==null?void 0:_e.class]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("state")}},[(Ke=o.value.mermaid)==null?void 0:Ke.state]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("pie")}},[(We=o.value.mermaid)==null?void 0:We.pie]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("relationship")}},[(ze=o.value.mermaid)==null?void 0:ze.relationship]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("journey")}},[(Ze=o.value.mermaid)==null?void 0:Ze.journey])]),key:"bar-mermaid"},{default:()=>{var C,M;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.mermaid},[t.createVNode(k.Icon,{name:"mermaid"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(M=o.value.toolbarTips)==null?void 0:M.mermaid])])]}});case"katex":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:u.katex,onChange:C=>{u.katex=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{u.katex=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexInline")}},[(Xe=o.value.katex)==null?void 0:Xe.inline]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexBlock")}},[(Ye=o.value.katex)==null?void 0:Ye.block])]),key:"bar-katex"},{default:()=>{var C,M;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.katex},[t.createVNode(k.Icon,{name:"formula"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(M=o.value.toolbarTips)==null?void 0:M.katex])])]}})}else if(e.defToolbars instanceof Array){const C=e.defToolbars[p];return C?t.cloneVNode(C,{insert(de){b.bus.emit(l,"replace","universal",{generate:de})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const C=e.defToolbars.children[p];return C?t.cloneVNode(C,{insert(de){b.bus.emit(l,"replace","universal",{generate:de})}}):""}else return""};return t.watch(()=>e.toolbars,()=>{t.nextTick(()=>{i.value&&Z.draggingScroll(i.value)})},{immediate:!0}),()=>{const p=m.value[0].map(v=>V(v)),g=m.value[1].map(v=>V(v));return t.createVNode(t.Fragment,null,[e.toolbars.length>0&&t.createVNode("div",{class:`${r.prefix}-toolbar-wrapper`,ref:i,id:n},[t.createVNode("div",{class:[`${r.prefix}-toolbar`,e.showToolbarName&&`${r.prefix}-stn`]},[t.createVNode("div",{class:`${r.prefix}-toolbar-left`,ref:f},[p]),t.createVNode("div",{class:`${r.prefix}-toolbar-right`},[g])])]),t.createVNode("input",{ref:h,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),t.createVNode(Mt,{linkVisible:s.linkVisible,clipVisible:s.clipVisible,type:s.type,onCancel:()=>{s.linkVisible=!1,s.clipVisible=!1},onOk:v=>{v&&d(s.type,{desc:v.desc,url:v.url}),s.linkVisible=!1,s.clipVisible=!1}},null)])}}}),Et=(e,l)=>{const o=Z.debounce(()=>{e.removeEventListener("scroll",a),e.addEventListener("scroll",a),l.removeEventListener("scroll",a),l.addEventListener("scroll",a)},50),a=n=>{const i=e.clientHeight,u=l.clientHeight,d=e.scrollHeight,s=l.scrollHeight,f=(d-i)/(s-u);n.target===e?(l.removeEventListener("scroll",a),l.scrollTo({top:e.scrollTop/f}),o()):(e.removeEventListener("scroll",a),e.scrollTo({top:l.scrollTop*f}),o())};return[()=>{o().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",a),l.removeEventListener("scroll",a)}]},Dt=(e,l,o)=>{const{view:a}=o,n=h=>a.lineBlockAt(a.state.doc.line(h).from).top,i=h=>a.lineBlockAt(a.state.doc.line(h).from).height;let u=[];const d=()=>{u=[];const h=Array.from(l.querySelectorAll("[data-line]")).map(g=>Number(g.dataset.line)+1),{lines:x}=a.state.doc;let V=1,p=h.shift()??x;for(let g=1;g<=x;g++)g===p&&(V=g,p=h.shift()||x+1),u.push({start:V,end:p-1})};let s=0,f=0;const m=Z.throttle(h=>{var v,N,$,y,D,I,X;if(!((v=l.firstElementChild)!=null&&v.firstElementChild))return;const x=a.lineBlockAtHeight(a.scrollDOM.scrollTop),{number:V}=a.state.doc.lineAt(x.from);if(V>u.length||a.state.doc.lines<u[u.length-1].end)return;let p=+getComputedStyle(l).paddingTop.replace("px","");const g=+getComputedStyle(l).paddingBottom.replace("px","");if(h.target===e){if(f!==0)return;s++;const T=u[V-1];let w=n(T.end)+i(T.end),R=0;const q=n(T.start),L=l.querySelector(`[data-line="${T.start-1}"]`)||((N=l.firstElementChild)==null?void 0:N.firstElementChild),A=l.querySelector(`[data-line="${T.end}"]`)||(($=l.lastElementChild)==null?void 0:$.lastElementChild);let E=0,O=0;q===0?L===A?(p=0,w=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight,R=a.scrollDOM.scrollTop/w,E=A.offsetTop+A.offsetHeight-l.clientHeight):(R=a.scrollDOM.scrollTop/w,E=A.offsetTop):w>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(R=(a.scrollDOM.scrollTop-q)/(a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight-q),O=L.offsetTop,E=l.scrollHeight-l.clientHeight-O+10):(R=(a.scrollDOM.scrollTop-q)/(w-q),O=L.offsetTop,E=A.offsetTop-O);const j=O-p+E*R;Z.smoothScroll(l,j,()=>{s--})}else{if(s!==0)return;f++;const T=Array.from(l.querySelectorAll("[data-line]")),w=l.scrollTop,R=l.scrollHeight;let q=T.length===0?1:Math.ceil(Number(T[T.length-1].dataset.line)*(w/R)),L=(y=l.firstElementChild)==null?void 0:y.firstElementChild;for(let F=q;F>=0;F--){const B=l.querySelector(`[data-line="${F}"]`);if(B&&B.offsetTop<=w){L=B,q=F;break}}let A=(D=l.firstElementChild)==null?void 0:D.firstElementChild,E=(I=l.firstElementChild)==null?void 0:I.lastElementChild;for(;T.length>0;){const F=T.indexOf(L);if(F+1>=T.length)break;const B=T[F+1];if(F===-1){E=B;break}const Q=L.offsetTop;if(Q>w){if(F===0){A=L,E=B;break}L=T[F-1];continue}const ne=B.offsetTop;if(Q<=w&&ne>w){A=L,E=B;break}L=B}const O=A.offsetTop;let j=E.offsetTop,G=0;const{start:re,end:Y}=u[Number(A.dataset.line||0)],K=n(re);let U=n(Y);const J=i(Y);let _=0;A===((X=l.firstElementChild)==null?void 0:X.firstElementChild)?(A===E?(j=E.offsetHeight-l.offsetHeight+p+g,_=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight):_=U+J-K,G=Math.max(w/j,0)):U>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(G=Math.max((w-O)/(l.scrollHeight-O-l.clientHeight),0),U=n(a.state.doc.lines)+i(a.state.doc.lines),_=8+U-K-e.clientHeight):(G=Math.max((w-O)/(j-O),0),_=U+J-K),Z.smoothScroll(e,K+_*G,()=>{f--})}},10);return[()=>{d(),e.addEventListener("scroll",m),l.addEventListener("scroll",m),e.dispatchEvent(new Event("scroll"))},()=>{u=[],e.removeEventListener("scroll",m),l.removeEventListener("scroll",m)}]},Lt=(e,l,o)=>{const a=t.inject("editorId");let n=()=>{},i=()=>{};const u=()=>{n();const d=document.querySelector(".cm-scroller"),s=document.querySelector(`[id="${a}-preview-wrapper"][data-show="true"]`),f=document.querySelector(`[id="${a}-html-wrapper"][data-show="true"]`);(s||f)&&([i,n]=(s?Dt:Et)(d,s||f,o.value)),e.scrollAuto&&i()};t.watch([l,t.toRef(e.setting,"preview"),t.toRef(e.setting,"htmlPreview"),t.toRef(e.setting,"fullscreen"),t.toRef(e.setting,"pageFullscreen")],()=>{t.nextTick(u)}),t.watch(()=>e.scrollAuto,d=>{d?i():n()}),t.onMounted(u)},Ht=Lt,Ot=(e,l,o)=>{var m,h,x,V,p,g;let a="",n=0,i=0,u=!0,d=!1;const s=l.getSelectedText(),f=(m=r.configOption.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const v=e.replace(/^h(\d)/,(N,$)=>new Array(Number($)).fill("#",0,$).join(""));a=`${v} ${s}`,n=v.length+1}else if(e==="prettier"){const v=window.prettier||((x=(h=r.configOption.editorExtensions)==null?void 0:h.prettier)==null?void 0:x.prettierInstance),N=[((V=window.prettierPlugins)==null?void 0:V.markdown)||((g=(p=r.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:g.parserMarkdownInstance)];!v||N[0]===void 0?(b.bus.emit(o.editorId,"errorCatcher",{name:"prettier",message:"prettier is undefined"}),a=l.getValue()):a=v.format(l.getValue(),{parser:"markdown",plugins:N}),u=!1,d=!0}else switch(e){case"bold":{a=`**${s}**`,n=2,i=-2;break}case"underline":{a=`<u>${s}</u>`,n=3,i=-4;break}case"italic":{a=`*${s}*`,n=1,i=-1;break}case"strikeThrough":{a=`~~${s}~~`,n=2,i=-2;break}case"sub":{a=`<sub>${s}</sub>`,n=5,i=-6;break}case"sup":{a=`<sup>${s}</sup>`,n=5,i=-6;break}case"codeRow":{a="`"+s+"`",n=1,i=-1;break}case"quote":{a=`> ${s}`,n=2;break}case"orderedList":{a=`1. ${s}`,n=3;break}case"unorderedList":{a=`- ${s}`,n=2;break}case"task":{a=`- [ ] ${s}`,n=6;break}case"code":{const v=o.text||s||"",N=o.mode||"language";a=`\`\`\`${N}
|
|
2
|
-
${
|
|
1
|
+
"use strict";var mt=Object.defineProperty;var ft=(e,l,o)=>l in e?mt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[l]=o;var q=(e,l,o)=>(ft(e,typeof l!="symbol"?l+"":l,o),o);const t=require("vue"),r=require("./chunks/config.cjs"),le=require("@vavt/util"),z=require("./chunks/index2.cjs"),s=require("./chunks/index4.cjs"),gt=require("./chunks/dom.cjs"),k=require("./chunks/index3.cjs"),ee=require("codemirror"),ae=require("@codemirror/view"),bt=require("@codemirror/language-data"),ht=require("@codemirror/lang-markdown"),dt=require("@codemirror/lang-html"),se=require("@codemirror/commands"),re=require("@codemirror/language"),c=require("@lezer/highlight"),R=require("@codemirror/state"),vt=require("@codemirror/autocomplete"),P=require("./chunks/index.cjs"),ut=require("./MdCatalog.cjs"),Je=require("./chunks/vue-tsx.cjs"),pt=require("./NormalToolbar.cjs"),kt=require("./ModalToolbar.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 Ct=t.defineComponent({setup(){return()=>t.createVNode("div",{class:`${r.prefix}-divider`},null)}}),xt={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},showToolbarName:{type:Boolean}},Nt=e=>{var u,f,m,v;const l=t.inject("editorId");let o=(f=(u=r.configOption.editorExtensions)==null?void 0:u.screenfull)==null?void 0:f.instance;const a=(v=(m=r.configOption.editorExtensions)==null?void 0:m.screenfull)==null?void 0:v.js,n=t.ref(!1),i=x=>{if(!o){s.bus.emit(l,s.ERROR_CATCHER,{name:"fullscreen",message:"fullscreen is undefined"});return}o.isEnabled?(n.value=!0,(x===void 0?!o.isFullscreen:x)?o.request():o.exit()):console.error("browser does not support screenfull!")},g=()=>{o&&o.isEnabled&&o.on("change",()=>{(n.value||e.setting.fullscreen)&&(n.value=!1,e.updateSetting("fullscreen"))})},d=()=>{o=window.screenfull,g()};return t.onMounted(()=>{if(g(),!o){const x=document.createElement("script");x.src=a||r.screenfullUrl,x.onload=d,x.id=`${r.prefix}-screenfull`,gt.appendHandler(x,"screenfull")}}),t.onMounted(()=>{s.bus.on(l,{name:s.CHANGE_FULL_SCREEN,callback:i})}),{fullscreenHandler:i}},Vt={tableShape:{type:Array,default:()=>[6,4]},onSelected:{type:Function,default:()=>{}}},$t=t.defineComponent({name:"TableShape",props:Vt,setup(e){const l=t.reactive({x:-1,y:-1});return()=>t.createVNode("div",{class:`${r.prefix}-table-shape`,onMouseleave:()=>{l.x=-1,l.y=-1}},[new Array(e.tableShape[1]).fill("").map((o,a)=>t.createVNode("div",{class:`${r.prefix}-table-shape-row`,key:`table-shape-row-${a}`},[new Array(e.tableShape[0]).fill("").map((n,i)=>t.createVNode("div",{class:`${r.prefix}-table-shape-col`,key:`table-shape-col-${i}`,onMouseenter:()=>{l.x=a,l.y=i},onClick:()=>{e.onSelected(l)}},[t.createVNode("div",{class:[`${r.prefix}-table-shape-col-default`,a<=l.x&&i<=l.y&&`${r.prefix}-table-shape-col-include`]},null)]))]))])}}),Tt=$t,yt={type:{type:String,default:"link"},visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},wt=t.defineComponent({props:yt,setup(e){const l=t.inject("usedLanguageText"),o=t.inject("editorId"),a=t.computed(()=>{var i,g;switch(e.type){case"link":return(i=l.value.linkModalTips)==null?void 0:i.linkTitle;case"image":return(g=l.value.linkModalTips)==null?void 0:g.imageTitle;default:return""}}),n=t.reactive({desc:"",url:""});return t.watch(()=>e.visible,i=>{i||setTimeout(()=>{n.desc="",n.url=""},200)}),()=>t.createVNode(k.MdModal,{title:a.value,visible:e.visible,onClose:e.onCancel},{default:()=>{var i,g,d,u,f;return[t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-desc-${o}`},[(i=l.value.linkModalTips)==null?void 0:i.descLabel]),t.createVNode("input",{placeholder:(g=l.value.linkModalTips)==null?void 0:g.descLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-desc-${o}`,type:"text",value:n.desc,onChange:m=>{n.desc=m.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("label",{class:`${r.prefix}-label`,for:`link-url-${o}`},[(d=l.value.linkModalTips)==null?void 0:d.urlLabel]),t.createVNode("input",{placeholder:(u=l.value.linkModalTips)==null?void 0:u.urlLabelPlaceHolder,class:`${r.prefix}-input`,id:`link-url-${o}`,type:"text",value:n.url,onChange:m=>{n.url=m.target.value},autocomplete:"off"},null)]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:[`${r.prefix}-btn`,`${r.prefix}-btn-row`],type:"button",onClick:()=>{e.onOk(n),n.desc="",n.url=""}},[(f=l.value.linkModalTips)==null?void 0:f.buttonOK])])]}})}}),Et={visible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},St=t.defineComponent({props:Et,setup(e){var m,v,x;const l=t.inject("usedLanguageText"),o=t.inject("editorId");let a=(x=(v=(m=r.configOption)==null?void 0:m.editorExtensions)==null?void 0:v.cropper)==null?void 0:x.instance;const n=t.ref(),i=t.ref(),g=t.ref(),d=t.reactive({cropperInited:!1,imgSelected:!1,imgSrc:"",isFullscreen:!1});let u=null;t.watch(()=>e.visible,()=>{e.visible&&!d.cropperInited&&(a=a||window.Cropper,n.value.onchange=()=>{if(!a){s.bus.emit(o,s.ERROR_CATCHER,{name:"Cropper",message:"Cropper is undefined"});return}const V=n.value.files||[];if(d.imgSelected=!0,(V==null?void 0:V.length)>0){const p=new FileReader;p.onload=b=>{d.imgSrc=b.target.result,t.nextTick(()=>{u=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`})})},p.readAsDataURL(V[0])}})}),t.watch(()=>[d.imgSelected],()=>{g.value.style=""}),t.watch(()=>d.isFullscreen,()=>{t.nextTick(()=>{u==null||u.destroy(),g.value.style="",i.value&&(u=new a(i.value,{viewMode:2,preview:`.${r.prefix}-clip-preview-target`}))})});const f=()=>{u.clear(),u.destroy(),u=null,n.value.value="",d.imgSelected=!1};return()=>{var V;return t.createVNode(k.MdModal,{class:`${r.prefix}-modal-clip`,title:(V=l.value.clipModalTips)==null?void 0:V.title,visible:e.visible,onClose:e.onCancel,showAdjust:!0,isFullscreen:d.isFullscreen,onAdjust:p=>{d.isFullscreen=p},width:"668px",height:"421px"},{default:()=>{var p,b;return[t.createVNode("div",{class:`${r.prefix}-form-item ${r.prefix}-clip`},[t.createVNode("div",{class:`${r.prefix}-clip-main`},[d.imgSelected?t.createVNode("div",{class:`${r.prefix}-clip-cropper`},[t.createVNode("img",{src:d.imgSrc,ref:i,style:{display:"none"},alt:""},null),t.createVNode("div",{class:`${r.prefix}-clip-delete`,onClick:f},[t.createVNode(k.Icon,{name:"delete"},null)])]):t.createVNode("div",{class:`${r.prefix}-clip-upload`,onClick:()=>{n.value.click()}},[t.createVNode(k.Icon,{name:"upload"},null)])]),t.createVNode("div",{class:`${r.prefix}-clip-preview`},[t.createVNode("div",{class:`${r.prefix}-clip-preview-target`,ref:g},null)])]),t.createVNode("div",{class:`${r.prefix}-form-item`},[t.createVNode("button",{class:`${r.prefix}-btn`,type:"button",onClick:()=>{if(u){const h=u.getCroppedCanvas();s.bus.emit(o,s.UPLOAD_IMAGE,[s.base642File(h.toDataURL("image/png"))],e.onOk),f()}}},[((p=l.value.clipModalTips)==null?void 0:p.buttonUpload)||((b=l.value.linkModalTips)==null?void 0:b.buttonOK)])]),t.createVNode("input",{ref:n,accept:"image/*",type:"file",multiple:!1,style:{display:"none"}},null)]}})}}}),At={type:{type:String,default:"link"},linkVisible:{type:Boolean,default:!1},clipVisible:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}},onOk:{type:Function,default:()=>{}}},It=t.defineComponent({props:At,setup(e){return()=>t.createVNode(t.Fragment,null,[t.createVNode(wt,{type:e.type,visible:e.linkVisible,onOk:e.onOk,onCancel:e.onCancel},null),t.createVNode(St,{visible:e.clipVisible,onOk:e.onOk,onCancel:e.onCancel},null)])}}),Lt=t.defineComponent({name:"MDEditorToolbar",props:xt,setup(e){const l=t.inject("editorId"),o=t.inject("usedLanguageText"),{fullscreenHandler:a}=Nt(e),n=`${l}-toolbar-wrapper`,i=t.ref(),g=t.reactive({title:!1,catalog:!1,image:!1,table:!1,mermaid:!1,katex:!1}),d=(p,b)=>{s.bus.emit(l,s.REPLACE,p,b)},u=t.reactive({type:"link",linkVisible:!1,clipVisible:!1}),f=t.ref();t.onMounted(()=>{s.bus.on(l,{name:s.OPEN_MODALS,callback(p){u.type=p,u.linkVisible=!0}})});const m=t.computed(()=>{const p=e.toolbars.filter($=>!e.toolbarsExclude.includes($)),b=p.indexOf("="),h=b===-1?p:p.slice(0,b+1),N=b===-1?[]:p.slice(b,Number.MAX_SAFE_INTEGER);return[h,N]}),v=t.ref(),x=()=>{s.bus.emit(l,s.UPLOAD_IMAGE,Array.from(v.value.files||[])),v.value.value=""};t.onMounted(()=>{v.value.addEventListener("change",x)});const V=p=>{var b,h,N,$,T,L,E,Z,X,y,w,B,F,M,A,I,D,_,j,ne,Y,K,G,J,U,H,O,Q,ie,ge,be,he,ve,pe,ke,Ce,xe,Ne,Ve,$e,Te,ye,we,Ee,Se,Ae,Ie,Le,Me,Re,De,He,Oe,Pe,Fe,Be,qe,_e,je,Ge,Ue,Ke,We,ze,Ze,Xe,Ye;if(r.allToolbar.includes(p))switch(p){case"-":return t.createVNode(Ct,null,null);case"bold":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(b=o.value.toolbarTips)==null?void 0:b.bold,onClick:()=>{d("bold")}},[t.createVNode(k.Icon,{name:"bold"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(h=o.value.toolbarTips)==null?void 0:h.bold])]);case"underline":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(N=o.value.toolbarTips)==null?void 0:N.underline,onClick:()=>{d("underline")}},[t.createVNode(k.Icon,{name:"underline"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[($=o.value.toolbarTips)==null?void 0:$.underline])]);case"italic":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(T=o.value.toolbarTips)==null?void 0:T.italic,onClick:()=>{d("italic")}},[t.createVNode(k.Icon,{name:"italic"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(L=o.value.toolbarTips)==null?void 0:L.italic])]);case"strikeThrough":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(E=o.value.toolbarTips)==null?void 0:E.strikeThrough,onClick:()=>{d("strikeThrough")}},[t.createVNode(k.Icon,{name:"strike-through"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Z=o.value.toolbarTips)==null?void 0:Z.strikeThrough])]);case"title":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.title,onChange:C=>{g.title=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h1")}},[(X=o.value.titleItem)==null?void 0:X.h1]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h2")}},[(y=o.value.titleItem)==null?void 0:y.h2]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h3")}},[(w=o.value.titleItem)==null?void 0:w.h3]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h4")}},[(B=o.value.titleItem)==null?void 0:B.h4]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h5")}},[(F=o.value.titleItem)==null?void 0:F.h5]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("h6")}},[(M=o.value.titleItem)==null?void 0:M.h6])])},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.title},[t.createVNode(k.Icon,{name:"title"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.title])])]}});case"sub":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(A=o.value.toolbarTips)==null?void 0:A.sub,onClick:()=>{d("sub")}},[t.createVNode(k.Icon,{name:"sub"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(I=o.value.toolbarTips)==null?void 0:I.sub])]);case"sup":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(D=o.value.toolbarTips)==null?void 0:D.sup,onClick:()=>{d("sup")}},[t.createVNode(k.Icon,{name:"sup"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(_=o.value.toolbarTips)==null?void 0:_.sup])]);case"quote":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(j=o.value.toolbarTips)==null?void 0:j.quote,onClick:()=>{d("quote")}},[t.createVNode(k.Icon,{name:"quote"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ne=o.value.toolbarTips)==null?void 0:ne.quote])]);case"unorderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Y=o.value.toolbarTips)==null?void 0:Y.unorderedList,onClick:()=>{d("unorderedList")}},[t.createVNode(k.Icon,{name:"unordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(K=o.value.toolbarTips)==null?void 0:K.unorderedList])]);case"orderedList":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(G=o.value.toolbarTips)==null?void 0:G.orderedList,onClick:()=>{d("orderedList")}},[t.createVNode(k.Icon,{name:"ordered-list"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(J=o.value.toolbarTips)==null?void 0:J.orderedList])]);case"task":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(U=o.value.toolbarTips)==null?void 0:U.task,onClick:()=>{d("task")}},[t.createVNode(k.Icon,{name:"task"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(H=o.value.toolbarTips)==null?void 0:H.task])]);case"codeRow":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(O=o.value.toolbarTips)==null?void 0:O.codeRow,onClick:()=>{d("codeRow")}},[t.createVNode(k.Icon,{name:"code-row"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Q=o.value.toolbarTips)==null?void 0:Q.codeRow])]);case"code":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ie=o.value.toolbarTips)==null?void 0:ie.code,onClick:()=>{d("code")}},[t.createVNode(k.Icon,{name:"code"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(ge=o.value.toolbarTips)==null?void 0:ge.code])]);case"link":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(be=o.value.toolbarTips)==null?void 0:be.link,onClick:()=>{u.type="link",u.linkVisible=!0}},[t.createVNode(k.Icon,{name:"link"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(he=o.value.toolbarTips)==null?void 0:he.link])]);case"image":return e.noUploadImg?t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ve=o.value.toolbarTips)==null?void 0:ve.image,onClick:()=>{u.type="image",u.linkVisible=!0}},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(pe=o.value.toolbarTips)==null?void 0:pe.image])]):t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.image,onChange:C=>{g.image=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.title=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{u.type="image",u.linkVisible=!0}},[(ke=o.value.imgTitleItem)==null?void 0:ke.link]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{v.value.click()}},[(Ce=o.value.imgTitleItem)==null?void 0:Ce.upload]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{u.clipVisible=!0}},[(xe=o.value.imgTitleItem)==null?void 0:xe.clip2upload])])},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.image},[t.createVNode(k.Icon,{name:"image"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.image])])]}});case"table":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.table,onChange:C=>{g.table=C},key:"bar-table",overlay:t.createVNode(Tt,{tableShape:e.tableShape,onSelected:C=>{d("table",{selectedShape:C})}},null)},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.table},[t.createVNode(k.Icon,{name:"table"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.table])])]}});case"revoke":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ne=o.value.toolbarTips)==null?void 0:Ne.revoke,onClick:()=>{s.bus.emit(l,s.CTRL_Z)}},[t.createVNode(k.Icon,{name:"revoke"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ve=o.value.toolbarTips)==null?void 0:Ve.revoke])]);case"next":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:($e=o.value.toolbarTips)==null?void 0:$e.next,onClick:()=>{s.bus.emit(l,s.CTRL_SHIFT_Z)}},[t.createVNode(k.Icon,{name:"next"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Te=o.value.toolbarTips)==null?void 0:Te.next])]);case"save":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(ye=o.value.toolbarTips)==null?void 0:ye.save,onClick:()=>{s.bus.emit(l,s.ON_SAVE)}},[t.createVNode(k.Icon,{name:"baocun"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(we=o.value.toolbarTips)==null?void 0:we.save])]);case"prettier":return e.noPrettier?"":t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ee=o.value.toolbarTips)==null?void 0:Ee.prettier,onClick:()=>{d("prettier")}},[t.createVNode(k.Icon,{name:"prettier"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Se=o.value.toolbarTips)==null?void 0:Se.prettier])]);case"pageFullscreen":return!e.setting.fullscreen&&t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Ae=o.value.toolbarTips)==null?void 0:Ae.pageFullscreen,onClick:()=>{e.updateSetting("pageFullscreen")}},[t.createVNode(k.Icon,{name:e.setting.pageFullscreen?"suoxiao":"fangda"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Ie=o.value.toolbarTips)==null?void 0:Ie.pageFullscreen])]);case"fullscreen":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Le=o.value.toolbarTips)==null?void 0:Le.fullscreen,onClick:()=>{a()}},[t.createVNode(k.Icon,{name:e.setting.fullscreen?"fullscreen-exit":"fullscreen"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Me=o.value.toolbarTips)==null?void 0:Me.fullscreen])]);case"preview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Re=o.value.toolbarTips)==null?void 0:Re.preview,onClick:()=>{e.updateSetting("preview")}},[t.createVNode(k.Icon,{name:"preview"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(De=o.value.toolbarTips)==null?void 0:De.preview])]);case"htmlPreview":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(He=o.value.toolbarTips)==null?void 0:He.htmlPreview,onClick:()=>{e.updateSetting("htmlPreview")}},[t.createVNode(k.Icon,{name:"coding"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Oe=o.value.toolbarTips)==null?void 0:Oe.htmlPreview])]);case"catalog":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Pe=o.value.toolbarTips)==null?void 0:Pe.catalog,onClick:()=>{s.bus.emit(l,s.CHANGE_CATALOG_VISIBLE)},key:"bar-catalog"},[t.createVNode(k.Icon,{name:"catalog"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(Fe=o.value.toolbarTips)==null?void 0:Fe.catalog])]);case"github":return t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(Be=o.value.toolbarTips)==null?void 0:Be.github,onClick:()=>le.linkTo("https://github.com/imzbf/md-editor-v3")},[t.createVNode(k.Icon,{name:"github"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(qe=o.value.toolbarTips)==null?void 0:qe.github])]);case"mermaid":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.mermaid,onChange:C=>{g.mermaid=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.mermaid=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("flow")}},[(_e=o.value.mermaid)==null?void 0:_e.flow]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("sequence")}},[(je=o.value.mermaid)==null?void 0:je.sequence]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("gantt")}},[(Ge=o.value.mermaid)==null?void 0:Ge.gantt]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("class")}},[(Ue=o.value.mermaid)==null?void 0:Ue.class]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("state")}},[(Ke=o.value.mermaid)==null?void 0:Ke.state]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("pie")}},[(We=o.value.mermaid)==null?void 0:We.pie]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("relationship")}},[(ze=o.value.mermaid)==null?void 0:ze.relationship]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("journey")}},[(Ze=o.value.mermaid)==null?void 0:Ze.journey])]),key:"bar-mermaid"},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.mermaid},[t.createVNode(k.Icon,{name:"mermaid"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.mermaid])])]}});case"katex":return t.createVNode(z.Dropdown,{relative:`#${n}`,visible:g.katex,onChange:C=>{g.katex=C},overlay:t.createVNode("ul",{class:`${r.prefix}-menu`,onClick:()=>{g.katex=!1}},[t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexInline")}},[(Xe=o.value.katex)==null?void 0:Xe.inline]),t.createVNode("li",{class:`${r.prefix}-menu-item`,onClick:()=>{d("katexBlock")}},[(Ye=o.value.katex)==null?void 0:Ye.block])]),key:"bar-katex"},{default:()=>{var C,S;return[t.createVNode("div",{class:`${r.prefix}-toolbar-item`,title:(C=o.value.toolbarTips)==null?void 0:C.katex},[t.createVNode(k.Icon,{name:"formula"},null),e.showToolbarName&&t.createVNode("div",{class:`${r.prefix}-toolbar-item-name`},[(S=o.value.toolbarTips)==null?void 0:S.katex])])]}})}else if(e.defToolbars instanceof Array){const C=e.defToolbars[p];return C?t.cloneVNode(C,{insert(ue){s.bus.emit(l,s.REPLACE,"universal",{generate:ue})}}):""}else if(e.defToolbars&&e.defToolbars.children instanceof Array){const C=e.defToolbars.children[p];return C?t.cloneVNode(C,{insert(ue){s.bus.emit(l,s.REPLACE,"universal",{generate:ue})}}):""}else return""};return t.watch(()=>e.toolbars,()=>{t.nextTick(()=>{i.value&&le.draggingScroll(i.value)})},{immediate:!0}),()=>{const p=m.value[0].map(h=>V(h)),b=m.value[1].map(h=>V(h));return t.createVNode(t.Fragment,null,[e.toolbars.length>0&&t.createVNode("div",{class:`${r.prefix}-toolbar-wrapper`,ref:i,id:n},[t.createVNode("div",{class:[`${r.prefix}-toolbar`,e.showToolbarName&&`${r.prefix}-stn`]},[t.createVNode("div",{class:`${r.prefix}-toolbar-left`,ref:f},[p]),t.createVNode("div",{class:`${r.prefix}-toolbar-right`},[b])])]),t.createVNode("input",{ref:v,accept:"image/*",type:"file",multiple:!0,style:{display:"none"}},null),t.createVNode(It,{linkVisible:u.linkVisible,clipVisible:u.clipVisible,type:u.type,onCancel:()=>{u.linkVisible=!1,u.clipVisible=!1},onOk:h=>{h&&d(u.type,{desc:h.desc,url:h.url}),u.linkVisible=!1,u.clipVisible=!1}},null)])}}}),Mt=(e,l)=>{const o=le.debounce(()=>{e.removeEventListener("scroll",a),e.addEventListener("scroll",a),l.removeEventListener("scroll",a),l.addEventListener("scroll",a)},50),a=n=>{const i=e.clientHeight,g=l.clientHeight,d=e.scrollHeight,u=l.scrollHeight,f=(d-i)/(u-g);n.target===e?(l.removeEventListener("scroll",a),l.scrollTo({top:e.scrollTop/f}),o()):(e.removeEventListener("scroll",a),e.scrollTo({top:l.scrollTop*f}),o())};return[()=>{o().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",a),l.removeEventListener("scroll",a)}]},Rt=(e,l,o)=>{const{view:a}=o,n=le.createSmoothScroll(),i=x=>a.lineBlockAt(a.state.doc.line(x).from).top,g=x=>a.lineBlockAt(a.state.doc.line(x).from).height;let d=[];const u=()=>{d=[];const x=Array.from(l.querySelectorAll("[data-line]")).map(h=>Number(h.dataset.line)+1),{lines:V}=a.state.doc;let p=1,b=x.shift()??V;for(let h=1;h<=V;h++)h===b&&(p=h,b=x.shift()||V+1),d.push({start:p,end:b-1})};let f=0,m=0;const v=le.throttle(x=>{var N,$,T,L,E,Z,X;if(!((N=l.firstElementChild)!=null&&N.firstElementChild))return;const V=a.lineBlockAtHeight(a.scrollDOM.scrollTop),{number:p}=a.state.doc.lineAt(V.from);if(p>d.length||a.state.doc.lines<d[d.length-1].end)return;let b=+getComputedStyle(l).paddingTop.replace("px","");const h=+getComputedStyle(l).paddingBottom.replace("px","");if(x.target===e){if(m!==0)return;f++;const y=d[p-1];let w=i(y.end)+g(y.end),B=0;const F=i(y.start),M=l.querySelector(`[data-line="${y.start-1}"]`)||(($=l.firstElementChild)==null?void 0:$.firstElementChild),A=l.querySelector(`[data-line="${y.end}"]`)||((T=l.lastElementChild)==null?void 0:T.lastElementChild);let I=0,D=0;F===0?M===A?(b=0,w=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight,B=a.scrollDOM.scrollTop/w,I=A.offsetTop+A.offsetHeight-l.clientHeight):(B=a.scrollDOM.scrollTop/w,I=A.offsetTop):w>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(B=(a.scrollDOM.scrollTop-F)/(a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight-F),D=M.offsetTop,I=l.scrollHeight-l.clientHeight-D+10):(B=(a.scrollDOM.scrollTop-F)/(w-F),D=M.offsetTop,I=A.offsetTop-D);const _=D-b+I*B;n(l,_,()=>{f--})}else{if(f!==0)return;m++;const y=Array.from(l.querySelectorAll("[data-line]")),w=l.scrollTop,B=l.scrollHeight;let F=y.length===0?1:Math.ceil(Number(y[y.length-1].dataset.line)*(w/B)),M=(L=l.firstElementChild)==null?void 0:L.firstElementChild;for(let H=F;H>=0;H--){const O=l.querySelector(`[data-line="${H}"]`);if(O&&O.offsetTop<=w){M=O,F=H;break}}let A=(E=l.firstElementChild)==null?void 0:E.firstElementChild,I=(Z=l.firstElementChild)==null?void 0:Z.lastElementChild;for(;y.length>0;){const H=y.indexOf(M);if(H+1>=y.length)break;const O=y[H+1];if(H===-1){I=O;break}const Q=M.offsetTop;if(Q>w){if(H===0){A=M,I=O;break}M=y[H-1];continue}const ie=O.offsetTop;if(Q<=w&&ie>w){A=M,I=O;break}M=O}const D=A.offsetTop;let _=I.offsetTop,j=0;const{start:ne,end:Y}=d[Number(A.dataset.line||0)],K=i(ne);let G=i(Y);const J=g(Y);let U=0;A===((X=l.firstElementChild)==null?void 0:X.firstElementChild)?(A===I?(_=I.offsetHeight-l.offsetHeight+b+h,U=a.contentDOM.offsetHeight-a.scrollDOM.offsetHeight):U=G+J-K,j=Math.max(w/_,0)):G>a.scrollDOM.scrollHeight-a.scrollDOM.clientHeight?(j=Math.max((w-D)/(l.scrollHeight-D-l.clientHeight),0),G=i(a.state.doc.lines)+g(a.state.doc.lines),U=8+G-K-e.clientHeight):(j=Math.max((w-D)/(_-D),0),U=G+J-K),n(e,K+U*j,()=>{m--})}},10);return[()=>{u(),e.addEventListener("scroll",v),l.addEventListener("scroll",v),e.dispatchEvent(new Event("scroll"))},()=>{d=[],e.removeEventListener("scroll",v),l.removeEventListener("scroll",v)}]},Dt=(e,l,o)=>{const a=t.inject("editorId");let n=()=>{},i=()=>{};const g=()=>{n();const d=document.querySelector(`#${a} .cm-scroller`),u=document.querySelector(`[id="${a}-preview-wrapper"][data-show="true"]`),f=document.querySelector(`[id="${a}-html-wrapper"][data-show="true"]`);(u||f)&&([i,n]=(u?Rt:Mt)(d,u||f,o.value)),e.scrollAuto&&i()};t.watch([l,t.toRef(e.setting,"preview"),t.toRef(e.setting,"htmlPreview"),t.toRef(e.setting,"fullscreen"),t.toRef(e.setting,"pageFullscreen")],()=>{t.nextTick(g)}),t.watch(()=>e.scrollAuto,d=>{d?i():n()}),t.onMounted(g)},Ht=Dt,Ot=(e,l,o)=>{var m,v,x,V,p,b;let a="",n=0,i=0,g=!0,d=!1;const u=l.getSelectedText(),f=(m=r.configOption.editorConfig)==null?void 0:m.mermaidTemplate;if(/^h[1-6]{1}$/.test(e)){const h=e.replace(/^h(\d)/,(N,$)=>new Array(Number($)).fill("#",0,$).join(""));a=`${h} ${u}`,n=h.length+1}else if(e==="prettier"){const h=window.prettier||((x=(v=r.configOption.editorExtensions)==null?void 0:v.prettier)==null?void 0:x.prettierInstance),N=[((V=window.prettierPlugins)==null?void 0:V.markdown)||((b=(p=r.configOption.editorExtensions)==null?void 0:p.prettier)==null?void 0:b.parserMarkdownInstance)];!h||N[0]===void 0?(s.bus.emit(o.editorId,s.ERROR_CATCHER,{name:"prettier",message:"prettier is undefined"}),a=l.getValue()):a=h.format(l.getValue(),{parser:"markdown",plugins:N}),g=!1,d=!0}else switch(e){case"bold":{a=`**${u}**`,n=2,i=-2;break}case"underline":{a=`<u>${u}</u>`,n=3,i=-4;break}case"italic":{a=`*${u}*`,n=1,i=-1;break}case"strikeThrough":{a=`~~${u}~~`,n=2,i=-2;break}case"sub":{a=`<sub>${u}</sub>`,n=5,i=-6;break}case"sup":{a=`<sup>${u}</sup>`,n=5,i=-6;break}case"codeRow":{a="`"+u+"`",n=1,i=-1;break}case"quote":{a=`> ${u}`,n=2;break}case"orderedList":{a=`1. ${u}`,n=3;break}case"unorderedList":{a=`- ${u}`,n=2;break}case"task":{a=`- [ ] ${u}`,n=6;break}case"code":{const h=o.text||u||"",N=o.mode||"language";a=`\`\`\`${N}
|
|
2
|
+
${h}
|
|
3
3
|
\`\`\`
|
|
4
|
-
`,n=3,i=3+N.length-a.length;break}case"table":{a="|";const{selectedShape:
|
|
5
|
-
|`;for(let
|
|
6
|
-
|`;for(let
|
|
7
|
-
`,""):a=``,g=!1;break}case"image":{const{desc:h,url:N,urls:$}=o;$ instanceof Array?a=$.reduce((T,L)=>T+`
|
|
7
|
+
`,""):a=`
|
|
8
|
+
`,g=!1;break}case"flow":{a=`\`\`\`mermaid
|
|
9
9
|
${(f==null?void 0:f.flow)||`flowchart TD
|
|
10
10
|
Start --> Stop`}
|
|
11
11
|
\`\`\`
|
|
@@ -57,11 +57,11 @@ ${(f==null?void 0:f.journey)||`journey
|
|
|
57
57
|
`,n=3,i=10-a.length;break}case"katexInline":{a="$$",n=1,i=-1;break}case"katexBlock":{a=`$$
|
|
58
58
|
|
|
59
59
|
$$
|
|
60
|
-
`,n=3,i=-4;break}case"universal":{const{generate:
|
|
60
|
+
`,n=3,i=-4;break}case"universal":{const{generate:h}=o,N=h(u);a=N.targetValue,g=N.select,n=N.deviationStart,i=N.deviationEnd}}return{text:a,options:{select:g,deviationStart:n,deviationEnd:i,replaceAll:d}}},Pt="#e5c07b",Qe="var(--md-color)",Ft="#56b6c2",Bt="#ffffff",te="var(--md-color)",et="#e5c07b",qt="#e5c07b",_t="var(--md-color)",tt="#d19a66",jt="#c678dd",Gt="#21252b",Ut="#2c313a",ot="var(--md-bk-color)",me="var(--md-bk-color)",Kt="#ceedfa33",lt="#528bff",Wt=ae.EditorView.theme({"&":{color:te,backgroundColor:ot},".cm-content":{caretColor:lt},".cm-cursor, .cm-dropCursor":{borderLeftColor:lt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Kt},".cm-panels":{backgroundColor:Gt,color:te},".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:ot,color:te,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:Ut},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"1px solid var(--md-border-color)",backgroundColor:me},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:me,borderBottomColor:me},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{color:te}}},{dark:!0}),zt=re.HighlightStyle.define([{tag:c.tags.keyword,color:jt},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:Qe},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:qt},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:tt},{tag:[c.tags.definition(c.tags.name),c.tags.separator],color:te},{tag:[c.tags.typeName,c.tags.className,c.tags.number,c.tags.changed,c.tags.annotation,c.tags.modifier,c.tags.self,c.tags.namespace],color:Pt},{tag:[c.tags.operator,c.tags.operatorKeyword,c.tags.url,c.tags.escape,c.tags.regexp,c.tags.link,c.tags.special(c.tags.string)],color:Ft},{tag:[c.tags.meta,c.tags.comment],color:et},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:et,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:Qe},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:tt},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:_t},{tag:c.tags.invalid,color:Bt}]),Zt=[Wt,re.syntaxHighlighting(zt)],Xt="#e5c07b",at="#3f4a54",Yt="#56b6c2",Jt="#fff",oe="#3f4a54",rt="#2d8cf0",Qt="#2d8cf0",eo="#3f4a54",nt="#d19a66",to="#c678dd",oo="#21252b",lo="#ceedfa33",it="var(--md-bk-color)",fe="var(--md-bk-color)",ao="#bad5fa",ct="#3f4a54",ro=ae.EditorView.theme({"&":{color:oe,backgroundColor:it},".cm-content":{caretColor:ct},".cm-cursor, .cm-dropCursor":{borderLeftColor:ct},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ao},".cm-panels":{backgroundColor:oo,color:oe},".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:it,color:oe,borderRight:"1px solid",borderColor:"var(--md-border-color)"},".cm-activeLineGutter":{backgroundColor:lo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"1px solid var(--md-border-color)",backgroundColor:fe},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fe,borderBottomColor:fe},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{color:oe}}}),no=re.HighlightStyle.define([{tag:c.tags.keyword,color:to},{tag:[c.tags.name,c.tags.deleted,c.tags.character,c.tags.propertyName,c.tags.macroName],color:at},{tag:[c.tags.function(c.tags.variableName),c.tags.labelName],color:Qt},{tag:[c.tags.color,c.tags.constant(c.tags.name),c.tags.standard(c.tags.name)],color:nt},{tag:[c.tags.definition(c.tags.name),c.tags.separator],color:oe},{tag:[c.tags.typeName,c.tags.className,c.tags.number,c.tags.changed,c.tags.annotation,c.tags.modifier,c.tags.self,c.tags.namespace],color:Xt},{tag:[c.tags.operator,c.tags.operatorKeyword,c.tags.url,c.tags.escape,c.tags.regexp,c.tags.link,c.tags.special(c.tags.string)],color:Yt},{tag:[c.tags.meta,c.tags.comment],color:rt},{tag:c.tags.strong,fontWeight:"bold"},{tag:c.tags.emphasis,fontStyle:"italic"},{tag:c.tags.strikethrough,textDecoration:"line-through"},{tag:c.tags.link,color:rt,textDecoration:"underline"},{tag:c.tags.heading,fontWeight:"bold",color:at},{tag:[c.tags.atom,c.tags.bool,c.tags.special(c.tags.variableName)],color:nt},{tag:[c.tags.processingInstruction,c.tags.string,c.tags.inserted],color:eo},{tag:c.tags.invalid,color:Jt}]),io=[ro,re.syntaxHighlighting(no)],ce=(e,l,o,a,n)=>(i,g,d,u)=>{const f=`${e}${l}`.slice(u-d);i.dispatch(i.state.replaceSelection(`${f}${o}${a}`));const m=d+g.label.length+(n==="title"?o.length:0);i.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(d+g.label.length+(n==="title"?1:-l.length),m),R.EditorSelection.cursor(m)],1)}),i.focus()},st=e=>(l,o,a,n)=>{const i=e.slice(n-a);l.dispatch(l.state.replaceSelection(`${i} `))},co=e=>{const l=o=>{const a=o.matchBefore(/^#+|^-\s*\[*\s*\]*|`+|\[|!\[*|^\|\s?\|?|^\$\$?|!+\s*\w*/);return a===null||a.from==a.to&&o.explicit?null:{from:a.from,options:[...["h1","h2","h3","h4","h5","h6"].map((n,i)=>{const g=new Array(i+1).fill("#").join("");return{label:g,type:"text",apply:st(g)}}),...["unchecked","checked"].map(n=>{const i=n==="checked"?"- [x]":"- [ ]";return{label:i,type:"text",apply:st(i)}}),...[["`",""],["```","language"],["```mermaid\n",""]].map(n=>({label:`${n[0]}${n[1]}`,type:"text",apply:ce(n[0],n[1],"",n[0]==="`"?"`":"\n```","type")})),{label:"[]()",type:"text"},{label:"![]()",type:"text"},{label:"| |",type:"text",detail:"table",apply:`| col | col | col |
|
|
61
61
|
| - | - | - |
|
|
62
62
|
| content | content | content |
|
|
63
|
-
| content | content | content |`},{label:"$",type:"text",apply:
|
|
63
|
+
| content | content | content |`},{label:"$",type:"text",apply:ce("$","","","$","type")},{label:"$$",type:"text",apply:ce("$$","",`
|
|
64
64
|
`,`
|
|
65
|
-
$$`,"title")},...["note","abstract","info","tip","success","question","warning","failure","danger","bug","example","quote","hint","caution","error","attention"].map(n=>({label:`!!! ${n}`,type:"text",apply:
|
|
65
|
+
$$`,"title")},...["note","abstract","info","tip","success","question","warning","failure","danger","bug","example","quote","hint","caution","error","attention"].map(n=>({label:`!!! ${n}`,type:"text",apply:ce("!!!",` ${n}`," Title",`
|
|
66
66
|
|
|
67
|
-
!!!`,"title")}))]}};return ht.autocompletion({override:e?[l,...e]:[l]})},co=io,W=e=>{const l=new H.Compartment;return a=>(l.get(e.state)?e.dispatch({effects:l.reconfigure(a)}):e.dispatch({effects:H.StateEffect.appendConfig.of(l.of(a))}),!0)};class so{constructor(l){P(this,"view");P(this,"maxLength",Number.MAX_SAFE_INTEGER);P(this,"toggleTabSize");P(this,"togglePlaceholder");P(this,"setExtensions");P(this,"toggleDisabled");P(this,"toggleReadOnly");P(this,"toggleMaxlength");this.view=l,this.toggleTabSize=W(this.view),this.togglePlaceholder=W(this.view),this.setExtensions=W(this.view),this.toggleDisabled=W(this.view),this.toggleReadOnly=W(this.view),this.toggleMaxlength=W(this.view)}getValue(){return this.view.state.doc.toString()}setValue(l,o=0,a=this.view.state.doc.length){this.view.dispatch({changes:{from:o,to:a,insert:l}})}getSelectedText(){const{from:l,to:o}=this.view.state.selection.main;return this.view.state.sliceDoc(l,o)}replaceSelectedText(l,o={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1},a){try{if(o.replaceAll){if(this.setValue(l),l.length>this.maxLength)throw new Error("The input text is too long");return}if(this.view.state.doc.length-this.getSelectedText().length+l.length>this.maxLength)throw new Error("The input text is too long");const{from:n}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(l)),o.select){const i=n+l.length+o.deviationEnd;this.view.dispatch({selection:H.EditorSelection.create([H.EditorSelection.range(n+o.deviationStart,i),H.EditorSelection.cursor(i)],1)})}this.view.focus()}catch(n){if(n.message==="The input text is too long")b.bus.emit(a,"errorCatcher",{name:"overlength",message:n.message,data:l});else throw n}}setTabSize(l){this.toggleTabSize([H.EditorState.tabSize.of(l),ae.indentUnit.of(" ".repeat(l))])}setPlaceholder(l){this.togglePlaceholder(le.placeholder(l))}focus(l){if(this.view.focus(),!l)return;let o=0,a=0,n=0;switch(l){case"start":break;case"end":{o=a=n=this.getValue().length;break}default:o=l.rangeAnchor||l.cursorPos,a=l.rangeHead||l.cursorPos,n=l.cursorPos}this.view.dispatch({scrollIntoView:!0,selection:H.EditorSelection.create([H.EditorSelection.range(o,a),H.EditorSelection.cursor(n)],1)})}setDisabled(l){this.toggleDisabled([le.EditorView.editable.of(!l)])}setReadOnly(l){this.toggleReadOnly([H.EditorState.readOnly.of(l)])}setMaxLength(l){this.maxLength=l,this.toggleMaxlength([H.EditorState.changeFilter.of(o=>o.newDoc.length<=l)])}}const uo=e=>{const l=t.inject("editorId");return a=>{if(!a.clipboardData)return;if(a.clipboardData.files.length>0){const{files:i}=a.clipboardData;b.bus.emit(l,"uploadImage",Array.from(i).filter(u=>/image\/.*/.test(u.type))),a.preventDefault();return}if(e.autoDetectCode&&a.clipboardData.types.includes("vscode-editor-data")){const i=JSON.parse(a.clipboardData.getData("vscode-editor-data"));b.bus.emit(l,"replace","code",{mode:i.mode,text:a.clipboardData.getData("text/plain")}),a.preventDefault();return}const n=a.clipboardData.getData("text/plain");e.maxlength&&n.length+e.modelValue.length>e.maxlength&&b.bus.emit(l,"errorCatcher",{name:"overlength",message:"The input text is too long",data:n})}},mo=uo,fo=e=>{const l=t.inject("editorId");t.onMounted(()=>{b.bus.on(l,{name:S.TEXTAREA_FOCUS,callback(o){var a;(a=e.value)==null||a.focus(o)}})})},go=fo,bo=(e,l)=>{const o={key:"Ctrl-b",mac:"Cmd-b",run:()=>(b.bus.emit(e,"replace","bold"),!0)},a={key:"Ctrl-s",mac:"Cmd-s",run:D=>(b.bus.emit(e,S.ON_SAVE,D.state.doc.toString()),!0),shift:()=>(b.bus.emit(e,"replace","strikeThrough"),!0)},n={key:"Ctrl-u",mac:"Cmd-u",run:()=>(b.bus.emit(e,"replace","underline"),!0),shift:()=>(b.bus.emit(e,"replace","unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(b.bus.emit(e,"replace","italic"),!0),shift:()=>(b.bus.emit(e,"openModals","image"),!0)},u={key:"Ctrl-1",mac:"Cmd-1",run:()=>(b.bus.emit(e,"replace","h1"),!0)},d={key:"Ctrl-2",mac:"Cmd-2",run:()=>(b.bus.emit(e,"replace","h2"),!0)},s={key:"Ctrl-3",mac:"Cmd-3",run:()=>(b.bus.emit(e,"replace","h3"),!0)},f={key:"Ctrl-4",mac:"Cmd-4",run:()=>(b.bus.emit(e,"replace","h4"),!0)},m={key:"Ctrl-5",mac:"Cmd-5",run:()=>(b.bus.emit(e,"replace","h5"),!0)},h={key:"Ctrl-6",mac:"Cmd-6",run:()=>(b.bus.emit(e,"replace","h6"),!0)},x={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(b.bus.emit(e,"replace","sup"),!0)},V={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(b.bus.emit(e,"replace","sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(b.bus.emit(e,"replace","orderedList"),!0)},g={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(b.bus.emit(e,"replace","code"),!0),any(D,I){return(I.ctrlKey||I.metaKey)&&I.altKey&&I.code==="KeyC"?(b.bus.emit(e,"replace","codeRow"),!0):!1}},v={key:"Ctrl-l",mac:"Cmd-l",run:()=>(b.bus.emit(e,"openModals","link"),!0)},N={key:"Ctrl-f",mac:"Cmd-f",shift:()=>l.noPrettier?!1:(b.bus.emit(e,"replace","prettier"),!0)},$={any:(D,I)=>(I.ctrlKey||I.metaKey)&&I.altKey&&I.shiftKey&&I.code==="KeyT"?(b.bus.emit(e,"replace","table"),!0):!1},y={key:"Ctrl-d",mac:"Cmd-d",run:ce.deleteLine,preventDefault:!0};return[o,y,a,n,i,u,d,s,f,m,h,x,V,p,g,v,N,$]},ho=bo,po=e=>{const l=t.inject("tabWidth"),o=t.inject("editorId"),a=t.inject("theme"),n=t.ref(),i=t.shallowRef(),u=ho(o,e),d=mo(e),s=[le.keymap.of([...u,ce.indentWithTab]),ee.minimalSetup,bt.markdown({codeLanguages:gt.languages}),ee.EditorView.lineWrapping,ee.EditorView.updateListener.of(m=>{m.docChanged&&e.onChange(m.state.doc.toString())}),ee.EditorView.domEventHandlers({paste:d,blur:e.onBlur,focus:e.onFocus,input:m=>{e.onInput&&e.onInput(m);const{data:h}=m;e.maxlength&&e.modelValue.length+h.length>e.maxlength&&b.bus.emit(o,"errorCatcher",{name:"overlength",message:"The input text is too long",data:h})}})],f=()=>{const m=[...s,a.value==="light"?no:zt,co(e.completions)];return r.configOption.codeMirrorExtensions(a.value,m,[...u])};return t.onMounted(()=>{const m=new ee.EditorView({doc:e.modelValue,parent:n.value}),h=new so(m);i.value=h,setTimeout(()=>{h.setTabSize(l),h.setDisabled(e.disabled),h.setReadOnly(e.readonly),h.setExtensions(f()),e.placeholder&&h.setPlaceholder(e.placeholder),typeof e.maxlength=="number"&&h.setMaxLength(e.maxlength),e.autofocus&&m.focus()},0),b.bus.on(o,{name:"ctrlZ",callback(){ce.undo(m)}}),b.bus.on(o,{name:"ctrlShiftZ",callback(){ce.redo(m)}}),b.bus.on(o,{name:"replace",callback(x,V={}){var v;const{text:p,options:g}=Ot(x,i.value,V);(v=i.value)==null||v.replaceSelectedText(p,g,o)}})}),t.watch([a,t.toRef(e,"completions")],()=>{var m;(m=i.value)==null||m.setExtensions(f())},{deep:!0}),t.watch(()=>e.modelValue,()=>{var m,h;((m=i.value)==null?void 0:m.getValue())!==e.modelValue&&((h=i.value)==null||h.setValue(e.modelValue))}),t.watch(()=>e.placeholder,()=>{var m;(m=i.value)==null||m.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var m;(m=i.value)==null||m.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var m;(m=i.value)==null||m.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var m;e.maxlength&&((m=i.value)==null||m.setMaxLength(e.maxlength))}),go(i),{inputWrapperRef:n,codeMirrorUt:i}},vo=po,ko=t.defineComponent({name:"MDEditorContent",props:S.contentProps,setup(e){const l=t.inject("editorId"),o=t.ref(""),{inputWrapperRef:a,codeMirrorUt:n}=vo(e);return Ht(e,o,n),()=>t.createVNode("div",{class:`${r.prefix}-content`},[t.createVNode("div",{class:`${r.prefix}-input-wrapper`,ref:a},null),t.createVNode(S.ContentPreview,{modelValue:e.modelValue,setting:e.setting,onHtmlChanged:i=>{o.value=i,e.onHtmlChanged(i)},onGetCatalog:e.onGetCatalog,mdHeadingId:e.mdHeadingId,noMermaid:e.noMermaid,sanitize:e.sanitize,noKatex:e.noKatex,formatCopiedText:e.formatCopiedText,noHighlight:e.noHighlight,noImgZoomIn:e.noImgZoomIn},null),e.catalogVisible&&t.createVNode(dt,{theme:e.theme,class:`${r.prefix}-catalog-editor`,editorId:l,mdHeadingId:e.mdHeadingId,key:"internal-catalog"},null)])}}),Co=t.defineComponent({props:{modelValue:{type:String,default:""}},setup(e){const l=t.inject("usedLanguageText");return()=>{var o,a;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`},[`${(o=l.value.footer)==null?void 0:o.markdownTotal}:`]),t.createVNode("span",null,[((a=e.modelValue)==null?void 0:a.length)||0])])}}}),xo={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},No=t.defineComponent({props:xo,setup(e){return()=>t.createVNode("div",{class:[`${r.prefix}-checkbox`,e.checked&&`${r.prefix}-checkbox-checked`],onClick:()=>{e.onChange(!e.checked)}},null)}}),Vo={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},$o=t.defineComponent({props:Vo,setup(e){const l=t.inject("usedLanguageText");return()=>{var o;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`,onClick:()=>{e.onScrollAutoChange(!e.scrollAuto)}},[(o=l.value.footer)==null?void 0:o.scrollAuto]),t.createVNode(No,{checked:e.scrollAuto,onChange:e.onScrollAutoChange},null)])}}}),yo={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},To=t.defineComponent({name:"MDEditorFooter",props:yo,setup(e){const l=t.computed(()=>{const a=e.footers.indexOf("="),n=a===-1?e.footers:e.footers.slice(0,a),i=a===-1?[]:e.footers.slice(a,Number.MAX_SAFE_INTEGER);return[n,i]}),o=a=>{if(r.allFooter.includes(a))switch(a){case"markdownTotal":return t.createVNode(Co,{modelValue:e.modelValue},null);case"scrollSwitch":return t.createVNode($o,{scrollAuto:e.scrollAuto,onScrollAutoChange:e.onScrollAutoChange},null)}else return e.defFooters instanceof Array?e.defFooters[a]||"":e.defFooters&&e.defFooters.children instanceof Array&&e.defFooters.children[a]||""};return()=>{const a=l.value[0].map(i=>o(i)),n=l.value[1].map(i=>o(i));return t.createVNode("div",{class:`${r.prefix}-footer`},[t.createVNode("div",{class:`${r.prefix}-footer-left`},[a]),t.createVNode("div",{class:`${r.prefix}-footer-right`},[n])])}}}),wo=t.defineComponent({name:"MdEditorV3",props:S.editorProps,emits:S.editorEmits,setup(e,l){const{editorId:o,noKatex:a,noMermaid:n,noPrettier:i,noUploadImg:u,noHighlight:d}=e,s=t.reactive({scrollAuto:e.scrollAuto});S.useOnSave(e,l),S.useProvide(e),S.useExpansion(e),S.useErrorCatcher(e,l);const[f,m]=S.useConfig(e,l),h=S.useCatalog(e);return t.onBeforeUnmount(()=>{b.bus.clear(o)}),S.useExpose(e,l,h,f,m),()=>{var p;const x=Je.getSlot({props:e,ctx:l},"defToolbars"),V=Je.getSlot({props:e,ctx:l},"defFooters");return t.createVNode("div",{id:o,class:[r.prefix,e.class,e.theme==="dark"&&`${r.prefix}-dark`,f.fullscreen||f.pageFullscreen?`${r.prefix}-fullscreen`:""],style:e.style},[t.createVNode(At,{noPrettier:i,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:f,updateSetting:m,tableShape:e.tableShape,defToolbars:x,noUploadImg:u,showToolbarName:e.showToolbarName},null),t.createVNode(ko,{modelValue:e.modelValue,setting:f,mdHeadingId:e.mdHeadingId,noMermaid:n,noPrettier:i,sanitize:e.sanitize,placeholder:e.placeholder,noKatex:a,scrollAuto:s.scrollAuto,formatCopiedText:e.formatCopiedText,autofocus:e.autoFocus,disabled:e.disabled,readonly:e.readOnly,maxlength:e.maxLength,autoDetectCode:e.autoDetectCode,noHighlight:d,onChange:g=>{e.onChange?e.onChange(g):(l.emit("update:modelValue",g),l.emit("onChange",g))},onHtmlChanged:g=>{e.onHtmlChanged?e.onHtmlChanged(g):l.emit("onHtmlChanged",g)},onGetCatalog:g=>{e.onGetCatalog?e.onGetCatalog(g):l.emit("onGetCatalog",g)},onBlur:g=>{e.onBlur?e.onBlur(g):l.emit("onBlur",g)},onFocus:g=>{e.onFocus?e.onFocus(g):l.emit("onFocus",g)},onInput:g=>{e.onInput?e.onInput(g):l.emit("onInput",g)},completions:e.completions,catalogVisible:h.value,theme:e.theme,noImgZoomIn:e.noImgZoomIn},null),((p=e.footers)==null?void 0:p.length)>0&&t.createVNode(To,{modelValue:e.modelValue,footers:e.footers,defFooters:V,scrollAuto:s.scrollAuto,onScrollAutoChange:g=>s.scrollAuto=g},null)])}}}),se=wo;se.install=e=>(e.component(se.name,se),e.use(pt).use(z.DropdownToolbar).use(vt).use(dt).use(S.MdPreview),e);module.exports=se;
|
|
67
|
+
!!!`,"title")}))]}};return vt.autocompletion({override:e?[l,dt.htmlCompletionSource,...e]:[l]})},so=co,W=e=>{const l=new R.Compartment;return a=>(l.get(e.state)?e.dispatch({effects:l.reconfigure(a)}):e.dispatch({effects:R.StateEffect.appendConfig.of(l.of(a))}),!0)};class uo{constructor(l){q(this,"view");q(this,"maxLength",Number.MAX_SAFE_INTEGER);q(this,"toggleTabSize");q(this,"togglePlaceholder");q(this,"setExtensions");q(this,"toggleDisabled");q(this,"toggleReadOnly");q(this,"toggleMaxlength");this.view=l,this.toggleTabSize=W(this.view),this.togglePlaceholder=W(this.view),this.setExtensions=W(this.view),this.toggleDisabled=W(this.view),this.toggleReadOnly=W(this.view),this.toggleMaxlength=W(this.view)}getValue(){return this.view.state.doc.toString()}setValue(l,o=0,a=this.view.state.doc.length){this.view.dispatch({changes:{from:o,to:a,insert:l}})}getSelectedText(){const{from:l,to:o}=this.view.state.selection.main;return this.view.state.sliceDoc(l,o)}replaceSelectedText(l,o={select:!0,deviationStart:0,deviationEnd:0,replaceAll:!1},a){try{if(o.replaceAll){if(this.setValue(l),l.length>this.maxLength)throw new Error("The input text is too long");return}if(this.view.state.doc.length-this.getSelectedText().length+l.length>this.maxLength)throw new Error("The input text is too long");const{from:n}=this.view.state.selection.main;if(this.view.dispatch(this.view.state.replaceSelection(l)),o.select){const i=n+l.length+o.deviationEnd;this.view.dispatch({selection:R.EditorSelection.create([R.EditorSelection.range(n+o.deviationStart,i),R.EditorSelection.cursor(i)],1)})}this.view.focus()}catch(n){if(n.message==="The input text is too long")s.bus.emit(a,s.ERROR_CATCHER,{name:"overlength",message:n.message,data:l});else throw n}}setTabSize(l){this.toggleTabSize([R.EditorState.tabSize.of(l),re.indentUnit.of(" ".repeat(l))])}setPlaceholder(l){this.togglePlaceholder(ae.placeholder(l))}focus(l){if(this.view.focus(),!l)return;let o=0,a=0,n=0;switch(l){case"start":break;case"end":{o=a=n=this.getValue().length;break}default:o=l.rangeAnchor||l.cursorPos,a=l.rangeHead||l.cursorPos,n=l.cursorPos}this.view.dispatch({scrollIntoView:!0,selection:R.EditorSelection.create([R.EditorSelection.range(o,a),R.EditorSelection.cursor(n)],1)})}setDisabled(l){this.toggleDisabled([ae.EditorView.editable.of(!l)])}setReadOnly(l){this.toggleReadOnly([R.EditorState.readOnly.of(l)])}setMaxLength(l){this.maxLength=l,this.toggleMaxlength([R.EditorState.changeFilter.of(o=>o.newDoc.length<=l)])}}const mo=e=>{const l=t.inject("editorId");return a=>{if(!a.clipboardData)return;if(a.clipboardData.files.length>0){const{files:i}=a.clipboardData;s.bus.emit(l,s.UPLOAD_IMAGE,Array.from(i).filter(g=>/image\/.*/.test(g.type))),a.preventDefault();return}if(e.autoDetectCode&&a.clipboardData.types.includes("vscode-editor-data")){const i=JSON.parse(a.clipboardData.getData("vscode-editor-data"));s.bus.emit(l,s.REPLACE,"code",{mode:i.mode,text:a.clipboardData.getData("text/plain")}),a.preventDefault();return}const n=a.clipboardData.getData("text/plain");e.maxlength&&n.length+e.modelValue.length>e.maxlength&&s.bus.emit(l,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:n})}},fo=mo,go=e=>{const l=t.inject("editorId");t.onMounted(()=>{s.bus.on(l,{name:s.TEXTAREA_FOCUS,callback(o){var a;(a=e.value)==null||a.focus(o)}})})},bo=go,ho=(e,l)=>{const o={key:"Ctrl-b",mac:"Cmd-b",run:()=>(s.bus.emit(e,s.REPLACE,"bold"),!0)},a={key:"Ctrl-s",mac:"Cmd-s",run:L=>(s.bus.emit(e,s.ON_SAVE,L.state.doc.toString()),!0),shift:()=>(s.bus.emit(e,s.REPLACE,"strikeThrough"),!0)},n={key:"Ctrl-u",mac:"Cmd-u",run:()=>(s.bus.emit(e,s.REPLACE,"underline"),!0),shift:()=>(s.bus.emit(e,s.REPLACE,"unorderedList"),!0)},i={key:"Ctrl-i",mac:"Cmd-i",run:()=>(s.bus.emit(e,s.REPLACE,"italic"),!0),shift:()=>(s.bus.emit(e,s.OPEN_MODALS,"image"),!0)},g={key:"Ctrl-1",mac:"Cmd-1",run:()=>(s.bus.emit(e,s.REPLACE,"h1"),!0)},d={key:"Ctrl-2",mac:"Cmd-2",run:()=>(s.bus.emit(e,s.REPLACE,"h2"),!0)},u={key:"Ctrl-3",mac:"Cmd-3",run:()=>(s.bus.emit(e,s.REPLACE,"h3"),!0)},f={key:"Ctrl-4",mac:"Cmd-4",run:()=>(s.bus.emit(e,s.REPLACE,"h4"),!0)},m={key:"Ctrl-5",mac:"Cmd-5",run:()=>(s.bus.emit(e,s.REPLACE,"h5"),!0)},v={key:"Ctrl-6",mac:"Cmd-6",run:()=>(s.bus.emit(e,s.REPLACE,"h6"),!0)},x={key:"Ctrl-ArrowUp",mac:"Cmd-ArrowUp",run:()=>(s.bus.emit(e,s.REPLACE,"sup"),!0)},V={key:"Ctrl-ArrowDown",mac:"Cmd-ArrowDown",run:()=>(s.bus.emit(e,s.REPLACE,"sub"),!0)},p={key:"Ctrl-o",mac:"Cmd-o",run:()=>(s.bus.emit(e,s.REPLACE,"orderedList"),!0)},b={key:"Ctrl-c",mac:"Cmd-c",shift:()=>(s.bus.emit(e,s.REPLACE,"code"),!0),any(L,E){return(E.ctrlKey||E.metaKey)&&E.altKey&&E.code==="KeyC"?(s.bus.emit(e,s.REPLACE,"codeRow"),!0):!1}},h={key:"Ctrl-l",mac:"Cmd-l",run:()=>(s.bus.emit(e,s.OPEN_MODALS,"link"),!0)},N={key:"Ctrl-f",mac:"Cmd-f",shift:()=>l.noPrettier?!1:(s.bus.emit(e,s.REPLACE,"prettier"),!0)},$={any:(L,E)=>(E.ctrlKey||E.metaKey)&&E.altKey&&E.shiftKey&&E.code==="KeyT"?(s.bus.emit(e,s.REPLACE,"table"),!0):!1},T={key:"Ctrl-d",mac:"Cmd-d",run:se.deleteLine,preventDefault:!0};return[o,T,a,n,i,g,d,u,f,m,v,x,V,p,b,h,N,$]},vo=ho,po=e=>{const l=t.inject("tabWidth"),o=t.inject("editorId"),a=t.inject("theme"),n=t.ref(),i=t.shallowRef(),g=vo(o,e),d=fo(e),u=[ae.keymap.of([...g,se.indentWithTab]),ee.minimalSetup,dt.html(),ht.markdown({codeLanguages:bt.languages}),ee.EditorView.lineWrapping,ee.EditorView.updateListener.of(m=>{m.docChanged&&e.onChange(m.state.doc.toString())}),ee.EditorView.domEventHandlers({paste:d,blur:e.onBlur,focus:e.onFocus,drop:e.onDrop,input:m=>{e.onInput&&e.onInput(m);const{data:v}=m;e.maxlength&&e.modelValue.length+v.length>e.maxlength&&s.bus.emit(o,s.ERROR_CATCHER,{name:"overlength",message:"The input text is too long",data:v})}})],f=()=>{const m=[...u,a.value==="light"?io:Zt,so(e.completions)];return r.configOption.codeMirrorExtensions(a.value,m,[...g])};return t.onMounted(()=>{const m=new ee.EditorView({doc:e.modelValue,parent:n.value}),v=new uo(m);i.value=v,setTimeout(()=>{v.setTabSize(l),v.setDisabled(e.disabled),v.setReadOnly(e.readonly),v.setExtensions(f()),e.placeholder&&v.setPlaceholder(e.placeholder),typeof e.maxlength=="number"&&v.setMaxLength(e.maxlength),e.autofocus&&m.focus()},0),s.bus.on(o,{name:s.CTRL_Z,callback(){se.undo(m)}}),s.bus.on(o,{name:s.CTRL_SHIFT_Z,callback(){se.redo(m)}}),s.bus.on(o,{name:s.REPLACE,callback(x,V={}){var h;const{text:p,options:b}=Ot(x,i.value,V);(h=i.value)==null||h.replaceSelectedText(p,b,o)}})}),t.watch([a,t.toRef(e,"completions")],()=>{var m;(m=i.value)==null||m.setExtensions(f())},{deep:!0}),t.watch(()=>e.modelValue,()=>{var m,v;((m=i.value)==null?void 0:m.getValue())!==e.modelValue&&((v=i.value)==null||v.setValue(e.modelValue))}),t.watch(()=>e.placeholder,()=>{var m;(m=i.value)==null||m.setPlaceholder(e.placeholder)}),t.watch(()=>e.disabled,()=>{var m;(m=i.value)==null||m.setDisabled(e.disabled)}),t.watch(()=>e.readonly,()=>{var m;(m=i.value)==null||m.setDisabled(e.readonly)}),t.watch(()=>e.maxlength,()=>{var m;e.maxlength&&((m=i.value)==null||m.setMaxLength(e.maxlength))}),bo(i),{inputWrapperRef:n,codeMirrorUt:i}},ko=po,Co=t.defineComponent({name:"MDEditorContent",props:P.contentProps,setup(e){const l=t.inject("editorId"),o=t.ref(""),{inputWrapperRef:a,codeMirrorUt:n}=ko(e);return Ht(e,o,n),()=>t.createVNode("div",{class:`${r.prefix}-content`},[t.createVNode("div",{class:`${r.prefix}-input-wrapper`,ref:a},null),t.createVNode(P.ContentPreview,{modelValue:e.modelValue,setting:e.setting,onHtmlChanged:i=>{o.value=i,e.onHtmlChanged(i)},onGetCatalog:e.onGetCatalog,mdHeadingId:e.mdHeadingId,noMermaid:e.noMermaid,sanitize:e.sanitize,noKatex:e.noKatex,formatCopiedText:e.formatCopiedText,noHighlight:e.noHighlight,noImgZoomIn:e.noImgZoomIn},null),e.catalogVisible&&t.createVNode(ut,{theme:e.theme,class:`${r.prefix}-catalog-editor`,editorId:l,mdHeadingId:e.mdHeadingId,key:"internal-catalog"},null)])}}),xo=t.defineComponent({props:{modelValue:{type:String,default:""}},setup(e){const l=t.inject("usedLanguageText");return()=>{var o,a;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`},[`${(o=l.value.footer)==null?void 0:o.markdownTotal}:`]),t.createVNode("span",null,[((a=e.modelValue)==null?void 0:a.length)||0])])}}}),No={checked:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}}},Vo=t.defineComponent({props:No,setup(e){return()=>t.createVNode("div",{class:[`${r.prefix}-checkbox`,e.checked&&`${r.prefix}-checkbox-checked`],onClick:()=>{e.onChange(!e.checked)}},null)}}),$o={scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}}},To=t.defineComponent({props:$o,setup(e){const l=t.inject("usedLanguageText");return()=>{var o;return t.createVNode("div",{class:`${r.prefix}-footer-item`},[t.createVNode("label",{class:`${r.prefix}-footer-label`,onClick:()=>{e.onScrollAutoChange(!e.scrollAuto)}},[(o=l.value.footer)==null?void 0:o.scrollAuto]),t.createVNode(Vo,{checked:e.scrollAuto,onChange:e.onScrollAutoChange},null)])}}}),yo={modelValue:{type:String,default:""},footers:{type:Array,default:[]},scrollAuto:{type:Boolean},onScrollAutoChange:{type:Function,default:()=>{}},defFooters:{type:Object}},wo=t.defineComponent({name:"MDEditorFooter",props:yo,setup(e){const l=t.computed(()=>{const a=e.footers.indexOf("="),n=a===-1?e.footers:e.footers.slice(0,a),i=a===-1?[]:e.footers.slice(a,Number.MAX_SAFE_INTEGER);return[n,i]}),o=a=>{if(r.allFooter.includes(a))switch(a){case"markdownTotal":return t.createVNode(xo,{modelValue:e.modelValue},null);case"scrollSwitch":return t.createVNode(To,{scrollAuto:e.scrollAuto,onScrollAutoChange:e.onScrollAutoChange},null)}else return e.defFooters instanceof Array?e.defFooters[a]||"":e.defFooters&&e.defFooters.children instanceof Array&&e.defFooters.children[a]||""};return()=>{const a=l.value[0].map(i=>o(i)),n=l.value[1].map(i=>o(i));return t.createVNode("div",{class:`${r.prefix}-footer`},[t.createVNode("div",{class:`${r.prefix}-footer-left`},[a]),t.createVNode("div",{class:`${r.prefix}-footer-right`},[n])])}}}),Eo=t.defineComponent({name:"MdEditorV3",props:P.editorProps,emits:P.editorEmits,setup(e,l){const{editorId:o,noKatex:a,noMermaid:n,noPrettier:i,noUploadImg:g,noHighlight:d}=e,u=t.reactive({scrollAuto:e.scrollAuto});P.useOnSave(e,l),P.useProvide(e),P.useExpansion(e),P.useErrorCatcher(e,l);const[f,m]=P.useConfig(e,l),v=P.useCatalog(e);return t.onBeforeUnmount(()=>{s.bus.clear(o)}),P.useExpose(e,l,v,f,m),()=>{var p;const x=Je.getSlot({props:e,ctx:l},"defToolbars"),V=Je.getSlot({props:e,ctx:l},"defFooters");return t.createVNode("div",{id:o,class:[r.prefix,e.class,e.theme==="dark"&&`${r.prefix}-dark`,f.fullscreen||f.pageFullscreen?`${r.prefix}-fullscreen`:""],style:e.style},[t.createVNode(Lt,{noPrettier:i,toolbars:e.toolbars,toolbarsExclude:e.toolbarsExclude,setting:f,updateSetting:m,tableShape:e.tableShape,defToolbars:x,noUploadImg:g,showToolbarName:e.showToolbarName},null),t.createVNode(Co,{modelValue:e.modelValue,setting:f,mdHeadingId:e.mdHeadingId,noMermaid:n,noPrettier:i,sanitize:e.sanitize,placeholder:e.placeholder,noKatex:a,scrollAuto:u.scrollAuto,formatCopiedText:e.formatCopiedText,autofocus:e.autoFocus,disabled:e.disabled,readonly:e.readOnly,maxlength:e.maxLength,autoDetectCode:e.autoDetectCode,noHighlight:d,onChange:b=>{e.onChange?e.onChange(b):(l.emit("update:modelValue",b),l.emit("onChange",b))},onHtmlChanged:b=>{e.onHtmlChanged?e.onHtmlChanged(b):l.emit("onHtmlChanged",b)},onGetCatalog:b=>{e.onGetCatalog?e.onGetCatalog(b):l.emit("onGetCatalog",b)},onBlur:b=>{e.onBlur?e.onBlur(b):l.emit("onBlur",b)},onFocus:b=>{e.onFocus?e.onFocus(b):l.emit("onFocus",b)},onInput:b=>{e.onInput?e.onInput(b):l.emit("onInput",b)},completions:e.completions,catalogVisible:v.value,theme:e.theme,noImgZoomIn:e.noImgZoomIn,onDrop:b=>{e.onDrop?e.onDrop(b):l.emit("onDrop",b)}},null),((p=e.footers)==null?void 0:p.length)>0&&t.createVNode(wo,{modelValue:e.modelValue,footers:e.footers,defFooters:V,scrollAuto:u.scrollAuto,onScrollAutoChange:b=>u.scrollAuto=b},null)])}}}),de=Eo;de.install=e=>(e.component(de.name,de),e.use(pt).use(z.DropdownToolbar).use(kt).use(ut).use(P.MdPreview),e);module.exports=de;
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";const c=require("vue"),d=require("./config.cjs"),
|
|
2
|
-
`:"")+e.getLines(i+1,a,e.tShift[i],!0)+(r&&r.trim()?r:""),
|
|
3
|
-
`},
|
|
4
|
-
`,
|
|
5
|
-
`+l(u,
|
|
1
|
+
"use strict";const c=require("vue"),d=require("./config.cjs"),p=require("./index4.cjs"),E=require("./dom.cjs"),O=require("medium-zoom"),P=require("@vavt/util"),B=require("copy-to-clipboard"),G=require("markdown-it"),j=require("markdown-it-image-figures"),D=require("markdown-it-task-lists"),U=require("lru-cache"),V=(e,i)=>{const l=c.inject("editorId"),{noImgZoomIn:t}=e,n=P.debounce(()=>{const r=document.querySelectorAll(`#${l}-preview img`);r.length!==0&&O(r,{background:"#00000073"})});c.onMounted(()=>{!t&&n()}),c.watch([i,c.toRef(e.setting,"preview")],()=>{!t&&n()})},q=V,z=(e,i)=>{if(typeof i[e]=="string")return i[e];const l=`<i class="${d.prefix}-iconfont ${d.prefix}-icon-${e}"></i>`;switch(d.configOption.iconfontType){case"svg":return`<svg class="${d.prefix}-icon" aria-hidden="true"><use xlink:href="#${d.prefix}-icon-${e}"></use></svg>`;default:return l}},K=(e,i)=>{const l=c.inject("editorId"),t=c.inject("usedLanguageText"),n=c.inject("customIcon"),r=()=>{document.querySelectorAll(`#${l}-preview pre`).forEach(m=>{var w,b;let u=-1;(w=m.querySelector(".copy-button"))==null||w.remove();const o=((b=t.value.copyCode)==null?void 0:b.text)||"复制代码",f=document.createElement("span");f.setAttribute("class","copy-button"),f.dataset.tips=o,f.innerHTML=z("copy",n.value),f.addEventListener("click",()=>{var y,k;clearTimeout(u);const h=m.querySelector("code").innerText,v=B(e.formatCopiedText(h)),g=((y=t.value.copyCode)==null?void 0:y.successTips)||"已复制!",C=((k=t.value.copyCode)==null?void 0:k.failTips)||"已复制!";f.dataset.tips=v?g:C,u=window.setTimeout(()=>{f.dataset.tips=o},1500)}),m.appendChild(f)})},a=()=>{c.nextTick(r)},s=m=>{m&&c.nextTick(r)};c.watch(()=>i.value,a),c.watch(()=>e.setting.preview,s),c.watch(()=>e.setting.htmlPreview,s),c.watch(()=>t.value,r),c.onMounted(r)},W=K,Z=e=>{var r;const i=(r=d.configOption.editorExtensions)==null?void 0:r.highlight,l=i==null?void 0:i.instance,t=c.inject("highlight"),n=c.shallowRef(l);return c.onMounted(()=>{if(!e.noHighlight&&!n.value){const a=document.createElement("script");a.src=t.value.js,a.onload=()=>{n.value=window.hljs},a.id=`${d.prefix}-hljs`,E.appendHandler(a,"hljs");const s=document.createElement("link");s.rel="stylesheet",s.href=t.value.css,s.id=`${d.prefix}-hlCss`,E.appendHandler(s)}}),c.watch(()=>t.value.css,a=>{E.updateHandler(`${d.prefix}-hlCss`,"href",a)}),n},J=Z,X=e=>{const i=c.inject("theme"),{editorExtensions:l}=d.configOption,t=l==null?void 0:l.mermaid,n=c.shallowRef(t==null?void 0:t.instance),r=c.shallowRef(-1),a=new U({max:1e3,ttl:6e5}),s=()=>{const u=n.value;!e.noMermaid&&u&&(u.initialize({startOnLoad:!1,theme:i.value==="dark"?"dark":"default"}),r.value=r.value+1)};return c.watch(()=>i.value,()=>{a.clear(),s()}),c.onMounted(()=>{if(!e.noMermaid&&!(t!=null&&t.instance)){const u=(t==null?void 0:t.js)||d.mermaidUrl;if(/\.mjs/.test(u))import(u).then(o=>{n.value=o.default,s()});else{const o=document.createElement("script");o.id=`${d.prefix}-mermaid`,o.src=u,o.onload=()=>{n.value=window.mermaid,s()},E.appendHandler(o,"mermaid")}}}),{mermaidRef:n,reRenderRef:r,replaceMermaid:()=>{c.nextTick(()=>{if(!e.noMermaid&&n.value){const u=document.querySelectorAll(`div.${d.prefix}-mermaid`),o=document.createElement("div");o.style.width=document.body.offsetWidth+"px",o.style.height=document.body.offsetHeight+"px",o.style.position="fixed",o.style.zIndex="-10000",o.style.top="-10000";let f=u.length;f>0&&document.body.appendChild(o),u.forEach(async w=>{let b=a.get(w.innerText);if(!b){const v=p.uuid(),g=n.value.renderAsync||n.value.render;let C="";try{C=await g(v,w.innerText,o)}catch{}b=typeof C=="string"?C:C.svg,a.set(w.innerText,b)}const h=document.createElement("p");h.className=`${d.prefix}-mermaid`,h.setAttribute("data-processed",""),h.innerHTML=b,w.dataset.line!==void 0&&(h.dataset.line=w.dataset.line),w.replaceWith(h),--f===0&&o.remove()})}})}}},Q=X,Y=e=>{var n;const i=(n=d.configOption.editorExtensions)==null?void 0:n.katex,l=i==null?void 0:i.instance,t=c.shallowRef(l);return c.onMounted(()=>{if(!e.noKatex&&!t.value){const r=document.createElement("script");r.src=(i==null?void 0:i.js)||d.katexUrl.js,r.onload=()=>{t.value=window.katex},r.id=`${d.prefix}-katex`;const a=document.createElement("link");a.rel="stylesheet",a.href=(i==null?void 0:i.css)||d.katexUrl.css,a.id=`${d.prefix}-katexCss`,E.appendHandler(r,"katex"),E.appendHandler(a)}}),t},ee=Y,te=(e,i)=>{const l=e.renderer.rules.fence.bind(e.renderer.rules);e.renderer.rules.fence=(t,n,r,a,s)=>{const m=t[n],u=m.content.trim();if(m.info==="mermaid"){let o;return t[n].map&&t[n].level===0&&(o=t[n].map[0],t[n].attrSet("data-line",String(o))),`<div class="${d.prefix}-mermaid" ${o!==void 0?"data-line="+o:""} data-mermaid-theme=${i.themeRef.value}>${u}</div>`}return l(t,n,r,a,s)}},ne=te,H=(e,i)=>{let l=!0,t=!0;const n=e.posMax,r=i>0?e.src.charCodeAt(i-1):-1,a=i+1<=n?e.src.charCodeAt(i+1):-1;return(r===32||r===9||a>=48&&a<=57)&&(t=!1),(a===32||a===9)&&(l=!1),{can_open:l,can_close:t}},oe=(e,i)=>{let l,t,n,r;if(e.src[e.pos]!=="$")return!1;if(n=H(e,e.pos),!n.can_open)return i||(e.pending+="$"),e.pos+=1,!0;const a=e.pos+1;for(l=a;(l=e.src.indexOf("$",l))!==-1;){for(r=l-1;e.src[r]==="\\";)r-=1;if((l-r)%2==1)break;l+=1}return l===-1?(i||(e.pending+="$"),e.pos=a,!0):l-a===0?(i||(e.pending+="$$"),e.pos=a+1,!0):(n=H(e,l),n.can_close?(i||(t=e.push("math_inline","math",0),t.markup="$",t.content=e.src.slice(a,l)),e.pos=l+1,!0):(i||(e.pending+="$"),e.pos=a,!0))},re=(e,i,l,t)=>{let n,r,a,s,m=!1,u=e.bMarks[i]+e.tShift[i],o=e.eMarks[i];if(u+2>o||e.src.slice(u,u+2)!=="$$")return!1;if(u+=2,n=e.src.slice(u,o),t)return!0;for(n.trim().slice(-2)==="$$"&&(n=n.trim().slice(0,-2),m=!0),a=i;!m&&(a++,!(a>=l||(u=e.bMarks[a]+e.tShift[a],o=e.eMarks[a],u<o&&e.tShift[a]<e.blkIndent)));)e.src.slice(u,o).trim().slice(-2)==="$$"&&(s=e.src.slice(0,o).lastIndexOf("$$"),r=e.src.slice(u,s),m=!0);e.line=a+1;const f=e.push("math_block","math",0);return f.block=!0,f.content=(n&&n.trim()?n+`
|
|
2
|
+
`:"")+e.getLines(i+1,a,e.tShift[i],!0)+(r&&r.trim()?r:""),f.map=[i,e.line],f.markup="$$",!0},ie=(e,i)=>{const l=n=>{if(i.katexRef.value){const r=i.katexRef.value.renderToString(n,{throwOnError:!1});return`<span class="${d.prefix}-katex-inline" data-processed>${r}</span>`}else return`<span class="${d.prefix}-katex-inline">${n}</span>`},t=(n,r)=>{if(i.katexRef.value){const a=i.katexRef.value.renderToString(n,{throwOnError:!1,displayMode:!0});return`<p class="${d.prefix}-katex-block" data-line=${r} data-processed>${a}</p>`}else return`<p class="${d.prefix}-katex-block" data-line=${r}>${n}</p>`};e.inline.ruler.after("escape","math_inline",oe),e.block.ruler.after("blockquote","math_block",re,{alt:["paragraph","reference","blockquote","list"]}),e.renderer.rules.math_inline=(n,r)=>l(n[r].content),e.renderer.rules.math_block=(n,r)=>t(n[r].content,n[r].map[0])+`
|
|
3
|
+
`},le=ie,ae=(e,i)=>{i=i||{};const l=3,t=i.marker||"!",n=t.charCodeAt(0),r=t.length;let a="",s="";const m=(o,f,w,b,h)=>{const v=o[f];return v.type==="admonition_open"?(o[f].attrPush(["class",`${d.prefix}-admonition ${d.prefix}-admonition-${v.info}`]),o[f].attrSet("data-line",String(o[f].map[0]))):v.type==="admonition_title_open"&&o[f].attrPush(["class",`${d.prefix}-admonition-title`]),h.renderToken(o,f,w)},u=o=>{const f=o.trim().split(" ",2);s="",a=f[0],f.length>1&&(s=o.substring(a.length+2)),(s===""||!s)&&(s=a)};e.block.ruler.before("code","admonition",(o,f,w,b)=>{let h,v,g,C=!1,y=o.bMarks[f]+o.tShift[f],k=o.eMarks[f];if(n!==o.src.charCodeAt(y))return!1;for(h=y+1;h<=k&&t[(h-y)%r]===o.src[h];h++);const $=Math.floor((h-y)/r);if($!==l)return!1;h-=(h-y)%r;const I=o.src.slice(y,h),x=o.src.slice(h,k);if(u(x),b)return!0;for(v=f;v++,!(v>=w||(y=o.bMarks[v]+o.tShift[v],k=o.eMarks[v],y<k&&o.sCount[v]<o.blkIndent));)if(n===o.src.charCodeAt(y)&&!(o.sCount[v]-o.blkIndent>=4)){for(h=y+1;h<=k&&t[(h-y)%r]===o.src[h];h++);if(!(Math.floor((h-y)/r)<$)&&(h-=(h-y)%r,h=o.skipSpaces(h),!(h<k))){C=!0;break}}const _=o.parentType,N=o.lineMax;return o.parentType="root",o.lineMax=v,g=o.push("admonition_open","div",1),g.markup=I,g.block=!0,g.info=a,g.map=[f,v],g=o.push("admonition_title_open","p",1),g.markup=I+" "+a,g.map=[f,v],g=o.push("inline","",0),g.content=s,g.map=[f,o.line-1],g.children=[],g=o.push("admonition_title_close","p",-1),g.markup=I+" "+a,o.md.block.tokenize(o,f+1,v),g=o.push("admonition_close","div",-1),g.markup=o.src.slice(y,h),g.block=!0,o.parentType=_,o.lineMax=N,o.line=v+(C?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},ce=ae,se=(e,i)=>{e.renderer.rules.heading_open=(l,t)=>{const n=l[t],r=l[t+1].content,a=n.markup.length;return i.headsRef.value.push({text:r,level:a}),n.map&&n.level===0&&(n.attrSet("data-line",String(n.map[0])),n.attrSet("id",i.mdHeadingId(r,a,i.headsRef.value.length))),e.renderer.renderToken(l,t,i)},e.renderer.rules.heading_close=(l,t,n,r,a)=>a.renderToken(l,t,n)},ue=se,de=(e,i)=>{const l=e.renderer.rules.fence,t=e.utils.unescapeAll,n=/\[(\w*)(?::([\w ]*))?\]/;function r(u){return u.info?t(u.info).trim():""}function a(u){const o=r(u),[f=null,w=""]=(n.exec(o)||[]).slice(1);return[f,w]}function s(u){const o=r(u);return o?o.split(/(\s+)/g)[0]:""}const m=(u,o,f,w,b)=>{if(u[o].hidden)return"";const[h,v]=a(u[o]);if(h===null)return l(u,o,f,w,b);let g,C,y,k,$="",I="";for(let x=o;x<u.length&&(g=u[x],[C,y]=a(g),C===h);x++)g.info=g.info.replace(n,""),g.hidden=!0,k=x-o>0?"":" checked",$+=`<li><input type="radio" name="label-group-${i.editorId}-${o}"${k}><label for="group-${i.editorId}-${o}-tab-${x-o}" onclick="this.previousElementSibling.click()">${y||s(g)}</label></li>
|
|
4
|
+
`,I+=`<input type="radio" id="group-${i.editorId}-${o}-tab-${x-o}" name="group-${i.editorId}-${o}"${k}>
|
|
5
|
+
`+l(u,x,f,w,b);return`<div class="code-tabs">
|
|
6
6
|
<ul>
|
|
7
7
|
`+$+`</ul>
|
|
8
|
-
`+x+"</div>"};e.renderer.rules.fence=p},ke=we,Ce=e=>{["paragraph_open","table_open","ordered_list_open","bullet_list_open","blockquote_open","hr","html_block","fence"].forEach(i=>{const l=e.renderer.rules[i];l?e.renderer.rules[i]=(t,n,r,a,s)=>{let p;const u=l(t,n,r,a,s);return t[n].map&&t[n].level===0?(p=t[n].map[0],u.replace(/^(<[^>]*)/,`$1 data-line="${p}"`)):u}:e.renderer.rules[i]=(t,n,r,a,s)=>{let p;return t[n].map&&t[n].level===0&&(p=t[n].map[0],t[n].attrSet("data-line",String(p))),s.renderToken(t,n,r)}})},$e=(e,i)=>{const{editorConfig:l,markdownItConfig:t,markdownItPlugins:n}=d.configOption,r=c.inject("editorId"),a=c.inject("showCodeRowNumber"),s=c.inject("theme"),p=c.ref([]),u=ie(e),o=se(e),{reRenderRef:m,replaceMermaid:w}=ae(e),b=W({html:!0,breaks:!0});t(b);const f=[{type:"katex",plugin:he,options:{katexRef:o}},{type:"image",plugin:J,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:ve,options:{}},{type:"taskList",plugin:X,options:{}},{type:"heading",plugin:be,options:{mdHeadingId:e.mdHeadingId,headsRef:p}},{type:"codeTabs",plugin:ke,options:{editorId:r}}];e.noMermaid||f.push({type:"mermaid",plugin:de,options:{themeRef:s}}),n(f).forEach(k=>{b.use(k.plugin,k.options)}),b.set({highlight:(k,$)=>{let x;!e.noHighlight&&u.value?u.value.getLanguage($)?x=u.value.highlight(k,{language:$,ignoreIllegals:!0}).value:x=u.value.highlightAuto(k).value:x=b.utils.escapeHtml(k);const S=a?v.generateCodeRowNumber(x.trim()):`<span class="code-block">${x.trim()}</span>`;return`<pre><code class="language-${$}" language=${$}>${S}</code></pre>`}}),Ce(b);const g=c.ref(e.sanitize(b.render(e.modelValue))),h=()=>{v.bus.emit(r,"buildFinished",g.value),e.onHtmlChanged(g.value),e.onGetCatalog(p.value),v.bus.emit(r,"catalogChanged",p.value),w()};c.onMounted(h);const C=L.debounce(async()=>{p.value=[],g.value=e.sanitize(b.render(e.modelValue)),h()},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:i?0:500),y=c.computed(()=>(e.noKatex||o.value)&&(e.noHighlight||u.value));return c.watch([c.toRef(e,"modelValue"),y,m],C),c.onMounted(()=>{v.bus.on(r,{name:"pushCatalog",callback(){v.bus.emit(r,"catalogChanged",p.value)}})}),{html:g}},xe=$e,j={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},noImgZoomIn:{type:Boolean}},Ie={...j,onChange:{type:Function,default:()=>{}},placeholder:{type:String,default:""},scrollAuto:{type:Boolean},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},completions:{type:Array},catalogVisible:{type:Boolean},theme:{type:String,default:"light"},onInput:{type:Function}},V=c.defineComponent({name:"ContentPreview",props:j,setup(e){const i=c.inject("editorId"),l=c.inject("previewTheme"),t=c.inject("showCodeRowNumber"),{html:n}=xe(e,e.previewOnly);return oe(e,n),ee(e,n),()=>c.createVNode(c.Fragment,null,[c.createVNode("div",{id:`${i}-preview-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.preview,key:"content-preview-wrapper"},[c.createVNode("article",{id:`${i}-preview`,class:[`${d.prefix}-preview`,`${l==null?void 0:l.value}-theme`,t&&`${d.prefix}-scrn`],innerHTML:n.value},null)]),!e.previewOnly&&c.createVNode("div",{id:`${i}-html-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.htmlPreview,key:"html-preview-wrapper"},[c.createVNode("div",{class:`${d.prefix}-html`},[n.value])])])}}),Se=(e,i)=>{const{editorId:l}=e,t=c.reactive({buildFinished:!1,html:""});c.watch(()=>e.modelValue,()=>{t.buildFinished=!1}),c.onMounted(()=>{v.bus.on(l,{name:"buildFinished",callback(n){t.buildFinished=!0,t.html=n}}),v.bus.on(l,{name:P,callback(){const n=new Promise(r=>{if(t.buildFinished)r(t.html);else{const a=s=>{r(s),v.bus.remove(l,"buildFinished",a)};v.bus.on(l,{name:"buildFinished",callback:a})}});e.onSave?e.onSave(e.modelValue,n):i.emit("onSave",e.modelValue,n)}})})},U=e=>{var n,r;const{editorId:i}=e,l=(r=(n=d.configOption)==null?void 0:n.editorExtensions)==null?void 0:r.highlight;c.provide("editorId",i),c.provide("theme",c.computed(()=>e.theme)),c.provide("highlight",c.computed(()=>{const a={...d.codeCss,...l==null?void 0:l.css},s=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(l==null?void 0:l.js)||d.highlightUrl,css:a[e.codeTheme]?a[e.codeTheme][s]:d.codeCss.atom[s]}})),c.provide("showCodeRowNumber",e.showCodeRowNumber);const t=c.computed(()=>{var s,p;const a={...d.staticTextDefault,...(p=(s=d.configOption)==null?void 0:s.editorConfig)==null?void 0:p.languageUserDefined};return a[e.language]?a[e.language]:d.staticTextDefault["zh-CN"]});c.provide("usedLanguageText",t),c.provide("previewTheme",c.computed(()=>e.previewTheme)),c.provide("customIcon",c.computed(()=>e.customIcon))},Ee=e=>{U(e),c.provide("tabWidth",e.tabWidth)},G=e=>{c.onMounted(()=>{var i,l;if(!e.noIconfont)if(d.configOption.iconfontType==="svg"){const t=document.createElement("script");t.src=((i=d.configOption.editorExtensions)==null?void 0:i.iconfont)||d.iconfontSvgUrl,t.id=`${d.prefix}-icon`,I.appendHandler(t)}else{const t=document.createElement("link");t.rel="stylesheet",t.href=((l=d.configOption.editorExtensions)==null?void 0:l.iconfontClass)||d.iconfontClassUrl,t.id=`${d.prefix}-icon-class`,I.appendHandler(t)}})},Pe=e=>{var s,p,u,o,m,w;const{noPrettier:i,noUploadImg:l}=e,{editorExtensions:t}=d.configOption,n=i||!!((p=(s=d.configOption.editorExtensions)==null?void 0:s.prettier)!=null&&p.prettierInstance),r=i||!!((o=(u=d.configOption.editorExtensions)==null?void 0:u.prettier)!=null&&o.parserMarkdownInstance),a=l||!!((w=(m=d.configOption.editorExtensions)==null?void 0:m.cropper)!=null&&w.instance);c.onMounted(()=>{var C,y,k,$;const b=document.createElement("script"),f=document.createElement("script");b.src=((C=t==null?void 0:t.prettier)==null?void 0:C.standaloneJs)||d.prettierUrl.main,b.id=`${d.prefix}-prettier`,f.src=((y=t==null?void 0:t.prettier)==null?void 0:y.parserMarkdownJs)||d.prettierUrl.markdown,f.id=`${d.prefix}-prettierMD`;const g=document.createElement("link");g.rel="stylesheet",g.href=((k=t==null?void 0:t.cropper)==null?void 0:k.css)||d.cropperUrl.css,g.id=`${d.prefix}-cropperCss`;const h=document.createElement("script");h.src=(($=t==null?void 0:t.cropper)==null?void 0:$.js)||d.cropperUrl.js,h.id=`${d.prefix}-cropper`,a||(I.appendHandler(g),I.appendHandler(h)),n||I.appendHandler(b),r||I.appendHandler(f)}),G(e)},Te=(e,i)=>{const{editorId:l}=e;c.onMounted(()=>{v.bus.on(l,{name:"errorCatcher",callback:t=>{e.onError instanceof Function?e.onError(t):i.emit("onError",t)}})})},He=(e,i)=>{const{editorId:l}=e,t=c.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),n=(s,p)=>{t[s]=p===void 0?!t[s]:p,s==="preview"&&t.preview?t.htmlPreview=!1:s==="htmlPreview"&&t.htmlPreview&&(t.preview=!1)};let r="";const a=()=>{t.pageFullscreen||t.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=r};return c.watch(()=>[t.pageFullscreen,t.fullscreen],a),c.onMounted(()=>{v.bus.on(l,{name:"uploadImage",callback(s,p){const u=o=>{v.bus.emit(l,"replace","image",{desc:"",urls:o}),p&&p()};e.onUploadImg?e.onUploadImg(s,u):i.emit("onUploadImg",s,u)}}),r=document.body.style.overflow,a()}),[t,n]},_e=e=>{const{editorId:i}=e,l=c.ref(!1);return c.onMounted(()=>{v.bus.on(i,{name:T,callback:n=>{n===void 0?l.value=!l.value:l.value=n}})}),c.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog")&&l.value)},Me=(e,i,l,t,n)=>{const{editorId:r}=e;c.watch(()=>t.pageFullscreen,s=>{v.bus.emit(r,_,s)}),c.watch(()=>t.fullscreen,s=>{v.bus.emit(r,M,s)}),c.watch(()=>t.preview,s=>{v.bus.emit(r,F,s)}),c.watch(()=>t.htmlPreview,s=>{v.bus.emit(r,R,s)}),c.watch(l,s=>{v.bus.emit(r,A,s)});const a={on(s,p){switch(s){case"pageFullscreen":{v.bus.on(r,{name:_,callback(u){p(u)}});break}case"fullscreen":{v.bus.on(r,{name:M,callback(u){p(u)}});break}case"preview":{v.bus.on(r,{name:F,callback(u){p(u)}});break}case"htmlPreview":{v.bus.on(r,{name:R,callback(u){p(u)}});break}case"catalog":{v.bus.on(r,{name:A,callback(u){p(u)}});break}}},togglePageFullscreen(s){n("pageFullscreen",s)},toggleFullscreen(s){v.bus.emit(r,N,s)},togglePreview(s){n("preview",s)},toggleHtmlPreview(s){n("htmlPreview",s)},toggleCatalog(s){v.bus.emit(r,T,s)},triggerSave(){v.bus.emit(r,P)},insert(s){v.bus.emit(r,"replace","universal",{generate:s})},focus(s){v.bus.emit(r,B,s)}};i.expose(a)},Fe=e=>e,q={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:Fe},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},noImgZoomIn:{type:Boolean,default:!1},customIcon:{type:Object,default:{}}},Re={...q,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},completions:{type:Array},showToolbarName:{type:Boolean,default:!1},onInput:{type:Function}},D=["onHtmlChanged","onGetCatalog"],Ae=[...D,"onChange","onSave","onUploadImg","onError","update:modelValue","onBlur","onFocus","onInput"],Oe=c.defineComponent({name:"MdPreview",props:q,emits:D,setup(e,i){const{editorId:l,noKatex:t,noMermaid:n,noHighlight:r}=e;return U(e),G(e),c.onBeforeUnmount(()=>{v.bus.clear(l)}),()=>c.createVNode("div",{id:l,class:[d.prefix,e.class,e.theme==="dark"&&`${d.prefix}-dark`,`${d.prefix}-previewOnly`],style:e.style},[c.createVNode(V,{modelValue:e.modelValue,onHtmlChanged:a=>{e.onHtmlChanged?e.onHtmlChanged(a):i.emit("onHtmlChanged",a)},onGetCatalog:a=>{e.onGetCatalog?e.onGetCatalog(a):i.emit("onGetCatalog",a)},mdHeadingId:e.mdHeadingId,noMermaid:n,sanitize:e.sanitize,noKatex:t,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0},null)])}}),E=Oe;E.install=e=>(e.component(E.name,E),e);exports.CHANGE_CATALOG_VISIBLE=T;exports.CHANGE_FULL_SCREEN=N;exports.ContentPreview=V;exports.MdPreview=E;exports.ON_SAVE=P;exports.TEXTAREA_FOCUS=B;exports.contentProps=Ie;exports.editorEmits=Ae;exports.editorProps=Re;exports.useCatalog=_e;exports.useConfig=He;exports.useErrorCatcher=Te;exports.useExpansion=Pe;exports.useExpose=Me;exports.useOnSave=Se;exports.useProvide=Ee;
|
|
8
|
+
`+I+"</div>"};e.renderer.rules.fence=m},pe=de,me=e=>{["paragraph_open","table_open","ordered_list_open","bullet_list_open","blockquote_open","hr","html_block","fence"].forEach(i=>{const l=e.renderer.rules[i];l?e.renderer.rules[i]=(t,n,r,a,s)=>{let m;const u=l(t,n,r,a,s);return t[n].map&&t[n].level===0?(m=t[n].map[0],u.replace(/^(<[^>]*)/,`$1 data-line="${m}"`)):u}:e.renderer.rules[i]=(t,n,r,a,s)=>{let m;return t[n].map&&t[n].level===0&&(m=t[n].map[0],t[n].attrSet("data-line",String(m))),s.renderToken(t,n,r)}})},fe=(e,i)=>{const{editorConfig:l,markdownItConfig:t,markdownItPlugins:n}=d.configOption,r=c.inject("editorId"),a=c.inject("showCodeRowNumber"),s=c.inject("theme"),m=c.ref([]),u=J(e),o=ee(e),{reRenderRef:f,replaceMermaid:w}=Q(e),b=G({html:!0,breaks:!0});t(b);const h=[{type:"katex",plugin:le,options:{katexRef:o}},{type:"image",plugin:j,options:{figcaption:!0,classes:"md-zoom"}},{type:"admonition",plugin:ce,options:{}},{type:"taskList",plugin:D,options:{}},{type:"heading",plugin:ue,options:{mdHeadingId:e.mdHeadingId,headsRef:m}},{type:"codeTabs",plugin:pe,options:{editorId:r}}];e.noMermaid||h.push({type:"mermaid",plugin:ne,options:{themeRef:s}}),n(h).forEach(k=>{b.use(k.plugin,k.options)}),b.set({highlight:(k,$)=>{let I;!e.noHighlight&&u.value?u.value.getLanguage($)?I=u.value.highlight(k,{language:$,ignoreIllegals:!0}).value:I=u.value.highlightAuto(k).value:I=b.utils.escapeHtml(k);const x=a?p.generateCodeRowNumber(I.trim()):`<span class="code-block">${I.trim()}</span>`;return`<pre><code class="language-${$}" language=${$}>${x}</code></pre>`}}),me(b);const v=c.ref(e.sanitize(b.render(e.modelValue))),g=()=>{p.bus.emit(r,p.BUILD_FINISHED,v.value),e.onHtmlChanged(v.value),e.onGetCatalog(m.value),p.bus.emit(r,p.CATALOG_CHANGED,m.value),w()};c.onMounted(g);const C=P.debounce(async()=>{m.value=[],v.value=e.sanitize(b.render(e.modelValue)),g()},(l==null?void 0:l.renderDelay)!==void 0?l==null?void 0:l.renderDelay:i?0:500),y=c.computed(()=>(e.noKatex||o.value)&&(e.noHighlight||u.value));return c.watch([c.toRef(e,"modelValue"),y,f],C),c.onMounted(()=>{p.bus.on(r,{name:p.PUSH_CATALOG,callback(){p.bus.emit(r,p.CATALOG_CHANGED,m.value)}})}),{html:v}},he=fe,T={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},noImgZoomIn:{type:Boolean}},ge={...T,onChange:{type:Function,default:()=>{}},placeholder:{type:String,default:""},scrollAuto:{type:Boolean},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},completions:{type:Array},catalogVisible:{type:Boolean},theme:{type:String,default:"light"},onInput:{type:Function},onDrop:{type:Function,default:()=>{}}},A=c.defineComponent({name:"ContentPreview",props:T,setup(e){const i=c.inject("editorId"),l=c.inject("previewTheme"),t=c.inject("showCodeRowNumber"),{html:n}=he(e,e.previewOnly);return W(e,n),q(e,n),()=>c.createVNode(c.Fragment,null,[c.createVNode("div",{id:`${i}-preview-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.preview,key:"content-preview-wrapper"},[c.createVNode("article",{id:`${i}-preview`,class:[`${d.prefix}-preview`,`${l==null?void 0:l.value}-theme`,t&&`${d.prefix}-scrn`],innerHTML:n.value},null)]),!e.previewOnly&&c.createVNode("div",{id:`${i}-html-wrapper`,class:`${d.prefix}-preview-wrapper`,"data-show":e.setting.htmlPreview,key:"html-preview-wrapper"},[c.createVNode("div",{class:`${d.prefix}-html`},[n.value])])])}}),ve=(e,i)=>{const{editorId:l}=e,t=c.reactive({buildFinished:!1,html:""});c.watch(()=>e.modelValue,()=>{t.buildFinished=!1}),c.onMounted(()=>{p.bus.on(l,{name:p.BUILD_FINISHED,callback(n){t.buildFinished=!0,t.html=n}}),p.bus.on(l,{name:p.ON_SAVE,callback(){const n=new Promise(r=>{if(t.buildFinished)r(t.html);else{const a=s=>{r(s),p.bus.remove(l,p.BUILD_FINISHED,a)};p.bus.on(l,{name:p.BUILD_FINISHED,callback:a})}});e.onSave?e.onSave(e.modelValue,n):i.emit("onSave",e.modelValue,n)}})})},M=e=>{var n,r;const{editorId:i}=e,l=(r=(n=d.configOption)==null?void 0:n.editorExtensions)==null?void 0:r.highlight;c.provide("editorId",i),c.provide("theme",c.computed(()=>e.theme)),c.provide("highlight",c.computed(()=>{const a={...d.codeCss,...l==null?void 0:l.css},s=e.codeStyleReverse&&e.codeStyleReverseList.includes(e.previewTheme)?"dark":e.theme;return{js:(l==null?void 0:l.js)||d.highlightUrl,css:a[e.codeTheme]?a[e.codeTheme][s]:d.codeCss.atom[s]}})),c.provide("showCodeRowNumber",e.showCodeRowNumber);const t=c.computed(()=>{var s,m;const a={...d.staticTextDefault,...(m=(s=d.configOption)==null?void 0:s.editorConfig)==null?void 0:m.languageUserDefined};return a[e.language]?a[e.language]:d.staticTextDefault["zh-CN"]});c.provide("usedLanguageText",t),c.provide("previewTheme",c.computed(()=>e.previewTheme)),c.provide("customIcon",c.computed(()=>e.customIcon))},ye=e=>{M(e),c.provide("tabWidth",e.tabWidth)},F=e=>{c.onMounted(()=>{var i,l;if(!e.noIconfont)if(d.configOption.iconfontType==="svg"){const t=document.createElement("script");t.src=((i=d.configOption.editorExtensions)==null?void 0:i.iconfont)||d.iconfontSvgUrl,t.id=`${d.prefix}-icon`,E.appendHandler(t)}else{const t=document.createElement("link");t.rel="stylesheet",t.href=((l=d.configOption.editorExtensions)==null?void 0:l.iconfontClass)||d.iconfontClassUrl,t.id=`${d.prefix}-icon-class`,E.appendHandler(t)}})},be=e=>{var s,m,u,o,f,w;const{noPrettier:i,noUploadImg:l}=e,{editorExtensions:t}=d.configOption,n=i||!!((m=(s=d.configOption.editorExtensions)==null?void 0:s.prettier)!=null&&m.prettierInstance),r=i||!!((o=(u=d.configOption.editorExtensions)==null?void 0:u.prettier)!=null&&o.parserMarkdownInstance),a=l||!!((w=(f=d.configOption.editorExtensions)==null?void 0:f.cropper)!=null&&w.instance);c.onMounted(()=>{var C,y,k,$;const b=document.createElement("script"),h=document.createElement("script");b.src=((C=t==null?void 0:t.prettier)==null?void 0:C.standaloneJs)||d.prettierUrl.main,b.id=`${d.prefix}-prettier`,h.src=((y=t==null?void 0:t.prettier)==null?void 0:y.parserMarkdownJs)||d.prettierUrl.markdown,h.id=`${d.prefix}-prettierMD`;const v=document.createElement("link");v.rel="stylesheet",v.href=((k=t==null?void 0:t.cropper)==null?void 0:k.css)||d.cropperUrl.css,v.id=`${d.prefix}-cropperCss`;const g=document.createElement("script");g.src=(($=t==null?void 0:t.cropper)==null?void 0:$.js)||d.cropperUrl.js,g.id=`${d.prefix}-cropper`,a||(E.appendHandler(v),E.appendHandler(g)),n||E.appendHandler(b),r||E.appendHandler(h)}),F(e)},we=(e,i)=>{const{editorId:l}=e;c.onMounted(()=>{p.bus.on(l,{name:p.ERROR_CATCHER,callback:t=>{e.onError instanceof Function?e.onError(t):i.emit("onError",t)}})})},ke=(e,i)=>{const{editorId:l}=e,t=c.reactive({pageFullscreen:e.pageFullscreen,fullscreen:!1,preview:e.preview,htmlPreview:e.preview?!1:e.htmlPreview}),n=(s,m)=>{t[s]=m===void 0?!t[s]:m,s==="preview"&&t.preview?t.htmlPreview=!1:s==="htmlPreview"&&t.htmlPreview&&(t.preview=!1)};let r="";const a=()=>{t.pageFullscreen||t.fullscreen?document.body.style.overflow="hidden":document.body.style.overflow=r};return c.watch(()=>[t.pageFullscreen,t.fullscreen],a),c.onMounted(()=>{p.bus.on(l,{name:p.UPLOAD_IMAGE,callback(s,m){const u=o=>{p.bus.emit(l,p.REPLACE,"image",{desc:"",urls:o}),m&&m()};e.onUploadImg?e.onUploadImg(s,u):i.emit("onUploadImg",s,u)}}),r=document.body.style.overflow,a()}),[t,n]},Ce=e=>{const{editorId:i}=e,l=c.ref(!1);return c.onMounted(()=>{p.bus.on(i,{name:p.CHANGE_CATALOG_VISIBLE,callback:n=>{n===void 0?l.value=!l.value:l.value=n}})}),c.computed(()=>!e.toolbarsExclude.includes("catalog")&&e.toolbars.includes("catalog")&&l.value)},$e=(e,i,l,t,n)=>{const{editorId:r}=e;c.watch(()=>t.pageFullscreen,s=>{p.bus.emit(r,p.PAGE_FULL_SCREEN_CHANGED,s)}),c.watch(()=>t.fullscreen,s=>{p.bus.emit(r,p.FULL_SCREEN_CHANGED,s)}),c.watch(()=>t.preview,s=>{p.bus.emit(r,p.PREVIEW_CHANGED,s)}),c.watch(()=>t.htmlPreview,s=>{p.bus.emit(r,p.HTML_PREVIEW_CHANGED,s)}),c.watch(l,s=>{p.bus.emit(r,p.CATALOG_VISIBLE_CHANGED,s)});const a={on(s,m){switch(s){case"pageFullscreen":{p.bus.on(r,{name:p.PAGE_FULL_SCREEN_CHANGED,callback(u){m(u)}});break}case"fullscreen":{p.bus.on(r,{name:p.FULL_SCREEN_CHANGED,callback(u){m(u)}});break}case"preview":{p.bus.on(r,{name:p.PREVIEW_CHANGED,callback(u){m(u)}});break}case"htmlPreview":{p.bus.on(r,{name:p.HTML_PREVIEW_CHANGED,callback(u){m(u)}});break}case"catalog":{p.bus.on(r,{name:p.CATALOG_VISIBLE_CHANGED,callback(u){m(u)}});break}}},togglePageFullscreen(s){n("pageFullscreen",s)},toggleFullscreen(s){p.bus.emit(r,p.CHANGE_FULL_SCREEN,s)},togglePreview(s){n("preview",s)},toggleHtmlPreview(s){n("htmlPreview",s)},toggleCatalog(s){p.bus.emit(r,p.CHANGE_CATALOG_VISIBLE,s)},triggerSave(){p.bus.emit(r,p.ON_SAVE)},insert(s){p.bus.emit(r,p.REPLACE,"universal",{generate:s})},focus(s){p.bus.emit(r,p.TEXTAREA_FOCUS,s)}};i.expose(a)},Ie=e=>e,R={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:Ie},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},noImgZoomIn:{type:Boolean,default:!1},customIcon:{type:Object,default:{}}},Ee={...R,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},completions:{type:Array},showToolbarName:{type:Boolean,default:!1},onInput:{type:Function},onDrop:{type:Function}},L=["onHtmlChanged","onGetCatalog"],xe=[...L,"onChange","onSave","onUploadImg","onError","update:modelValue","onBlur","onFocus","onInput","onDrop"],Se=c.defineComponent({name:"MdPreview",props:R,emits:L,setup(e,i){const{editorId:l,noKatex:t,noMermaid:n,noHighlight:r}=e;return M(e),F(e),c.onBeforeUnmount(()=>{p.bus.clear(l)}),()=>c.createVNode("div",{id:l,class:[d.prefix,e.class,e.theme==="dark"&&`${d.prefix}-dark`,`${d.prefix}-previewOnly`],style:e.style},[c.createVNode(A,{modelValue:e.modelValue,onHtmlChanged:a=>{e.onHtmlChanged?e.onHtmlChanged(a):i.emit("onHtmlChanged",a)},onGetCatalog:a=>{e.onGetCatalog?e.onGetCatalog(a):i.emit("onGetCatalog",a)},mdHeadingId:e.mdHeadingId,noMermaid:n,sanitize:e.sanitize,noKatex:t,formatCopiedText:e.formatCopiedText,noHighlight:r,noImgZoomIn:e.noImgZoomIn,previewOnly:!0},null)])}}),S=Se;S.install=e=>(e.component(S.name,S),e);exports.ContentPreview=A;exports.MdPreview=S;exports.contentProps=ge;exports.editorEmits=xe;exports.editorProps=Ee;exports.useCatalog=Ce;exports.useConfig=ke;exports.useErrorCatcher=we;exports.useExpansion=be;exports.useExpose=$e;exports.useOnSave=ve;exports.useProvide=ye;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
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("")}`},
|
|
1
|
+
"use strict";var C=Object.defineProperty;var r=(o,t,s)=>t in o?C(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var i=(o,t,s)=>(r(o,typeof t!="symbol"?t+"":t,s),s);class a{constructor(){i(this,"pools",{})}remove(t,s,n){const e=this.pools[t]&&this.pools[t][s];e&&(this.pools[t][s]=e.filter(E=>E!==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(E=>{try{E(...n)}catch(c){console.error(`${s} monitor event exception!`,c)}})}}const A=new a,_="onSave",p="changeCatalogVisible",u="changeFullscreen",L="pageFullscreenChanged",R="fullscreenChanged",h="previewChanged",g="htmlPreviewChanged",N="catalogVisibleChanged",G="textareaFocus",H="buildFinished",S="errorCatcher",T="replace",I="uploadImage",d="openModals",D="ctrlZ",O="ctrlShiftZ",F="catalogChanged",b="pushCatalog",P=(o,t="image.png")=>{const s=o.split(","),n=s[0].match(/:(.*?);/);if(n){const l=n[1],e=atob(s[1]);let E=e.length;const c=new Uint8Array(E);for(;E--;)c[E]=e.charCodeAt(E);return new File([c],t,{type:l})}return null},U=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("")}`},f=(o,t)=>{if(!o||!t)return 0;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.BUILD_FINISHED=H;exports.CATALOG_CHANGED=F;exports.CATALOG_VISIBLE_CHANGED=N;exports.CHANGE_CATALOG_VISIBLE=p;exports.CHANGE_FULL_SCREEN=u;exports.CTRL_SHIFT_Z=O;exports.CTRL_Z=D;exports.ERROR_CATCHER=S;exports.FULL_SCREEN_CHANGED=R;exports.HTML_PREVIEW_CHANGED=g;exports.ON_SAVE=_;exports.OPEN_MODALS=d;exports.PAGE_FULL_SCREEN_CHANGED=L;exports.PREVIEW_CHANGED=h;exports.PUSH_CATALOG=b;exports.REPLACE=T;exports.TEXTAREA_FOCUS=G;exports.UPLOAD_IMAGE=I;exports.base642File=P;exports.bus=A;exports.generateCodeRowNumber=U;exports.getRelativeTop=f;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("./ModalToolbar.cjs"),q=require("./MdCatalog.cjs"),d=require("./chunks/config.cjs"),a=require("./chunks/index3.cjs");require("vue");require("@vavt/util");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("@codemirror/autocomplete");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;exports.MdCatalog=q;exports.config=d.config;exports.MdModal=a.MdModal;
|
|
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("./ModalToolbar.cjs"),q=require("./MdCatalog.cjs"),d=require("./chunks/config.cjs"),a=require("./chunks/index3.cjs");require("vue");require("@vavt/util");require("./chunks/index4.cjs");require("./chunks/dom.cjs");require("codemirror");require("@codemirror/view");require("@codemirror/language-data");require("@codemirror/lang-markdown");require("@codemirror/lang-html");require("@codemirror/commands");require("@codemirror/language");require("@lezer/highlight");require("@codemirror/state");require("@codemirror/autocomplete");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;exports.MdCatalog=q;exports.config=d.config;exports.MdModal=a.MdModal;
|