@salesforcedevs/docs-components 0.7.59-sppage-alpha2 → 0.7.76-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/lwc.config.json +3 -0
- package/package.json +9 -4
- package/src/modules/doc/amfReference/amfReference.css +0 -12
- package/src/modules/doc/amfReference/amfReference.html +1 -6
- package/src/modules/doc/amfReference/amfReference.ts +10 -37
- package/src/modules/doc/amfTopic/amfTopic.ts +24 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +0 -1
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +14 -23
- package/src/modules/doc/componentPlayground/componentPlayground.css +30 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +97 -0
- package/src/modules/doc/content/content.html +1 -0
- package/src/modules/doc/content/content.ts +7 -33
- package/src/modules/doc/contentCallout/contentCallout.css +1 -0
- package/src/modules/doc/contentLayout/contentLayout.css +27 -123
- package/src/modules/doc/contentLayout/contentLayout.html +42 -36
- package/src/modules/doc/contentLayout/contentLayout.ts +152 -204
- package/src/modules/doc/contentMedia/contentMedia.css +1 -1
- package/src/modules/doc/header/header.html +8 -3
- package/src/modules/doc/header/header.ts +49 -10
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +9 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +64 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +269 -0
- package/src/modules/doc/phase/phase.css +0 -7
- package/src/modules/doc/redocReference/redocReference.css +7 -0
- package/src/modules/doc/redocReference/redocReference.html +13 -0
- package/src/modules/doc/redocReference/redocReference.ts +427 -0
- package/src/modules/doc/specificationContent/specificationContent.css +33 -0
- package/src/modules/doc/specificationContent/specificationContent.html +94 -16
- package/src/modules/doc/specificationContent/specificationContent.ts +131 -21
- package/src/modules/doc/versionPicker/versionPicker.html +2 -0
- package/src/modules/doc/xmlContent/xmlContent.css +0 -10
- package/src/modules/doc/xmlContent/xmlContent.html +11 -8
- package/src/modules/doc/xmlContent/xmlContent.ts +76 -57
- package/src/modules/docHelpers/amfStyle/amfStyle.css +0 -2
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +160 -0
- package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
- package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
- package/src/modules/docUtils/utils/utils.ts +1 -1
|
@@ -5,13 +5,14 @@ import { toJson } from "dxUtils/normalizers";
|
|
|
5
5
|
import { highlightTerms } from "dxUtils/highlight";
|
|
6
6
|
import { SearchSyncer } from "docUtils/searchSyncer";
|
|
7
7
|
import type { OptionWithLink } from "typings/custom";
|
|
8
|
+
import { buildDocLinkClickHandler } from "dxUtils/analytics";
|
|
8
9
|
|
|
9
10
|
type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
|
|
10
11
|
|
|
11
12
|
declare const Sprig: (eventType: string, eventNme: string) => void;
|
|
12
13
|
|
|
13
14
|
const TOC_HEADER_TAG = "doc-heading";
|
|
14
|
-
|
|
15
|
+
|
|
15
16
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
16
17
|
"p",
|
|
17
18
|
"h1",
|
|
@@ -32,20 +33,20 @@ export default class ContentLayout extends LightningElement {
|
|
|
32
33
|
@api sidebarHeader!: string;
|
|
33
34
|
@api tocTitle!: string;
|
|
34
35
|
@api enableSlotChange = false;
|
|
35
|
-
@api coveoOrganizationId!: string;
|
|
36
|
-
@api coveoPublicAccessToken!: string;
|
|
37
|
-
@api coveoAnalyticsToken!: string;
|
|
38
|
-
@api coveoSearchHub!: string;
|
|
39
|
-
@api coveoAdvancedQueryConfig!: string;
|
|
40
36
|
@api useOldSidebar?: boolean = false;
|
|
41
37
|
@api languages!: OptionWithLink[];
|
|
42
38
|
@api language!: string;
|
|
43
39
|
@api bailHref!: string;
|
|
44
40
|
@api bailLabel!: string;
|
|
41
|
+
@api devCenter: any;
|
|
42
|
+
@api brand: any;
|
|
43
|
+
@api emptyStateMessage?: string;
|
|
45
44
|
|
|
46
45
|
// This is needed for now to prevent failing snapshot tests due to links in the footer
|
|
47
46
|
@api showFooter = false;
|
|
48
47
|
|
|
48
|
+
@api readingTime?: number;
|
|
49
|
+
|
|
49
50
|
@api
|
|
50
51
|
get breadcrumbs() {
|
|
51
52
|
return this._breadcrumbs;
|
|
@@ -83,87 +84,26 @@ export default class ContentLayout extends LightningElement {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
@track
|
|
86
|
-
|
|
87
|
+
protected _sidebarContent: unknown;
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
protected _breadcrumbs = null;
|
|
89
90
|
|
|
90
91
|
@track
|
|
91
|
-
|
|
92
|
+
protected _tocOptions!: Array<unknown>;
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
private rnbByTab: boolean = false;
|
|
94
|
+
protected tocOptionIdsSet = new Set();
|
|
95
|
+
protected anchoredElements: AnchorMap = {};
|
|
96
|
+
protected lastScrollPosition!: number;
|
|
97
|
+
protected observer?: IntersectionObserver;
|
|
98
|
+
protected hasRendered: boolean = false;
|
|
99
|
+
protected contentLoaded: boolean = false;
|
|
100
|
+
protected sidebarOpen: boolean = false;
|
|
101
101
|
|
|
102
102
|
get shouldDisplayFeedback() {
|
|
103
103
|
return this.contentLoaded && typeof Sprig !== "undefined";
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
const tabPanelListItem: any = this.getTabPanelList();
|
|
108
|
-
this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB ? true : false;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get showTabBasedRNB() {
|
|
112
|
-
return this.rnbByTab;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
onTabChanged = () => {
|
|
116
|
-
this.updateRNB();
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
private getTabPanelList() {
|
|
120
|
-
return document.querySelector("dx-tab-panel-list");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
updateRNB = () => {
|
|
124
|
-
const headingElements = this.getHeadingElements();
|
|
125
|
-
headingElements.forEach((headingElement: any) => {
|
|
126
|
-
// Sometimes elements hash and header is not being set when slot content is wrapped with div
|
|
127
|
-
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
128
|
-
headingElement.header = headingElement.attributes.header?.nodeValue;
|
|
129
|
-
});
|
|
130
|
-
this.updateTocItems(headingElements);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
private getHeadingElements() {
|
|
134
|
-
let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
135
|
-
if (this.showTabBasedRNB) {
|
|
136
|
-
const tabPanelListItem: any = this.getTabPanelList();
|
|
137
|
-
const tabPanels =
|
|
138
|
-
tabPanelListItem?.querySelectorAll("dx-tab-panel");
|
|
139
|
-
for (const tabPanelItem of tabPanels) {
|
|
140
|
-
if (tabPanelItem.active) {
|
|
141
|
-
headingElements =
|
|
142
|
-
tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return headingElements;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private updateURL() {
|
|
151
|
-
const tabs = this.getAllTabs();
|
|
152
|
-
const selectedTabId = this.getSelectedTabId();
|
|
153
|
-
tabs.forEach((tab: any) => {
|
|
154
|
-
if (tab.getAttribute("aria-selected") === "true") {
|
|
155
|
-
const tabID = tab.getAttribute("aria-label");
|
|
156
|
-
const url = new URL(window.location.href);
|
|
157
|
-
if (selectedTabId !== tabID) {
|
|
158
|
-
url.searchParams.set("type", tabID);
|
|
159
|
-
url.hash = "";
|
|
160
|
-
window.history.pushState({}, "", url.toString());
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private searchSyncer = new SearchSyncer({
|
|
106
|
+
protected searchSyncer = new SearchSyncer({
|
|
167
107
|
callbacks: {
|
|
168
108
|
onSearchChange: (nextSearchString: string): void => {
|
|
169
109
|
this.dispatchHighlightChange(
|
|
@@ -177,11 +117,12 @@ export default class ContentLayout extends LightningElement {
|
|
|
177
117
|
shouldStopPropagation: true,
|
|
178
118
|
target: window
|
|
179
119
|
});
|
|
180
|
-
|
|
120
|
+
protected tocValue?: string = undefined;
|
|
181
121
|
// eslint-disable-next-line no-undef
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
122
|
+
protected observerTimerId?: NodeJS.Timeout;
|
|
123
|
+
protected didScrollToSelectedHash = false;
|
|
124
|
+
protected _scrollInterval = 0;
|
|
125
|
+
protected handleLinkClick = buildDocLinkClickHandler();
|
|
185
126
|
|
|
186
127
|
get showToc(): boolean {
|
|
187
128
|
return this.tocOptions && this.tocOptions.length > 0;
|
|
@@ -198,12 +139,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
198
139
|
);
|
|
199
140
|
}
|
|
200
141
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.restoreTabSelection();
|
|
205
|
-
}
|
|
206
|
-
};
|
|
142
|
+
get showReadingTime(): boolean {
|
|
143
|
+
return this.readingTime != null && this.readingTime > 0;
|
|
144
|
+
}
|
|
207
145
|
|
|
208
146
|
connectedCallback(): void {
|
|
209
147
|
const hasParentHighlightListener = closest(
|
|
@@ -217,46 +155,13 @@ export default class ContentLayout extends LightningElement {
|
|
|
217
155
|
);
|
|
218
156
|
this.searchSyncer.init();
|
|
219
157
|
}
|
|
220
|
-
window.addEventListener("popstate", this.handlePopState);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
private getSelectedTabId() {
|
|
224
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
225
|
-
const selectedTabId = urlParams.get("type");
|
|
226
|
-
return selectedTabId;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
private restoreTabSelection() {
|
|
230
|
-
requestAnimationFrame(() => {
|
|
231
|
-
const selectedTabId = this.getSelectedTabId();
|
|
232
|
-
if (selectedTabId) {
|
|
233
|
-
this.selectTabById(selectedTabId);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
158
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (tabPanelListItem?.shadowRoot) {
|
|
241
|
-
return Array.from(
|
|
242
|
-
tabPanelListItem.shadowRoot.querySelectorAll(
|
|
243
|
-
"dx-tab-panel-item"
|
|
244
|
-
)
|
|
245
|
-
).map((tabPanelItem: any) =>
|
|
246
|
-
tabPanelItem.shadowRoot.querySelector("button")
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
return [];
|
|
159
|
+
// Add click handler for all links
|
|
160
|
+
this.template.addEventListener("click", this.handleLinkClick);
|
|
250
161
|
}
|
|
251
162
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
tabs.forEach((tab: any) => {
|
|
255
|
-
if (tab.getAttribute("aria-label") === tabId) {
|
|
256
|
-
tab.click();
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
163
|
+
// Placeholder for childs renderedCallback
|
|
164
|
+
protected postRenderedCallback?(): void;
|
|
260
165
|
|
|
261
166
|
renderedCallback(): void {
|
|
262
167
|
/**
|
|
@@ -275,12 +180,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
275
180
|
|
|
276
181
|
if (!this.hasRendered) {
|
|
277
182
|
this.hasRendered = true;
|
|
278
|
-
this.setRNBByTab();
|
|
279
|
-
if (this.showTabBasedRNB) {
|
|
280
|
-
window.addEventListener("tabchanged", this.onTabChanged);
|
|
281
|
-
this.restoreTabSelection();
|
|
282
|
-
}
|
|
283
183
|
this.restoreScroll();
|
|
184
|
+
|
|
185
|
+
// Dynamically call `renderedCallbackForLwcContentLayout` if it exists
|
|
186
|
+
this.postRenderedCallback?.();
|
|
284
187
|
}
|
|
285
188
|
}
|
|
286
189
|
|
|
@@ -292,12 +195,13 @@ export default class ContentLayout extends LightningElement {
|
|
|
292
195
|
);
|
|
293
196
|
window.removeEventListener("scroll", this.adjustNavPosition);
|
|
294
197
|
window.removeEventListener("resize", this.adjustNavPosition);
|
|
295
|
-
window.removeEventListener("tabchanged", this.onTabChanged);
|
|
296
|
-
window.removeEventListener("popstate", this.handlePopState);
|
|
297
198
|
this.searchSyncer.dispose();
|
|
298
199
|
this.clearRenderObserverTimer();
|
|
299
200
|
|
|
300
201
|
window.clearInterval(this._scrollInterval);
|
|
202
|
+
|
|
203
|
+
// Remove link click handler
|
|
204
|
+
this.template.removeEventListener("click", this.handleLinkClick);
|
|
301
205
|
}
|
|
302
206
|
|
|
303
207
|
restoreScroll() {
|
|
@@ -316,10 +220,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
316
220
|
We have to account for the global nav changing height due to animations.
|
|
317
221
|
*/
|
|
318
222
|
adjustNavPosition = () => {
|
|
319
|
-
const
|
|
320
|
-
? "dx-sidebar-old"
|
|
321
|
-
: "dx-sidebar";
|
|
322
|
-
const sidebarEl = this.template.querySelector(sidebarType);
|
|
223
|
+
const sidebarEl = this.template.querySelector("dx-sidebar-old");
|
|
323
224
|
const globalNavEl = document.querySelector(
|
|
324
225
|
"hgf-c360nav"
|
|
325
226
|
) as HTMLElement;
|
|
@@ -330,15 +231,20 @@ export default class ContentLayout extends LightningElement {
|
|
|
330
231
|
".sticky-doc-header"
|
|
331
232
|
) as HTMLElement;
|
|
332
233
|
|
|
333
|
-
|
|
334
|
-
|
|
234
|
+
const docPhaseWrapper = this.template.querySelector(
|
|
235
|
+
".doc-phase-wrapper"
|
|
236
|
+
) as HTMLElement;
|
|
237
|
+
const versionWrapper = this.template.querySelector(
|
|
238
|
+
".version-wrapper"
|
|
239
|
+
) as HTMLElement;
|
|
240
|
+
|
|
241
|
+
const docPhaseEl = (
|
|
242
|
+
docPhaseWrapper.querySelector("[name=doc-phase]")! as any
|
|
335
243
|
).assignedElements()[0] as HTMLSlotElement;
|
|
336
244
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
).assignedElements()[0] as HTMLSlotElement;
|
|
341
|
-
}
|
|
245
|
+
const verBannerEl = (
|
|
246
|
+
versionWrapper.querySelector("[name=version-banner]")! as any
|
|
247
|
+
).assignedElements()[0] as HTMLSlotElement;
|
|
342
248
|
|
|
343
249
|
if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
|
|
344
250
|
console.warn("One or more required elements are missing.");
|
|
@@ -370,39 +276,54 @@ export default class ContentLayout extends LightningElement {
|
|
|
370
276
|
`${globalNavHeight}px`
|
|
371
277
|
);
|
|
372
278
|
|
|
279
|
+
const docPhaseElHeight =
|
|
280
|
+
docPhaseEl || verBannerEl
|
|
281
|
+
? (docPhaseEl || verBannerEl).getBoundingClientRect().height
|
|
282
|
+
: 0;
|
|
283
|
+
|
|
373
284
|
// Adjusting the doc section heading on scroll.
|
|
374
285
|
docHeadingEls.forEach((docHeadingEl) => {
|
|
375
|
-
(docHeadingEl as any).style.scrollMarginTop =
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
docPhaseEl.getBoundingClientRect().height +
|
|
379
|
-
40
|
|
380
|
-
}px`
|
|
381
|
-
: `${totalHeaderHeight + 40}px`;
|
|
286
|
+
(docHeadingEl as any).style.scrollMarginTop = `${
|
|
287
|
+
totalHeaderHeight + docPhaseElHeight + 40
|
|
288
|
+
}px`;
|
|
382
289
|
});
|
|
383
290
|
|
|
384
291
|
// Adjusting the right nav bar on scroll.
|
|
292
|
+
// setting maxheight to make the RNB scrollable based on different parent elements
|
|
385
293
|
if (rightNavBarEl) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
294
|
+
const viewportHeight = window.innerHeight;
|
|
295
|
+
const maxHeight =
|
|
296
|
+
viewportHeight -
|
|
297
|
+
(docPhaseElHeight + totalHeaderHeight + 24); //added some margin of dx-toc
|
|
298
|
+
|
|
299
|
+
rightNavBarEl.style.top = `${
|
|
300
|
+
totalHeaderHeight + docPhaseElHeight
|
|
301
|
+
}px`;
|
|
302
|
+
|
|
303
|
+
const toc = rightNavBarEl.querySelector("dx-toc");
|
|
304
|
+
const listContainer = toc?.shadowRoot?.querySelector(
|
|
305
|
+
".toc"
|
|
306
|
+
) as HTMLElement;
|
|
307
|
+
|
|
308
|
+
if (listContainer) {
|
|
309
|
+
listContainer.style.maxHeight = `${maxHeight}px`;
|
|
310
|
+
}
|
|
392
311
|
}
|
|
393
312
|
|
|
313
|
+
const docPhaseTop =
|
|
314
|
+
window.innerWidth < 769
|
|
315
|
+
? globalNavHeight +
|
|
316
|
+
docHeaderHeight +
|
|
317
|
+
sidebarEl.getBoundingClientRect().height
|
|
318
|
+
: globalNavHeight + docHeaderHeight;
|
|
319
|
+
|
|
394
320
|
// If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
|
|
321
|
+
// To handle sticky position for safari browser, position sticky given to wrapper class
|
|
395
322
|
if (docPhaseEl) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
? globalNavHeight +
|
|
401
|
-
docHeaderHeight +
|
|
402
|
-
sidebarEl.getBoundingClientRect().height
|
|
403
|
-
: globalNavHeight + docHeaderHeight
|
|
404
|
-
}px`
|
|
405
|
-
);
|
|
323
|
+
docPhaseWrapper.style.top = `${docPhaseTop}px`;
|
|
324
|
+
} else if (verBannerEl) {
|
|
325
|
+
versionWrapper.style.position = "sticky";
|
|
326
|
+
versionWrapper.style.top = `${docPhaseTop}px`;
|
|
406
327
|
}
|
|
407
328
|
});
|
|
408
329
|
};
|
|
@@ -413,6 +334,34 @@ export default class ContentLayout extends LightningElement {
|
|
|
413
334
|
(event as CustomEvent<string>).detail
|
|
414
335
|
);
|
|
415
336
|
|
|
337
|
+
protected getHeadingElements() {
|
|
338
|
+
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
339
|
+
const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
340
|
+
return headingElements;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
updateHeadingForRNB(): void {
|
|
344
|
+
const headingElements = this.getHeadingElements();
|
|
345
|
+
this.addObserverAndScroll(headingElements);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
addObserverAndScroll(headingElements: any) {
|
|
349
|
+
for (const headingElement of headingElements as any) {
|
|
350
|
+
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
351
|
+
const id = headingElement.getAttribute("id")!;
|
|
352
|
+
this.anchoredElements[id] = {
|
|
353
|
+
id,
|
|
354
|
+
intersect: false
|
|
355
|
+
};
|
|
356
|
+
this.observer?.observe(headingElement);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (!this.didScrollToSelectedHash) {
|
|
360
|
+
this.didScrollToSelectedHash = true;
|
|
361
|
+
this.scrollToHash(headingElements);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
416
365
|
attachInteractionObserver = (): void => {
|
|
417
366
|
if (!this.enableSlotChange) {
|
|
418
367
|
return;
|
|
@@ -437,38 +386,11 @@ export default class ContentLayout extends LightningElement {
|
|
|
437
386
|
rootMargin: globalNavOffset.trim()
|
|
438
387
|
}
|
|
439
388
|
);
|
|
440
|
-
|
|
441
|
-
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
442
|
-
const headingElements = this.getHeadingElements();
|
|
443
|
-
|
|
444
|
-
// We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
|
|
445
|
-
if (this.showTabBasedRNB) {
|
|
446
|
-
this.updateURL();
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
for (const headingElement of headingElements as any) {
|
|
450
|
-
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
451
|
-
const id = headingElement.getAttribute("id")!;
|
|
452
|
-
this.anchoredElements[id] = {
|
|
453
|
-
id,
|
|
454
|
-
intersect: false
|
|
455
|
-
};
|
|
456
|
-
this.observer.observe(headingElement);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (!this.didScrollToSelectedHash) {
|
|
460
|
-
this.didScrollToSelectedHash = true;
|
|
461
|
-
this.scrollToHash(headingElements);
|
|
462
|
-
}
|
|
389
|
+
this.updateHeadingForRNB();
|
|
463
390
|
};
|
|
464
391
|
|
|
465
|
-
onSlotChange(): void {
|
|
466
|
-
this.updateRNB();
|
|
467
|
-
this.contentLoaded = true;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
392
|
// eslint-disable-next-line no-undef
|
|
471
|
-
|
|
393
|
+
updateTocItems(headingElements: any): void {
|
|
472
394
|
const tocOptions = [];
|
|
473
395
|
|
|
474
396
|
for (const headingElement of headingElements as any) {
|
|
@@ -493,7 +415,33 @@ export default class ContentLayout extends LightningElement {
|
|
|
493
415
|
this._tocOptions = tocOptions;
|
|
494
416
|
}
|
|
495
417
|
|
|
496
|
-
|
|
418
|
+
setHashAndHeaderForDocHeading(headingElements: any) {
|
|
419
|
+
for (const headingElement of headingElements as any) {
|
|
420
|
+
// Sometimes elements hash and header is not being set when slot content is wrapped with div
|
|
421
|
+
if (!headingElement.hash) {
|
|
422
|
+
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (!headingElement.header) {
|
|
426
|
+
headingElement.header =
|
|
427
|
+
headingElement.attributes.header?.nodeValue;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
this.updateTocItems(headingElements);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
updateRNB = () => {
|
|
435
|
+
const headingElements = this.getHeadingElements();
|
|
436
|
+
this.setHashAndHeaderForDocHeading(headingElements);
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
onSlotChange(): void {
|
|
440
|
+
this.updateRNB();
|
|
441
|
+
this.contentLoaded = true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
protected disconnectObserver(): void {
|
|
497
445
|
if (this.observer) {
|
|
498
446
|
this.observer.disconnect();
|
|
499
447
|
this.observer = undefined;
|
|
@@ -501,7 +449,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
501
449
|
}
|
|
502
450
|
|
|
503
451
|
// eslint-disable-next-line no-undef
|
|
504
|
-
|
|
452
|
+
protected scrollToHash(headingElements: NodeListOf<Element>): void {
|
|
505
453
|
let { hash } = window.location;
|
|
506
454
|
if (hash) {
|
|
507
455
|
hash = hash.substr(1);
|
|
@@ -538,7 +486,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
538
486
|
}
|
|
539
487
|
}
|
|
540
488
|
|
|
541
|
-
|
|
489
|
+
protected scrollIntoViewWithOffset(
|
|
542
490
|
headingElement: HTMLElement,
|
|
543
491
|
offset: number
|
|
544
492
|
) {
|
|
@@ -551,7 +499,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
551
499
|
});
|
|
552
500
|
}
|
|
553
501
|
|
|
554
|
-
|
|
502
|
+
protected calculateActualSection(): void {
|
|
555
503
|
const currentScrollPosition = document.documentElement.scrollTop;
|
|
556
504
|
const id = Object.keys(this.anchoredElements).find(
|
|
557
505
|
(_id) => this.anchoredElements[_id].intersect
|
|
@@ -566,21 +514,21 @@ export default class ContentLayout extends LightningElement {
|
|
|
566
514
|
this.lastScrollPosition = currentScrollPosition;
|
|
567
515
|
}
|
|
568
516
|
|
|
569
|
-
|
|
517
|
+
protected calculatePreviousElementId(): string | undefined {
|
|
570
518
|
const keys = Object.keys(this.anchoredElements);
|
|
571
519
|
const currentIndex = keys.findIndex((id) => this.tocValue === id);
|
|
572
520
|
|
|
573
521
|
return currentIndex > 0 ? keys[currentIndex - 1] : undefined;
|
|
574
522
|
}
|
|
575
523
|
|
|
576
|
-
|
|
524
|
+
protected assignElementId(id: string | undefined): void {
|
|
577
525
|
// Change toc(RNB) highlight only for H2
|
|
578
526
|
if (this.tocOptionIdsSet.has(id)) {
|
|
579
527
|
this.tocValue = id;
|
|
580
528
|
}
|
|
581
529
|
}
|
|
582
530
|
|
|
583
|
-
|
|
531
|
+
protected dispatchHighlightChange(term: string): void {
|
|
584
532
|
this.dispatchEvent(
|
|
585
533
|
new CustomEvent("highlightedtermchange", {
|
|
586
534
|
detail: term,
|
|
@@ -590,14 +538,14 @@ export default class ContentLayout extends LightningElement {
|
|
|
590
538
|
);
|
|
591
539
|
}
|
|
592
540
|
|
|
593
|
-
|
|
541
|
+
protected updateHighlightsAndSearch(nextSearchString: string): void {
|
|
594
542
|
const nextSearchParam =
|
|
595
543
|
new URLSearchParams(nextSearchString).get("q") || "";
|
|
596
544
|
this.setSidebarInputValue(nextSearchParam);
|
|
597
545
|
this.dispatchHighlightChange(nextSearchParam);
|
|
598
546
|
}
|
|
599
547
|
|
|
600
|
-
|
|
548
|
+
protected onToggleSidebar(e: CustomEvent): void {
|
|
601
549
|
this.sidebarOpen = e.detail.open;
|
|
602
550
|
|
|
603
551
|
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
@@ -6,8 +6,13 @@
|
|
|
6
6
|
lwc:if={showBanner}
|
|
7
7
|
banner-markup={bannerMarkup}
|
|
8
8
|
></dx-banner>
|
|
9
|
+
<!-- To-Do: Move the devCenter as a new component and use it here, as devCenter is also used in Sidebar now -->
|
|
9
10
|
<div lwc:if={devCenter} class="dev-center-link">
|
|
10
|
-
<a
|
|
11
|
+
<a
|
|
12
|
+
href={devCenter.link}
|
|
13
|
+
onclick={onLinkClick}
|
|
14
|
+
class="dev-center-content"
|
|
15
|
+
>
|
|
11
16
|
<dx-icon symbol="back"></dx-icon>
|
|
12
17
|
<dx-icon
|
|
13
18
|
class="brand-icon"
|
|
@@ -30,7 +35,7 @@
|
|
|
30
35
|
</a>
|
|
31
36
|
</div>
|
|
32
37
|
<div
|
|
33
|
-
lwc:if={
|
|
38
|
+
lwc:if={showScopedNavItems}
|
|
34
39
|
class="header_l2_group header_l2_group-nav"
|
|
35
40
|
>
|
|
36
41
|
<div
|
|
@@ -48,7 +53,7 @@
|
|
|
48
53
|
</header>
|
|
49
54
|
</dx-brand-theme-provider>
|
|
50
55
|
</template>
|
|
51
|
-
<template lwc:if={
|
|
56
|
+
<template lwc:if={shouldHideHeader}>
|
|
52
57
|
<div class="no-header-content"></div>
|
|
53
58
|
</template>
|
|
54
59
|
</template>
|