@xiee/utils
Advanced tools
Comparing version 1.13.11 to 1.13.12
@@ -113,3 +113,3 @@ // move elements into page boxes such that each box contains as many elements as | ||
// remove possible classes on TOC/footnotes that we don't need for printing | ||
$$(':is(#TOC, .footnotes):is(.side-left, .side-right).side').forEach(el => { | ||
$$(':is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side').forEach(el => { | ||
el.classList.remove('side', 'side-left', 'side-right'); | ||
@@ -116,0 +116,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
(e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}const a=e.createElement("div"),r=n("h1").length>1;a.className="pagesjs-page",a.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let s,i,o,l=[];function c(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",a.innerHTML),s=e||a.cloneNode(!0),i=s.children[1],l.length&&s.classList.add(...l),s}function d(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function f(e){if(e.classList.contains("pagesjs-page"))return s.after(c(e)),void(e.childElementCount>3&&(i.append(...[...e.children].slice(3)),s.after(c())));if(s.scrollHeight>o){const[e,t]=[s,i];e.after(c()),t.childElementCount>1&&i.append(t.lastElementChild)}i.append(e),p(e)}function p(e,t,n,a){if(s.scrollHeight<=o)return;const r=a||s,l=e.cloneNode();if(t?t.append(l):(i.append(l),r.after(c()),i.append(e)),"DIV"===e.tagName&&1===e.childElementCount&&p(e.firstElementChild,l,e,r),["UL","BLOCKQUOTE"].indexOf(e.tagName)>-1&&e.childElementCount>1)for(;;){const t=e.firstChild;if(!t)break;if(l.append(t),r.scrollHeight>o){e.insertBefore(t,e.firstChild);break}}l.lastChild||l.remove(),p(t?n:e)}function g(e){return e&&(e.dataset.shortTitle||e.innerText)}const h=g(t("h1.title, .frontmatter h1, .title, h1")),u=(r?"h1":"h2")+":not(.frontmatter *)",m=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));function b(){const a=e.body.classList;if(a.contains("pagesjs"))return;a.add("pagesjs"),r&&a.add("page-book"),e.body.insertAdjacentElement("afterbegin",c()),o=s.clientHeight||window.innerHeight,n(":is(#TOC, .footnotes):is(.side-left, .side-right).side").forEach((e=>{e.classList.remove("side","side-left","side-right")})),a.add("pagesjs-filling"),n(".frontmatter, #TOC, .abstract").forEach((e=>(f(e),r&&s.after(c())))),n(".body").forEach((e=>{l=["chapter","appendix"].filter((t=>e.classList.contains(t))),c(s),r&&""!==s.innerText&&s.after(c()),[...e.children].map(f),d(e.parentNode),d(e)})),a.remove("pagesjs-filling");const i=t("#TOC");n('a[href^="#"]',i).forEach((t=>{const n=e.createElement("span"),a=t.firstElementChild;for(a?.classList.contains("section-number")?a.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));let p,b=0;n(".pagesjs-page").forEach((e=>{if(d(e))return;r&&t(u,e)&&(p="");const a=function(e){let t=+e.dataset.pagesOffset;if(t)return t;const a=e.scrollHeight;if(t=Math.ceil(a/o),t<=1)return t;const r=m.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!r)return t;function s(){return Math.ceil((a+(t-1)*r)/o)}let i=s();for(;i>t;)t=i,i=s();return t}(e);a>1&&e.classList.add("page-multiple"),b+=a;const s={pageNumber:b,mainTitle:h,pageTitle:p};let i;[e.children[0],e.children[2]].forEach((e=>{for(const t in s)s[t]&&(e.dataset[t]=s[t])})),p=g([...n(u,e)].pop())||p,n(".footnotes",e).forEach(((t,n)=>{0===n?(i=t,e.children[1].after(t)):(i.append(...t.children),t.remove())}))})),n('a[href^="#"]',i).forEach((e=>{const n=t(`.pagesjs-page:has(${e.getAttribute("href")}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}))}addEventListener("beforeprint",b);let E=sessionStorage.getItem("pagesjs");E&&b(),addEventListener("keypress",(e=>"p"===e.key&&(b(),E=E?"":"1",sessionStorage.setItem("pagesjs",E),E||location.reload())))})(document); | ||
(e=>{function t(t,n=e){return n?.querySelector(t)}function n(t,n=e){return n?n.querySelectorAll(t):[]}const a=e.createElement("div"),r=n("h1").length>1;a.className="pagesjs-page",a.innerHTML='<div class="pagesjs-header"></div>\n<div class="pagesjs-body"></div>\n<div class="pagesjs-footer"></div>';let s,i,o,l=[];function c(e){return e&&!t(".pagesjs-body",e)&&e.insertAdjacentHTML("afterbegin",a.innerHTML),s=e||a.cloneNode(!0),i=s.children[1],l.length&&s.classList.add(...l),s}function d(e){if(!e)return!1;const t=""===e.innerText.trim();return t&&e.remove(),t}function f(e){if(e.classList.contains("pagesjs-page"))return s.after(c(e)),void(e.childElementCount>3&&(i.append(...[...e.children].slice(3)),s.after(c())));if(s.scrollHeight>o){const[e,t]=[s,i];e.after(c()),t.childElementCount>1&&i.append(t.lastElementChild)}i.append(e),p(e)}function p(e,t,n,a){if(s.scrollHeight<=o)return;const r=a||s,l=e.cloneNode();if(t?t.append(l):(i.append(l),r.after(c()),i.append(e)),"DIV"===e.tagName&&1===e.childElementCount&&p(e.firstElementChild,l,e,r),["UL","BLOCKQUOTE"].indexOf(e.tagName)>-1&&e.childElementCount>1)for(;;){const t=e.firstChild;if(!t)break;if(l.append(t),r.scrollHeight>o){e.insertBefore(t,e.firstChild);break}}l.lastChild||l.remove(),p(t?n:e)}function h(e){return e&&(e.dataset.shortTitle||e.innerText)}const g=h(t("h1.title, .frontmatter h1, .title, h1")),u=(r?"h1":"h2")+":not(.frontmatter *)",m=["top","bottom"].map((t=>+getComputedStyle(e.documentElement).getPropertyValue(`--paper-margin-${t}`).replace("px","")||0));function b(){const a=e.body.classList;if(a.contains("pagesjs"))return;a.add("pagesjs"),r&&a.add("page-book"),e.body.insertAdjacentElement("afterbegin",c()),o=s.clientHeight||window.innerHeight,n(":is(#TOC, .footnotes, .chapter-before, .chapter-after):is(.side-left, .side-right).side").forEach((e=>{e.classList.remove("side","side-left","side-right")})),a.add("pagesjs-filling"),n(".frontmatter, #TOC, .abstract").forEach((e=>(f(e),r&&s.after(c())))),n(".body").forEach((e=>{l=["chapter","appendix"].filter((t=>e.classList.contains(t))),c(s),r&&""!==s.innerText&&s.after(c()),[...e.children].map(f),d(e.parentNode),d(e)})),a.remove("pagesjs-filling");const i=t("#TOC");n('a[href^="#"]',i).forEach((t=>{const n=e.createElement("span"),a=t.firstElementChild;for(a?.classList.contains("section-number")?a.after(n):t.insertAdjacentElement("afterbegin",n);n.nextSibling;)n.append(n.nextSibling);t.insertAdjacentHTML("beforeend",'<span class="dot-leader"></span>'),t.dataset.pageNumber="000"}));let p,b=0;n(".pagesjs-page").forEach((e=>{if(d(e))return;r&&t(u,e)&&(p="");const a=function(e){let t=+e.dataset.pagesOffset;if(t)return t;const a=e.scrollHeight;if(t=Math.ceil(a/o),t<=1)return t;const r=m.concat([...n("thead",e)].map((e=>+e.offsetHeight))).reduce(((e,t)=>e+t));if(!r)return t;function s(){return Math.ceil((a+(t-1)*r)/o)}let i=s();for(;i>t;)t=i,i=s();return t}(e);a>1&&e.classList.add("page-multiple"),b+=a;const s={pageNumber:b,mainTitle:g,pageTitle:p};let i;[e.children[0],e.children[2]].forEach((e=>{for(const t in s)s[t]&&(e.dataset[t]=s[t])})),p=h([...n(u,e)].pop())||p,n(".footnotes",e).forEach(((t,n)=>{0===n?(i=t,e.children[1].after(t)):(i.append(...t.children),t.remove())}))})),n('a[href^="#"]',i).forEach((e=>{const n=t(`.pagesjs-page:has(${e.getAttribute("href")}) .pagesjs-header`);e.dataset.pageNumber=n?n.dataset.pageNumber:""}))}addEventListener("beforeprint",b);let E=sessionStorage.getItem("pagesjs");E&&b(),addEventListener("keypress",(e=>"p"===e.key&&(b(),E=E?"":"1",sessionStorage.setItem("pagesjs",E),E||location.reload())))})(document); |
{ | ||
"name": "@xiee/utils", | ||
"version": "1.13.11", | ||
"version": "1.13.12", | ||
"description": "Miscellaneous tools and utilities to manipulate HTML pages", | ||
@@ -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
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
207579
2362