@salesforcedevs/docs-components 0.56.2-snyk → 0.56.3-example

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,16 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "0.56.2-snyk",
3
+ "version": "0.56.3-example",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "engines": {
8
- "node": "20.x"
8
+ "node": "20.x",
9
+ "yarn": "1.22.x"
10
+ },
11
+ "volta": {
12
+ "node": "20.18.2",
13
+ "yarn": "1.22.19"
9
14
  },
10
15
  "publishConfig": {
11
16
  "access": "public"
@@ -17,6 +17,6 @@ iframe {
17
17
  border: 1px solid var(--dx-g-gray-90);
18
18
  }
19
19
 
20
- .container {
20
+ .playground-container {
21
21
  position: relative;
22
22
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="container">
2
+ <div class="playground-container" lwc:if={playgroundAvailable}>
3
3
  <dx-spinner
4
4
  size="large"
5
5
  variant="brand"
@@ -8,8 +8,13 @@
8
8
  <iframe
9
9
  src={playgroundSrc}
10
10
  onload={handleIframeLoad}
11
- title="Component Playground"
11
+ title={playgroundTitle}
12
12
  allow="clipboard-write"
13
13
  ></iframe>
14
14
  </div>
15
+ <dx-error-fallback
16
+ lwc:else
17
+ title="Code Examples Unavailable"
18
+ description="This component's code examples are currently unavailable. Please check again later."
19
+ ></dx-error-fallback>
15
20
  </template>
@@ -8,6 +8,28 @@ export default class ComponentPlayground extends LightningElement {
8
8
 
9
9
  isLoading = true;
10
10
 
11
+ /**
12
+ * Returns a formatted title for the component playground
13
+ * Maps 'aura' model to 'Aura' and 'lwc' model to 'Lightning'
14
+ * Capitalizes the first letter of the component name
15
+ * @returns {string} Formatted playground title
16
+ */
17
+ get playgroundTitle() {
18
+ const modelName = this.model === "aura" ? "Aura" : "Lightning";
19
+ const componentName =
20
+ this.component.charAt(0).toUpperCase() + this.component.slice(1);
21
+ return `Example previews and code for ${modelName} ${componentName} component`;
22
+ }
23
+
24
+ get playgroundAvailable() {
25
+ return (
26
+ this.playgroundAppUrl &&
27
+ this.model &&
28
+ this.namespace &&
29
+ this.component
30
+ );
31
+ }
32
+
11
33
  get playgroundSrc(): string {
12
34
  return `${this.playgroundAppUrl}/playground/${this.model}/${
13
35
  this.namespace
@@ -1,4 +1,5 @@
1
1
  <template>
2
+ <dx-redirect-checker></dx-redirect-checker>
2
3
  <template if:true={docsData}>
3
4
  <div class="container" data-name="content" lwc:dom="manual"></div>
4
5
  </template>
@@ -43,26 +43,10 @@ export default class Content extends LightningElement {
43
43
  return this.docContent;
44
44
  }
45
45
 
46
- @api
47
- set codeBlockTheme(value) {
48
- this._codeBlockTheme = value;
49
- }
50
-
51
- get codeBlockTheme() {
52
- return this._codeBlockTheme;
53
- }
54
-
55
46
  @track docContent: DocContent = "";
56
- _codeBlockTheme: string = "dark";
57
47
  _docRendered: boolean = false;
58
- originalCodeBlockThemeValue: String = "";
59
48
 
60
49
  connectedCallback() {
61
- this.template.addEventListener(
62
- "themechange",
63
- this.updateTheme.bind(this) // eslint-disableline no-use-before-define
64
- );
65
-
66
50
  window.addEventListener(
67
51
  "highlightedtermchange",
68
52
  this.updateHighlighted
@@ -76,15 +60,6 @@ export default class Content extends LightningElement {
76
60
  );
77
61
  }
78
62
 
79
- updateTheme() {
80
- this._codeBlockTheme =
81
- this._codeBlockTheme === "dark" ? "light" : "dark";
82
- const codeBlockEls = this.template.querySelectorAll("dx-code-block");
83
- codeBlockEls.forEach((codeBlockEl) => {
84
- codeBlockEl.setAttribute("theme", this._codeBlockTheme);
85
- });
86
- }
87
-
88
63
  renderPaginationButton(anchorEl: HTMLElement) {
89
64
  const isNext = anchorEl.textContent!.includes("Next →");
90
65
  anchorEl.innerHTML = "";
@@ -116,11 +91,11 @@ export default class Content extends LightningElement {
116
91
  const codeBlockEls = divEl.querySelectorAll(".codeSection");
117
92
  codeBlockEls.forEach((codeBlockEl) => {
118
93
  codeBlockEl.setAttribute("lwc:dom", "manual");
119
- const classList = (codeBlockEl.firstChild as any).classList;
94
+ const classList = codeBlockEl.firstElementChild?.classList;
120
95
  let language = "";
121
- for (const key in classList) {
122
- if (typeof classList[key] === "string") {
123
- const className = classList[key];
96
+ if (classList) {
97
+ for (let i = 0; i < classList.length; i++) {
98
+ const className = classList[i];
124
99
  if (className.startsWith("brush:")) {
125
100
  language = className.split(":")[1];
126
101
  }
@@ -133,7 +108,6 @@ export default class Content extends LightningElement {
133
108
  codeBlock: codeBlockEl.innerHTML,
134
109
  // ! Hot fix for incoming html tags from couchdb for xml blocks, fix me soon please
135
110
  language: LANGUAGE_MAP[language] || language,
136
- theme: this.codeBlockTheme,
137
111
  header: "", // Default no title.
138
112
  variant: this.codeBlockType,
139
113
  isEncoded: true
@@ -158,6 +132,7 @@ export default class Content extends LightningElement {
158
132
  }
159
133
  });
160
134
 
135
+ // Set a flag to 1 (true) if and only if all detailEls have no content.
161
136
  let flag = 1;
162
137
  for (let i: number = 0; i < detailEls.length; i++) {
163
138
  flag &= (detailEls[i].innerHTML.trim() === "") as any; // Dark Magic TM
@@ -359,7 +334,7 @@ export default class Content extends LightningElement {
359
334
  );
360
335
 
361
336
  @api
362
- public navigateToHash(hash: String) {
337
+ public navigateToHash = (hash: String) => {
363
338
  const splitHash = hash.split("#");
364
339
  if (splitHash.length === 2) {
365
340
  hash = splitHash[1];
@@ -370,7 +345,7 @@ export default class Content extends LightningElement {
370
345
  } else {
371
346
  window.scrollTo({ top: 0, behavior: "smooth" });
372
347
  }
373
- }
348
+ };
374
349
 
375
350
  renderedCallback() {
376
351
  if (this._docRendered) {
@@ -11,6 +11,8 @@
11
11
  language={language}
12
12
  bail-href={bailHref}
13
13
  bail-label={bailLabel}
14
+ dev-center={devCenter}
15
+ brand={brand}
14
16
  >
15
17
  <slot name="sidebar-header" slot="version-picker"></slot>
16
18
  </dx-sidebar-old>
@@ -30,6 +32,8 @@
30
32
  language={language}
31
33
  bail-href={bailHref}
32
34
  bail-label={bailLabel}
35
+ dev-center={devCenter}
36
+ brand={brand}
33
37
  >
34
38
  <slot name="sidebar-header" slot="version-picker"></slot>
35
39
  </dx-sidebar>
@@ -42,6 +42,8 @@ export default class ContentLayout extends LightningElement {
42
42
  @api language!: string;
43
43
  @api bailHref!: string;
44
44
  @api bailLabel!: string;
45
+ @api devCenter: any;
46
+ @api brand: any;
45
47
 
46
48
  // This is needed for now to prevent failing snapshot tests due to links in the footer
47
49
  @api showFooter = false;
@@ -6,6 +6,7 @@
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
11
  <a href={devCenter.link} class="dev-center-content">
11
12
  <dx-icon symbol="back"></dx-icon>
@@ -30,7 +31,7 @@
30
31
  </a>
31
32
  </div>
32
33
  <div
33
- lwc:if={hasScopedNavItems}
34
+ lwc:if={showScopedNavItems}
34
35
  class="header_l2_group header_l2_group-nav"
35
36
  >
36
37
  <div
@@ -48,7 +49,7 @@
48
49
  </header>
49
50
  </dx-brand-theme-provider>
50
51
  </template>
51
- <template lwc:if={showDocDivider}>
52
+ <template lwc:if={shouldHideHeader}>
52
53
  <div class="no-header-content"></div>
53
54
  </template>
54
55
  </template>
@@ -1,8 +1,8 @@
1
1
  import { api } from "lwc";
2
2
  import cx from "classnames";
3
- import type { OptionWithNested } from "typings/custom";
3
+ import type { OptionWithNested, DevCenterConfig } from "typings/custom";
4
4
  import { HeaderBase } from "dxBaseElements/headerBase";
5
- import { toJson } from "dxUtils/normalizers";
5
+ import { toJson, normalizeBoolean } from "dxUtils/normalizers";
6
6
 
7
7
  const TABLET_MATCH = "980px";
8
8
  const MOBILE_MATCH = "768px";
@@ -18,6 +18,15 @@ export default class Header extends HeaderBase {
18
18
  @api langValuePath: string = "id"; // allows to override how language property is interpreted, follows valuePath dropdown api.
19
19
  @api headerHref: string = "/";
20
20
 
21
+ @api
22
+ get hideDocHeader() {
23
+ return this._hideDocHeader;
24
+ }
25
+
26
+ set hideDocHeader(value) {
27
+ this._hideDocHeader = normalizeBoolean(value);
28
+ }
29
+
21
30
  @api
22
31
  get scopedNavItems() {
23
32
  return this._scopedNavItems;
@@ -28,7 +37,7 @@ export default class Header extends HeaderBase {
28
37
  }
29
38
 
30
39
  @api
31
- get devCenter() {
40
+ get devCenter(): DevCenterConfig {
32
41
  return this._devCenter;
33
42
  }
34
43
 
@@ -41,14 +50,27 @@ export default class Header extends HeaderBase {
41
50
  private tabletMatchMedia!: MediaQueryList;
42
51
  private shouldRender: boolean = false;
43
52
  private showDocDivider: boolean = false;
44
- private _devCenter: any;
53
+ private _devCenter!: DevCenterConfig;
54
+ private _hideDocHeader: boolean = false;
45
55
 
46
56
  protected mobileBreakpoint(): string {
47
57
  return MOBILE_MATCH;
48
58
  }
49
59
 
50
- private get hasScopedNavItems(): boolean {
51
- return this.scopedNavItems && this.scopedNavItems.length > 0;
60
+ private get showScopedNavItems(): boolean {
61
+ return (
62
+ this.scopedNavItems &&
63
+ this.scopedNavItems.length > 0 &&
64
+ !this.hideDocHeader
65
+ );
66
+ }
67
+
68
+ /**
69
+ * This function returns true if the hideDocHeader is true and the view is not mobile.
70
+ * Also we need to show the header border in case the doc is hidden or if the brand information doesn't exists.
71
+ */
72
+ private get shouldHideHeader(): boolean {
73
+ return (this.hideDocHeader && !this.mobile) || this.showDocDivider;
52
74
  }
53
75
 
54
76
  connectedCallback(): void {
@@ -60,7 +82,8 @@ export default class Header extends HeaderBase {
60
82
  this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
61
83
 
62
84
  if (
63
- (window.location.pathname.includes("/docs/") &&
85
+ (!this.shouldHideHeader &&
86
+ window.location.pathname.includes("/docs/") &&
64
87
  window.location.pathname !== "/docs/apis") ||
65
88
  window.location.pathname ===
66
89
  "/tableau/embedding-playground/overview" ||
@@ -91,7 +114,7 @@ export default class Header extends HeaderBase {
91
114
  protected additionalClasses(): string {
92
115
  return cx(
93
116
  this.brand && "has-brand",
94
- this.hasScopedNavItems && "has-scoped-nav-items"
117
+ this.showScopedNavItems && "has-scoped-nav-items"
95
118
  );
96
119
  }
97
120
  }
@@ -11,6 +11,8 @@
11
11
  language={language}
12
12
  bail-href={bailHref}
13
13
  bail-label={bailLabel}
14
+ dev-center={devCenter}
15
+ brand={brand}
14
16
  >
15
17
  <slot name="sidebar-header" slot="version-picker"></slot>
16
18
  </dx-sidebar-old>
@@ -30,6 +32,8 @@
30
32
  language={language}
31
33
  bail-href={bailHref}
32
34
  bail-label={bailLabel}
35
+ dev-center={devCenter}
36
+ brand={brand}
33
37
  >
34
38
  <slot name="sidebar-header" slot="version-picker"></slot>
35
39
  </dx-sidebar>
@@ -2,44 +2,111 @@ import ContentLayout from "doc/contentLayout";
2
2
 
3
3
  const TOC_HEADER_TAG = "doc-heading";
4
4
  const RNB_BY_TAB = "docs-tab";
5
- const SPECIFICATION_TAB_TITLE = "Specification";
5
+ const SPECIFICATION_TAG = "doc-specification-content";
6
6
  export const OBSERVER_ATTACH_WAIT_TIME = 500;
7
7
 
8
8
  export default class LwcContentLayout extends ContentLayout {
9
9
  private rnbByTab: boolean = false;
10
10
 
11
+ // DOM element caches to avoid repeated queries
12
+ private tabPanelListCache: any = null;
13
+ private hasSpecContentCache: boolean | null = null;
14
+ private allTabsCache: any[] | null = null;
15
+ private mainSlotCache: any = null;
16
+
11
17
  private setRNBByTab() {
12
- const tabPanelListItem: any = this.getTabPanelList();
13
- this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB ? true : false;
18
+ const tabPanelListItem = this.getTabPanelList();
19
+ this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB;
14
20
  }
15
21
 
16
22
  get showTabBasedRNB() {
17
23
  return this.rnbByTab;
18
24
  }
19
25
 
26
+ /**
27
+ * Check if the main slot contains doc-specification-content
28
+ * Uses caching to avoid repeated DOM queries
29
+ */
30
+ private hasSpecificationContent(): boolean {
31
+ if (this.hasSpecContentCache !== null) {
32
+ return this.hasSpecContentCache;
33
+ }
34
+
35
+ const mainSlot = this.getMainSlot();
36
+ if (mainSlot) {
37
+ const assignedElements = (mainSlot as any).assignedElements();
38
+
39
+ for (const element of assignedElements) {
40
+ if (
41
+ element.tagName === SPECIFICATION_TAG ||
42
+ element.querySelector(SPECIFICATION_TAG) ||
43
+ element.shadowRoot?.querySelector(SPECIFICATION_TAG)
44
+ ) {
45
+ return (this.hasSpecContentCache = true);
46
+ }
47
+ }
48
+ }
49
+ return (this.hasSpecContentCache = false);
50
+ }
51
+
52
+ /**
53
+ * Clear all caches when content changes
54
+ */
55
+ private clearAllCaches(): void {
56
+ this.hasSpecContentCache = null;
57
+ this.tabPanelListCache = null;
58
+ this.allTabsCache = null;
59
+ this.mainSlotCache = null;
60
+ }
61
+
62
+ /**
63
+ * Get the main slot element with caching
64
+ */
65
+ private getMainSlot(): any {
66
+ if (!this.mainSlotCache) {
67
+ this.mainSlotCache =
68
+ this.template.querySelector("slot:not([name])");
69
+ }
70
+ return this.mainSlotCache;
71
+ }
72
+
73
+ /**
74
+ * Get tab panel list with caching
75
+ */
76
+ private getTabPanelList(): any {
77
+ if (!this.tabPanelListCache) {
78
+ // eslint-disable-next-line @lwc/lwc/no-document-query
79
+ this.tabPanelListCache =
80
+ document.querySelector("dx-tab-panel-list");
81
+ }
82
+ return this.tabPanelListCache;
83
+ }
84
+
20
85
  onRNBClick = (event: CustomEvent) => {
21
86
  event.stopPropagation();
22
- const currentTab = this.getSelectedTabId();
23
- if (currentTab === SPECIFICATION_TAB_TITLE) {
87
+ if (this.hasSpecificationContent()) {
24
88
  this.didScrollToSelectedHash = false;
25
89
  }
26
90
  };
27
91
 
28
92
  onTabChanged = () => {
29
93
  this.updateRNB();
30
- };
31
94
 
32
- private getTabPanelList() {
33
- // eslint-disable-next-line @lwc/lwc/no-document-query
34
- return document.querySelector("dx-tab-panel-list");
35
- }
95
+ const { hash } = window.location;
96
+ if (this.hasSpecificationContent() && hash) {
97
+ this.didScrollToSelectedHash = false;
98
+
99
+ requestAnimationFrame(() => this.updateHeadingForRNB());
100
+ }
101
+ };
36
102
 
37
103
  protected getHeadingElements() {
38
104
  let headingElements = super.getHeadingElements();
39
105
  if (this.showTabBasedRNB) {
40
- const tabPanelListItem: any = this.getTabPanelList();
106
+ const tabPanelListItem = this.getTabPanelList();
41
107
  const tabPanels =
42
108
  tabPanelListItem?.querySelectorAll("dx-tab-panel");
109
+
43
110
  for (const tabPanelItem of tabPanels) {
44
111
  if (tabPanelItem.active) {
45
112
  // This is needed for Specification tab content
@@ -65,6 +132,7 @@ export default class LwcContentLayout extends ContentLayout {
65
132
  private updateURL() {
66
133
  const tabs = this.getAllTabs();
67
134
  const selectedTabId = this.getSelectedTabId();
135
+
68
136
  tabs.forEach((tab: any) => {
69
137
  if (tab.getAttribute("aria-selected") === "true") {
70
138
  const tabID = tab.getAttribute("aria-label");
@@ -101,22 +169,38 @@ export default class LwcContentLayout extends ContentLayout {
101
169
  const selectedTabId = this.getSelectedTabId();
102
170
  if (selectedTabId) {
103
171
  this.selectTabById(selectedTabId);
172
+
173
+ // If there's a hash and we have specification content,
174
+ // we need to wait for the content to load before scrolling
175
+ const { hash } = window.location;
176
+ if (this.hasSpecificationContent() && hash) {
177
+ // Reset the scroll flag to allow scrolling once content is loaded
178
+ this.didScrollToSelectedHash = false;
179
+ }
104
180
  }
105
181
  });
106
182
  }
107
183
 
108
184
  private getAllTabs(): any[] {
109
- const tabPanelListItem: any = this.getTabPanelList();
185
+ // Return cached result if available
186
+ if (this.allTabsCache) {
187
+ return this.allTabsCache;
188
+ }
189
+
190
+ const tabPanelListItem = this.getTabPanelList();
110
191
  if (tabPanelListItem?.shadowRoot) {
111
- return Array.from(
192
+ this.allTabsCache = Array.from(
112
193
  tabPanelListItem.shadowRoot.querySelectorAll(
113
194
  "dx-tab-panel-item"
114
195
  )
115
196
  ).map((tabPanelItem: any) =>
116
197
  tabPanelItem.shadowRoot.querySelector("button")
117
198
  );
199
+ } else {
200
+ this.allTabsCache = [];
118
201
  }
119
- return [];
202
+
203
+ return this.allTabsCache;
120
204
  }
121
205
 
122
206
  private selectTabById(tabId: string) {
@@ -158,8 +242,12 @@ export default class LwcContentLayout extends ContentLayout {
158
242
  }
159
243
  }
160
244
 
245
+ onSlotChange(): void {
246
+ this.clearAllCaches();
247
+ super.onSlotChange();
248
+ }
249
+
161
250
  updateHeadingForRNB(): void {
162
- // We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
163
251
  if (this.showTabBasedRNB) {
164
252
  this.updateURL();
165
253
  }
@@ -29,3 +29,8 @@ table {
29
29
  .icon {
30
30
  display: inline-block;
31
31
  }
32
+
33
+ .loader {
34
+ pointer-events: none;
35
+ bottom: 30%;
36
+ }
@@ -1,5 +1,12 @@
1
1
  <template>
2
2
  <div class="specification-properties">
3
+ <dx-spinner
4
+ size="large"
5
+ variant="brand"
6
+ class="loader"
7
+ if:true={isLoading}
8
+ ></dx-spinner>
9
+ <dx-error-fallback lwc:if={showError}></dx-error-fallback>
3
10
  <template lwc:if={hasAttributes}>
4
11
  <doc-heading
5
12
  header="Attributes"
@@ -66,9 +73,7 @@
66
73
  <template lwc:if={method.firstArgument}>
67
74
  <tr key={method.name}>
68
75
  <td rowspan={method.arguments.length}>
69
- <span class="code">
70
- {method.nameInKebabCase}
71
- </span>
76
+ <span class="code">{method.name}</span>
72
77
  </td>
73
78
  <td rowspan={method.arguments.length}>
74
79
  {method.description}
@@ -93,9 +98,7 @@
93
98
  <template lwc:else>
94
99
  <tr key={method.name}>
95
100
  <td>
96
- <span class="code">
97
- {method.nameInKebabCase}
98
- </span>
101
+ <span class="code">{method.name}</span>
99
102
  </td>
100
103
  <td>{method.description}</td>
101
104
  <td colspan="3"></td>
@@ -10,6 +10,9 @@ export default class SpecificationContent extends LightningElement {
10
10
  @api model!: string;
11
11
  @api namespace!: string;
12
12
 
13
+ isLoading: boolean = true;
14
+ showError: boolean = false;
15
+
13
16
  private attributes: Specification[] = [];
14
17
  private methods: Method[] = [];
15
18
  private slots: Specification[] = [];
@@ -60,7 +63,10 @@ export default class SpecificationContent extends LightningElement {
60
63
  }
61
64
  } catch (error) {
62
65
  this.data = {};
66
+ this.showError = true;
63
67
  console.error("fetchComponentMetadata() failed:", error);
68
+ } finally {
69
+ this.isLoading = false;
64
70
  }
65
71
  }
66
72
 
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <doc-content-layout
3
- lwc:if={loaded}
3
+ lwc:if={displayContent}
4
4
  lwc:ref="docContentLayout"
5
5
  coveo-organization-id={coveoOrganizationId}
6
6
  coveo-public-access-token={coveoPublicAccessToken}
@@ -49,4 +49,12 @@
49
49
  onnavclick={handleNavClick}
50
50
  ></doc-content>
51
51
  </doc-content-layout>
52
+ <div lwc:if={display404}>
53
+ <dx-error
54
+ image="https://a.sfdcstatic.com/developer-website/images/404.svg"
55
+ code="404"
56
+ header="Beep boop. That did not compute."
57
+ subtitle="The document you're looking for doesn't seem to exist."
58
+ ></dx-error>
59
+ </div>
52
60
  </template>
@@ -11,7 +11,8 @@ import {
11
11
  SiderbarFooter,
12
12
  HistoryState,
13
13
  PageReference,
14
- TocMap
14
+ TocMap,
15
+ ContentData
15
16
  } from "./types";
16
17
  import { SearchSyncer } from "docUtils/searchSyncer";
17
18
  import { LightningElementWithState } from "dxBaseElements/lightningElementWithState";
@@ -72,7 +73,8 @@ export default class DocXmlContent extends LightningElementWithState<{
72
73
  private contentProvider?: FetchContent;
73
74
  private docContent = "";
74
75
  private language?: DocLanguage | null = null;
75
- private loaded = false;
76
+ private displayContent = false;
77
+ private display404 = false;
76
78
  private _pageHeader?: Header;
77
79
  private pdfUrl = "";
78
80
  private tocMap: TocMap = {};
@@ -185,7 +187,13 @@ export default class DocXmlContent extends LightningElementWithState<{
185
187
  this.apiDomain,
186
188
  this.allLanguages
187
189
  );
188
- this.fetchDocument().then(() => (this.loaded = true));
190
+ this.fetchDocument().then((content: any) => {
191
+ if (content) {
192
+ this.displayContent = true;
193
+ } else {
194
+ this.display404 = true;
195
+ }
196
+ });
189
197
  window.addEventListener("popstate", this.handlePopState);
190
198
 
191
199
  this.searchSyncer.init();
@@ -463,7 +471,7 @@ export default class DocXmlContent extends LightningElementWithState<{
463
471
  );
464
472
  }
465
473
 
466
- async fetchDocument(): Promise<void> {
474
+ async fetchDocument(): Promise<string> {
467
475
  this.setState({
468
476
  isFetchingDocument: true
469
477
  });
@@ -477,7 +485,7 @@ export default class DocXmlContent extends LightningElementWithState<{
477
485
  this.setState({
478
486
  isFetchingDocument: false
479
487
  });
480
- return;
488
+ return "";
481
489
  }
482
490
 
483
491
  this.docTitle = data.docTitle;
@@ -509,11 +517,11 @@ export default class DocXmlContent extends LightningElementWithState<{
509
517
  data.id
510
518
  ) {
511
519
  try {
512
- await this.fetchContent();
520
+ const moreData = await this.fetchContent();
513
521
  this.setState({
514
522
  isFetchingDocument: false
515
523
  });
516
- return;
524
+ return moreData.content;
517
525
  } catch (error) {
518
526
  this.pageReference.contentDocumentId = `${data.id}.htm`;
519
527
  this.pageReference.hash = "";
@@ -527,9 +535,10 @@ export default class DocXmlContent extends LightningElementWithState<{
527
535
  this.setState({
528
536
  isFetchingDocument: false
529
537
  });
538
+ return data.content;
530
539
  }
531
540
 
532
- async fetchContent(): Promise<void> {
541
+ async fetchContent(): Promise<ContentData> {
533
542
  this.setState({
534
543
  isFetchingContent: true
535
544
  });
@@ -553,6 +562,7 @@ export default class DocXmlContent extends LightningElementWithState<{
553
562
  this.setState({
554
563
  isFetchingContent: false
555
564
  });
565
+ return data;
556
566
  }
557
567
 
558
568
  updateHeaderAndSidebarFooter(): void {