1 Star 0 Fork 34

/outline.js

forked from Yaohaixiao/outline.js 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
outline.min.js 39.89 KB
一键复制 编辑 原始数据 按行查看 历史
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Outline=e()}(this,(function(){"use strict";const t=t=>Object.prototype.toString.apply(t),e=e=>"function"==typeof e||"[object Function]"===t(e),s=(t,s=300)=>!!e(t)&&setTimeout((()=>{t()}),s),i=e=>Array.isArray?Array.isArray(e):"[object Array]"===t(e),r=t=>{let e;return null===t?null:(e=Object.assign({},t),Object.keys(e).forEach((s=>e[s]="object"==typeof t[s]?r(t[s]):t[s])),i(t)?(e.length=t.length,Array.from(e)):e)},l=t=>"string"==typeof t,n=s=>("[object Object]"===t(s)||"object"==typeof s||e(s))&&null!==s,o=t=>!!(n(t)&&t.nodeName&&t.tagName&&1===t.nodeType),h=(t,e)=>{const s=new RegExp("(\\s|^)"+e+"(\\s|$)");let i,r;return!!o(t)&&(i=t.className,!!i&&(r=t.classList,r?.contains?t.classList.contains(e):!!s.exec(i)))},a=(t,e)=>{let s,i;if(h(t,e))return!1;s=t.classList,s?.add?s.add(e):(i=t.className,i+=i.length>0?" "+e:e,t.className=i)},c=t=>!!l(t)&&t.replace(/(^\s+)|(\s+$)/g,""),d=(t,e)=>{let s,i=t.className;if(!i||!h(t,e))return!1;s=t.classList,s?.remove?s.remove(e):(i=c(i.replace(e,"")),t.className=i)},u=t=>t*t,p=(t=null)=>{let e,s;return t?l(t)?s=document.querySelector(t):o(t)&&(s=t):(e=document.querySelectorAll("html,body"),s=e[0].scrollTop-e[1].scrollTop>=0?e[0]:e[1]),s},m=(t,s,i)=>{const r=p(t);let l=r.scrollTop,n=0;const o=s-l,h=r.scrollHeight,a=s-h<=0?s:h,c=t=>(e(i)&&i(t),!1),d=()=>{if(n+=1,o<0){if(l-=u(n),r.scrollTop=l,l<=s)return r.scrollTop=s,c(s)}else if(l+=u(n),r.scrollTop=l,l>=a)return r.scrollTop=a,c(a);requestAnimationFrame(d)};requestAnimationFrame(d)},g=["focusout","blur","focusin","focus","load","unload","mouseenter","mouseleave"],f=(t,e,s)=>{const i=g.indexOf(e)>-1;s._delegateListener&&delete(s=s._delegateListener)._delegateListener,function(t,e,s){const i=t._listeners;let r=-1;if(i.length<1)return!1;i.forEach(((t,i)=>{const l=t.fn;e===t.type&&(r=i,l===s&&(r=i))})),r>-1&&i.splice(r,1)}(t,e,s),t.removeEventListener(e,s,i)},y=function(t,e,s=!1){const i=l(t)?document.querySelector(t):t,r=i.childNodes,n=((t,e)=>{let s=t._listeners||[];return l(e)&&e&&(s=s.filter((t=>t.type===e))),s})(i,e);n.forEach((t=>{f(i,t.type,t.fn)})),(s||!0===e||1===arguments.length)&&i&&r&&r.forEach((t=>{o(t)&&y(t,e,s)}))},b=(t,s,i)=>{if(!e(i))return y(t,s);f(t,s,i)},$=(t,s,i,r,l,n=!1)=>{const o=g.indexOf(s)>-1,h=function(e){let o=l||t;!0===l&&(o=r),!0===n&&b(t,s,h),i.call(o,e,r)};if(!e(i))return!1;t._listeners||(t._listeners=[]),t._listeners.push({el:t,type:s,fn:h,data:r,context:l,capture:o}),i._delegateListener=h,t.addEventListener(s,h,o)},v=(t,e="")=>{const s=e.replace(/^>/i,"");return!!(e&&s&&t)&&(t.matches?t.matches(s):!!t.msMatchesSelector&&t.msMatchesSelector(s))},_=t=>t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode,E=(t,e,s,i,r,l,n=!1)=>{const o=g.indexOf(s)>-1,h=function(o){const a=function(t){const e=t.target;return(s=e)&&3===s.nodeType?s.parentNode:s;var s}(o),c=((t,e,s,i)=>{const r=s||document;if(!t)return null;do{if(null!=e&&(e.startsWith(">")?t.parentNode===r&&v(t,e):v(t,e))||i&&t===r)return t;if(t===r)break}while(t=_(t))})(a,e,t);let d=l||t;o.delegateTarget=c,!0===l&&(d=r),c&&(!0===n&&b(t,s,h),i.call(d,o,r))};t._listeners||(t._listeners=[]),t._listeners.push({el:t,selector:e,type:s,fn:h,data:r,context:l,capture:o}),i._delegateListener=h,t.addEventListener(s,h,o)},w=function(t){t.stopPropagation(),t.preventDefault()},T=(t,e)=>{const s=Object.prototype.hasOwnProperty;return t&&s.call(t,e)},S={},x=t=>T(S,t)&&S[t].length>0,L=(t,e=!0)=>e?x(t):(t=>{let e=x(t),s=t.lastIndexOf(".");for(;!e&&-1!==s;)s=(t=t.substring(0,s)).lastIndexOf("."),e=x(t);return e})(t),C=(e,s,i=!0)=>{const r=e=>{if(!x(e))return!1;S[e].forEach((e=>{const i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]","[object BigInt64Array]","[object BigUint64Array]"].indexOf(t(s))>-1?s.toString():s;e.callback.call(e.context||e,i)}))},l=()=>{let t=e,s=e.lastIndexOf(".");for(;-1!==s;)t=t.substring(0,s),s=t.lastIndexOf("."),r(t);r(e),r("*")};if(!L(e))return!1;i?setTimeout(l,10):l()},z=(()=>{let t=0;return e=>(t+=1,e?e+"-"+t:"guid-"+t)})(),k=t=>{if(!T(S,t))return!1;delete S[t]},A=(t,e)=>{if(!L(t))return!1;e?(t=>{const e=Object.keys(S);if(!t||e.length<1)return!1;e.forEach((e=>{const s=S[e];let i;s.forEach(((e,r)=>{e.callback!==t&&e.token!==t||(i=e.topic,s.splice(-1,r))})),s.length<1&&k(i)}))})(e):k(t)};class N{constructor(t){this.attrs={},t&&this.initialize(t)}initialize(t){return this.attr(t).render().addListeners(),this}attr(t,e){const s=this.attrs;return l(t)?e&&T(s,t)?(s[t]=e,this):s[t]:n(t)?(i=s,r=t,Object.keys(r).forEach((t=>{T(r,t)&&(i[t]=r[t])})),this):0===arguments.length?s:this;var i,r}render(){return this}destroy(){return this.removeListeners(),this}reload(t){return this.destroy().initialize(this.attr(t)),this}$emit(t,e){return C(t,e),this}$on(t,s){return((t,s,i=null)=>{const r=z();let l="symbol"==typeof t?t.toString():t;e(s)&&(S[l]||(S[l]=[]),S[l].push({topic:l,callback:s,context:i,token:r}))})(t,s,this),this}$off(t,e){return A(t,e),this}addListeners(){return this}removeListeners(){return this}}const H=t=>{let e=t.offsetTop;return null!==t.offsetParent&&(e+=H(t.offsetParent)),e},M=['<symbol id="outline-icon-up" viewBox="0 0 1024 1024"><path d="M494.784 261.696c0.832-0.448 1.536-1.216 2.368-1.536a38.72 38.72 0 0 1 46.08 8.256l277.824 302.272a41.92 41.92 0 0 1-1.536 58.048 39.104 39.104 0 0 1-56.448-1.6L513.728 355.904 260.736 626.048a39.104 39.104 0 0 1-56.448 1.088 41.6 41.6 0 0 1-1.088-57.984L483.84 269.696c0.512-0.512 1.344-0.768 1.92-1.408l1.088-1.344c2.368-2.496 5.312-3.648 8-5.248z"></path></symbol>','<symbol id="outline-icon-down" viewBox="0 0 1024 1024"><path d="M494.784 762.304c0.832 0.448 1.536 1.216 2.368 1.536 15.232 7.488 33.92 4.992 46.08-8.256l277.824-302.272a41.92 41.92 0 0 0-1.536-58.048 39.104 39.104 0 0 0-56.448 1.6l-249.344 271.232-252.992-270.144a39.104 39.104 0 0 0-56.448-1.088 41.6 41.6 0 0 0-1.088 57.984l280.576 299.456c0.512 0.512 1.344 0.768 1.92 1.408l1.088 1.344c2.368 2.496 5.312 3.648 8 5.248z"></path></symbol>','<symbol id="outline-icon-menu" viewBox="0 0 1024 1024"><path d="M320 256h640V128H320zM320 576h640V448H320zM320 896h640v-128H320zM64 256h128V128H64zM64 576h128V448H64zM64 896h128v-128H64z"></path></symbol>','<symbol id="outline-icon-file" viewBox="0 0 1024 1024"><path d="M320 640h256v128H320z"></path><path d="M320 448h384v128H320z"></path><path d="M640 0l320 320v557.696C960 958.528 909.824 1024 848 1024H176C114.176 1024 64 958.528 64 877.696V146.304C64 65.472 114.176 0 176 0H640z m0 128H192v768h640V320h-192V128z"></path></symbol>','<symbol id="outline-icon-hash" viewBox="0 0 24 24"><path d="M14.216 10l-0.444 4h-3.988l0.444-4zM15.006 2.89l-0.568 5.11h-3.988l0.543-4.89c0.061-0.549-0.335-1.043-0.883-1.104s-1.043 0.335-1.104 0.884l-0.568 5.11h-4.438c-0.552 0-1 0.448-1 1s0.448 1 1 1h4.216l-0.444 4h-3.772c-0.552 0-1 0.448-1 1s0.448 1 1 1h3.549l-0.543 4.89c-0.061 0.549 0.335 1.043 0.883 1.104s1.043-0.335 1.104-0.883l0.569-5.111h3.988l-0.543 4.89c-0.061 0.549 0.335 1.043 0.883 1.104s1.043-0.335 1.104-0.883l0.568-5.111h4.438c0.552 0 1-0.448 1-1s-0.448-1-1-1h-4.216l0.444-4h3.772c0.552 0 1-0.448 1-1s-0.448-1-1-1h-3.549l0.543-4.89c0.061-0.549-0.335-1.043-0.883-1.104s-1.043 0.335-1.104 0.883z"></path></symbol>','<symbol id="outline-icon-close" viewBox="0 0 1024 1024"><path d="M536.96 491.648L310.592 265.344a32 32 0 1 0-45.248 45.248L491.584 536.96l-226.304 226.304a32 32 0 0 0 45.312 45.248l226.24-226.304 226.304 226.304a32 32 0 0 0 45.248-45.248L582.144 536.896l226.304-226.24a32 32 0 0 0-45.248-45.248L536.896 491.584z"></path></symbol>','<symbol id="outline-icon-homepage" viewBox="0 0 26 28"><path d="M22 15.5v7.5c0 0.547-0.453 1-1 1h-6v-6h-4v6h-6c-0.547 0-1-0.453-1-1v-7.5c0-0.031 0.016-0.063 0.016-0.094l8.984-7.406 8.984 7.406c0.016 0.031 0.016 0.063 0.016 0.094zM25.484 14.422l-0.969 1.156c-0.078 0.094-0.203 0.156-0.328 0.172h-0.047c-0.125 0-0.234-0.031-0.328-0.109l-10.813-9.016-10.813 9.016c-0.109 0.078-0.234 0.125-0.375 0.109-0.125-0.016-0.25-0.078-0.328-0.172l-0.969-1.156c-0.172-0.203-0.141-0.531 0.063-0.703l11.234-9.359c0.656-0.547 1.719-0.547 2.375 0l3.813 3.187v-3.047c0-0.281 0.219-0.5 0.5-0.5h3c0.281 0 0.5 0.219 0.5 0.5v6.375l3.422 2.844c0.203 0.172 0.234 0.5 0.063 0.703z"></path></symbol>','<symbol id="outline-icon-github" viewBox="0 0 24 28"><path d="M12 2c6.625 0 12 5.375 12 12 0 5.297-3.437 9.797-8.203 11.391-0.609 0.109-0.828-0.266-0.828-0.578 0-0.391 0.016-1.687 0.016-3.297 0-1.125-0.375-1.844-0.812-2.219 2.672-0.297 5.484-1.313 5.484-5.922 0-1.313-0.469-2.375-1.234-3.219 0.125-0.313 0.531-1.531-0.125-3.187-1-0.313-3.297 1.234-3.297 1.234-0.953-0.266-1.984-0.406-3-0.406s-2.047 0.141-3 0.406c0 0-2.297-1.547-3.297-1.234-0.656 1.656-0.25 2.875-0.125 3.187-0.766 0.844-1.234 1.906-1.234 3.219 0 4.594 2.797 5.625 5.469 5.922-0.344 0.313-0.656 0.844-0.766 1.609-0.688 0.313-2.438 0.844-3.484-1-0.656-1.141-1.844-1.234-1.844-1.234-1.172-0.016-0.078 0.734-0.078 0.734 0.781 0.359 1.328 1.75 1.328 1.75 0.703 2.141 4.047 1.422 4.047 1.422 0 1 0.016 1.937 0.016 2.234 0 0.313-0.219 0.688-0.828 0.578-4.766-1.594-8.203-6.094-8.203-11.391 0-6.625 5.375-12 12-12zM4.547 19.234c0.031-0.063-0.016-0.141-0.109-0.187-0.094-0.031-0.172-0.016-0.203 0.031-0.031 0.063 0.016 0.141 0.109 0.187 0.078 0.047 0.172 0.031 0.203-0.031zM5.031 19.766c0.063-0.047 0.047-0.156-0.031-0.25-0.078-0.078-0.187-0.109-0.25-0.047-0.063 0.047-0.047 0.156 0.031 0.25 0.078 0.078 0.187 0.109 0.25 0.047zM5.5 20.469c0.078-0.063 0.078-0.187 0-0.297-0.063-0.109-0.187-0.156-0.266-0.094-0.078 0.047-0.078 0.172 0 0.281s0.203 0.156 0.266 0.109zM6.156 21.125c0.063-0.063 0.031-0.203-0.063-0.297-0.109-0.109-0.25-0.125-0.313-0.047-0.078 0.063-0.047 0.203 0.063 0.297 0.109 0.109 0.25 0.125 0.313 0.047zM7.047 21.516c0.031-0.094-0.063-0.203-0.203-0.25-0.125-0.031-0.266 0.016-0.297 0.109s0.063 0.203 0.203 0.234c0.125 0.047 0.266 0 0.297-0.094zM8.031 21.594c0-0.109-0.125-0.187-0.266-0.172-0.141 0-0.25 0.078-0.25 0.172 0 0.109 0.109 0.187 0.266 0.172 0.141 0 0.25-0.078 0.25-0.172zM8.937 21.438c-0.016-0.094-0.141-0.156-0.281-0.141-0.141 0.031-0.234 0.125-0.219 0.234 0.016 0.094 0.141 0.156 0.281 0.125s0.234-0.125 0.219-0.219z"></path></symbol>','<symbol id="outline-icon-issues" viewBox="0 0 24 28"><path d="M25.5 15c0 0.547-0.453 1-1 1h-3.5c0 1.953-0.422 3.422-1.047 4.531l3.25 3.266c0.391 0.391 0.391 1.016 0 1.406-0.187 0.203-0.453 0.297-0.703 0.297s-0.516-0.094-0.703-0.297l-3.094-3.078s-2.047 1.875-4.703 1.875v-14h-2v14c-2.828 0-4.891-2.063-4.891-2.063l-2.859 3.234c-0.203 0.219-0.469 0.328-0.75 0.328-0.234 0-0.469-0.078-0.672-0.25-0.406-0.375-0.438-1-0.078-1.422l3.156-3.547c-0.547-1.078-0.906-2.469-0.906-4.281h-3.5c-0.547 0-1-0.453-1-1s0.453-1 1-1h3.5v-4.594l-2.703-2.703c-0.391-0.391-0.391-1.016 0-1.406s1.016-0.391 1.406 0l2.703 2.703h13.188l2.703-2.703c0.391-0.391 1.016-0.391 1.406 0s0.391 1.016 0 1.406l-2.703 2.703v4.594h3.5c0.547 0 1 0.453 1 1zM18 6h-10c0-2.766 2.234-5 5-5s5 2.234 5 5z"></path></symbol>','<symbol id="outline-icon-tags" viewBox="0 0 26 28"><path d="M7 7c0-1.109-0.891-2-2-2s-2 0.891-2 2 0.891 2 2 2 2-0.891 2-2zM23.672 16c0 0.531-0.219 1.047-0.578 1.406l-7.672 7.688c-0.375 0.359-0.891 0.578-1.422 0.578s-1.047-0.219-1.406-0.578l-11.172-11.188c-0.797-0.781-1.422-2.297-1.422-3.406v-6.5c0-1.094 0.906-2 2-2h6.5c1.109 0 2.625 0.625 3.422 1.422l11.172 11.156c0.359 0.375 0.578 0.891 0.578 1.422zM29.672 16c0 0.531-0.219 1.047-0.578 1.406l-7.672 7.688c-0.375 0.359-0.891 0.578-1.422 0.578-0.812 0-1.219-0.375-1.75-0.922l7.344-7.344c0.359-0.359 0.578-0.875 0.578-1.406s-0.219-1.047-0.578-1.422l-11.172-11.156c-0.797-0.797-2.312-1.422-3.422-1.422h3.5c1.109 0 2.625 0.625 3.422 1.422l11.172 11.156c0.359 0.375 0.578 0.891 0.578 1.422z"></path></symbol>'],O=(t,e="icon")=>l(t)?((t,e="icon")=>{const s=/id="(.*?)"/,i=/^(\w+)-/;return M.find((r=>{const l=s.exec(r)[1];return i.exec(l)[1]===e&&l===("icon"===e?`${e}-${t}`:`${e}-icon-${t}`)}))})(t,e):[...M],j=(t="")=>{const e=document.body;let s=document.querySelector("#outline-icons"),r=[];(t=>{if(!t)return!1;i(t)&&t.length>0?t.forEach((t=>{-1===M.indexOf(t)&&l(t)&&M.push(t)})):l(t)&&M.push(t)})(t),r=O(),s?s.innerHTML=r.join(""):(s=document.createElement("div"),s.innerHTML=`<svg id="outline-icons" aria-hidden="true" style="position:absolute;display:none;width:0;height:0;overflow:hidden;">${r.join("")}</svg>`,e.insertBefore(s.firstChild,e.firstChild))},D=e=>{return!(!n(e)||!(o(e)||(e=>!(!n(e)||"[object NodeList]"!==t(e)))(e)||(s=e,n(s)&&"[object DocumentFragment]"===t(s))||(e=>!(!n(e)||!("[object Text]"===t(e)||e.tagName&&3===e.nodeType)))(e)));var s},F=(t,e,s)=>{let i=t.tagName.toLowerCase();switch(e){case"style":t.style.cssText=s;break;case"value":"input"===i||"textarea"===i?t.value=s:t.setAttribute(e,s);break;case"className":t.className=s;break;default:t.setAttribute(e,s)}},q=(t,e,s)=>{const r=document.createDocumentFragment(),o=document.createElement(t),h=t=>D(t)||l(t),a=t=>{let e;if(!h(t))return!1;D(t)?e=t:l(t)&&(e=document.createTextNode(t)),r.appendChild(e)};return n(e)?Object.keys(e).forEach((t=>{T(e,t)&&F(o,t,e[t])})):i(e)&&e.every((t=>h(t)))&&e.forEach((t=>{a(t)})),i(s)?s.forEach((t=>{a(t)})):a(s),o.appendChild(r),o},U=t=>{const e=new RegExp("^\\s*(?:<\\?xml[^>]*>\\s*)?(?:<\\!doctype svg[^>]*\\s*(?:\\[?(?:\\s*<![^>]*>\\s*)*\\]?)*[^>]*>\\s*)?<svg[^>]*>[^]*<\\/svg>\\s*$\\s*$","i");return l(t)&&e.test(t)},R=(t,e={})=>((t,e={})=>{const s=e.size||0,r=e.color||"",n=e.iconSet||"",o=i(s)?s[0]:s,h=i(s)?s[1]:s,a=s?`width:${o}px;height:${h}px;`:"",c=r?a+`color:${r}`:a,d=document.createElement("i");let u,p="",m="";return l(t)?(U(t)?m=t:(p=n&&"icon"!==n?`xlink:href="#${n}-icon-${t}"`:`xlink:href="#icon-${t}"`,m=`<svg aria-hidden="true" class="outline-icon__svg" style="${c}"><use ${p}></use></svg>`),d.className="outline-icon",d.innerHTML=m,U(t)&&(u=d.querySelector("svg"),u.setAttribute("aria-hidden","true"),u.setAttribute("xmlns","http://www.w3.org/2000/svg"),u.setAttribute("class","outline-icon__svg"),u.setAttribute("width","200"),u.setAttribute("height","200"),u.style.cssText=c),d):null})(t,e),I=(t,e=!0,s=!0)=>{const i="outline-heading",r=t.innerHTML;let n;if(t.innerHTML=r.replace(/^\d+(\.?\d+)*\s?/gi,""),t.removeAttribute("id"),t.removeAttribute("data-id"),d(t,i),!e)return!1;var o;n=t.querySelector(`.${i}__anchor`),s&&d(t,`${i}_start`),o=c(t.className),l(o)&&""===o&&t.removeAttribute("class"),t.removeChild(n)},B=(t,s=!0,r=null)=>{let n=1,o=0,h="";const a=[];return t.forEach(((t,s)=>{const i=t.tagName,d=i.replace(/h/i,"");let u=parseInt(d,10),p=-1;var m;u>n?(o+=1,p=1===o?-1:s-1):u===n||u<n&&u>o?1===u?(o=1,p=-1):p=a[s-1].pid:u<=o&&(1===u?o=1:(o-=n-u,o<=1&&(o=1)),p=1===o?-1:((t,e,s)=>{let i,r,l=t[s-1];for(r=0;r<e;r+=1)i=l.pid,l=t[i];return i=l.pid,i})(a,n-u,s)),n=u,m=c(t.innerHTML),h=l(m)?m.replace(/<\/?[^>]+(>|$)/g,""):"",e(r)&&(h=r(h)),a.push({id:s,pid:p,level:o,rel:`heading-${s}`,text:h,tagName:i})})),s?(t=>{const e={};return t.forEach((t=>{const s=JSON.stringify((t=>[t.pid])(t));e[s]=e[s]||[],e[s].push(t),t.index=e[s].length,-1===t.pid&&(t.code=String(t.index))})),Object.keys(e).forEach((t=>{e[t].forEach((t=>{const s=e[`[${t.id}]`];if(!s||!i(s))return!1;s.forEach((e=>{e.code=t.code+"."+e.index}))}))})),t})(a):a};class P extends N{constructor(t){super(),this.attrs=P.DEFAULTS,this.$articleElement=null,this.$scrollElement=null,this.$headings=[],this.chapters=[],t&&this.initialize(t)}initialize(t){const s=this.attr("showCode")||!0;let i,r,n,h,a;return this.attr(t),a=this.attr("articleElement"),r=this.attr("scrollElement"),n=this.attr("selector"),i=this.attr("created"),l(a)?h=document.querySelector(a):o(a)&&(h=a),h?(this.$articleElement=h,this.$scrollElement=p(r),this.$headings=[...h.querySelectorAll(n)],this.$headings.length<1||(this.chapters=B(this.$headings,s,this.attr("chapterTextFilter")),e(i)&&i.call(this),this.render().addListeners()),this):this}getChapters(t=!1){const e=this.chapters;return t?((t,e,s)=>{const i={},r=[];return t.forEach(((t,s)=>{i[t[e]]=s,t.children=[]})),t.forEach((e=>{const l=t[i[e[s]]];-1!==e[s]?l.children.push(e):r.push(e)})),r})(e,"id","pid"):e}count(){return this.chapters.length}render(){const t=this.attr("mounted"),s=this.attr("hasAnchor"),i=this.attr("isAtStart"),r=this.attr("showCode"),l=this.attr("anchorURL"),n=this.$headings,o=this.getChapters();return j(),n.forEach(((t,e)=>{const n=o[e].code;((t,e,s)=>{const i="outline-heading",r=s.hasAnchor||!0,l=s.isAtStart||!0,n=s.showCode||!1,o=s.chapterCode||"",h=s.anchorURL||"",a=`heading-${e}`,d={id:a,className:l?`${i} ${i}_start`:i,"data-id":e},u=Object.keys(d),p=c(t.innerHTML);let m,g;if(u.forEach((e=>{F(t,e,d[e])})),n&&(t.innerHTML=o+" "+p),!r)return!1;g=R("hash",{iconSet:"outline"}),m=q("a",{id:`anchor-${e}`,className:`${i}__anchor anchor-${e}`,href:h||`#${a}`,target:h?"_blank":"self","data-id":e},g),t.appendChild(m)})(t,e,{hasAnchor:s,isAtStart:i,showCode:r,chapterCode:n,anchorURL:l})})),e(t)&&t.call(this),this}scrollTo(t,e){const s=this.$scrollElement;return m(s,t,e),this}destroy(){const t=this.attr("hasAnchor"),s=this.attr("isAtStart"),i=this.attr("beforeDestroy"),r=this.attr("afterDestroy"),l=this.$headings;return e(i)&&i.call(this),this.removeListeners(),l.forEach((e=>{I(e,t,s)})),this.attr(P.DEFAULTS),this.$articleElement=null,this.$scrollElement=null,this.$headings=[],this.chapters=[],e(r)&&r.call(this),this}onAnchorTrigger(t){const i=this.attr("anchorURL"),r=this.attr("afterScroll"),l=this.attr("stickyHeight"),n=t.delegateTarget.parentNode,o=H(n)-(l+10),h=this.$scrollElement,a=h.scrollHeight-h.clientHeight;return this.scrollTo(o,(()=>{e(r)&&r.call(this,"anchor"),s((()=>{this.$emit("toolbar:update",{top:o,min:0,max:a})}))})),i||w(t),this}addListeners(){const t=this.$articleElement;return E(t,".outline-heading__anchor","click",this.onAnchorTrigger,this,!0),this}removeListeners(){const t=this.$articleElement;return b(t,"click",this.onAnchorTrigger),this}}P.DEFAULTS={scrollElement:"html,body",articleElement:"#article",selector:"h1,h2,h3,h4,h5,h6",stickyHeight:0,anchorURL:"",hasAnchor:!0,isAtStart:!0,showCode:!1,created:null,mounted:null,afterScroll:null,beforeDestroy:null,afterDestroy:null,chapterTextFilter:null};const V=(t,e)=>{document.documentElement.style.setProperty(t,e)};let Q=2e3;const W=t=>(t?Q=t:Q+=1,V("--outline-zIndex",`${Q}`),Q);class J extends N{constructor(t){super(),this.attrs=r(J.DEFAULTS),this.title="",this.closed=!0,this.$el=null,this.$modal=null,this.$header=null,this.$title=null,this.$close=null,this.$main=null,this.$footer=null,this.$overlay=null,this.zIndex=0,t&&this.initialize(t)}initialize(t){let s;return this.attr(t),this.title=this.attr("title"),s=this.attr("created"),e(s)&&s.call(this),this.render().addListeners(),this}setTitle(t){return this.attr("title",t),this.title=t,this.$title.innerHTML=t,this}isClosed(){return this.closed}render(){const t=this.attr("mounted"),s=this.attr("size"),i=this.attr("placement"),r=this.attr("hasClose"),l=this.attr("hasOverlay"),n=this.attr("hasOffset"),o=this.attr("hasPadding"),h=this.attr("autoHeight"),c=this.attr("customClass");let d,u,p,m,g,f,y,b;return j(),this.zIndex=W(),m=q("h2",{className:"outline-drawer__title"},this.title),this.$title=m,r&&(g=q("div",{className:"outline-drawer__close"},R("close",{size:20})),this.$close=g),p=q("header",{className:"outline-drawer__header"},[m,g]),this.$header=p,f=q("div",{className:"outline-drawer__main"}),this.$main=f,o||a(f,"outline-drawer_full"),y=q("footer",{className:"outline-drawer__footer"}),this.$footer=y,u=q("div",{className:`outline-drawer__modal outline-drawer_${i} outline-drawer_${s} outline-drawer_closed`},[p,f,y]),this.$modal=u,n&&a(u,"outline-drawer_offset"),h&&a(u,"outline-drawer_auto"),c&&a(u,c),l&&(b=q("div",{className:"outline-drawer__overlay"}),this.$overlay=b),d=q("div",{className:"outline-drawer"},[u,b]),this.$el=d,document.body.appendChild(d),e(t)&&t.call(this),this}open(){const t=this.attr("afterOpened"),i=this.$modal;return a(this.$el,"outline-drawer_opened"),d(i,"outline-drawer_closed"),a(i,"outline-drawer_opened"),s((()=>{this.closed=!1,e(t)&&t.call(this)})),this}close(){const t=this.attr("afterClosed"),i=this.$modal;return d(i,"outline-drawer_opened"),a(i,"outline-drawer_closed"),s((()=>{d(this.$el,"outline-drawer_opened"),this.closed=!0,e(t)&&t.call(this)})),this}toggle(){const t=this.attr("afterToggle"),i=this.isClosed();return i?this.open():this.close(),e(t)&&s((()=>{t.call(this,i)})),this}destroy(){const t=this.attr("afterDestroy"),s=this.attr("beforeDestroy");let i=this.zIndex;return e(s)&&s.call(this),this.removeListeners(),this.attrs=J.DEFAULTS,this.title="",this.closed=!1,this.$el=null,this.$modal=null,this.$header=null,this.$title=null,this.$close=null,this.$main=null,this.$footer=null,this.$overlay=null,i-=1,W(i),this.zIndex=0,e(t)&&t.call(this),this}addListeners(){const t=this.attr("hasClose"),e=this.attr("hasOverlay"),s=this.$el;return t&&E(s,".outline-drawer__close","click",this.onClose,this,!0),e&&E(s,".outline-drawer__overlay","click",this.onClose,this,!0),this}removeListeners(){const t=this.attr("hasClose"),e=this.attr("hasOverlay"),s=this.$el;return t||e?(b(s,"click",this.onClose),this):this}onClose(){return this.close(),this}}J.DEFAULTS={placement:"rtl",title:"标题",size:"regular",hasClose:!0,hasOverlay:!0,hasOffset:!1,hasPadding:!0,autoHeight:!0,created:null,mounted:null,afterClosed:null,afterOpened:null,afterScroll:null,beforeDestroy:null,afterDestroy:null,afterToggle:null};const Y=(t,e)=>getComputedStyle(t)[e];class G extends N{constructor(t){super(),this.attrs=r(G.DEFAULTS),this._reset(),this.offsetWidth=0,this.playing=!1,this.scrollTimer=null,this.resizeTimer=null,this.Observer=null,t&&this.initialize(t)}_reset(){return this.$el=null,this.$title=null,this.$main=null,this.$list=null,this.$placeholder=null,this.$parentElement=null,this.$scrollElement=null,this.$active=null,this.chapters=[],this.active=0,this.offsetTop=0,this.closed=!1,this}initialize(t){let s,i,r,n;return this.attr(t),s=this.attr("created"),i=this.attr("parentElement"),r=this.attr("scrollElement"),l(i)?n=document.querySelector(i):o(i)&&(n=i),this.$parentElement=n,this.$scrollElement=p(r),this.chapters=this.attr("chapters"),this.closed=this.attr("closed"),this.active=this.attr("active"),e(s)&&s.call(this),this.chapters.length<1||(this.render().addListeners(),this.$active=document.querySelector(`#chapter-${this.active}`)),this}isClosed(){return this.closed}isSticky(){return"sticky"===this.attr("position")}isFixed(){return"fixed"===this.attr("position")}isInside(){return this.isFixed()||this.isSticky()}isOutside(){return!this.isInside()}_paintEdge(){const t=document.createDocumentFragment(),e=this.attr("title"),s=this.attr("customClass"),i=this.$parentElement,r=[];let l,n,o,h,c=null;return i?(this.isInside()&&e&&(c=q("h2",{className:"outline-chapters__title"},e),this.$title=c,r.push(c)),o=q("ul",{className:"outline-chapters__list"}),this.$list=o,h=q("div",{className:"outline-chapters__placeholder"}),this.$placeholder=h,n=q("div",{className:"outline-chapters__main"},[o,h]),this.$main=n,r.push(n),l=q("nav",{id:"outline-chapters",className:"outline-chapters outline-chapters_hidden"},r),this.$el=l,this.isSticky()&&(this.calculateStickyHeight(),a(l,"outline-chapters_sticky")),s&&a(l,s),t.appendChild(l),i.appendChild(t),this):this}render(){const t=this.attr("showCode"),s=this.attr("mounted"),i=this.$parentElement,r=this.chapters;let l,n;return!i||r.length<1||(this._paintEdge(),l=this.$el,n=this.$list,((t,e,s=!1)=>{const i=e=>t.querySelector(`#${e}`);e.forEach((e=>{const r=e.pid,l=e.id,n=e.rel,o=[],h=q("span",{className:"outline-chapters__text"},e.text);let a,c,d,u,p;s&&(c=q("span",{className:"outline-chapters__code","data-id":l},e.code),o.push(c)),o.push(h),a=q("a",{id:`chapter__anchor-${l}`,className:"outline-chapters__anchor",href:"#"+n,rel:n,"data-id":l},o),d=q("li",{id:`chapter-${l}`,className:"outline-chapters__item","data-id":l},a),-1===r?t.appendChild(d):(p=i(`chapter-${r}`),u=i(`subject-${r}`),u?u.appendChild(d):(u=q("ul",{id:"subject-"+r,className:"outline-chapters__subject"},d),p.appendChild(u)))}))})(n,r,t),d(l,"outline-chapters_hidden"),this.positionPlaceholder(this.active),this.offsetTop=H(l),this.offsetWidth=l.offsetWidth,this.isFixed()&&(this.sticky(),V("--outline-chapters-width",`${this.offsetWidth}px`)),e(s)&&s.call(this),this.onObserver()),this}positionPlaceholder(t){const e=this.$main,s=this.$list,i=this.$placeholder,r=s.querySelector(".outline-chapters__anchor"),l=parseInt(Y(e,"padding-top"),10),n=parseInt(Y(e,"border-top-width"),10),o=parseInt(Y(s,"padding-top"),10),h=parseInt(Y(s,"margin-top"),10),a=parseInt(Y(s,"border-top-width"),10);let c,d=r.offsetHeight,u=0;return l&&(u+=l),o&&(u+=o),h&&(u+=h),n&&(u+=n),a&&(u+=a),c=d*t,i.style.cssText=`transform: translateY(${u+c}px);height:${d}px;`,this}highlight(t){const e=this.$el.querySelector(`#chapter__anchor-${t}`),s="outline-chapters_active";return e?(this.$active&&d(this.$active,s),this.active=parseInt(e.getAttribute("data-id"),10),this.$active=e,a(this.$active,s),this.positionPlaceholder(this.active),this):this}sticky(){const t=this.attr("afterSticky"),s="outline-chapters_fixed",i=this.$el,r=this.offsetTop,l=this.$scrollElement.scrollTop;let n;return this.isFixed()?(n=l>=r,n?a(i,s):d(i,s),e(t)&&t.call(this,this.isClosed(),n),this):this}calculateStickyHeight(){const t=document.documentElement,e=Math.max(t.clientHeight||0,window.innerHeight||0);return V("--outline-sticky-height",`${e}px`),this}scrollTo(t,e){const s=this.$scrollElement;return m(s,t,e),this}show(){const t="outline-chapters_folded",i="outline-chapters_hidden",r=this.attr("afterOpened"),l=this.$el,n=this.$parentElement;return this.isInside()?(d(n,i),d(l,i),s((()=>{d(n,t),d(l,t)}),30)):d(l,i),this.closed=!1,e(r)&&r.call(this),this}hide(){const t="outline-chapters_folded",i="outline-chapters_hidden",r=this.attr("afterClosed"),l=this.$el,n=this.$parentElement;return this.isInside()?(a(n,t),a(l,t),s((()=>{a(n,i),a(l,i)}))):a(l,i),this.closed=!0,e(r)&&r.call(this),this}toggle(){const t=this.attr("afterToggle"),i=this.offsetTop,r=this.$scrollElement.scrollTop;let l;return this.isClosed()?this.show():this.hide(),e(t)&&s((()=>{l=r>=i,t.call(this,this.isClosed(),l)})),this}destroy(){const t=this.attr("beforeDestroy"),s=this.attr("afterDestroy");return e(t)&&t.call(this),this.removeListeners(),this.$parentElement.removeChild(this.$el),this.attr(G.DEFAULTS)._reset(),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=null),e(s)&&s.call(this),this.Observer&&(this.Observer=null),this}onObserver(){const t=this.attr("selector");let i=null;return this.Observer=((t,s={})=>{const i=s.root||null,r=s.selector||".outline-heading",l=s.context||null,n={rootMargin:s.rootMargin||"0px 0px -90% 0px"},h=new IntersectionObserver((s=>{s.forEach((s=>{s.intersectionRatio>0&&e(t)&&t.call(l||s.target,s.target)}))}),n),a=o(i)?i:document;return i&&(n.root=i),a.querySelectorAll(r).forEach((t=>{h.observe(t)})),h})((t=>{const e=t.getAttribute("data-id");if(this.playing)return!1;i&&clearTimeout(i),i=s((()=>{this.highlight(e)}),100)}),{selector:t,context:this}),this}onSelect(t){const i=this.attr("stickyHeight"),r=t.delegateTarget,l=r.getAttribute("data-id"),n=r.href.split("#")[1],o=document.querySelector(`#${n}`),h=H(o)-(i+10),a=this.$scrollElement.scrollHeight,c=this.attr("afterScroll"),d=()=>{e(c)&&c.call(this,"chapter"),s((()=>{this.playing=!1,this.$emit("toolbar:update",{top:h,min:0,max:a})}))};return this.playing=!0,this.isFixed()?(this.sticky(),s((()=>{this.scrollTo(h,d),this.highlight(l)}),10)):(this.scrollTo(h,d),this.highlight(l)),w(t),this}onScroll(){const t=this.$scrollElement;return this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=s((()=>{const e=t.scrollTop,s=t.scrollHeight-t.clientHeight;this.isFixed()&&this.sticky(),this.$emit("toolbar:update",{top:e,min:0,max:s})}),100),this}onResize(){return this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=s((()=>{this.calculateStickyHeight()})),this}addListeners(){const t=this.$el,e=this.$scrollElement,s=e.tagName.toLowerCase();let i=e;return"html"!==s&&"body"!==s||(i=window),E(t,".outline-chapters__anchor","click",this.onSelect,this,!0),$(i,"scroll",this.onScroll,this,!0),this.isSticky()&&$(window,"resize",this.onResize,this,!0),this}removeListeners(){const t=this.attr("selector"),e=this.$el,s=this.$scrollElement,i=s.tagName.toLowerCase();let r=s;return"html"!==i&&"body"!==i||(r=window),b(e,"click",this.onSelect),b(r,"scroll",this.onScroll),this.isSticky()&&$(window,"resize",this.onResize),this.Observer&&document.querySelectorAll(t).forEach((t=>{this.Observer.unobserve(t)})),this}}G.DEFAULTS={parentElement:"",scrollElement:"",selector:".outline-heading",active:0,closed:!1,showCode:!0,position:"relative",stickyHeight:0,chapters:[],created:null,mounted:null,afterClosed:null,afterOpened:null,afterScroll:null,beforeDestroy:null,afterDestroy:null,afterSticky:null};const K=(t,e=!0)=>{const s=R(t.icon,{iconSet:t.iconSet||"outline",color:t.color||"",size:t.size}),i=q("a",{className:"outline-toolbar__anchor",href:t.link},s),r=q("div",{className:`outline-toolbar__button ${t.name}`},[t.link?i:s]);return a(s,"outline-toolbar__icon"),e&&a(r,"outline-toolbar_rounded"),t.disabled&&a(r,"outline-toolbar_disabled"),r},X="outline-toolbar_disabled",Z="outline-toolbar_hidden";class tt extends N{constructor(t){super(),this.attrs=r(tt.DEFAULTS),this.$el=null,this.disabled=!1,this.closed=!1,this.buttons=[],t&&this.initialize(t)}initialize(t){let s;return this.attr(t),s=this.attr("created"),this.disabled=this.attr("disabled"),this.closed=this.attr("closed"),e(s)&&s.call(this),this.render().addListeners(),this}isDisabled(t){const e=this.attr("buttons");let s;return t?(s=e.find((e=>e.name===t)),s?.disabled):this.disabled}isClosed(){return this.closed}highlight(t){const e=this.buttons.find((e=>e.name===t)),s="outline-toolbar_active";let i;return i||(i=e.$el,h(i,s)?d(i,s):a(i,s)),this}render(){const t=this.attr("mounted"),s=this.attr("buttons")||[],i=this.attr("rounded"),r=this.attr("placement"),l=[];return j(),s.forEach((t=>{const e=K(t,i);l.push(e),this.buttons.push({name:t.name,$el:e})})),this.$el=q("div",{id:"outline-toolbar",className:`outline-toolbar outline-toolbar_${r}`},l),document.body.appendChild(this.$el),this.closed&&this.hide(),this.disabled&&this.disable(),e(t)&&t.call(this),this}add(t){const s=this.$el,r=this.attr("buttons"),l=t.action,o=document.createDocumentFragment();let h;return n(t)?(r.push(t),o.appendChild(K(t))):i(t)&&t.forEach((t=>{o.appendChild(K(t))})),s.appendChild(o),l&&e(l.handler)&&(h=l.type||"click",E(s,`.${t.name}`,h,l.handler)),this}remove(t){const e=this.$el,s=this.attr("buttons"),i=s.find((e=>e.name===t));let r,l=-1;return i?(s.forEach(((e,s)=>{e.name===t&&(l=s)})),l>-1&&this.attr().buttons.splice(l,1),r=e.querySelector(`.${t}`),this.switch(t,!1),e.removeChild(r),this):this}switch(t,e){const s=this.$el,i=this.attr("buttons"),r=i.find((e=>e.name===t));let l,n,o,h;return r?(i.forEach((s=>{s.name===t&&(r.disabled=!e)})),l=r.action,h=s.querySelector(`.${t}`),l&&(n=l.type||"click",o=l.handler),e?(d(h,X),n&&o&&E(s,`.${t}`,n,o)):(a(h,X),n&&o&&b(s,n,o)),this):this}disable(t){const s=this.attr("afterDisabled");return t?this.switch(t,!1):(a(this.$el,X),this.removeListeners(),this.disabled=!0,e(s)&&s.call(this)),this}enable(t){const s=this.attr("afterEnabled");return t?this.switch(t,!0):(this.disabled=!1,d(this.$el,X),this.addListeners(),e(s)&&s.call(this)),this}show(t){const i=this.attr("afterOpened"),r=this.attr("buttons").find((e=>e.name===t)),l=this.$el;let n;if(t){if(!r)return this;n=l.querySelector(`.${t}`),d(n,Z)}else d(l,Z),this.closed=!1,e(i)&&s((()=>{i.call(this)}),310);return this}hide(t){const i=this.attr("afterClosed"),r=this.attr("buttons").find((e=>e.name===t)),l=this.$el;let n;if(t){if(!r)return this;n=l.querySelector(`.${t}`),a(n,Z)}else a(l,Z),this.closed=!0,e(i)&&s((()=>{i.call(this)}),310);return this}toggle(){return this.isClosed()?this.show():this.hide(),this}destroy(){const t=this.attr("beforeDestroy"),s=this.attr("afterDestroy");let i=this.$el;return e(t)&&t.call(this),this.removeListeners(),document.body.removeChild(i),i=null,this.attr(tt.DEFAULTS),this.disabled=!1,this.closed=!1,this.buttons=[],e(s)&&s.call(this),this}refresh(){const t=this.$el,e=this.attr("buttons")||[];return this.removeListeners(),t.innerHTML="",e.forEach((t=>{this.$el.appendChild(K(t))})),this.addListeners(),this}addListeners(){const t=this.attr("buttons"),s=this.$el;return!t||t.length<1||t.forEach((t=>{const i=t.action;let r,n,o,h;if(this.disabled)return!1;i&&(n=i.handler,l(n)&&(h=n,i.handler=function(){this.$emit(h,t.name)},n=i.handler),r=i.type||"click",o=i.context),e(n)&&E(s,`.${t.name}`,r,n,o||this,!0)})),this}removeListeners(){const t=this.attr("buttons"),s=this.$el;return!t||t.length<1||t.forEach((t=>{const i=t.action;let r,l;if(this.disabled)return!1;i&&(l=i.handler,r=i.type||"click"),e(l)&&b(s,r,l)})),this}}tt.DEFAULTS={placement:"ltr",closed:!1,disabled:!1,rounded:!0,buttons:[],created:null,mounted:null,afterClosed:null,afterOpened:null,afterDisabled:null,afterEnabled:null,beforeDestroy:null,afterDestroy:null};const et=(t,e)=>{let s,i=t;for(;i;)s=i.tagName.toLowerCase(),"script"!==s&&"style"!==s&&a(i,"outline-print_sibling"),i=e?i.previousElementSibling:i.nextElementSibling};class st extends N{constructor(t){super(),this.attrs=r(st.DEFAULTS),this.anchors=null,this.drawer=null,this.chapters=null,this.toolbar=null,this.buttons=[],this.reading=!1,t&&this.initialize(t)}initialize(t){return this.attr(t),this.$emit("created",{...this.attr()}),this.render().addListeners(),this}getChapters(t=!1){return this.anchors.getChapters(t)}count(){return this.anchors.count()}render(){const t=this.attr("scrollElement"),e=document.querySelector(t)||document.getElementById(t);return this._renderPrint()._renderAnchors()._renderChapters()._renderToolbar(),e&&this.onToolbarUpdate({top:e.scrollTop,min:0,max:e.scrollHeight}),this.$emit("mounted"),this}_renderPrint(){const t=this.attr("print"),e=this.attr("articleElement");let i;return t.element?(l(e)?i=document.querySelector(e):o(e)&&(i=e),a(i,"outline-article"),((t,e)=>{let i,r,n,h,c,d,u=e;l(t)?i=document.querySelector(t)||document.getElementById(t):o(t)&&(i=t),d=R("close",{iconSet:"outline",size:20}),a(d,"outline-print__close"),h=i.querySelector("h1"),o(e)&&(h=e),o(h)&&(u=h.innerText),n=q("article",{id:"outline-print__article",className:"outline-print__article"}),n.innerHTML=i.innerHTML,h=q("h1",{className:"outline-print__title"},u),r=q("section",{id:"outline-print",className:"outline-print"},[d,h,n]),document.body.appendChild(r),s((()=>{c=r.previousElementSibling,et(c,!0),c=r.nextElementSibling,et(c)}),350)})(t.element,t.title),this):this}_renderAnchors(){const t=this.attr("articleElement"),e=this.attr("selector"),s=this.attr("stickyHeight"),i=this.attr("scrollElement"),r=this.attr("showCode"),l=this.attr("anchorURL"),n=this.attr("afterScroll"),o=this.attr("chapterTextFilter");return this.anchors=new P({articleElement:t,stickyHeight:s,scrollElement:i,selector:e,showCode:r,anchorURL:l,afterScroll:n,chapterTextFilter:o}),this}_renderChapters(){const t=this.attr("title"),e=this.attr("stickyHeight"),s=this.attr("scrollElement"),i=this.attr("customClass"),r=this.attr("showCode"),l=this.attr("position"),n=this.attr("placement"),o=this.attr("afterSticky"),h=this.attr("afterToggle"),a=this.attr("afterScroll"),c=this.count();let d,u=this.attr("parentElement");return c<1||(d={scrollElement:s,showCode:r,position:l,title:t,stickyHeight:e,chapters:this.getChapters(),afterSticky:o,afterToggle:h,afterScroll:a},"relative"===l?(this.drawer=new J({placement:n,title:t,size:"tiny",hasOffset:!0,hasPadding:!1,customClass:i,afterClosed:()=>{this.toolbar.toggle()}}),u=this.drawer.$main):d.customClass=i,d.parentElement=u,this.chapters=new G(d)),this}_renderToolbar(){const t=this.attr("placement"),e=this.attr("homepage"),s=this.attr("git"),i=this.attr("tags"),r=this.attr("issues"),l=this.attr("tools"),n=this.attr("print"),o=this.count(),h={name:"homepage",icon:"homepage",size:20,link:e},a={name:"github",icon:"github",size:20,link:s},c={name:"tags",icon:"tags",size:20,link:i},d={name:"issues",icon:"issues",size:20,link:r},u={name:"menu",icon:"menu",size:18,action:{type:"click",handler:"toolbar:action:toggle"}},p={name:"reading",icon:"file",size:18,action:{type:"click",handler:"toolbar:action:reading"}},m=[];return m.push({name:"up",icon:"up",size:20,action:{type:"click",handler:"toolbar:action:up"}}),o>0&&m.push(u),n.element&&m.push(p),e&&m.push(h),s&&m.push(a),i&&m.push(c),r&&m.push(d),l?.length>0&&m.push(...l),m.push({name:"down",icon:"down",size:20,action:{type:"click",handler:"toolbar:action:down"}}),this.buttons=[...m],this.toolbar=new tt({placement:t,buttons:m}),this}addButton(t){const e=this.toolbar,s=this.buttons;return s.splice(-1,0,t),e.attr({buttons:s}),e.refresh(),this}removeButton(t){return this.toolbar.remove(t),this}toTop(){const t=this.attr("afterScroll"),s=this.toolbar,i=this.chapters,r=this.count();return r>0&&(i.playing=!0),this.scrollTo(0,(()=>{s.hide("up"),s.show("down"),r>0&&(i.highlight(0),i.playing=!1),e(t)&&t.call(s,"up")})),this}toBottom(){const t=this.attr("afterScroll"),s=p(this.attr("scrollElement")),i=this.toolbar,r=this.chapters,l=this.count(),n=Math.floor(s.scrollHeight-s.clientHeight);return l>0&&(r.playing=!0),this.scrollTo(n,(()=>{i.hide("down"),i.show("up"),l>0&&(r.highlight(l-1),r.playing=!1),e(t)&&t.call(i,"bottom")})),this}scrollTo(t,e){const s=this.attr("scrollElement");return m(s,t,e),this}enterReading(){const t="outline-reading",e=`${t}_hidden`,s=document.querySelector("#outline-print"),i=document.querySelectorAll(".outline-print_sibling");return this.reading||!s||(i.forEach((t=>{a(t,e)})),a(s,t),this.reading=!0,this.toolbar.toggle(),this.$emit("enterReading")),this}exitReading(){const t="outline-reading",e=`${t}_hidden`,s=document.querySelector("#outline-print"),i=document.querySelectorAll(".outline-print_sibling");return this.reading&&s?(d(s,t),i.forEach((t=>{d(t,e)})),this.reading=!1,this.toolbar.toggle(),this.$emit("exitReading"),this):this}switchReading(){return document.querySelector("#outline-print")?(this.reading?this.exitReading():this.enterReading(),this):this}toggle(){const t=this.attr("position"),e=this.toolbar,i=this.drawer,r=this.chapters;return this.count()<1||("relative"!==t?(r.toggle(),e.highlight("menu")):(e.toggle(),s((()=>{i.toggle()})))),this}destroy(){let t=this.anchors,e=this.chapters,s=this.drawer,i=this.toolbar,r=!1;const l=this.count(),n=document.querySelector("#outline-print");return this.$emit("beforeDestroy"),this.removeListeners(),n&&document.body.removeChild(n),l>0&&(r=e.isOutside(),e.destroy(),e=null,r&&(s.destroy(),s=null)),i.destroy(),i=null,t.destroy(),t=null,this.attr(st.DEFAULTS),this.$emit("destroyed"),this}onToggle(){return this.toggle(),this}onScrollTop(){return this.toTop(),this}onScrollBottom(){return this.toBottom(),this}onEnterReading(){return this.switchReading(),this}onExitReading(t){return 27===t.keyCode&&this.reading&&(this.switchReading(),w(t)),this}onToolbarUpdate({top:t,min:e,max:s}){const i=this.toolbar,r=Math.ceil(t);return r<=e?(i.hide("up"),i.show("down")):r>=s?(i.hide("down"),i.show("up")):r>e&&r<s&&(i.show("up"),i.show("down")),this}addListeners(){const t=document.querySelector("#outline-print");return this.$on("toolbar:update",this.onToolbarUpdate),this.$on("toolbar:action:up",this.onScrollTop),this.$on("toolbar:action:toggle",this.onToggle),this.$on("toolbar:action:reading",this.onEnterReading),this.$on("toolbar:action:down",this.onScrollBottom),t&&($(document,"keyup",this.onExitReading,this,!0),E(t,".outline-print__close","click",this.exitReading,this,!0)),this}removeListeners(){const t=document.querySelector("#outline-print");return this.$off("toolbar:update"),this.$off("toolbar:action:up"),this.$off("toolbar:action:toggle"),this.$off("toolbar:action:down"),t&&(b(document,"keyup",this.onExitReading),b(t,"click",this.exitReading)),this}}return st.DEFAULTS={articleElement:"#article",selector:"h2,h3,h4,h5,h6",title:"目录",scrollElement:"html,body",position:"relative",parentElement:"#aside",placement:"rtl",showCode:!0,anchorURL:"",stickyHeight:0,homepage:"",git:"",tags:"",issues:"",tools:[],print:{element:"",title:""},customClass:"",afterSticky:null,afterToggle:null,afterScroll:null,chapterTextFilter:null},window.jQuery&&jQuery.extend(jQuery.fn,{outline:function(t){let e=jQuery(this);return new st(jQuery.extend({},t,{articleElement:e}))}}),st}));
//# sourceMappingURL=outline.min.js.map
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/qdplatform/outline.js.git
git@gitee.com:qdplatform/outline.js.git
qdplatform
outline.js
outline.js
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385