@salesforcedevs/docs-components 1.3.300-fix-alpha2 → 1.3.300-rnb-tab-alpha
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
|
@@ -1475,18 +1475,10 @@ export default class AmfReference extends LightningElement {
|
|
|
1475
1475
|
// update topic view
|
|
1476
1476
|
const { referenceId, amfId, type } = this.selectedTopic!;
|
|
1477
1477
|
|
|
1478
|
-
// Adding stringify inside try/catch
|
|
1479
|
-
let amfString = "";
|
|
1480
|
-
try {
|
|
1481
|
-
amfString = JSON.stringify(this.amfMap[referenceId].model);
|
|
1482
|
-
} catch (error) {
|
|
1483
|
-
console.error(`Error stringifying amf model: ${error}`);
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
1478
|
// This updates the component in the content section.
|
|
1487
1479
|
this.topicModel = {
|
|
1488
1480
|
type,
|
|
1489
|
-
amf:
|
|
1481
|
+
amf: this.amfMap[referenceId].model,
|
|
1490
1482
|
parser: this.amfMap[referenceId].parser,
|
|
1491
1483
|
id: amfId
|
|
1492
1484
|
};
|
|
@@ -27,11 +27,7 @@ export default class AmfTopic extends LightningElement {
|
|
|
27
27
|
!this.amf ||
|
|
28
28
|
(value && this._model && value.amf !== this._model?.amf)
|
|
29
29
|
) {
|
|
30
|
-
|
|
31
|
-
this.amf = value && JSON.parse(value.amf);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error(`Error parsing amf model:: ${error}`);
|
|
34
|
-
}
|
|
30
|
+
this.amf = value && clone(value.amf);
|
|
35
31
|
}
|
|
36
32
|
if (
|
|
37
33
|
!this.type ||
|
|
@@ -41,6 +41,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
41
41
|
@api language!: string;
|
|
42
42
|
@api bailHref!: string;
|
|
43
43
|
@api bailLabel!: string;
|
|
44
|
+
@api rnbByTabId?: string = "lwc-doc-tab";
|
|
44
45
|
|
|
45
46
|
// This is needed for now to prevent failing snapshot tests due to links in the footer
|
|
46
47
|
@api showFooter = false;
|
|
@@ -101,6 +102,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
101
102
|
return this.contentLoaded && typeof Sprig !== "undefined";
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
get showTabBasedRNB() {
|
|
106
|
+
return this.rnbByTabId ? true : false;
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
private searchSyncer = new SearchSyncer({
|
|
105
110
|
callbacks: {
|
|
106
111
|
onSearchChange: (nextSearchString: string): void => {
|
|
@@ -136,6 +141,41 @@ export default class ContentLayout extends LightningElement {
|
|
|
136
141
|
);
|
|
137
142
|
}
|
|
138
143
|
|
|
144
|
+
onTabChanged = () => {
|
|
145
|
+
this.updateRNB();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
updateRNB = () => {
|
|
149
|
+
const headingElements = this.getHeadingElements();
|
|
150
|
+
headingElements.forEach((headingElement: any) => {
|
|
151
|
+
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
152
|
+
});
|
|
153
|
+
this.updateTocItems(headingElements);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
private getHeadingElements() {
|
|
157
|
+
let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
158
|
+
if (this.showTabBasedRNB) {
|
|
159
|
+
const tabPanelListItems: any =
|
|
160
|
+
document.querySelectorAll("dx-tab-panel-list");
|
|
161
|
+
for (const tabPanelListItem of tabPanelListItems) {
|
|
162
|
+
if (tabPanelListItem.id === this.rnbByTabId) {
|
|
163
|
+
const tabPanelItems =
|
|
164
|
+
tabPanelListItem.querySelectorAll("dx-tab-panel");
|
|
165
|
+
for (const tabPanelItem of tabPanelItems) {
|
|
166
|
+
if (tabPanelItem.active) {
|
|
167
|
+
headingElements =
|
|
168
|
+
tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return headingElements;
|
|
177
|
+
}
|
|
178
|
+
|
|
139
179
|
connectedCallback(): void {
|
|
140
180
|
const hasParentHighlightListener = closest(
|
|
141
181
|
"doc-xml-content",
|
|
@@ -148,6 +188,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
148
188
|
);
|
|
149
189
|
this.searchSyncer.init();
|
|
150
190
|
}
|
|
191
|
+
if (this.showTabBasedRNB) {
|
|
192
|
+
window.addEventListener("tabchanged", this.onTabChanged);
|
|
193
|
+
}
|
|
151
194
|
}
|
|
152
195
|
|
|
153
196
|
renderedCallback(): void {
|
|
@@ -255,9 +298,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
255
298
|
);
|
|
256
299
|
|
|
257
300
|
// Adjust scroll margin for doc headings when doc phase is present
|
|
258
|
-
const docHeadingEls =
|
|
259
|
-
document.querySelectorAll("doc-heading")
|
|
260
|
-
);
|
|
301
|
+
const docHeadingEls = this.getHeadingElements();
|
|
261
302
|
docHeadingEls.forEach((docHeadingEl) => {
|
|
262
303
|
(docHeadingEl as any).style.scrollMarginTop = `${
|
|
263
304
|
globalNavHeight +
|
|
@@ -313,7 +354,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
313
354
|
);
|
|
314
355
|
|
|
315
356
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
316
|
-
const headingElements =
|
|
357
|
+
const headingElements = this.getHeadingElements();
|
|
317
358
|
for (const headingElement of headingElements as any) {
|
|
318
359
|
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
319
360
|
const id = headingElement.getAttribute("id")!;
|
|
@@ -329,47 +370,34 @@ export default class ContentLayout extends LightningElement {
|
|
|
329
370
|
}
|
|
330
371
|
};
|
|
331
372
|
|
|
332
|
-
onSlotChange(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
).assignedElements();
|
|
336
|
-
|
|
337
|
-
if (slotElements.length) {
|
|
338
|
-
this.contentLoaded = true;
|
|
339
|
-
const slotContentElement = slotElements[0];
|
|
340
|
-
const headingElements =
|
|
341
|
-
slotContentElement.ownerDocument?.getElementsByTagName(
|
|
342
|
-
TOC_HEADER_TAG
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
for (const headingElement of headingElements as any) {
|
|
346
|
-
// Sometimes elements hash is not being set when slot content is wrapped with div
|
|
347
|
-
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
348
|
-
}
|
|
373
|
+
onSlotChange(): void {
|
|
374
|
+
this.updateRNB();
|
|
375
|
+
}
|
|
349
376
|
|
|
350
|
-
|
|
377
|
+
// eslint-disable-next-line no-undef
|
|
378
|
+
private updateTocItems(headingElements: NodeListOf<Element>): void {
|
|
379
|
+
const tocOptions = [];
|
|
351
380
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
381
|
+
for (const headingElement of headingElements as any) {
|
|
382
|
+
headingElement.id = headingElement.hash;
|
|
383
|
+
|
|
384
|
+
// Update tocOptions from anchorTags only for H2, consider default as 2 as per component
|
|
385
|
+
const headingAriaLevel =
|
|
386
|
+
headingElement.attributes["aria-level"]?.nodeValue || "2";
|
|
387
|
+
const isH2 = headingAriaLevel === "2";
|
|
388
|
+
|
|
389
|
+
if (isH2) {
|
|
390
|
+
const tocItem = {
|
|
391
|
+
anchor: `#${headingElement.hash}`,
|
|
392
|
+
id: headingElement.id,
|
|
393
|
+
label: headingElement.title
|
|
394
|
+
};
|
|
395
|
+
tocOptions.push(tocItem);
|
|
396
|
+
this.tocOptionIdsSet.add(headingElement.id);
|
|
369
397
|
}
|
|
370
|
-
|
|
371
|
-
this._tocOptions = tocOptions;
|
|
372
398
|
}
|
|
399
|
+
|
|
400
|
+
this._tocOptions = tocOptions;
|
|
373
401
|
}
|
|
374
402
|
|
|
375
403
|
private disconnectObserver(): void {
|