md-editor-v3 7.1.0-1 → 7.1.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.
@@ -1 +1 @@
1
- "use strict";const e=require("vue"),i=require("./config.cjs"),t=require("@lucide/vue"),S=require("./index5.cjs"),x=require("./dom.cjs"),k=require("./vue-tsx.cjs"),V=()=>e.createVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-github-icon"},[e.createVNode("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"},null),e.createVNode("path",{d:"M9 18c-4.51 2-5-2-7-2"},null)]),P={bold:t.Bold,underline:t.Underline,italic:t.Italic,"strike-through":t.Strikethrough,title:t.Heading,sub:t.Subscript,sup:t.Superscript,quote:t.Quote,"unordered-list":t.List,"ordered-list":t.ListOrdered,task:t.ListTodo,"code-row":t.Code,code:t.SquareCode,link:t.Link,image:t.Image,table:t.Table,revoke:t.Reply,next:t.Forward,save:t.Save,prettier:t.SquareCode,minimize:t.Minimize2,maximize:t.Maximize2,"fullscreen-exit":t.Shrink,fullscreen:t.Expand,"preview-only":t.View,preview:t.Eye,"preview-html":t.CodeXml,catalog:t.ListTree,github:V,mermaid:t.ChartArea,formula:t.SquareSigma,close:t.X,delete:t.Trash2,upload:t.Upload},$=e.defineComponent({name:`${i.prefix}-icon-set`,props:{name:{type:String,default:""}},setup(n){return()=>e.h(P[n.name],{class:`${i.prefix}-icon`})}}),p=e.defineComponent({name:`${i.prefix}-icon`,props:{name:{type:String,default:""}},setup(n){const d=e.inject("customIcon");return()=>{const r=d.value[n.name];return typeof r=="object"?typeof r.component=="object"?e.h(r.component,r.props):e.createVNode("span",{innerHTML:r.component},null):e.createVNode($,{name:n.name},null)}}}),B={title:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>{}},class:{type:String,default:void 0},style:{type:[Object,String],default:()=>({})},showMask:{type:Boolean,default:!0}},m=e.defineComponent({name:"MdModal",props:B,emits:["onClose"],setup(n,d){const r=e.inject("theme"),C=e.inject("rootRef"),f=e.ref(n.visible),c=e.ref([`${i.prefix}-modal`]),h=e.ref(),v=e.ref(),y=e.ref(),b=e.shallowRef();let u=()=>{};const o=e.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{insetInlineStart:"0px",insetBlockStart:"0px"},historyPos:{insetInlineStart:"0px",insetBlockStart:"0px"}}),w=e.computed(()=>n.isFullscreen?{width:"100%",height:"100%"}:{width:n.width,height:n.height});e.watch(()=>n.isFullscreen,l=>{l?u():e.nextTick(()=>{u=x.keyMove(v.value,(a,s)=>{o.initPos.insetInlineStart=a+"px",o.initPos.insetBlockStart=s+"px"})})}),e.watch(()=>n.visible,l=>{l?(o.maskStyle.zIndex=i.globalConfig.editorConfig.zIndex+S.getZIndexIncrement(),o.modalStyle.zIndex=i.globalConfig.editorConfig.zIndex+S.getZIndexIncrement(),c.value.push("zoom-in"),f.value=l,e.nextTick(()=>{const a=h.value.offsetWidth/2,s=h.value.offsetHeight/2,N=document.documentElement.clientWidth/2,M=document.documentElement.clientHeight/2;o.initPos.insetInlineStart=N-a+"px",o.initPos.insetBlockStart=M-s+"px",n.isFullscreen||(u=x.keyMove(v.value,(j,z)=>{o.initPos.insetInlineStart=j+"px",o.initPos.insetBlockStart=z+"px"}))}),setTimeout(()=>{c.value=c.value.filter(a=>a!=="zoom-in")},140)):(c.value.push("zoom-out"),u(),setTimeout(()=>{c.value=c.value.filter(a=>a!=="zoom-out"),f.value=l},130))});const g=e.computed(()=>({display:f.value?"block":"none"})),I=e.computed(()=>{if(typeof n.style=="string"){const l=Object.entries(g.value).map(([a,s])=>`${a}: ${s}`).join("; ");return[n.style,l].join("; ")}else return n.style instanceof Object?{...g.value,...n.style}:g.value});return e.onMounted(()=>{const l=C.value?.getRootNode();y.value=l instanceof Document?document.body:l}),()=>{const l=k.getSlot({ctx:d}),a=k.getSlot({props:n,ctx:d},"title");return y.value?e.createVNode(e.Teleport,{to:y.value},{default:()=>[e.createVNode("div",{ref:b,class:`${i.prefix}-modal-container`,"data-theme":r.value},[e.createVNode("div",{class:n.class,style:I.value},[n.showMask&&e.createVNode("div",{class:`${i.prefix}-modal-mask`,style:o.maskStyle,onClick:()=>{n.onClose?.(),d.emit("onClose")}},null),e.createVNode("div",{class:c.value,style:{...o.modalStyle,...o.initPos,...w.value},ref:h},[e.createVNode("div",{class:`${i.prefix}-modal-header`,ref:v},[a||""]),e.createVNode("div",{class:`${i.prefix}-modal-body`},[l]),e.createVNode("div",{class:`${i.prefix}-modal-func`},[n.showAdjust&&e.createVNode("div",{class:`${i.prefix}-modal-adjust`,onClick:s=>{s.stopPropagation(),n.isFullscreen?o.initPos=o.historyPos:(o.historyPos=o.initPos,o.initPos={insetInlineStart:"0",insetBlockStart:"0"}),n.onAdjust(!n.isFullscreen)}},[e.createVNode(p,{name:n.isFullscreen?"minimize":"maximize"},null)]),e.createVNode("div",{class:`${i.prefix}-modal-close`,onClick:s=>{s.stopPropagation(),n.onClose?.(),d.emit("onClose")}},[e.createVNode(p,{name:"close"},null)])])])])])]}):""}}});m.install=n=>(n.component(m.name,m),n);exports.Icon=p;exports.MdModal=m;
1
+ "use strict";const e=require("vue"),i=require("./config.cjs"),S=require("./index5.cjs"),x=require("./dom.cjs"),k=require("./vue-tsx.cjs"),t=require("@lucide/vue"),V=()=>e.createVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-github-icon"},[e.createVNode("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"},null),e.createVNode("path",{d:"M9 18c-4.51 2-5-2-7-2"},null)]),P={bold:t.Bold,underline:t.Underline,italic:t.Italic,"strike-through":t.Strikethrough,title:t.Heading,sub:t.Subscript,sup:t.Superscript,quote:t.Quote,"unordered-list":t.List,"ordered-list":t.ListOrdered,task:t.ListTodo,"code-row":t.Code,code:t.SquareCode,link:t.Link,image:t.Image,table:t.Table,revoke:t.Reply,next:t.Forward,save:t.Save,prettier:t.SquareCode,minimize:t.Minimize2,maximize:t.Maximize2,"fullscreen-exit":t.Shrink,fullscreen:t.Expand,"preview-only":t.View,preview:t.Eye,"preview-html":t.CodeXml,catalog:t.ListTree,github:V,mermaid:t.ChartArea,formula:t.SquareSigma,close:t.X,delete:t.Trash2,upload:t.Upload},$=e.defineComponent({name:`${i.prefix}-icon-set`,props:{name:{type:String,default:""}},setup(n){return()=>e.h(P[n.name],{class:`${i.prefix}-icon`})}}),p=e.defineComponent({name:`${i.prefix}-icon`,props:{name:{type:String,default:""}},setup(n){const d=e.inject("customIcon");return()=>{const r=d.value[n.name];return typeof r=="object"?typeof r.component=="object"?e.h(r.component,r.props):e.createVNode("span",{innerHTML:r.component},null):e.createVNode($,{name:n.name},null)}}}),B={title:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>{}},class:{type:String,default:void 0},style:{type:[Object,String],default:()=>({})},showMask:{type:Boolean,default:!0}},m=e.defineComponent({name:"MdModal",props:B,emits:["onClose"],setup(n,d){const r=e.inject("theme"),C=e.inject("rootRef"),f=e.ref(n.visible),c=e.ref([`${i.prefix}-modal`]),h=e.ref(),v=e.ref(),y=e.ref(),b=e.shallowRef();let u=()=>{};const o=e.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{insetInlineStart:"0px",insetBlockStart:"0px"},historyPos:{insetInlineStart:"0px",insetBlockStart:"0px"}}),w=e.computed(()=>n.isFullscreen?{width:"100%",height:"100%"}:{width:n.width,height:n.height});e.watch(()=>n.isFullscreen,l=>{l?u():e.nextTick(()=>{u=x.keyMove(v.value,(a,s)=>{o.initPos.insetInlineStart=a+"px",o.initPos.insetBlockStart=s+"px"})})}),e.watch(()=>n.visible,l=>{l?(o.maskStyle.zIndex=i.globalConfig.editorConfig.zIndex+S.getZIndexIncrement(),o.modalStyle.zIndex=i.globalConfig.editorConfig.zIndex+S.getZIndexIncrement(),c.value.push("zoom-in"),f.value=l,e.nextTick(()=>{const a=h.value.offsetWidth/2,s=h.value.offsetHeight/2,N=document.documentElement.clientWidth/2,M=document.documentElement.clientHeight/2;o.initPos.insetInlineStart=N-a+"px",o.initPos.insetBlockStart=M-s+"px",n.isFullscreen||(u=x.keyMove(v.value,(j,z)=>{o.initPos.insetInlineStart=j+"px",o.initPos.insetBlockStart=z+"px"}))}),setTimeout(()=>{c.value=c.value.filter(a=>a!=="zoom-in")},140)):(c.value.push("zoom-out"),u(),setTimeout(()=>{c.value=c.value.filter(a=>a!=="zoom-out"),f.value=l},130))});const g=e.computed(()=>({display:f.value?"block":"none"})),I=e.computed(()=>{if(typeof n.style=="string"){const l=Object.entries(g.value).map(([a,s])=>`${a}: ${s}`).join("; ");return[n.style,l].join("; ")}else return n.style instanceof Object?{...g.value,...n.style}:g.value});return e.onMounted(()=>{const l=C.value?.getRootNode();y.value=l instanceof Document?document.body:l}),()=>{const l=k.getSlot({ctx:d}),a=k.getSlot({props:n,ctx:d},"title");return y.value?e.createVNode(e.Teleport,{to:y.value},{default:()=>[e.createVNode("div",{ref:b,class:`${i.prefix}-modal-container`,"data-theme":r.value},[e.createVNode("div",{class:n.class,style:I.value},[n.showMask&&e.createVNode("div",{class:`${i.prefix}-modal-mask`,style:o.maskStyle,onClick:()=>{n.onClose?.(),d.emit("onClose")}},null),e.createVNode("div",{class:c.value,style:{...o.modalStyle,...o.initPos,...w.value},ref:h},[e.createVNode("div",{class:`${i.prefix}-modal-header`,ref:v},[a||""]),e.createVNode("div",{class:`${i.prefix}-modal-body`},[l]),e.createVNode("div",{class:`${i.prefix}-modal-func`},[n.showAdjust&&e.createVNode("div",{class:`${i.prefix}-modal-adjust`,onClick:s=>{s.stopPropagation(),n.isFullscreen?o.initPos=o.historyPos:(o.historyPos=o.initPos,o.initPos={insetInlineStart:"0",insetBlockStart:"0"}),n.onAdjust(!n.isFullscreen)}},[e.createVNode(p,{name:n.isFullscreen?"minimize":"maximize"},null)]),e.createVNode("div",{class:`${i.prefix}-modal-close`,onClick:s=>{s.stopPropagation(),n.onClose?.(),d.emit("onClose")}},[e.createVNode(p,{name:"close"},null)])])])])])]}):""}}});m.install=n=>(n.component(m.name,m),n);exports.Icon=p;exports.MdModal=m;
@@ -1 +1 @@
1
- "use strict";const o=require("vue"),D=require("./config.cjs"),P=require("@vavt/util"),S=require("./event-bus.cjs"),F=require("./index5.cjs"),G=`.${D.prefix}-preview > [data-line]`,w=(e,l)=>+getComputedStyle(e).getPropertyValue(l).replace("px",""),j=(e,l)=>{const I=P.debounce(()=>{e.removeEventListener("scroll",c),e.addEventListener("scroll",c),l.removeEventListener("scroll",c),l.addEventListener("scroll",c)},50),c=k=>{const u=e.clientHeight,y=l.clientHeight,m=e.scrollHeight,d=l.scrollHeight,s=(m-u)/(d-y);k.target===e?(l.removeEventListener("scroll",c),l.scrollTo({top:e.scrollTop/s}),I()):(e.removeEventListener("scroll",c),e.scrollTo({top:l.scrollTop*s}),I())};return[()=>{I().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",c),l.removeEventListener("scroll",c)}]},U=(e,l,I)=>{const{view:c}=I,k=P.createSmoothScroll(),u=r=>c.lineBlockAt(c.state.doc.line(r+1).from).top,y=r=>c.lineBlockAt(c.state.doc.line(r+1).from).bottom;let m=[],d=[],s=[];const N=()=>{m=[],d=Array.from(l.querySelectorAll(G)),s=d.map(n=>Number(n.dataset.line));const r=[...s],{lines:h}=c.state.doc;r[0]!==0&&r.unshift(0);let C=r.shift()||0,t=r.shift()||h;for(let n=0;n<h;n++)n===t&&(C=n,t=r.shift()||h),m.push({start:C,end:t-1})},R=(r,h)=>{let C=1;for(let t=d.length-1;t-1>=0;t--){const n=d[t];if(n.offsetTop<=h){C=Number(n.dataset.line);break}}for(let t=m.length-1;t>=0;t--)if(u(m[t].start)<=r){C=C<m[t].start?C:m[t].start;break}return C};let A=0,$=0;const V=()=>{if($!==0)return!1;A++;const{scrollDOM:r}=c;let h=w(l,"padding-block-start");const C=c.lineBlockAtHeight(r.scrollTop),{number:t}=c.state.doc.lineAt(C.from),n=m[t-1];if(!n)return!1;let H=1;const f=l.querySelector(`[data-line="${n.start}"]`)||l.firstElementChild?.firstElementChild,v=l.querySelector(`[data-line="${n.end+1}"]`)||l.lastElementChild?.lastElementChild,g=r.scrollHeight-r.clientHeight,i=l.scrollHeight-l.clientHeight;let T=u(n.start);const b=y(n.end);let a=f.offsetTop,x=v.offsetTop-a;T===0&&(a=0,f===v?(h=0,x=0):x=v.offsetTop),H=(r.scrollTop-T)/(b-T);const M=v==l.lastElementChild?.lastElementChild?v.offsetTop+v.clientHeight:v.offsetTop;if(b>=g||M>i){const L=R(g,i);T=u(L),H=(r.scrollTop-T)/(g-T);const E=l.querySelector(`[data-line="${L}"]`);T>0&&E&&(a=E.offsetTop),x=i-a+w(l,"padding-block-start")}const q=a-h+x*H;k(l,q,()=>{A--})},B=()=>{if(A!==0)return;$++;const{scrollDOM:r}=c,h=l.scrollTop,C=l.scrollHeight,t=r.scrollHeight-r.clientHeight,n=l.scrollHeight-l.clientHeight;let H=l.firstElementChild?.firstElementChild,f=l.firstElementChild?.lastElementChild;if(s.length>0){let L=Math.ceil(s[s.length-1]*(h/C)),E=s.findLastIndex(p=>p<=L);E=E===-1?0:E,L=s[E];for(let p=E;p>=0&&p<s.length;)if(d[p].offsetTop>h){if(p-1>=0){p--;continue}L=-1,E=-1;break}else{if(p+1<s.length&&d[p+1].offsetTop<h){p++;continue}L=s[p],E=p;break}switch(E){case-1:{H=l.firstElementChild?.firstElementChild,f=d[0];break}case s.length-1:{H=d[E],f=l.firstElementChild?.lastElementChild;break}default:H=d[E],f=d[E+1]}}let v=H===l.firstElementChild?.firstElementChild?0:H.offsetTop-w(H,"margin-block-start"),g=f.offsetTop,i=0;const{start:T,end:b}=m[Number(H.dataset.line||0)];let a=u(T);const x=u(b+1===c.state.doc.lines?b:b+1);let M=0;const q=f==l.lastElementChild?.lastElementChild?f.offsetTop+f.offsetHeight:f.offsetTop;if(x>t||q>n){const L=R(t,n),E=l.querySelector(`[data-line="${L}"]`);v=E?E.offsetTop-w(E,"margin-block-start"):v,a=u(L),i=(h-v)/(n-v),M=t-a}else H===l.firstElementChild?.firstElementChild?(H===f&&(g=f.offsetTop+f.offsetHeight+w(f,"margin-block-end")),M=x,a=0,i=Math.max(h/g,0)):(i=Math.max((h-v)/(g-v),0),M=x-a);k(e,a+M*i,()=>{$--})},O=r=>{const{scrollDOM:h,contentHeight:C}=c,t=h.clientHeight;if(C<=t||l.firstElementChild.clientHeight<=l.clientHeight||c.state.doc.lines<=m[m.length-1]?.end)return!1;r.target===e?V():B()};return[()=>{N(),e.addEventListener("scroll",O),l.addEventListener("scroll",O),e.dispatchEvent(new Event("scroll"))},()=>{e.removeEventListener("scroll",O),l.removeEventListener("scroll",O)}]},z={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},onActive:{type:Function,default:()=>{}},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},W=o.defineComponent({props:z,setup(e){const l=o.inject("scrollElementRef"),I=o.inject("roorNodeRef"),c=o.ref();o.watch(()=>e.tocItem.active,u=>{u&&e.onActive(e.tocItem,c.value)}),o.onMounted(()=>{e.tocItem.active&&e.onActive(e.tocItem,c.value)});const k=u=>{if(u.stopPropagation(),e.onClick(u,e.tocItem),u.defaultPrevented)return;const y=e.mdHeadingId({text:e.tocItem.text,level:e.tocItem.level,index:e.tocItem.index,currentToken:e.tocItem.currentToken,nextToken:e.tocItem.nextToken}),m=I.value.getElementById(y),d=l.value;if(m&&d){let s=m.offsetParent,N=m.offsetTop;if(d.contains(s))for(;s&&d!=s;)N+=s?.offsetTop,s=s?.offsetParent;const R=m.previousElementSibling;let A=0;R||(A=w(m,"margin-block-start")),d?.scrollTo({top:N-e.scrollElementOffsetTop-A,behavior:"smooth"})}};return()=>o.createVNode("div",{ref:c,class:[`${D.prefix}-catalog-link`,e.tocItem.active&&`${D.prefix}-catalog-active`],onClick:k},[o.createVNode("span",{title:e.tocItem.text},[e.tocItem.text]),e.tocItem.children&&e.tocItem.children.length>0&&o.createVNode("div",{class:`${D.prefix}-catalog-wrapper`},[e.tocItem.children.map(u=>o.createVNode(W,{mdHeadingId:e.mdHeadingId,key:`${e.tocItem.text}-link-${u.level}-${u.text}`,tocItem:u,onActive:e.onActive,onClick:e.onClick,scrollElementOffsetTop:e.scrollElementOffsetTop},null))])])}}),J={editorId:{type:String,default:void 0},class:{type:String,default:""},mdHeadingId:{type:Function,default:({text:e})=>e},scrollElement:{type:[String,Object],default:void 0},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function,default:void 0},onActive:{type:Function,default:void 0},isScrollElementInShadow:{type:Boolean,default:!1},syncWith:{type:String,default:"preview"},catalogMaxDepth:{type:Number,default:void 0}},_=o.defineComponent({name:"MdCatalog",props:J,emits:["onClick","onActive"],setup(e,l){const I=e.editorId,c=`#${I}-preview-wrapper`,k=o.reactive({list:[],show:!1,scrollElement:e.scrollElement||c}),u=o.shallowRef(),y=o.ref(),m=o.ref(),d=o.ref(),s=o.ref(),N=o.shallowRef(),R=o.ref({});o.provide("scrollElementRef",m),o.provide("roorNodeRef",s);const A=o.computed(()=>{const t=[];return k.list.forEach((n,H)=>{if(e.catalogMaxDepth&&n.level>e.catalogMaxDepth)return;const{text:f,level:v,line:g}=n,i={level:v,text:f,line:g,index:H+1,active:u.value===n};if(t.length===0)t.push(i);else{let T=t[t.length-1];if(i.level>T.level)for(let b=T.level+1;b<=6;b++){const{children:a}=T;if(!a){T.children=[i];break}if(T=a[a.length-1],i.level<=T.level){a.push(i);break}}else t.push(i)}}),t}),$=()=>{if(k.scrollElement instanceof HTMLElement)return k.scrollElement;let t=document;return(k.scrollElement===c||e.isScrollElementInShadow)&&(t=y.value?.getRootNode()),t.querySelector(k.scrollElement)},V=t=>{if(t.length===0)return u.value=void 0,k.list=[],!1;const{activeHead:n,activeIndex:H}=t.reduce((g,i,T)=>{let b=0;if(e.syncWith==="preview"){const a=s.value?.getElementById(e.mdHeadingId({text:i.text,level:i.level,index:T+1,currentToken:i.currentToken,nextToken:i.nextToken}));a instanceof HTMLElement&&(b=F.getRelativeTop(a,m.value))}else{const a=N.value;if(a){const x=a.lineBlockAt(a.state.doc.line(i.line+1).from).top,M=a.scrollDOM.scrollTop;b=x-M}}return b<e.offsetTop&&b>g.minTop?{activeHead:i,activeIndex:T,minTop:b}:g},{activeHead:t[0],activeIndex:0,minTop:Number.MIN_SAFE_INTEGER});let f=n;const{catalogMaxDepth:v}=e;if(v&&f.level>v){for(let g=H;g>=0;g--){const i=t[g];if(i.level<=v){f=i;break}}if(f.level>v){const g=t.find(i=>i.level<=v);g&&(f=g)}}u.value=f,k.list=t},B=(t,n)=>{R.value.top=n.offsetTop+w(n,"padding-block-start")+"px",e.onActive?.(t,n),l.emit("onActive",t,n)},O=()=>{V(k.list)},r=t=>{if(d.value?.removeEventListener("scroll",O),e.syncWith==="editor")d.value=N.value?.scrollDOM;else{const n=$();m.value=n,d.value=n===document.documentElement?document:n}V(t),d.value?.addEventListener("scroll",O)},h=t=>{N.value=t};o.watch([()=>e.syncWith,N,()=>e.catalogMaxDepth],()=>{r(k.list)}),o.onMounted(()=>{s.value=y.value.getRootNode(),S.bus.on(I,{name:S.CATALOG_CHANGED,callback:r}),S.bus.on(I,{name:S.GET_EDITOR_VIEW,callback:h}),S.bus.emit(I,S.PUSH_CATALOG),S.bus.emit(I,S.SEND_EDITOR_VIEW)}),o.onBeforeUnmount(()=>{S.bus.remove(I,S.CATALOG_CHANGED,r),S.bus.remove(I,S.GET_EDITOR_VIEW,h),d.value?.removeEventListener("scroll",O)});const C=(t,n)=>{e.onClick?.(t,n),l.emit("onClick",t,n)};return()=>o.createVNode("div",{class:[`${D.prefix}-catalog`,e.class||""],"data-theme":e.theme,ref:y},[A.value.length>0&&o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${D.prefix}-catalog-indicator`,style:R.value},null),o.createVNode("div",{class:`${D.prefix}-catalog-container`},[A.value.map(t=>o.createVNode(W,{mdHeadingId:e.mdHeadingId,tocItem:t,key:`link-${t.level}-${t.text}`,onActive:B,onClick:C,scrollElementOffsetTop:e.scrollElementOffsetTop},null))])])])}});_.install=e=>(e.component(_.name,_),e);exports.MdCatalog=_;exports.scrollAuto=U;exports.scrollAutoWithScale=j;
1
+ "use strict";const o=require("vue"),D=require("./config.cjs"),P=require("@vavt/util"),S=require("./event-bus.cjs"),F=require("./index5.cjs"),G=`.${D.prefix}-preview > [data-line]`,w=(e,l)=>+getComputedStyle(e).getPropertyValue(l).replace("px",""),j=(e,l)=>{const I=P.debounce(()=>{e.removeEventListener("scroll",c),e.addEventListener("scroll",c),l.removeEventListener("scroll",c),l.addEventListener("scroll",c)},50),c=k=>{const u=e.clientHeight,y=l.clientHeight,m=e.scrollHeight,d=l.scrollHeight,s=(m-u)/(d-y);k.target===e?(l.removeEventListener("scroll",c),l.scrollTo({top:e.scrollTop/s}),I()):(e.removeEventListener("scroll",c),e.scrollTo({top:l.scrollTop*s}),I())};return[()=>{I().finally(()=>{e.dispatchEvent(new Event("scroll"))})},()=>{e.removeEventListener("scroll",c),l.removeEventListener("scroll",c)}]},U=(e,l,I)=>{const{view:c}=I,k=P.createSmoothScroll(),u=r=>c.lineBlockAt(c.state.doc.line(r+1).from).top,y=r=>c.lineBlockAt(c.state.doc.line(r+1).from).bottom;let m=[],d=[],s=[];const N=()=>{m=[],d=Array.from(l.querySelectorAll(G)),s=d.map(n=>Number(n.dataset.line));const r=[...s],{lines:h}=c.state.doc;r[0]!==0&&r.unshift(0);let C=r.shift()||0,t=r.shift()||h;for(let n=0;n<h;n++)n===t&&(C=n,t=r.shift()||h),m.push({start:C,end:t-1})},R=(r,h)=>{let C=1;for(let t=d.length-1;t-1>=0;t--){const n=d[t];if(n.offsetTop<=h){C=Number(n.dataset.line);break}}for(let t=m.length-1;t>=0;t--)if(u(m[t].start)<=r){C=C<m[t].start?C:m[t].start;break}return C};let A=0,$=0;const V=()=>{if($!==0)return!1;A++;const{scrollDOM:r}=c;let h=w(l,"padding-block-start");const C=c.lineBlockAtHeight(r.scrollTop),{number:t}=c.state.doc.lineAt(C.from),n=m[t-1];if(!n)return!1;let H=1;const f=l.querySelector(`[data-line="${n.start}"]`)||l.firstElementChild?.firstElementChild,v=l.querySelector(`[data-line="${n.end+1}"]`)||l.lastElementChild?.lastElementChild,g=r.scrollHeight-r.clientHeight,i=l.scrollHeight-l.clientHeight;let T=u(n.start),b=y(n.end),a=f.offsetTop,x=v.offsetTop-a;T===0&&(a=0,f===v?(h=0,x=0):x=v.offsetTop),H=(r.scrollTop-T)/(b-T);const M=v==l.lastElementChild?.lastElementChild?v.offsetTop+v.clientHeight:v.offsetTop;if(b>=g||M>i){const L=R(g,i);T=u(L),H=(r.scrollTop-T)/(g-T);const E=l.querySelector(`[data-line="${L}"]`);T>0&&E&&(a=E.offsetTop),x=i-a+w(l,"padding-block-start")}const q=a-h+x*H;k(l,q,()=>{A--})},B=()=>{if(A!==0)return;$++;const{scrollDOM:r}=c,h=l.scrollTop,C=l.scrollHeight,t=r.scrollHeight-r.clientHeight,n=l.scrollHeight-l.clientHeight;let H=l.firstElementChild?.firstElementChild,f=l.firstElementChild?.lastElementChild;if(s.length>0){let L=Math.ceil(s[s.length-1]*(h/C)),E=s.findLastIndex(p=>p<=L);E=E===-1?0:E,L=s[E];for(let p=E;p>=0&&p<s.length;)if(d[p].offsetTop>h){if(p-1>=0){p--;continue}L=-1,E=-1;break}else{if(p+1<s.length&&d[p+1].offsetTop<h){p++;continue}L=s[p],E=p;break}switch(E){case-1:{H=l.firstElementChild?.firstElementChild,f=d[0];break}case s.length-1:{H=d[E],f=l.firstElementChild?.lastElementChild;break}default:H=d[E],f=d[E+1]}}let v=H===l.firstElementChild?.firstElementChild?0:H.offsetTop-w(H,"margin-block-start"),g=f.offsetTop,i=0;const{start:T,end:b}=m[Number(H.dataset.line||0)];let a=u(T);const x=u(b+1===c.state.doc.lines?b:b+1);let M=0;const q=f==l.lastElementChild?.lastElementChild?f.offsetTop+f.offsetHeight:f.offsetTop;if(x>t||q>n){const L=R(t,n),E=l.querySelector(`[data-line="${L}"]`);v=E?E.offsetTop-w(E,"margin-block-start"):v,a=u(L),i=(h-v)/(n-v),M=t-a}else H===l.firstElementChild?.firstElementChild?(H===f&&(g=f.offsetTop+f.offsetHeight+w(f,"margin-block-end")),M=x,a=0,i=Math.max(h/g,0)):(i=Math.max((h-v)/(g-v),0),M=x-a);k(e,a+M*i,()=>{$--})},O=r=>{const{scrollDOM:h,contentHeight:C}=c,t=h.clientHeight;if(C<=t||l.firstElementChild.clientHeight<=l.clientHeight||c.state.doc.lines<=m[m.length-1]?.end)return!1;r.target===e?V():B()};return[()=>{N(),e.addEventListener("scroll",O),l.addEventListener("scroll",O),e.dispatchEvent(new Event("scroll"))},()=>{e.removeEventListener("scroll",O),l.removeEventListener("scroll",O)}]},z={tocItem:{type:Object,default:()=>({})},mdHeadingId:{type:Function,default:()=>{}},onActive:{type:Function,default:()=>{}},onClick:{type:Function,default:()=>{}},scrollElementOffsetTop:{type:Number,default:0}},W=o.defineComponent({props:z,setup(e){const l=o.inject("scrollElementRef"),I=o.inject("roorNodeRef"),c=o.ref();o.watch(()=>e.tocItem.active,u=>{u&&e.onActive(e.tocItem,c.value)}),o.onMounted(()=>{e.tocItem.active&&e.onActive(e.tocItem,c.value)});const k=u=>{if(u.stopPropagation(),e.onClick(u,e.tocItem),u.defaultPrevented)return;const y=e.mdHeadingId({text:e.tocItem.text,level:e.tocItem.level,index:e.tocItem.index,currentToken:e.tocItem.currentToken,nextToken:e.tocItem.nextToken}),m=I.value.getElementById(y),d=l.value;if(m&&d){let s=m.offsetParent,N=m.offsetTop;if(d.contains(s))for(;s&&d!=s;)N+=s?.offsetTop,s=s?.offsetParent;const R=m.previousElementSibling;let A=0;R||(A=w(m,"margin-block-start")),d?.scrollTo({top:N-e.scrollElementOffsetTop-A,behavior:"smooth"})}};return()=>o.createVNode("div",{ref:c,class:[`${D.prefix}-catalog-link`,e.tocItem.active&&`${D.prefix}-catalog-active`],onClick:k},[o.createVNode("span",{title:e.tocItem.text},[e.tocItem.text]),e.tocItem.children&&e.tocItem.children.length>0&&o.createVNode("div",{class:`${D.prefix}-catalog-wrapper`},[e.tocItem.children.map(u=>o.createVNode(W,{mdHeadingId:e.mdHeadingId,key:`${e.tocItem.text}-link-${u.level}-${u.text}`,tocItem:u,onActive:e.onActive,onClick:e.onClick,scrollElementOffsetTop:e.scrollElementOffsetTop},null))])])}}),J={editorId:{type:String,default:void 0},class:{type:String,default:""},mdHeadingId:{type:Function,default:({text:e})=>e},scrollElement:{type:[String,Object],default:void 0},theme:{type:String,default:"light"},offsetTop:{type:Number,default:20},scrollElementOffsetTop:{type:Number,default:0},onClick:{type:Function,default:void 0},onActive:{type:Function,default:void 0},isScrollElementInShadow:{type:Boolean,default:!1},syncWith:{type:String,default:"preview"},catalogMaxDepth:{type:Number,default:void 0}},_=o.defineComponent({name:"MdCatalog",props:J,emits:["onClick","onActive"],setup(e,l){const I=e.editorId,c=`#${I}-preview-wrapper`,k=o.reactive({list:[],show:!1,scrollElement:e.scrollElement||c}),u=o.shallowRef(),y=o.ref(),m=o.ref(),d=o.ref(),s=o.ref(),N=o.shallowRef(),R=o.ref({});o.provide("scrollElementRef",m),o.provide("roorNodeRef",s);const A=o.computed(()=>{const t=[];return k.list.forEach((n,H)=>{if(e.catalogMaxDepth&&n.level>e.catalogMaxDepth)return;const{text:f,level:v,line:g}=n,i={level:v,text:f,line:g,index:H+1,active:u.value===n};if(t.length===0)t.push(i);else{let T=t[t.length-1];if(i.level>T.level)for(let b=T.level+1;b<=6;b++){const{children:a}=T;if(!a){T.children=[i];break}if(T=a[a.length-1],i.level<=T.level){a.push(i);break}}else t.push(i)}}),t}),$=()=>{if(k.scrollElement instanceof HTMLElement)return k.scrollElement;let t=document;return(k.scrollElement===c||e.isScrollElementInShadow)&&(t=y.value?.getRootNode()),t.querySelector(k.scrollElement)},V=t=>{if(t.length===0)return u.value=void 0,k.list=[],!1;const{activeHead:n,activeIndex:H}=t.reduce((g,i,T)=>{let b=0;if(e.syncWith==="preview"){const a=s.value?.getElementById(e.mdHeadingId({text:i.text,level:i.level,index:T+1,currentToken:i.currentToken,nextToken:i.nextToken}));a instanceof HTMLElement&&(b=F.getRelativeTop(a,m.value))}else{const a=N.value;if(a){const x=a.lineBlockAt(a.state.doc.line(i.line+1).from).top,M=a.scrollDOM.scrollTop;b=x-M}}return b<e.offsetTop&&b>g.minTop?{activeHead:i,activeIndex:T,minTop:b}:g},{activeHead:t[0],activeIndex:0,minTop:Number.MIN_SAFE_INTEGER});let f=n;const{catalogMaxDepth:v}=e;if(v&&f.level>v){for(let g=H;g>=0;g--){const i=t[g];if(i.level<=v){f=i;break}}if(f.level>v){const g=t.find(i=>i.level<=v);g&&(f=g)}}u.value=f,k.list=t},B=(t,n)=>{R.value.top=n.offsetTop+w(n,"padding-block-start")+"px",e.onActive?.(t,n),l.emit("onActive",t,n)},O=()=>{V(k.list)},r=t=>{if(d.value?.removeEventListener("scroll",O),e.syncWith==="editor")d.value=N.value?.scrollDOM;else{const n=$();m.value=n,d.value=n===document.documentElement?document:n}V(t),d.value?.addEventListener("scroll",O)},h=t=>{N.value=t};o.watch([()=>e.syncWith,N,()=>e.catalogMaxDepth],()=>{r(k.list)}),o.onMounted(()=>{s.value=y.value.getRootNode(),S.bus.on(I,{name:S.CATALOG_CHANGED,callback:r}),S.bus.on(I,{name:S.GET_EDITOR_VIEW,callback:h}),S.bus.emit(I,S.PUSH_CATALOG),S.bus.emit(I,S.SEND_EDITOR_VIEW)}),o.onBeforeUnmount(()=>{S.bus.remove(I,S.CATALOG_CHANGED,r),S.bus.remove(I,S.GET_EDITOR_VIEW,h),d.value?.removeEventListener("scroll",O)});const C=(t,n)=>{e.onClick?.(t,n),l.emit("onClick",t,n)};return()=>o.createVNode("div",{class:[`${D.prefix}-catalog`,e.class||""],"data-theme":e.theme,ref:y},[A.value.length>0&&o.createVNode(o.Fragment,null,[o.createVNode("div",{class:`${D.prefix}-catalog-indicator`,style:R.value},null),o.createVNode("div",{class:`${D.prefix}-catalog-container`},[A.value.map(t=>o.createVNode(W,{mdHeadingId:e.mdHeadingId,tocItem:t,key:`link-${t.level}-${t.text}`,onActive:B,onClick:C,scrollElementOffsetTop:e.scrollElementOffsetTop},null))])])])}});_.install=e=>(e.component(_.name,_),e);exports.MdCatalog=_;exports.scrollAuto=U;exports.scrollAutoWithScale=j;
@@ -1,9 +1,9 @@
1
1
  import { createVNode as t, defineComponent as k, h as j, inject as p, ref as c, shallowRef as O, reactive as E, computed as g, watch as x, nextTick as b, onMounted as W, Teleport as q } from "vue";
2
2
  import { p as l, g as C } from "./config.mjs";
3
- import { Upload as N, Trash2 as D, X as U, SquareSigma as X, ChartArea as G, ListTree as Q, CodeXml as V, Eye as Z, View as J, Expand as K, Shrink as Y, Maximize2 as _, Minimize2 as ee, SquareCode as w, Save as te, Forward as ne, Reply as oe, Table as ie, Image as le, Link as se, Code as ae, ListTodo as re, ListOrdered as ue, List as ce, Quote as de, Superscript as me, Subscript as fe, Heading as he, Strikethrough as ve, Italic as ye, Underline as ge, Bold as Se } from "@lucide/vue";
4
- import { c as I } from "./index5.mjs";
5
- import { k as z } from "./dom.mjs";
6
- import { g as M } from "./vue-tsx.mjs";
3
+ import { c as w } from "./index5.mjs";
4
+ import { k as I } from "./dom.mjs";
5
+ import { g as z } from "./vue-tsx.mjs";
6
+ import { Upload as N, Trash2 as D, X as U, SquareSigma as X, ChartArea as G, ListTree as Q, CodeXml as V, Eye as Z, View as J, Expand as K, Shrink as Y, Maximize2 as _, Minimize2 as ee, SquareCode as M, Save as te, Forward as ne, Reply as oe, Table as ie, Image as le, Link as se, Code as ae, ListTodo as re, ListOrdered as ue, List as ce, Quote as de, Superscript as me, Subscript as fe, Heading as he, Strikethrough as ve, Italic as ye, Underline as ge, Bold as Se } from "@lucide/vue";
7
7
  const pe = () => t("svg", {
8
8
  xmlns: "http://www.w3.org/2000/svg",
9
9
  viewBox: "0 0 24 24",
@@ -30,14 +30,14 @@ const pe = () => t("svg", {
30
30
  "ordered-list": ue,
31
31
  task: re,
32
32
  "code-row": ae,
33
- code: w,
33
+ code: M,
34
34
  link: se,
35
35
  image: le,
36
36
  table: ie,
37
37
  revoke: oe,
38
38
  next: ne,
39
39
  save: te,
40
- prettier: w,
40
+ prettier: M,
41
41
  minimize: ee,
42
42
  maximize: _,
43
43
  "fullscreen-exit": Y,
@@ -161,14 +161,14 @@ const pe = () => t("svg", {
161
161
  });
162
162
  x(() => e.isFullscreen, (o) => {
163
163
  o ? d() : b(() => {
164
- d = z(h.value, (i, s) => {
164
+ d = I(h.value, (i, s) => {
165
165
  n.initPos.insetInlineStart = i + "px", n.initPos.insetBlockStart = s + "px";
166
166
  });
167
167
  });
168
168
  }), x(() => e.visible, (o) => {
169
- o ? (n.maskStyle.zIndex = C.editorConfig.zIndex + I(), n.modalStyle.zIndex = C.editorConfig.zIndex + I(), r.value.push("zoom-in"), m.value = o, b(() => {
169
+ o ? (n.maskStyle.zIndex = C.editorConfig.zIndex + w(), n.modalStyle.zIndex = C.editorConfig.zIndex + w(), r.value.push("zoom-in"), m.value = o, b(() => {
170
170
  const i = f.value.offsetWidth / 2, s = f.value.offsetHeight / 2, T = document.documentElement.clientWidth / 2, H = document.documentElement.clientHeight / 2;
171
- n.initPos.insetInlineStart = T - i + "px", n.initPos.insetBlockStart = H - s + "px", e.isFullscreen || (d = z(h.value, (A, L) => {
171
+ n.initPos.insetInlineStart = T - i + "px", n.initPos.insetBlockStart = H - s + "px", e.isFullscreen || (d = I(h.value, (A, L) => {
172
172
  n.initPos.insetInlineStart = A + "px", n.initPos.insetBlockStart = L + "px";
173
173
  }));
174
174
  }), setTimeout(() => {
@@ -192,9 +192,9 @@ const pe = () => t("svg", {
192
192
  const o = $.value?.getRootNode();
193
193
  v.value = o instanceof Document ? document.body : o;
194
194
  }), () => {
195
- const o = M({
195
+ const o = z({
196
196
  ctx: u
197
- }), i = M({
197
+ }), i = z({
198
198
  props: e,
199
199
  ctx: u
200
200
  }, "title");
@@ -69,9 +69,7 @@ const ce = `.${w}-preview > [data-line]`, R = (e, l) => +getComputedStyle(e).get
69
69
  return !1;
70
70
  let E = 1;
71
71
  const f = l.querySelector(`[data-line="${n.start}"]`) || l.firstElementChild?.firstElementChild, u = l.querySelector(`[data-line="${n.end + 1}"]`) || l.lastElementChild?.lastElementChild, h = c.scrollHeight - c.clientHeight, i = l.scrollHeight - l.clientHeight;
72
- let g = d(n.start);
73
- const p = y(n.end);
74
- let r = f.offsetTop, b = u.offsetTop - r;
72
+ let g = d(n.start), p = y(n.end), r = f.offsetTop, b = u.offsetTop - r;
75
73
  g === 0 && (r = 0, f === u ? (v = 0, b = 0) : b = u.offsetTop), E = (c.scrollTop - g) / (p - g);
76
74
  const A = u == l.lastElementChild?.lastElementChild ? u.offsetTop + u.clientHeight : u.offsetTop;
77
75
  if (p >= h || A > i) {
@@ -2393,17 +2393,17 @@ declare const _default$7: vue.DefineComponent<vue.ExtractPropTypes<{
2393
2393
  [key: string]: any;
2394
2394
  }>;
2395
2395
  insert: () => void;
2396
- visible: boolean;
2397
2396
  onClose: () => void;
2397
+ onAdjust: (val: boolean) => void;
2398
+ modalTitle: string | VNode<vue.RendererNode, vue.RendererElement, {
2399
+ [key: string]: any;
2400
+ }>;
2401
+ visible: boolean;
2398
2402
  width: string;
2399
2403
  height: string;
2400
2404
  showAdjust: boolean;
2401
2405
  isFullscreen: boolean;
2402
- onAdjust: (val: boolean) => void;
2403
2406
  showMask: boolean;
2404
- modalTitle: string | VNode<vue.RendererNode, vue.RendererElement, {
2405
- [key: string]: any;
2406
- }>;
2407
2407
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2408
2408
 
2409
2409
  declare const _default$6: typeof _default$7 & {
@@ -2508,12 +2508,12 @@ declare const _default$5: vue.DefineComponent<vue.ExtractPropTypes<{
2508
2508
  }>[];
2509
2509
  class: string;
2510
2510
  style: string | CSSProperties;
2511
+ onAdjust: (val: boolean) => void;
2511
2512
  visible: boolean;
2512
2513
  width: string;
2513
2514
  height: string;
2514
2515
  showAdjust: boolean;
2515
2516
  isFullscreen: boolean;
2516
- onAdjust: (val: boolean) => void;
2517
2517
  showMask: boolean;
2518
2518
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
2519
2519
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-editor-v3",
3
- "version": "7.1.0-1",
3
+ "version": "7.1.0",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "vue",