@salesforcedevs/docs-components 1.3.103 → 1.3.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.104",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@types/lodash.orderby": "^4.6.7",
|
|
25
25
|
"@types/lodash.uniqby": "^4.7.7"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "ebf2666c47ab115c2a14383eb6961fb990fd77d3"
|
|
28
28
|
}
|
|
@@ -77,6 +77,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
77
77
|
@track
|
|
78
78
|
private _tocOptions: Array<unknown>;
|
|
79
79
|
|
|
80
|
+
private tocOptionIdsSet = new Set();
|
|
80
81
|
private anchoredElements: AnchorMap = {};
|
|
81
82
|
private lastScrollPosition: number;
|
|
82
83
|
private observer?: IntersectionObserver;
|
|
@@ -220,14 +221,17 @@ export default class ContentLayout extends LightningElement {
|
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
onSlotChange(event: Event): void {
|
|
223
|
-
const slotElements = (
|
|
224
|
+
const slotElements = (
|
|
225
|
+
event.target as HTMLSlotElement
|
|
226
|
+
).assignedElements();
|
|
224
227
|
|
|
225
228
|
if (slotElements.length) {
|
|
226
229
|
this.contentLoaded = true;
|
|
227
230
|
const slotContentElement = slotElements[0];
|
|
228
|
-
const headingElements =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
const headingElements =
|
|
232
|
+
slotContentElement.ownerDocument?.getElementsByTagName(
|
|
233
|
+
TOC_HEADER_TAG
|
|
234
|
+
);
|
|
231
235
|
|
|
232
236
|
for (const headingElement of headingElements) {
|
|
233
237
|
// Sometimes elements hash is not being set when slot content is wrapped with div
|
|
@@ -239,13 +243,20 @@ export default class ContentLayout extends LightningElement {
|
|
|
239
243
|
for (const headingElement of headingElements) {
|
|
240
244
|
headingElement.id = headingElement.hash;
|
|
241
245
|
|
|
242
|
-
// Update tocOptions from anchorTags
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
// Update tocOptions from anchorTags only for H2, consider default as 2 as per component
|
|
247
|
+
const headingAriaLevel =
|
|
248
|
+
headingElement.attributes["aria-level"]?.nodeValue || "2";
|
|
249
|
+
const isH2 = headingAriaLevel === "2";
|
|
250
|
+
|
|
251
|
+
if (isH2) {
|
|
252
|
+
const tocItem = {
|
|
253
|
+
anchor: `#${headingElement.hash}`,
|
|
254
|
+
id: headingElement.id,
|
|
255
|
+
label: headingElement.title
|
|
256
|
+
};
|
|
257
|
+
tocOptions.push(tocItem);
|
|
258
|
+
this.tocOptionIdsSet.add(headingElement.id);
|
|
259
|
+
}
|
|
249
260
|
}
|
|
250
261
|
|
|
251
262
|
this._tocOptions = tocOptions;
|
|
@@ -296,7 +307,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
296
307
|
}
|
|
297
308
|
|
|
298
309
|
private assignElementId(id: string): void {
|
|
299
|
-
|
|
310
|
+
// Change toc(RNB) highlight only for H2
|
|
311
|
+
if (this.tocOptionIdsSet.has(id)) {
|
|
312
|
+
this.tocValue = id;
|
|
313
|
+
}
|
|
300
314
|
}
|
|
301
315
|
|
|
302
316
|
private dispatchHighlightChange(term: string): void {
|