Comparing version 4.31.0 to 4.32.0
@@ -463,6 +463,7 @@ /******/ (() => { // webpackBootstrap | ||
// scrolling an outer element (like a nav panel w/ search) containing the toc. | ||
// Please pass an element, not a selector here. | ||
tocScrollingWrapper: null, | ||
// Offset for the toc scroll (top) position when scrolling the page. | ||
// Only effective if `disableTocScrollSync` is false. | ||
tocScrollOffset: 0, | ||
tocScrollOffset: 30, | ||
// Enable the URL hash to update with the proper heading ID as | ||
@@ -1083,3 +1084,3 @@ // a user scrolls the page. | ||
/* harmony export */ }); | ||
const SCROLL_LEEWAY = 30 | ||
function updateTocScroll (options) { | ||
@@ -1090,18 +1091,9 @@ const toc = options.tocScrollingWrapper || options.tocElement || document.querySelector(options.tocSelector) | ||
if (activeItem) { | ||
// Determine container top and bottom | ||
const cTop = toc.scrollTop | ||
const cBottom = cTop + toc.clientHeight | ||
// Determine element top and bottom | ||
const eTop = activeItem.offsetTop | ||
const eBottom = eTop + activeItem.clientHeight | ||
// Check if out of view | ||
// Above scroll view | ||
if (eTop < cTop + options.tocScrollOffset) { | ||
toc.scrollTop -= (cTop - eTop) + options.tocScrollOffset | ||
// Below scroll view | ||
} else if (eBottom > cBottom - options.tocScrollOffset - SCROLL_LEEWAY) { | ||
toc.scrollTop += (eBottom - cBottom) + options.tocScrollOffset + (2 * SCROLL_LEEWAY) | ||
} | ||
const scrollAmount = eTop - options.tocScrollOffset | ||
toc.scrollTop = scrollAmount > 0 ? scrollAmount : 0 | ||
} | ||
@@ -1108,0 +1100,0 @@ } |
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";var e={d:(t,n)=>{for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){const t=[].forEach,n=[].some,l="undefined"!=typeof window&&document.body,o=" ";let s,r=!0;function i(n,l){const s=l.appendChild(function(n){const l=document.createElement("li"),s=document.createElement("a");return e.listItemClass&&l.setAttribute("class",e.listItemClass),e.onClick&&(s.onclick=e.onClick),e.includeTitleTags&&s.setAttribute("title",n.textContent),e.includeHtml&&n.childNodes.length?t.call(n.childNodes,(e=>{s.appendChild(e.cloneNode(!0))})):s.textContent=n.textContent,s.setAttribute("href",`${e.basePath}#${n.id}`),s.setAttribute("class",`${e.linkClass+o}node-name--${n.nodeName} ${e.extraLinkClasses}`),l.appendChild(s),l}(n));if(n.children.length){const e=c(n.isCollapsed);n.children.forEach((t=>{i(t,e)})),s.appendChild(e)}}function c(t){const n=e.orderedList?"ol":"ul",l=document.createElement(n);let s=e.listClass+o+e.extraListClasses;return t&&(s=s+o+e.collapsibleClass,s=s+o+e.isCollapsedClass),l.setAttribute("class",s),l}function a(t){let n=0;return null!==t&&(n=t.offsetTop,e.hasInnerContainers&&(n+=a(t.offsetParent))),n}function d(e,t){return e&&e.className!==t&&(e.className=t),e}function u(t){return t&&-1!==t.className.indexOf(e.collapsibleClass)&&-1!==t.className.indexOf(e.isCollapsedClass)?(d(t,t.className.replace(o+e.isCollapsedClass,"")),u(t.parentNode.parentNode)):t}function f(){let t;return t=e.scrollContainer&&document.querySelector(e.scrollContainer)?document.querySelector(e.scrollContainer).scrollTop:document.documentElement.scrollTop||l.scrollTop,t}function m(t,l=f()){let o;return n.call(t,((n,s)=>a(n)>l+e.headingsOffset+10?(o=t[0===s?s:s-1],!0):s===t.length-1?(o=t[t.length-1],!0):void 0)),o}return{enableTocAnimation:function(){r=!0},disableTocAnimation:function(t){const n=t.target||t.srcElement;"string"==typeof n.className&&-1!==n.className.indexOf(e.linkClass)&&(r=!1)},render:function(e,t){const n=c(!1);if(t.forEach((e=>{i(e,n)})),s=e||s,null!==s)return s.firstChild&&s.removeChild(s.firstChild),0===t.length?s:s.appendChild(n)},updateToc:function(n){e.positionFixedSelector&&function(){const t=f(),n=document.querySelector(e.positionFixedSelector);"auto"===e.fixedSidebarOffset&&(e.fixedSidebarOffset=s.offsetTop),t>e.fixedSidebarOffset?-1===n.className.indexOf(e.positionFixedClass)&&(n.className+=o+e.positionFixedClass):n.className=n.className.replace(o+e.positionFixedClass,"")}();const l=n;if(r&&s&&l.length>0){const n=m(l),r=s.querySelector(`.${e.activeLinkClass}`),i=s.querySelector(`.${e.linkClass}.node-name--${n.nodeName}[href="${e.basePath}#${n.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/\\@])/g,"\\$1")}"]`);if(r===i)return;const c=s.querySelectorAll(`.${e.linkClass}`);t.call(c,(t=>{d(t,t.className.replace(o+e.activeLinkClass,""))}));const a=s.querySelectorAll(`.${e.listItemClass}`);t.call(a,(t=>{d(t,t.className.replace(o+e.activeListItemClass,""))})),i&&-1===i.className.indexOf(e.activeLinkClass)&&(i.className+=o+e.activeLinkClass);const f=i?.parentNode;f&&-1===f.className.indexOf(e.activeListItemClass)&&(f.className+=o+e.activeListItemClass);const h=s.querySelectorAll(`.${e.listClass}.${e.collapsibleClass}`);t.call(h,(t=>{-1===t.className.indexOf(e.isCollapsedClass)&&(t.className+=o+e.isCollapsedClass)})),i?.nextSibling&&-1!==i.nextSibling.className.indexOf(e.isCollapsedClass)&&d(i.nextSibling,i.nextSibling.className.replace(o+e.isCollapsedClass,"")),u(i?.parentNode.parentNode)}},getCurrentlyHighlighting:function(){return r},getTopHeader:m,getScrollTop:f,updateUrlHashForHeader:function(e){const t=f(),n=m(e,t);if(!n||t<5)"#"!==window.location.hash&&""!==window.location.hash&&window.history.pushState(null,null,"#");else if(n){const e=`#${n.id}`;window.location.hash!==e&&window.history.pushState(null,null,e)}}}}e.r(t),e.d(t,{_buildHtml:()=>s,_headingsArray:()=>i,_options:()=>d,_parseContent:()=>r,_scrollListener:()=>c,default:()=>g,destroy:()=>f,init:()=>u,refresh:()=>m});const l={tocSelector:".js-toc",tocElement:null,contentSelector:".js-toc-content",contentElement:null,headingSelector:"h1, h2, h3",ignoreSelector:".js-toc-ignore",hasInnerContainers:!1,linkClass:"toc-link",extraLinkClasses:"",activeLinkClass:"is-active-link",listClass:"toc-list",extraListClasses:"",isCollapsedClass:"is-collapsed",collapsibleClass:"is-collapsible",listItemClass:"toc-list-item",activeListItemClass:"is-active-li",collapseDepth:0,scrollSmooth:!0,scrollSmoothDuration:420,scrollSmoothOffset:0,scrollEndCallback:function(e){},headingsOffset:1,throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1,includeTitleTags:!1,onClick:function(e){},orderedList:!0,scrollContainer:null,skipRendering:!1,headingLabelCallback:!1,ignoreHiddenElements:!1,headingObjectCallback:null,basePath:"",disableTocScrollSync:!1,tocScrollingWrapper:null,tocScrollOffset:0,enableUrlHashUpdateOnScroll:!1};function o(e){var t=e.duration,n=e.offset;if("undefined"!=typeof window&&"undefined"!=typeof location){var l=location.hash?o(location.href):location.href;document.body.addEventListener("click",(function(s){var r;"a"!==(r=s.target).tagName.toLowerCase()||!(r.hash.length>0||"#"===r.href.charAt(r.href.length-1))||o(r.href)!==l&&o(r.href)+"#"!==l||s.target.className.indexOf("no-smooth-scroll")>-1||"#"===s.target.href.charAt(s.target.href.length-2)&&"!"===s.target.href.charAt(s.target.href.length-1)||-1===s.target.className.indexOf(e.linkClass)||function(e,t){var n,l,o=window.pageYOffset,s={duration:t.duration,offset:t.offset||0,callback:t.callback,easing:t.easing||function(e,t,n,l){return(e/=l/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}},r=document.querySelector('[id="'+decodeURI(e).split("#").join("")+'"]')||document.querySelector('[id="'+e.split("#").join("")+'"]'),i="string"==typeof e?s.offset+(e?r&&r.getBoundingClientRect().top||0:-(document.documentElement.scrollTop||document.body.scrollTop)):e,c="function"==typeof s.duration?s.duration(i):s.duration;function a(e){l=e-n,window.scrollTo(0,s.easing(l,o,i,c)),l<c?requestAnimationFrame(a):(window.scrollTo(0,o+i),"function"==typeof s.callback&&s.callback())}requestAnimationFrame((function(e){n=e,a(e)}))}(s.target.hash,{duration:t,offset:n,callback:function(){var e,t;e=s.target.hash,(t=document.getElementById(e.substring(1)))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())}})}),!1)}function o(e){return e.slice(0,e.lastIndexOf("#"))}}let s,r,i,c,a,d={};function u(e){d=function(...e){const t={};for(let n=0;n<e.length;n++){const l=e[n];for(const e in l)h.call(l,e)&&(t[e]=l[e])}return t}(l,e||{}),d.scrollSmooth&&(d.duration=d.scrollSmoothDuration,d.offset=d.scrollSmoothOffset,o(d)),s=n(d),r=function(e){const t=[].reduce;function n(e){return e[e.length-1]}function l(e){return+e.nodeName.toUpperCase().replace("H","")}function o(t){if(!function(e){try{return e instanceof window.HTMLElement||e instanceof window.parent.HTMLElement}catch(t){return e instanceof window.HTMLElement}}(t))return t;if(e.ignoreHiddenElements&&(!t.offsetHeight||!t.offsetParent))return null;const n=t.getAttribute("data-heading-label")||(e.headingLabelCallback?String(e.headingLabelCallback(t.innerText)):(t.innerText||t.textContent).trim()),o={id:t.id,children:[],nodeName:t.nodeName,headingLevel:l(t),textContent:n};return e.includeHtml&&(o.childNodes=t.childNodes),e.headingObjectCallback?e.headingObjectCallback(o,t):o}return{nestHeadingsArray:function(l){return t.call(l,(function(t,l){const s=o(l);return s&&function(t,l){const s=o(t),r=s.headingLevel;let i=l,c=n(i),a=r-(c?c.headingLevel:0);for(;a>0&&(c=n(i),!c||r!==c.headingLevel);)c&&void 0!==c.children&&(i=c.children),a--;r>=e.collapseDepth&&(s.isCollapsed=!0),i.push(s)}(s,t.nest),t}),{nest:[]})},selectHeadings:function(t,n){let l=n;e.ignoreSelector&&(l=n.split(",").map((function(t){return`${t.trim()}:not(${e.ignoreSelector})`})));try{return t.querySelectorAll(l)}catch(e){return console.warn(`Headers not found with selector: ${l}`),null}}}}(d),f();const t=function(e){try{return e.contentElement||document.querySelector(e.contentSelector)}catch(t){return console.warn(`Contents element not found: ${e.contentSelector}`),null}}(d);if(null===t)return;const u=C(d);if(null===u)return;if(i=r.selectHeadings(t,d.headingSelector),null===i)return;const m=r.nestHeadingsArray(i).nest;if(d.skipRendering)return this;s.render(u,m),c=p((e=>{s.updateToc(i),!d.disableTocScrollSync&&function(e){const t=e.tocScrollingWrapper||e.tocElement||document.querySelector(e.tocSelector);if(t&&t.scrollHeight>t.clientHeight){const n=t.querySelector(`.${e.activeListItemClass}`);if(n){const l=t.scrollTop,o=l+t.clientHeight,s=n.offsetTop,r=s+n.clientHeight;s<l+e.tocScrollOffset?t.scrollTop-=l-s+e.tocScrollOffset:r>o-e.tocScrollOffset-30&&(t.scrollTop+=r-o+e.tocScrollOffset+60)}}}(d),d.enableUrlHashUpdateOnScroll&&s.getCurrentlyHighlighting()&&s.updateUrlHashForHeader(i);const t=e?.target?.scrollingElement&&0===e.target.scrollingElement.scrollTop;(e&&(0===e.eventPhase||null===e.currentTarget)||t)&&(s.updateToc(i),d.scrollEndCallback&&d.scrollEndCallback(e))}),d.throttleTimeout),c(),d.scrollContainer&&document.querySelector(d.scrollContainer)?(document.querySelector(d.scrollContainer).addEventListener("scroll",c,!1),document.querySelector(d.scrollContainer).addEventListener("resize",c,!1)):(document.addEventListener("scroll",c,!1),document.addEventListener("resize",c,!1));let g=null;a=p((e=>{d.scrollSmooth&&s.disableTocAnimation(e),s.updateToc(i),g&&clearTimeout(g),g=setTimeout((()=>{s.enableTocAnimation()}),d.scrollSmoothDuration)}),d.throttleTimeout),d.scrollContainer&&document.querySelector(d.scrollContainer)?document.querySelector(d.scrollContainer).addEventListener("click",a,!1):document.addEventListener("click",a,!1)}function f(){const e=C(d);null!==e&&(d.skipRendering||e&&(e.innerHTML=""),d.scrollContainer&&document.querySelector(d.scrollContainer)?(document.querySelector(d.scrollContainer).removeEventListener("scroll",c,!1),document.querySelector(d.scrollContainer).removeEventListener("resize",c,!1),s&&document.querySelector(d.scrollContainer).removeEventListener("click",a,!1)):(document.removeEventListener("scroll",c,!1),document.removeEventListener("resize",c,!1),s&&document.removeEventListener("click",a,!1)))}function m(e){f(),u(e||d)}const h=Object.prototype.hasOwnProperty;function p(e,t,n){let l,o;return t||(t=250),function(...s){const r=n||this,i=+new Date;l&&i<l+t?(clearTimeout(o),o=setTimeout((()=>{l=i,e.apply(r,s)}),t)):(l=i,e.apply(r,s))}}function C(e){try{return e.tocElement||document.querySelector(e.tocSelector)}catch(t){return console.warn(`TOC element not found: ${e.tocSelector}`),null}}const g={_options:d,_buildHtml:s,_parseContent:r,init:u,destroy:f,refresh:m};var S,b;S="undefined"!=typeof global?global:window||global,b=function(e){const n=!!(e&&e.document&&e.document.querySelector&&e.addEventListener);if("undefined"!=typeof window||n)return e.tocbot=t,t},"function"==typeof define&&define.amd?define([],b(S)):"object"==typeof exports?module.exports=b(S):S.tocbot=b(S)})(); | ||
(()=>{"use strict";var e={d:(t,n)=>{for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){const t=[].forEach,n=[].some,l="undefined"!=typeof window&&document.body,o=" ";let s,r=!0;function i(n,l){const s=l.appendChild(function(n){const l=document.createElement("li"),s=document.createElement("a");return e.listItemClass&&l.setAttribute("class",e.listItemClass),e.onClick&&(s.onclick=e.onClick),e.includeTitleTags&&s.setAttribute("title",n.textContent),e.includeHtml&&n.childNodes.length?t.call(n.childNodes,(e=>{s.appendChild(e.cloneNode(!0))})):s.textContent=n.textContent,s.setAttribute("href",`${e.basePath}#${n.id}`),s.setAttribute("class",`${e.linkClass+o}node-name--${n.nodeName} ${e.extraLinkClasses}`),l.appendChild(s),l}(n));if(n.children.length){const e=c(n.isCollapsed);n.children.forEach((t=>{i(t,e)})),s.appendChild(e)}}function c(t){const n=e.orderedList?"ol":"ul",l=document.createElement(n);let s=e.listClass+o+e.extraListClasses;return t&&(s=s+o+e.collapsibleClass,s=s+o+e.isCollapsedClass),l.setAttribute("class",s),l}function a(t){let n=0;return null!==t&&(n=t.offsetTop,e.hasInnerContainers&&(n+=a(t.offsetParent))),n}function d(e,t){return e&&e.className!==t&&(e.className=t),e}function u(t){return t&&-1!==t.className.indexOf(e.collapsibleClass)&&-1!==t.className.indexOf(e.isCollapsedClass)?(d(t,t.className.replace(o+e.isCollapsedClass,"")),u(t.parentNode.parentNode)):t}function f(){let t;return t=e.scrollContainer&&document.querySelector(e.scrollContainer)?document.querySelector(e.scrollContainer).scrollTop:document.documentElement.scrollTop||l.scrollTop,t}function m(t,l=f()){let o;return n.call(t,((n,s)=>a(n)>l+e.headingsOffset+10?(o=t[0===s?s:s-1],!0):s===t.length-1?(o=t[t.length-1],!0):void 0)),o}return{enableTocAnimation:function(){r=!0},disableTocAnimation:function(t){const n=t.target||t.srcElement;"string"==typeof n.className&&-1!==n.className.indexOf(e.linkClass)&&(r=!1)},render:function(e,t){const n=c(!1);if(t.forEach((e=>{i(e,n)})),s=e||s,null!==s)return s.firstChild&&s.removeChild(s.firstChild),0===t.length?s:s.appendChild(n)},updateToc:function(n){e.positionFixedSelector&&function(){const t=f(),n=document.querySelector(e.positionFixedSelector);"auto"===e.fixedSidebarOffset&&(e.fixedSidebarOffset=s.offsetTop),t>e.fixedSidebarOffset?-1===n.className.indexOf(e.positionFixedClass)&&(n.className+=o+e.positionFixedClass):n.className=n.className.replace(o+e.positionFixedClass,"")}();const l=n;if(r&&s&&l.length>0){const n=m(l),r=s.querySelector(`.${e.activeLinkClass}`),i=s.querySelector(`.${e.linkClass}.node-name--${n.nodeName}[href="${e.basePath}#${n.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/\\@])/g,"\\$1")}"]`);if(r===i)return;const c=s.querySelectorAll(`.${e.linkClass}`);t.call(c,(t=>{d(t,t.className.replace(o+e.activeLinkClass,""))}));const a=s.querySelectorAll(`.${e.listItemClass}`);t.call(a,(t=>{d(t,t.className.replace(o+e.activeListItemClass,""))})),i&&-1===i.className.indexOf(e.activeLinkClass)&&(i.className+=o+e.activeLinkClass);const f=i?.parentNode;f&&-1===f.className.indexOf(e.activeListItemClass)&&(f.className+=o+e.activeListItemClass);const h=s.querySelectorAll(`.${e.listClass}.${e.collapsibleClass}`);t.call(h,(t=>{-1===t.className.indexOf(e.isCollapsedClass)&&(t.className+=o+e.isCollapsedClass)})),i?.nextSibling&&-1!==i.nextSibling.className.indexOf(e.isCollapsedClass)&&d(i.nextSibling,i.nextSibling.className.replace(o+e.isCollapsedClass,"")),u(i?.parentNode.parentNode)}},getCurrentlyHighlighting:function(){return r},getTopHeader:m,getScrollTop:f,updateUrlHashForHeader:function(e){const t=f(),n=m(e,t);if(!n||t<5)"#"!==window.location.hash&&""!==window.location.hash&&window.history.pushState(null,null,"#");else if(n){const e=`#${n.id}`;window.location.hash!==e&&window.history.pushState(null,null,e)}}}}e.r(t),e.d(t,{_buildHtml:()=>s,_headingsArray:()=>i,_options:()=>d,_parseContent:()=>r,_scrollListener:()=>c,default:()=>g,destroy:()=>f,init:()=>u,refresh:()=>m});const l={tocSelector:".js-toc",tocElement:null,contentSelector:".js-toc-content",contentElement:null,headingSelector:"h1, h2, h3",ignoreSelector:".js-toc-ignore",hasInnerContainers:!1,linkClass:"toc-link",extraLinkClasses:"",activeLinkClass:"is-active-link",listClass:"toc-list",extraListClasses:"",isCollapsedClass:"is-collapsed",collapsibleClass:"is-collapsible",listItemClass:"toc-list-item",activeListItemClass:"is-active-li",collapseDepth:0,scrollSmooth:!0,scrollSmoothDuration:420,scrollSmoothOffset:0,scrollEndCallback:function(e){},headingsOffset:1,throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1,includeTitleTags:!1,onClick:function(e){},orderedList:!0,scrollContainer:null,skipRendering:!1,headingLabelCallback:!1,ignoreHiddenElements:!1,headingObjectCallback:null,basePath:"",disableTocScrollSync:!1,tocScrollingWrapper:null,tocScrollOffset:30,enableUrlHashUpdateOnScroll:!1};function o(e){var t=e.duration,n=e.offset;if("undefined"!=typeof window&&"undefined"!=typeof location){var l=location.hash?o(location.href):location.href;document.body.addEventListener("click",(function(s){var r;"a"!==(r=s.target).tagName.toLowerCase()||!(r.hash.length>0||"#"===r.href.charAt(r.href.length-1))||o(r.href)!==l&&o(r.href)+"#"!==l||s.target.className.indexOf("no-smooth-scroll")>-1||"#"===s.target.href.charAt(s.target.href.length-2)&&"!"===s.target.href.charAt(s.target.href.length-1)||-1===s.target.className.indexOf(e.linkClass)||function(e,t){var n,l,o=window.pageYOffset,s={duration:t.duration,offset:t.offset||0,callback:t.callback,easing:t.easing||function(e,t,n,l){return(e/=l/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}},r=document.querySelector('[id="'+decodeURI(e).split("#").join("")+'"]')||document.querySelector('[id="'+e.split("#").join("")+'"]'),i="string"==typeof e?s.offset+(e?r&&r.getBoundingClientRect().top||0:-(document.documentElement.scrollTop||document.body.scrollTop)):e,c="function"==typeof s.duration?s.duration(i):s.duration;function a(e){l=e-n,window.scrollTo(0,s.easing(l,o,i,c)),l<c?requestAnimationFrame(a):(window.scrollTo(0,o+i),"function"==typeof s.callback&&s.callback())}requestAnimationFrame((function(e){n=e,a(e)}))}(s.target.hash,{duration:t,offset:n,callback:function(){var e,t;e=s.target.hash,(t=document.getElementById(e.substring(1)))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())}})}),!1)}function o(e){return e.slice(0,e.lastIndexOf("#"))}}let s,r,i,c,a,d={};function u(e){d=function(...e){const t={};for(let n=0;n<e.length;n++){const l=e[n];for(const e in l)h.call(l,e)&&(t[e]=l[e])}return t}(l,e||{}),d.scrollSmooth&&(d.duration=d.scrollSmoothDuration,d.offset=d.scrollSmoothOffset,o(d)),s=n(d),r=function(e){const t=[].reduce;function n(e){return e[e.length-1]}function l(e){return+e.nodeName.toUpperCase().replace("H","")}function o(t){if(!function(e){try{return e instanceof window.HTMLElement||e instanceof window.parent.HTMLElement}catch(t){return e instanceof window.HTMLElement}}(t))return t;if(e.ignoreHiddenElements&&(!t.offsetHeight||!t.offsetParent))return null;const n=t.getAttribute("data-heading-label")||(e.headingLabelCallback?String(e.headingLabelCallback(t.innerText)):(t.innerText||t.textContent).trim()),o={id:t.id,children:[],nodeName:t.nodeName,headingLevel:l(t),textContent:n};return e.includeHtml&&(o.childNodes=t.childNodes),e.headingObjectCallback?e.headingObjectCallback(o,t):o}return{nestHeadingsArray:function(l){return t.call(l,(function(t,l){const s=o(l);return s&&function(t,l){const s=o(t),r=s.headingLevel;let i=l,c=n(i),a=r-(c?c.headingLevel:0);for(;a>0&&(c=n(i),!c||r!==c.headingLevel);)c&&void 0!==c.children&&(i=c.children),a--;r>=e.collapseDepth&&(s.isCollapsed=!0),i.push(s)}(s,t.nest),t}),{nest:[]})},selectHeadings:function(t,n){let l=n;e.ignoreSelector&&(l=n.split(",").map((function(t){return`${t.trim()}:not(${e.ignoreSelector})`})));try{return t.querySelectorAll(l)}catch(e){return console.warn(`Headers not found with selector: ${l}`),null}}}}(d),f();const t=function(e){try{return e.contentElement||document.querySelector(e.contentSelector)}catch(t){return console.warn(`Contents element not found: ${e.contentSelector}`),null}}(d);if(null===t)return;const u=C(d);if(null===u)return;if(i=r.selectHeadings(t,d.headingSelector),null===i)return;const m=r.nestHeadingsArray(i).nest;if(d.skipRendering)return this;s.render(u,m),c=p((e=>{s.updateToc(i),!d.disableTocScrollSync&&function(e){const t=e.tocScrollingWrapper||e.tocElement||document.querySelector(e.tocSelector);if(t&&t.scrollHeight>t.clientHeight){const n=t.querySelector(`.${e.activeListItemClass}`);if(n){const l=n.offsetTop-e.tocScrollOffset;t.scrollTop=l>0?l:0}}}(d),d.enableUrlHashUpdateOnScroll&&s.getCurrentlyHighlighting()&&s.updateUrlHashForHeader(i);const t=e?.target?.scrollingElement&&0===e.target.scrollingElement.scrollTop;(e&&(0===e.eventPhase||null===e.currentTarget)||t)&&(s.updateToc(i),d.scrollEndCallback&&d.scrollEndCallback(e))}),d.throttleTimeout),c(),d.scrollContainer&&document.querySelector(d.scrollContainer)?(document.querySelector(d.scrollContainer).addEventListener("scroll",c,!1),document.querySelector(d.scrollContainer).addEventListener("resize",c,!1)):(document.addEventListener("scroll",c,!1),document.addEventListener("resize",c,!1));let g=null;a=p((e=>{d.scrollSmooth&&s.disableTocAnimation(e),s.updateToc(i),g&&clearTimeout(g),g=setTimeout((()=>{s.enableTocAnimation()}),d.scrollSmoothDuration)}),d.throttleTimeout),d.scrollContainer&&document.querySelector(d.scrollContainer)?document.querySelector(d.scrollContainer).addEventListener("click",a,!1):document.addEventListener("click",a,!1)}function f(){const e=C(d);null!==e&&(d.skipRendering||e&&(e.innerHTML=""),d.scrollContainer&&document.querySelector(d.scrollContainer)?(document.querySelector(d.scrollContainer).removeEventListener("scroll",c,!1),document.querySelector(d.scrollContainer).removeEventListener("resize",c,!1),s&&document.querySelector(d.scrollContainer).removeEventListener("click",a,!1)):(document.removeEventListener("scroll",c,!1),document.removeEventListener("resize",c,!1),s&&document.removeEventListener("click",a,!1)))}function m(e){f(),u(e||d)}const h=Object.prototype.hasOwnProperty;function p(e,t,n){let l,o;return t||(t=250),function(...s){const r=n||this,i=+new Date;l&&i<l+t?(clearTimeout(o),o=setTimeout((()=>{l=i,e.apply(r,s)}),t)):(l=i,e.apply(r,s))}}function C(e){try{return e.tocElement||document.querySelector(e.tocSelector)}catch(t){return console.warn(`TOC element not found: ${e.tocSelector}`),null}}const g={_options:d,_buildHtml:s,_parseContent:r,init:u,destroy:f,refresh:m};var S,b;S="undefined"!=typeof global?global:window||global,b=function(e){const n=!!(e&&e.document&&e.document.querySelector&&e.addEventListener);if("undefined"!=typeof window||n)return e.tocbot=t,t},"function"==typeof define&&define.amd?define([],b(S)):"object"==typeof exports?module.exports=b(S):S.tocbot=b(S)})(); |
{ | ||
"name": "tocbot", | ||
"version": "4.31.0", | ||
"version": "4.32.0", | ||
"description": "Generate a table of contents based on the heading structure of a html document.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/tocbot.cjs", |
@@ -250,3 +250,3 @@ <h1 class="dn"> | ||
// Only effective if `disableTocScrollSync` is false. | ||
tocScrollOffset: 0, | ||
tocScrollOffset: 30, | ||
// Enable the URL hash to update with the proper heading ID as | ||
@@ -253,0 +253,0 @@ // a user scrolls the page. |
@@ -108,6 +108,7 @@ export default { | ||
// scrolling an outer element (like a nav panel w/ search) containing the toc. | ||
// Please pass an element, not a selector here. | ||
tocScrollingWrapper: null, | ||
// Offset for the toc scroll (top) position when scrolling the page. | ||
// Only effective if `disableTocScrollSync` is false. | ||
tocScrollOffset: 0, | ||
tocScrollOffset: 30, | ||
// Enable the URL hash to update with the proper heading ID as | ||
@@ -114,0 +115,0 @@ // a user scrolls the page. |
@@ -1,2 +0,2 @@ | ||
const SCROLL_LEEWAY = 30 | ||
export default function updateTocScroll (options) { | ||
@@ -7,20 +7,11 @@ const toc = options.tocScrollingWrapper || options.tocElement || document.querySelector(options.tocSelector) | ||
if (activeItem) { | ||
// Determine container top and bottom | ||
const cTop = toc.scrollTop | ||
const cBottom = cTop + toc.clientHeight | ||
// Determine element top and bottom | ||
const eTop = activeItem.offsetTop | ||
const eBottom = eTop + activeItem.clientHeight | ||
// Check if out of view | ||
// Above scroll view | ||
if (eTop < cTop + options.tocScrollOffset) { | ||
toc.scrollTop -= (cTop - eTop) + options.tocScrollOffset | ||
// Below scroll view | ||
} else if (eBottom > cBottom - options.tocScrollOffset - SCROLL_LEEWAY) { | ||
toc.scrollTop += (eBottom - cBottom) + options.tocScrollOffset + (2 * SCROLL_LEEWAY) | ||
} | ||
const scrollAmount = eTop - options.tocScrollOffset | ||
toc.scrollTop = scrollAmount > 0 ? scrollAmount : 0 | ||
} | ||
} | ||
} |
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
155647
3286
3