@xiee/utils
Advanced tools
Comparing version 1.4.3 to 1.5.0
@@ -29,5 +29,5 @@ // fold elements with <details>: https://yihui.org/en/2023/09/code-folding/ | ||
d.querySelectorAll(`details.${cls}`).forEach(el => { | ||
el.toggleAttribute('open', status); | ||
el.open = status; | ||
}); | ||
}; | ||
})(document); |
@@ -1,1 +0,1 @@ | ||
(e=>{const t=e.currentScript?.dataset,a="folder";let r=!!t?.open;if(e.querySelectorAll(t?.selector||"pre>code[class],pre[class]").forEach((l=>{const n=e.createElement("details"),o=e.createElement("summary");n.className=a,n.open=r,o.innerText=(t?.label||"Details")+(t?.tagName?` <${l.tagName}>`:""),"CODE"===l.tagName&&"PRE"===l.parentNode.tagName&&(l=l.parentNode),n.append(o),l.before(n),n.append(l)})),!t?.hasOwnProperty("button"))return;const l=e.querySelector(t.parent);let n=e.querySelector(t.button);(n||l)&&(n||(n=e.createElement("button"),n.id="toggle-all",n.innerText=t.buttonLabel||"Toggle Details",l.insertAdjacentElement(t.position||"afterbegin",n)),n.onclick=t=>{r=!r,e.querySelectorAll(`details.${a}`).forEach((e=>{e.toggleAttribute("open",r)}))})})(document); | ||
(e=>{const t=e.currentScript?.dataset,a="folder";let r=!!t?.open;if(e.querySelectorAll(t?.selector||"pre>code[class],pre[class]").forEach((n=>{const l=e.createElement("details"),o=e.createElement("summary");l.className=a,l.open=r,o.innerText=(t?.label||"Details")+(t?.tagName?` <${n.tagName}>`:""),"CODE"===n.tagName&&"PRE"===n.parentNode.tagName&&(n=n.parentNode),l.append(o),n.before(l),l.append(n)})),!t?.hasOwnProperty("button"))return;const n=e.querySelector(t.parent);let l=e.querySelector(t.button);(l||n)&&(l||(l=e.createElement("button"),l.id="toggle-all",l.innerText=t.buttonLabel||"Toggle Details",n.insertAdjacentElement(t.position||"afterbegin",l)),l.onclick=t=>{r=!r,e.querySelectorAll(`details.${a}`).forEach((e=>{e.open=r}))})})(document); |
@@ -9,3 +9,3 @@ // look for overflowed <pre> and <table>, and assign .fullwidth class to them | ||
const el = node.firstElementChild; | ||
el?.tagName === 'CODE' && el.scrollWidth > el.offsetWidth && fullwidth(el); | ||
el?.tagName === 'CODE' && el.scrollWidth > el.offsetWidth && fullwidth(el.parentNode); | ||
break; | ||
@@ -12,0 +12,0 @@ case 'TABLE': |
@@ -1,1 +0,1 @@ | ||
document.querySelectorAll("pre,table,#TableOfContents").forEach((t=>{function e(t){t.classList.add("fullwidth")}switch(t.tagName){case"PRE":const l=t.firstElementChild;"CODE"===l?.tagName&&l.scrollWidth>l.offsetWidth&&e(l);break;case"TABLE":const a=t.parentElement;a&&a.offsetWidth<t.offsetWidth&&e(t);break;default:t.querySelectorAll("a").forEach((l=>{!t.classList.contains("fullwidth")&&l.getClientRects().length>1&&e(t)}))}})); | ||
document.querySelectorAll("pre,table,#TableOfContents").forEach((t=>{function e(t){t.classList.add("fullwidth")}switch(t.tagName){case"PRE":const l=t.firstElementChild;"CODE"===l?.tagName&&l.scrollWidth>l.offsetWidth&&e(l.parentNode);break;case"TABLE":const a=t.parentElement;a&&a.offsetWidth<t.offsetWidth&&e(t);break;default:t.querySelectorAll("a").forEach((l=>{!t.classList.contains("fullwidth")&&l.getClientRects().length>1&&e(t)}))}})); |
{ | ||
"name": "@xiee/utils", | ||
"version": "1.4.3", | ||
"version": "1.5.0", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -35,2 +35,7 @@ This repo contains miscellaneous tools and utilities written in JavaScript. They | ||
## copy-button.js | ||
Add a copy button to any element (by default, `<pre>` code blocks) on a page. | ||
See [this post](https://yihui.org/en/2023/09/copy-button/) for details. | ||
## external-link.js | ||
@@ -37,0 +42,0 @@ |
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
62492
75
968
142