@salesforcedevs/docs-components 1.34.6 → 1.34.8
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,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.8",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "22.
|
|
8
|
+
"node": "24.22.1"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "483ca68f1d878910284fbcb0df178fc2a4f48a3a"
|
|
29
29
|
}
|
|
@@ -31,6 +31,9 @@ const HIGHLIGHTABLE_SELECTOR = [
|
|
|
31
31
|
"td"
|
|
32
32
|
].join(",");
|
|
33
33
|
export const OBSERVER_ATTACH_WAIT_TIME = 500;
|
|
34
|
+
const HASH_SCROLL_DELAY = 500;
|
|
35
|
+
const MAX_HASH_SCROLL_WAIT_TIME = 10000;
|
|
36
|
+
const CODE_BLOCK_TAG = "dx-code-block";
|
|
34
37
|
|
|
35
38
|
const DEFAULT_READING_TIME_LOCALE = "en-us";
|
|
36
39
|
|
|
@@ -191,6 +194,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
191
194
|
// eslint-disable-next-line no-undef
|
|
192
195
|
protected observerTimerId?: NodeJS.Timeout;
|
|
193
196
|
protected didScrollToSelectedHash = false;
|
|
197
|
+
// eslint-disable-next-line no-undef
|
|
198
|
+
protected hashScrollTimerId?: NodeJS.Timeout;
|
|
199
|
+
protected hashScrollWaitStart?: number;
|
|
194
200
|
protected _scrollInterval = 0;
|
|
195
201
|
protected handleLinkClick = buildDocLinkClickHandler();
|
|
196
202
|
|
|
@@ -335,6 +341,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
335
341
|
this.clearRenderObserverTimer();
|
|
336
342
|
|
|
337
343
|
window.clearInterval(this._scrollInterval);
|
|
344
|
+
clearTimeout(this.hashScrollTimerId);
|
|
338
345
|
|
|
339
346
|
// Remove link click handler
|
|
340
347
|
this.template.removeEventListener("click", this.handleLinkClick);
|
|
@@ -496,9 +503,45 @@ export default class ContentLayout extends LightningElement {
|
|
|
496
503
|
}
|
|
497
504
|
|
|
498
505
|
if (!this.didScrollToSelectedHash) {
|
|
506
|
+
this.tryScrollToHash(headingElements);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Scrolls to the hash once available, retrying while code blocks render
|
|
512
|
+
* to avoid unexpected scrolling on observer re-attach.
|
|
513
|
+
*/
|
|
514
|
+
// eslint-disable-next-line no-undef
|
|
515
|
+
protected tryScrollToHash(headingElements: NodeListOf<Element>): void {
|
|
516
|
+
if (!window.location.hash) {
|
|
499
517
|
this.didScrollToSelectedHash = true;
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
this.hashScrollWaitStart ??= Date.now();
|
|
521
|
+
const waitExpired =
|
|
522
|
+
Date.now() - this.hashScrollWaitStart >= MAX_HASH_SCROLL_WAIT_TIME;
|
|
523
|
+
const scrolled =
|
|
524
|
+
(waitExpired || !this.hasPendingCodeBlocks()) &&
|
|
500
525
|
this.scrollToHash(headingElements);
|
|
526
|
+
|
|
527
|
+
if (scrolled || waitExpired) {
|
|
528
|
+
this.didScrollToSelectedHash = true;
|
|
529
|
+
this.hashScrollWaitStart = undefined;
|
|
530
|
+
clearTimeout(this.hashScrollTimerId);
|
|
531
|
+
return;
|
|
501
532
|
}
|
|
533
|
+
|
|
534
|
+
clearTimeout(this.hashScrollTimerId);
|
|
535
|
+
this.hashScrollTimerId = setTimeout(
|
|
536
|
+
() => this.tryScrollToHash(this.getHeadingElements()),
|
|
537
|
+
HASH_SCROLL_DELAY
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
protected hasPendingCodeBlocks(): boolean {
|
|
542
|
+
return Array.from(document.querySelectorAll(CODE_BLOCK_TAG)).some(
|
|
543
|
+
(codeBlock) => !(codeBlock as any).rendered
|
|
544
|
+
);
|
|
502
545
|
}
|
|
503
546
|
|
|
504
547
|
attachInteractionObserver = (): void => {
|
|
@@ -585,6 +628,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
585
628
|
this.updateRNB();
|
|
586
629
|
this.updateContentActionToolbar();
|
|
587
630
|
this.contentLoaded = true;
|
|
631
|
+
|
|
632
|
+
if (!this.didScrollToSelectedHash) {
|
|
633
|
+
this.tryScrollToHash(this.getHeadingElements());
|
|
634
|
+
}
|
|
588
635
|
}
|
|
589
636
|
|
|
590
637
|
protected disconnectObserver(): void {
|
|
@@ -595,7 +642,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
595
642
|
}
|
|
596
643
|
|
|
597
644
|
// eslint-disable-next-line no-undef
|
|
598
|
-
protected scrollToHash(headingElements: NodeListOf<Element>):
|
|
645
|
+
protected scrollToHash(headingElements: NodeListOf<Element>): boolean {
|
|
599
646
|
let { hash } = window.location;
|
|
600
647
|
if (hash) {
|
|
601
648
|
hash = hash.substr(1);
|
|
@@ -610,14 +657,18 @@ export default class ContentLayout extends LightningElement {
|
|
|
610
657
|
"hgf-c360contextnav"
|
|
611
658
|
) as HTMLElement;
|
|
612
659
|
|
|
660
|
+
if (!docHeaderEl || !globalNavEl || !contextNavEl) {
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
|
|
613
664
|
const headerHeight =
|
|
614
|
-
docHeaderEl
|
|
615
|
-
globalNavEl
|
|
616
|
-
contextNavEl
|
|
665
|
+
(docHeaderEl.offsetHeight || 0) +
|
|
666
|
+
(globalNavEl.offsetHeight || 0) +
|
|
667
|
+
(contextNavEl.offsetHeight || 0);
|
|
617
668
|
|
|
618
669
|
const docPhaseEl = (
|
|
619
670
|
this.template.querySelector("[name=doc-phase]")! as any
|
|
620
|
-
)
|
|
671
|
+
)?.assignedElements?.()[0] as HTMLSlotElement | undefined;
|
|
621
672
|
|
|
622
673
|
const offset = docPhaseEl
|
|
623
674
|
? headerHeight + docPhaseEl.offsetHeight
|
|
@@ -626,10 +677,11 @@ export default class ContentLayout extends LightningElement {
|
|
|
626
677
|
for (const headingElement of headingElements as any) {
|
|
627
678
|
if (headingElement.getAttribute("id") === hash) {
|
|
628
679
|
this.scrollIntoViewWithOffset(headingElement, offset);
|
|
629
|
-
|
|
680
|
+
return true;
|
|
630
681
|
}
|
|
631
682
|
}
|
|
632
683
|
}
|
|
684
|
+
return false;
|
|
633
685
|
}
|
|
634
686
|
|
|
635
687
|
protected scrollIntoViewWithOffset(
|