@salesforcedevs/docs-components 0.67.0 → 0.69.0

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": "0.67.0",
3
+ "version": "0.69.0",
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": "187d8abcbea7dd2ec9f0352c3563662c44abbde8"
27
+ "gitHead": "5183cd0ee93cedb7988377ff667f1e4c54ff8ea6"
28
28
  }
@@ -204,7 +204,7 @@ export default class AmfReference extends LightningElement {
204
204
  }
205
205
 
206
206
  restoreScroll() {
207
- document.body.scrollTop = document.documentElement.scrollTop = window.history.state.scrollValue;
207
+ document.body.scrollTop = document.documentElement.scrollTop = window.history.state?.scrollValue;
208
208
  }
209
209
 
210
210
  renderedCallback(): void {
@@ -845,7 +845,6 @@ export default class AmfReference extends LightningElement {
845
845
  */
846
846
  protected onApiNavigationChanged(): void {
847
847
  this.saveScroll();
848
- document.body.scrollTop = document.documentElement.scrollTop = 0;
849
848
 
850
849
  const specBasedReference = this.isSpecBasedReference(
851
850
  this._currentReferenceId
@@ -1275,7 +1274,6 @@ export default class AmfReference extends LightningElement {
1275
1274
 
1276
1275
  onNavSelect(event: CustomEvent): void {
1277
1276
  this.saveScroll();
1278
- document.body.scrollTop = document.documentElement.scrollTop = 0;
1279
1277
 
1280
1278
  const name = event.detail.name;
1281
1279
  if (name) {
@@ -158,7 +158,7 @@ export default class ContentLayout extends LightningElement {
158
158
  }
159
159
 
160
160
  restoreScroll() {
161
- document.body.scrollTop = document.documentElement.scrollTop = window.history.state.scrollValue;
161
+ document.body.scrollTop = document.documentElement.scrollTop = window.history.state?.scrollValue;
162
162
  }
163
163
 
164
164
  clearRenderObserverTimer = () => {
@@ -26,7 +26,7 @@
26
26
  </dx-dropdown>
27
27
  </div>
28
28
  <doc-breadcrumbs
29
- if:true={breadcrumbs}
29
+ if:true={showBreadcrumbs}
30
30
  breadcrumbs={breadcrumbs}
31
31
  pixel-per-character={breadcrumbPixelPerCharacter}
32
32
  ></doc-breadcrumbs>
@@ -18,11 +18,6 @@ import { Breadcrumb, Language } from "typings/custom";
18
18
  // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
19
19
  const handleContentError = (error): void => console.log(error);
20
20
 
21
- const FIRST_CRUMB = {
22
- href: "/docs",
23
- label: "Documentation"
24
- };
25
-
26
21
  const PIXEL_PER_CHARACTER_MAP: { [key: string]: number } = {
27
22
  default: 7.7,
28
23
  "ja-jp": 12.5
@@ -581,6 +576,10 @@ export default class DocXmlContent extends LightningElementWithState<{
581
576
  );
582
577
  }
583
578
 
579
+ get showBreadcrumbs(): boolean {
580
+ return this.breadcrumbs && this.breadcrumbs.length > 0;
581
+ }
582
+
584
583
  private buildBreadcrumbs(): void {
585
584
  const { contentDocumentId } = this.pageReference;
586
585
  if (!contentDocumentId) {
@@ -588,23 +587,31 @@ export default class DocXmlContent extends LightningElementWithState<{
588
587
  }
589
588
 
590
589
  const currentNode = this.tocMap[contentDocumentId];
591
- this.breadcrumbs = this.nodeToBreadcrumb(currentNode);
590
+
591
+ if(currentNode.parent) {
592
+ this.breadcrumbs = this.nodeToBreadcrumb(currentNode);
593
+ } else {
594
+ this.breadcrumbs = [];
595
+ }
592
596
  }
593
597
 
594
- private nodeToBreadcrumb(node?: TreeNode): Breadcrumb[] {
595
- if (!node) {
596
- return [FIRST_CRUMB];
598
+ private nodeToBreadcrumb(node: TreeNode): Breadcrumb[] {
599
+ const item = {
600
+ href: this.pageReferenceToString({
601
+ ...this.pageReference,
602
+ contentDocumentId: node.name
603
+ }),
604
+ label: node.label
605
+ };
606
+
607
+ if(node.parent) {
608
+ return [
609
+ ...this.nodeToBreadcrumb(node.parent),
610
+ item
611
+ ];
597
612
  }
598
- return [
599
- ...this.nodeToBreadcrumb(node.parent),
600
- {
601
- href: this.pageReferenceToString({
602
- ...this.pageReference,
603
- contentDocumentId: node.name
604
- }),
605
- label: node.label
606
- }
607
- ];
613
+
614
+ return [item];
608
615
  }
609
616
 
610
617
  addMetatags(): void {