Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bit-docs-html-toc

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bit-docs-html-toc - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

test/toc-container-control-test.js

2

package.json
{
"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");

@@ -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");
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc