Comparing version 1.4.0 to 1.4.1
@@ -131,3 +131,3 @@ /*! | ||
// unset storeIds | ||
storeIds = null; | ||
storeIds = []; | ||
@@ -134,0 +134,0 @@ return mokuji; |
@@ -7,2 +7,2 @@ /*! | ||
*/ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.Mokuji=r():e.Mokuji=r()}("undefined"!=typeof self?self:this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n={};return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=0)}([function(e,r,n){"use strict";function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0}),r.init=undefined;var o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},a=function(){function e(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(r,n,t){return n&&e(r.prototype,n),t&&e(r,t),r}}(),i=n(1),u=function(e){return e&&e.__esModule?e:{default:e}}(i),l={anchorType:!0,anchorLink:!1,anchorLinkSymbol:"#",anchorLinkBefore:!0,anchorLinkClassName:""},c=[];r.init=function(){function e(r,n){if(t(this,e),r){n=o(l,n);var a=this.render(r,n);return c=null,a}}return a(e,[{key:"render",value:function(e,r){var n=this.generateMokuji(e,r);return r.anchorLink&&this.renderAnchorLink(n,r),n}},{key:"generateMokuji",value:function(e,r){for(var n=this.createHeadingWalker(e),t=null,o=0,a=document.createElement("ol"),i=document.createElement("li"),l=document.createElement("a");t=n.nextNode();){var c=t.tagName.match(/\d/g).join("");if(c=Number(c),0!==o&&o<c){var f=document.createElement("ol");a.lastChild.appendChild(f),a=f}else if(0!==o&&o>c)for(var d=0;d<o-c;d++)(0,u["default"])(a,a.parentNode)&&(a=a.parentNode.parentNode);var s=this.censorshipId(t.textContent);t.id=this.setAnchor(t.id,s,r.anchorType),a.appendChild(this.buildList(t,l.cloneNode(!1),i.cloneNode(!1))),o=c}return 0===o?null:(a=this.reverseMokuji(a),this.removeDuplicateIds(a),a)}},{key:"censorshipId",value:function(e){var r=e,n=1;if(-1!==c.indexOf(r))for(;n<10;){var t=r+"_"+n;if(-1===c.indexOf(t)){r=t,c.push(r);break}n++}else c.push(r);return r}},{key:"createHeadingWalker",value:function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,function(e){return/^H[1-6]$/.test(e.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},!1)}},{key:"setAnchor",value:function(e,r,n){var t=e||this.replaceSpace2Underscore(r);return t=t.replace(/\&+/g,""),t=t.replace(/\&+/g,""),!0===n&&(t=encodeURIComponent(t),t=t.replace(/\%+/g,".")),t}},{key:"renderAnchorLink",value:function(e,r){if(e){var n=e.getElementsByTagName("a"),t=document.createElement("a");t.classList.add(r.anchorLinkClassName);for(var o=0;o<n.length;o++){var a=n[o].hash,i=document.querySelector('[id="'+a.replace("#","")+'"]');if(i){var u=t.cloneNode(!1);u.setAttribute("href",a),u.textContent=r.anchorLinkSymbol,r.anchorLinkBefore?i.insertBefore(u,i.firstChild):i.appendChild(u)}}}}},{key:"replaceSpace2Underscore",value:function(e){return String(e).replace(/\s+/g,"_")}},{key:"buildList",value:function(e,r,n){return r.href="#"+e.id,r.textContent=e.textContent,n.appendChild(r),n}},{key:"reverseMokuji",value:function(e){for(;e.parentNode;)e=e.parentNode;return e}},{key:"removeDuplicateIds",value:function(e){for(var r=e.getElementsByTagName("a"),n=0;n<r.length;n++){var t=r[n].innerText,o=r[n].hash,a=document.querySelectorAll('[id="'+t+'"]');if(1!==a.length){var i=0;Array.from||(Array.from=function(e){return Array.prototype.slice.call(e)});for(var u=Array.from(a),l=Array.isArray(u),c=0,u=l?u:u[Symbol.iterator]();;){var f;if(l){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}for(var d=f,s=d.id+"-"+i,p=Array.from(r),h=Array.isArray(p),v=0,p=h?p:p[Symbol.iterator]();;){var y;if(h){if(v>=p.length)break;y=p[v++]}else{if(v=p.next(),v.done)break;y=v.value}var m=y;if(m.hash===o){m.href="#"+s;break}}d.id=s,i++}}}}}]),e}()},function(e,r,n){"use strict";function t(e,r){for(;e;){if(e===r)return!0;e=e.parentNode}return!1}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=t}])}); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.Mokuji=r():e.Mokuji=r()}("undefined"!=typeof self?self:this,function(){return function(e){function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var n={};return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:t})},r.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=0)}([function(e,r,n){"use strict";function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(r,"__esModule",{value:!0}),r.init=undefined;var o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},a=function(){function e(e,r){for(var n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}return function(r,n,t){return n&&e(r.prototype,n),t&&e(r,t),r}}(),i=n(1),u=function(e){return e&&e.__esModule?e:{default:e}}(i),c={anchorType:!0,anchorLink:!1,anchorLinkSymbol:"#",anchorLinkBefore:!0,anchorLinkClassName:""},l=[];r.init=function(){function e(r,n){if(t(this,e),r){n=o(c,n);var a=this.render(r,n);return l=[],a}}return a(e,[{key:"render",value:function(e,r){var n=this.generateMokuji(e,r);return r.anchorLink&&this.renderAnchorLink(n,r),n}},{key:"generateMokuji",value:function(e,r){for(var n=this.createHeadingWalker(e),t=null,o=0,a=document.createElement("ol"),i=document.createElement("li"),c=document.createElement("a");t=n.nextNode();){var l=t.tagName.match(/\d/g).join("");if(l=Number(l),0!==o&&o<l){var f=document.createElement("ol");a.lastChild.appendChild(f),a=f}else if(0!==o&&o>l)for(var d=0;d<o-l;d++)(0,u["default"])(a,a.parentNode)&&(a=a.parentNode.parentNode);var s=this.censorshipId(t.textContent);t.id=this.setAnchor(t.id,s,r.anchorType),a.appendChild(this.buildList(t,c.cloneNode(!1),i.cloneNode(!1))),o=l}return 0===o?null:(a=this.reverseMokuji(a),this.removeDuplicateIds(a),a)}},{key:"censorshipId",value:function(e){var r=e,n=1;if(-1!==l.indexOf(r))for(;n<10;){var t=r+"_"+n;if(-1===l.indexOf(t)){r=t,l.push(r);break}n++}else l.push(r);return r}},{key:"createHeadingWalker",value:function(e){return document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,function(e){return/^H[1-6]$/.test(e.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},!1)}},{key:"setAnchor",value:function(e,r,n){var t=e||this.replaceSpace2Underscore(r);return t=t.replace(/\&+/g,""),t=t.replace(/\&+/g,""),!0===n&&(t=encodeURIComponent(t),t=t.replace(/\%+/g,".")),t}},{key:"renderAnchorLink",value:function(e,r){if(e){var n=e.getElementsByTagName("a"),t=document.createElement("a");t.classList.add(r.anchorLinkClassName);for(var o=0;o<n.length;o++){var a=n[o].hash,i=document.querySelector('[id="'+a.replace("#","")+'"]');if(i){var u=t.cloneNode(!1);u.setAttribute("href",a),u.textContent=r.anchorLinkSymbol,r.anchorLinkBefore?i.insertBefore(u,i.firstChild):i.appendChild(u)}}}}},{key:"replaceSpace2Underscore",value:function(e){return String(e).replace(/\s+/g,"_")}},{key:"buildList",value:function(e,r,n){return r.href="#"+e.id,r.textContent=e.textContent,n.appendChild(r),n}},{key:"reverseMokuji",value:function(e){for(;e.parentNode;)e=e.parentNode;return e}},{key:"removeDuplicateIds",value:function(e){for(var r=e.getElementsByTagName("a"),n=0;n<r.length;n++){var t=r[n].innerText,o=r[n].hash,a=document.querySelectorAll('[id="'+t+'"]');if(1!==a.length){var i=0;Array.from||(Array.from=function(e){return Array.prototype.slice.call(e)});for(var u=Array.from(a),c=Array.isArray(u),l=0,u=c?u:u[Symbol.iterator]();;){var f;if(c){if(l>=u.length)break;f=u[l++]}else{if(l=u.next(),l.done)break;f=l.value}for(var d=f,s=d.id+"-"+i,p=Array.from(r),h=Array.isArray(p),v=0,p=h?p:p[Symbol.iterator]();;){var y;if(h){if(v>=p.length)break;y=p[v++]}else{if(v=p.next(),v.done)break;y=v.value}var m=y;if(m.hash===o){m.href="#"+s;break}}d.id=s,i++}}}}}]),e}()},function(e,r,n){"use strict";function t(e,r){for(;e;){if(e===r)return!0;e=e.parentNode}return!1}Object.defineProperty(r,"__esModule",{value:!0}),r["default"]=t}])}); |
@@ -45,3 +45,3 @@ 'use strict'; | ||
// unset storeIds | ||
storeIds = null; | ||
storeIds = []; | ||
@@ -48,0 +48,0 @@ return mokuji; |
{ | ||
"name": "mokuji.js", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "A table of content JavaScript Library", | ||
@@ -43,3 +43,3 @@ "main": "lib/index.js", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.1.2", | ||
"babel-eslint": "^8.2.2", | ||
"babel-loader": "^7.1.2", | ||
@@ -50,14 +50,14 @@ "babel-plugin-transform-es2015-for-of": "^6.23.0", | ||
"cross-env": "^5.1.3", | ||
"eslint": "^4.14.0", | ||
"eslint": "^4.18.1", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-import": "^2.8.0", | ||
"eslint-plugin-node": "^5.2.1", | ||
"eslint-plugin-prettier": "^2.4.0", | ||
"eslint-plugin-import": "^2.9.0", | ||
"eslint-plugin-node": "^6.0.1", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"eslint-plugin-promise": "^3.6.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^6.0.0", | ||
"prettier": "^1.9.2", | ||
"lint-staged": "^7.0.0", | ||
"prettier": "^1.10.2", | ||
"rimraf": "^2.6.2", | ||
"webpack": "^3.10.0" | ||
"webpack": "^3.11.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
31371