|
1 |
| -export = tocbot; |
2 |
| -export as namespace tocbot; |
3 |
| - |
4 |
| -declare namespace tocbot { |
5 |
| - /** |
6 |
| - * @see https://github.com/tscanlin/tocbot#options |
7 |
| - */ |
8 |
| - interface IStaticOptions { |
9 |
| - // Where to render the table of contents. |
10 |
| - tocSelector?: string |
11 |
| - // Where to grab the headings to build the table of contents. |
12 |
| - contentSelector?: string |
13 |
| - // Which headings to grab inside of the contentSelector element. |
14 |
| - headingSelector?: string |
15 |
| - // Headings that match the ignoreSelector will be skipped. |
16 |
| - ignoreSelector?: string |
17 |
| - // For headings inside relative or absolute positioned containers within content. |
18 |
| - hasInnerContainers?: boolean |
19 |
| - // Main class to add to links. |
20 |
| - linkClass?: string |
21 |
| - // Extra classes to add to links. |
22 |
| - extraLinkClasses?: string |
23 |
| - // Class to add to active links // the link corresponding to the top most heading on the page. |
24 |
| - activeLinkClass?: string |
25 |
| - // Main class to add to lists. |
26 |
| - listClass?: string |
27 |
| - // Extra classes to add to lists. |
28 |
| - extraListClasses?: string |
29 |
| - // Class that gets added when a list should be collapsed. |
30 |
| - isCollapsedClass?: string |
31 |
| - // Class that gets added when a list should be able |
32 |
| - // to be collapsed but isn't necessarily collapsed. |
33 |
| - collapsibleClass?: string |
34 |
| - // Class to add to list items. |
35 |
| - listItemClass?: string |
36 |
| - // Class to add to active list items. |
37 |
| - activeListItemClass?: string |
38 |
| - // How many heading levels should not be collapsed. |
39 |
| - // For example; number 6 will show everything since |
40 |
| - // there are only 6 heading levels and number 0 will collapse them all. |
41 |
| - // The sections that are hidden will open |
42 |
| - // and close as you scroll to headings within them. |
43 |
| - collapseDepth?: number |
44 |
| - // Smooth scrolling enabled. |
45 |
| - scrollSmooth?: boolean |
46 |
| - // Smooth scroll duration. |
47 |
| - scrollSmoothDuration?: number |
48 |
| - // Smooth scroll offset. |
49 |
| - scrollSmoothOffset?: number |
50 |
| - // Callback for scroll end. |
51 |
| - scrollEndCallback?(e: WheelEvent): void |
52 |
| - // Headings offset between the headings and the top of the document (this is meant for minor adjustments). |
53 |
| - headingsOffset?: number |
54 |
| - // Timeout between events firing to make sure it's |
55 |
| - // not too rapid (for performance reasons). |
56 |
| - throttleTimeout?: number |
57 |
| - // Element to add the positionFixedClass to. |
58 |
| - positionFixedSelector?: string | null |
59 |
| - // Fixed position class to add to make sidebar fixed after scrolling |
60 |
| - // down past the fixedSidebarOffset. |
61 |
| - positionFixedClass?: string |
62 |
| - // fixedSidebarOffset can be any number but by default is set |
63 |
| - // to auto which sets the fixedSidebarOffset to the sidebar |
64 |
| - // element's offsetTop from the top of the document on init. |
65 |
| - fixedSidebarOffset?: 'auto' | number |
66 |
| - // includeHtml can be set to true to include the HTML markup from the |
67 |
| - // heading node instead of just including the innerText. |
68 |
| - includeHtml?: boolean |
69 |
| - // includeTitleTags automatically sets the html title tag of the link |
70 |
| - // to match the title. This can be useful for SEO purposes or |
71 |
| - // when truncating titles. |
72 |
| - includeTitleTags?: boolean |
73 |
| - // onclick function to apply to all links in toc. will be called with |
74 |
| - // the event as the first parameter; and this can be used to stop // propagation; prevent default or perform action |
75 |
| - onClick?: (e: MouseEvent) => void |
76 |
| - // orderedList can be set to false to generate unordered lists (ul) |
77 |
| - // instead of ordered lists (ol) |
78 |
| - orderedList?: boolean |
79 |
| - // If there is a fixed article scroll container; set to calculate titles' offset |
80 |
| - scrollContainer?: string | null |
81 |
| - // prevent ToC DOM rendering if it's already rendered by an external system |
82 |
| - skipRendering?: boolean |
83 |
| - // Optional callback to change heading labels. |
84 |
| - // For example it can be used to cut down and put ellipses on multiline headings you deem too long. |
85 |
| - // Called each time a heading is parsed. Expects a string in return, the modified label to display. |
86 |
| - headingLabelCallback?: (headingLabel: string) => string |
87 |
| - // ignore headings that are hidden in DOM |
88 |
| - ignoreHiddenElements?: boolean |
89 |
| - // Optional callback to modify properties of parsed headings. |
90 |
| - // The heading element is passed in node parameter and information parsed by default parser is provided in obj parameter. |
91 |
| - // Function has to return the same or modified obj. |
92 |
| - // The heading will be excluded from TOC if nothing is returned. |
93 |
| - headingObjectCallback?: (obj: object, node: HTMLElement) => object | void |
94 |
| - // Set the base path, useful if you use a `base` tag in `head`. |
95 |
| - basePath?: string |
96 |
| - // Only takes affect when `tocSelector` is scrolling, |
97 |
| - // keep the toc scroll position in sync with the content. |
98 |
| - disableTocScrollSync?: boolean |
99 |
| - // Offset for the toc scroll (top) position when scrolling the page. |
100 |
| - // Only effective if `disableTocScrollSync` is false. |
101 |
| - tocScrollOffset?: number |
102 |
| - // Enable the URL hash to update with the proper heading ID as |
103 |
| - // a user scrolls the page. |
104 |
| - enableUrlHashUpdateOnScroll?: boolean |
105 |
| - } |
106 |
| - |
107 |
| - /** |
108 |
| - * Initialize tocbot with an options object. |
109 |
| - * @see https://github.com/tscanlin/tocbot#init |
110 |
| - */ |
111 |
| - function init(options?: IStaticOptions): void |
112 |
| - /** |
113 |
| - * Destroy tocbot and remove event listeners. |
114 |
| - * @see https://github.com/tscanlin/tocbot#destroy |
115 |
| - */ |
116 |
| - function destroy(): void |
117 |
| - /** |
118 |
| - * Refresh tocbot if the document changes and it needs to be rebuilt. |
119 |
| - * @see https://github.com/tscanlin/tocbot#refresh |
120 |
| - */ |
121 |
| - function refresh(options?: IStaticOptions): void |
122 |
| -} |
| 1 | +export = tocbot |
| 2 | +export as namespace tocbot |
| 3 | + |
| 4 | +declare namespace tocbot { |
| 5 | + /** |
| 6 | + * @see https://github.com/tscanlin/tocbot#options |
| 7 | + */ |
| 8 | + interface IStaticOptions { |
| 9 | + // Where to render the table of contents. |
| 10 | + tocSelector?: string |
| 11 | + // Where to grab the headings to build the table of contents. |
| 12 | + contentSelector?: string |
| 13 | + // Which headings to grab inside of the contentSelector element. |
| 14 | + headingSelector?: string |
| 15 | + // Headings that match the ignoreSelector will be skipped. |
| 16 | + ignoreSelector?: string |
| 17 | + // For headings inside relative or absolute positioned containers within content. |
| 18 | + hasInnerContainers?: boolean |
| 19 | + // Main class to add to links. |
| 20 | + linkClass?: string |
| 21 | + // Extra classes to add to links. |
| 22 | + extraLinkClasses?: string |
| 23 | + // Class to add to active links // the link corresponding to the top most heading on the page. |
| 24 | + activeLinkClass?: string |
| 25 | + // Main class to add to lists. |
| 26 | + listClass?: string |
| 27 | + // Extra classes to add to lists. |
| 28 | + extraListClasses?: string |
| 29 | + // Class that gets added when a list should be collapsed. |
| 30 | + isCollapsedClass?: string |
| 31 | + // Class that gets added when a list should be able |
| 32 | + // to be collapsed but isn't necessarily collapsed. |
| 33 | + collapsibleClass?: string |
| 34 | + // Class to add to list items. |
| 35 | + listItemClass?: string |
| 36 | + // Class to add to active list items. |
| 37 | + activeListItemClass?: string |
| 38 | + // How many heading levels should not be collapsed. |
| 39 | + // For example; number 6 will show everything since |
| 40 | + // there are only 6 heading levels and number 0 will collapse them all. |
| 41 | + // The sections that are hidden will open |
| 42 | + // and close as you scroll to headings within them. |
| 43 | + collapseDepth?: number |
| 44 | + // Smooth scrolling enabled. |
| 45 | + scrollSmooth?: boolean |
| 46 | + // Smooth scroll duration. |
| 47 | + scrollSmoothDuration?: number |
| 48 | + // Smooth scroll offset. |
| 49 | + scrollSmoothOffset?: number |
| 50 | + // Callback for scroll end. |
| 51 | + scrollEndCallback?(e: WheelEvent): void |
| 52 | + // Headings offset between the headings and the top of the document (this is meant for minor adjustments). |
| 53 | + headingsOffset?: number |
| 54 | + // Timeout between events firing to make sure it's |
| 55 | + // not too rapid (for performance reasons). |
| 56 | + throttleTimeout?: number |
| 57 | + // Element to add the positionFixedClass to. |
| 58 | + positionFixedSelector?: string | null |
| 59 | + // Fixed position class to add to make sidebar fixed after scrolling |
| 60 | + // down past the fixedSidebarOffset. |
| 61 | + positionFixedClass?: string |
| 62 | + // fixedSidebarOffset can be any number but by default is set |
| 63 | + // to auto which sets the fixedSidebarOffset to the sidebar |
| 64 | + // element's offsetTop from the top of the document on init. |
| 65 | + fixedSidebarOffset?: "auto" | number |
| 66 | + // includeHtml can be set to true to include the HTML markup from the |
| 67 | + // heading node instead of just including the innerText. |
| 68 | + includeHtml?: boolean |
| 69 | + // includeTitleTags automatically sets the html title tag of the link |
| 70 | + // to match the title. This can be useful for SEO purposes or |
| 71 | + // when truncating titles. |
| 72 | + includeTitleTags?: boolean |
| 73 | + // onclick function to apply to all links in toc. will be called with |
| 74 | + // the event as the first parameter; and this can be used to stop // propagation; prevent default or perform action |
| 75 | + onClick?: (e: MouseEvent) => void |
| 76 | + // orderedList can be set to false to generate unordered lists (ul) |
| 77 | + // instead of ordered lists (ol) |
| 78 | + orderedList?: boolean |
| 79 | + // If there is a fixed article scroll container; set to calculate titles' offset |
| 80 | + scrollContainer?: string | null |
| 81 | + // prevent ToC DOM rendering if it's already rendered by an external system |
| 82 | + skipRendering?: boolean |
| 83 | + // Optional callback to change heading labels. |
| 84 | + // For example it can be used to cut down and put ellipses on multiline headings you deem too long. |
| 85 | + // Called each time a heading is parsed. Expects a string in return, the modified label to display. |
| 86 | + headingLabelCallback?: (headingLabel: string) => string |
| 87 | + // ignore headings that are hidden in DOM |
| 88 | + ignoreHiddenElements?: boolean |
| 89 | + // Optional callback to modify properties of parsed headings. |
| 90 | + // The heading element is passed in node parameter and information parsed by default parser is provided in obj parameter. |
| 91 | + // Function has to return the same or modified obj. |
| 92 | + // The heading will be excluded from TOC if nothing is returned. |
| 93 | + headingObjectCallback?: (obj: object, node: HTMLElement) => object | void |
| 94 | + // Set the base path, useful if you use a `base` tag in `head`. |
| 95 | + basePath?: string |
| 96 | + // Only takes affect when `tocSelector` is scrolling, |
| 97 | + // keep the toc scroll position in sync with the content. |
| 98 | + disableTocScrollSync?: boolean |
| 99 | + // Offset for the toc scroll (top) position when scrolling the page. |
| 100 | + // Only effective if `disableTocScrollSync` is false. |
| 101 | + tocScrollOffset?: number |
| 102 | + // Enable the URL hash to update with the proper heading ID as |
| 103 | + // a user scrolls the page. |
| 104 | + enableUrlHashUpdateOnScroll?: boolean |
| 105 | + // Threshold for when bottom mode should be enabled to handle |
| 106 | + // highlighting links that cannot be scrolled to. |
| 107 | + bottomModeThreshold?: number |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Initialize tocbot with an options object. |
| 112 | + * @see https://github.com/tscanlin/tocbot#init |
| 113 | + */ |
| 114 | + function init(options?: IStaticOptions): void |
| 115 | + /** |
| 116 | + * Destroy tocbot and remove event listeners. |
| 117 | + * @see https://github.com/tscanlin/tocbot#destroy |
| 118 | + */ |
| 119 | + function destroy(): void |
| 120 | + /** |
| 121 | + * Refresh tocbot if the document changes and it needs to be rebuilt. |
| 122 | + * @see https://github.com/tscanlin/tocbot#refresh |
| 123 | + */ |
| 124 | + function refresh(options?: IStaticOptions): void |
| 125 | +} |
0 commit comments