bit-docs-html-toc
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "bit-docs-html-toc", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "table of contents bit-docs plugin", | ||
@@ -5,0 +5,0 @@ "main": "toc.js", |
@@ -34,6 +34,18 @@ # bit-docs-html-toc | ||
```js | ||
```html | ||
<div class="on-this-page-container"></div> | ||
``` | ||
By default, all heading tags children of the first `article` tag on the page will | ||
be collected to create the table of contents; if you want to use a different element | ||
just do: | ||
```html | ||
<div | ||
class="on-this-page-container" | ||
data-heading-container-selector="#my-custom-selector" | ||
> | ||
</div> | ||
``` | ||
The table of contents will be injected into this element at run time. |
require("./make-tree-test"); | ||
require("./toc-control-test"); | ||
require("./toc-container-control-test"); | ||
40
toc.js
@@ -1,35 +0,9 @@ | ||
var Control = require("can-control"); | ||
var TableOfContents = require("./toc-control"); | ||
var TOCContainer = require("./toc-container-control"); | ||
var TOCContainer = Control.extend({ | ||
init: function(el) { | ||
el.style.display = "none"; | ||
var el = document.getElementsByClassName("on-this-page-container"); | ||
var depth = this.getOutlineDepth(); | ||
var tagName = this.getOutlineTagName(); | ||
var toc = document.createElement(tagName); | ||
toc.className = "on-this-page"; | ||
el.appendChild(toc); | ||
new TableOfContents(toc, { | ||
depth: depth, | ||
tagName: tagName, | ||
headingsContainerSelector: "article" | ||
}); | ||
}, | ||
getOutlineTagName: function() { | ||
var outline = window.docObject.outline || {}; | ||
return (outline.tag === "ol") ? "ol" : "ul"; | ||
}, | ||
getOutlineDepth: function() { | ||
var depth = window.docObject.outline && window.docObject.outline.depth; | ||
return (typeof depth === "number" ? Math.min(depth, 6) : 1); | ||
} | ||
}); | ||
new TOCContainer( | ||
document.getElementsByClassName("on-this-page-container")[0] | ||
); | ||
if (el.length) { | ||
new TOCContainer(el); | ||
} else { | ||
console.log("An element with class 'on-this-page-container' is required"); | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15944
17
419
51
0