Comparing version 4.4.0 to 4.4.1
@@ -12,4 +12,4 @@ type AnchorContainerTagNameProps = 'ul' | 'ol'; | ||
declare const Mokuji: (element: HTMLElement | null, externalOptions?: MokujiOption) => HTMLUListElement | HTMLOListElement | undefined; | ||
declare const destory: () => void; | ||
declare const Destroy: () => void; | ||
export { Mokuji, MokujiOption, destory }; | ||
export { Destroy, Mokuji, MokujiOption }; |
@@ -1,5 +0,5 @@ | ||
var g=(t,n)=>!t||!n?!1:n.contains(t),u=t=>t.querySelectorAll("h1, h2, h3, h4, h5, h6"),h=t=>document.createElement(t);var L=new Set,E=t=>t.replaceAll(/\s+/g,"_"),A=t=>encodeURIComponent(t).replaceAll(/%+/g,"."),T=(t,n="")=>{let e=n,o=1;for(;o<=t.length;){let r=o===1?e:`${e}_${o}`;if(!L.has(r)){e=r,L.add(e);break}o++;}return e},M=(t,n)=>{let e=E(t);return e=e.replaceAll(/&+/g,"").replaceAll(/&+/g,""),n&&(e=A(e)),e};var H="data-mokuji-anchor",k={anchorType:!0,anchorLink:!1,anchorLinkSymbol:"#",anchorLinkBefore:!0,anchorLinkClassName:"",anchorContainerTagName:"ol"},N=t=>{let n=new Map;for(let e=0;e<t.length;e++){let o=t[e].hash.replace("#","");n.set(o,t[e]);}return n},x=(t,n,e)=>{let o=h("a");o.setAttribute(H,""),e.anchorLinkClassName&&o.classList.add(e.anchorLinkClassName);for(let r=0;r<t.length;r++){let c=t[r],l=n.get(c.id);if(!l)continue;let s=o.cloneNode(!1);s.setAttribute("href",l.hash),e.anchorLinkSymbol&&(s.textContent=e.anchorLinkSymbol),e.anchorLinkBefore?c.insertBefore(s,c.firstChild):c.append(s);}},y=(t,n)=>{for(let e=0;e<n.length;e++){let o=n[e],r=o.textContent,c=o.hash,l=t.filter(a=>a.id===r);if(l.length===1)continue;let s=0;for(let a=0;a<l.length;a++){let f=l[a],d=`${f.id}-${s}`;for(let i=0;i<n.length;i++){let m=n[i];if(m.hash===c){m.href=`#${d}`;break}}f.id=d,s++;}}},C=(t,n,e)=>{let o=0,r=h("li"),c=h("a");for(let l=0;l<t.length;l++){let s=t[l],a=Number(s.tagName[1]);if(o!==0&&o<a){let p=h("ol");n.lastChild.append(p),n=p;}else if(o!==0&&o>a)for(let p=0;p<o-a;p++)g(n,n.parentNode)&&(n=n.parentNode?.parentNode);let f=T(t,s.textContent||""),d=M(f,e);s.id=d;let i=c.cloneNode(!1);i.href=`#${d}`,i.textContent=s.textContent;let m=r.cloneNode(!1);m.append(i),n.append(m),o=a;}},I=(t,n)=>{if(!t)return;let e={...k,...n},o=[...u(t)];if(o.length===0)return;let r=h(e.anchorContainerTagName);C(o,r,e.anchorType);let c=[...r.querySelectorAll("a")];if(c.length!==0){if(y(o,c),e.anchorLink){let l=N(c);x(o,l,e);}return r}},_=()=>{let t=document.querySelectorAll(`[${H}]`);for(let n=t.length-1;n>=0;n--)t[n].remove();}; | ||
var g=(t,n)=>!t||!n?!1:n.contains(t),u=t=>t.querySelectorAll("h1, h2, h3, h4, h5, h6"),h=t=>document.createElement(t);var L=new Set,E=t=>t.replaceAll(/\s+/g,"_"),A=t=>encodeURIComponent(t).replaceAll(/%+/g,"."),T=(t,n="")=>{let e=n,o=1;for(;o<=t.length;){let r=o===1?e:`${e}_${o}`;if(!L.has(r)){e=r,L.add(e);break}o++;}return e},M=(t,n)=>{let e=E(t);return e=e.replaceAll(/&+/g,"").replaceAll(/&+/g,""),n&&(e=A(e)),e};var H="data-mokuji-anchor",k={anchorType:!0,anchorLink:!1,anchorLinkSymbol:"#",anchorLinkBefore:!0,anchorLinkClassName:"",anchorContainerTagName:"ol"},N=t=>{let n=new Map;for(let e=0;e<t.length;e++){let o=t[e].hash.replace("#","");n.set(o,t[e]);}return n},x=(t,n,e)=>{let o=h("a");o.setAttribute(H,""),e.anchorLinkClassName&&o.classList.add(e.anchorLinkClassName);for(let r=0;r<t.length;r++){let c=t[r],l=n.get(c.id);if(!l)continue;let s=o.cloneNode(!1);s.setAttribute("href",l.hash),e.anchorLinkSymbol&&(s.textContent=e.anchorLinkSymbol),e.anchorLinkBefore?c.insertBefore(s,c.firstChild):c.append(s);}},y=(t,n)=>{for(let e=0;e<n.length;e++){let o=n[e],r=o.textContent,c=o.hash,l=t.filter(a=>a.id===r);if(l.length===1)continue;let s=0;for(let a=0;a<l.length;a++){let f=l[a],m=`${f.id}-${s}`;for(let i=0;i<n.length;i++){let d=n[i];if(d.hash===c){d.href=`#${m}`;break}}f.id=m,s++;}}},C=(t,n,e)=>{let o=0,r=h("li"),c=h("a");for(let l=0;l<t.length;l++){let s=t[l],a=Number(s.tagName[1]);if(o!==0&&o<a){let p=h("ol");n.lastChild.append(p),n=p;}else if(o!==0&&o>a)for(let p=0;p<o-a;p++)g(n,n.parentNode)&&(n=n.parentNode?.parentNode);let f=T(t,s.textContent||""),m=M(f,e);s.id=m;let i=c.cloneNode(!1);i.href=`#${m}`,i.textContent=s.textContent;let d=r.cloneNode(!1);d.append(i),n.append(d),o=a;}},I=(t,n)=>{if(!t)return;let e={...k,...n},o=[...u(t)];if(o.length===0)return;let r=h(e.anchorContainerTagName);C(o,r,e.anchorType);let c=[...r.querySelectorAll("a")];if(c.length!==0){if(y(o,c),e.anchorLink){let l=N(c);x(o,l,e);}return r}},_=()=>{let t=document.querySelectorAll(`[${H}]`);for(let n=t.length-1;n>=0;n--)t[n].remove();}; | ||
export { I as Mokuji, _ as destory }; | ||
export { _ as Destroy, I as Mokuji }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "mokuji.js", | ||
"version": "4.4.0", | ||
"version": "4.4.1", | ||
"description": "A table of content JavaScript Library", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0