@@ -5,7 +5,7 @@ import type { TocObserveConfig } from '../parameter/parameter.d.ts';
55 * Data attributes to override `toc` behavior per matching element
66 * @public
77 */
8- export interface TocDataAttributes {
8+ export interface TocElementDataAttributes {
99 /** whether to ignore this element when searching for matching elements */
1010 'data-toc-ignore' ?: boolean ;
1111 /**
@@ -28,6 +28,81 @@ export interface TocDataAttributes {
2828 'data-toc-threshold' ?: number ;
2929}
3030
31+ /**
32+ * Data attributes used by the `observe` operation when enabled
33+ * @public
34+ */
35+ export interface TocObserveDataAttributes {
36+ /**
37+ * added to the element where IntersectionObserver is used when observe is
38+ * turned on and references the associated toc element
39+ */
40+ readonly 'data-toc-observe-for' ?: string ;
41+ /**
42+ * added to toc root (the element where toc action is placed on) and
43+ * references the id of the active matching element
44+ *
45+ * @remarks
46+ *
47+ * This attribute is reactive. When changed (either by toc or manually),
48+ * it will trigger events and store update accordingly
49+ */
50+ 'data-toc-observe-active-id' ?: string ;
51+ /**
52+ * added to toc root (the element where toc action is placed on) and
53+ * indicate whether observe is being throttled, typically seen in conjunction
54+ * with usage of the complementary toclink action
55+ */
56+ readonly 'data-toc-observe-throttled' ?: boolean ;
57+ /**
58+ * added to the element where toclink is used and
59+ * set to true when the linked toc element is active
60+ */
61+ readonly 'data-toc-link-active' ?: boolean ;
62+ }
63+
64+ /**
65+ * Readonly reference markers added by toc
66+ * @public
67+ */
68+ export interface TocReferenceMarkerDataAttributes {
69+ /**
70+ * marking this element that it's been processed by toc
71+ *
72+ * @remarks
73+ *
74+ * If this is already preprocessed by {@link https://svelte-put.vnphanquang.com/docs/preprocess-auto-slug | @svelte-put/preprocess-auto-slug},
75+ * there will also be a `data-auto-slug` attribute.
76+ */
77+ readonly 'data-toc' ?: '' ;
78+ /**
79+ * if the anchor option is enabled in toc parameters, this attribute is present on the injected anchor element.
80+ *
81+ * @remarks
82+ *
83+ * If the element is already added by {@link https://svelte-put.vnphanquang.com/docs/preprocess-auto-slug | @svelte-put/preprocess-auto-slug},
84+ * there `data-auto-slug-anchor` attribute is found instead.
85+ */
86+ readonly 'data-toc-anchor' ?: '' ;
87+ /**
88+ * added to the element where toc action is used for internal reference
89+ */
90+ readonly 'data-toc-root' ?: '' ;
91+ /**
92+ * added to the element where toclink action is used and references the linked toc element
93+ */
94+ readonly 'data-toc-link-for' ?: '' ;
95+
96+ /**
97+ * from {@link https://svelte-put.vnphanquang.com/docs/preprocess-auto-slug | @svelte-put/preprocess-auto-slug}
98+ */
99+ 'data-auto-slug' ?: '' ;
100+ 'data-auto-slug-anchor' ?: '' ;
101+ 'data-auto-slug-anchor-position' ?: '' ;
102+ }
103+
104+ export interface TocDataAttributes extends TocElementDataAttributes , TocObserveDataAttributes , TocReferenceMarkerDataAttributes { }
105+
31106/**
32107 * ambient typing for `toc` event handlers
33108 * @public
0 commit comments