@salesforcedevs/docs-components 1.17.11-hover-edit → 1.17.11-lwc-fix-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 CHANGED
@@ -18,8 +18,6 @@
18
18
  "doc/header",
19
19
  "doc/heading",
20
20
  "doc/headingAnchor",
21
- "doc/markdownEditor",
22
- "doc/textSelectionSearch",
23
21
  "doc/overview",
24
22
  "doc/phase",
25
23
  "doc/specificationContent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.17.11-hover-edit",
3
+ "version": "1.17.11-lwc-fix-alpha",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -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" lwc:if={playgroundAvailable}>
2
+ <div class="playground-container" lwc:if={playgroundAvailable}>
3
3
  <dx-spinner
4
4
  size="large"
5
5
  variant="brand"
@@ -8,13 +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
15
  <dx-error-fallback
16
16
  lwc:else
17
- title="Playground Unavailable"
18
- description="This component's playground is currently unavailable. Please check again later."
17
+ title="Code Examples Unavailable"
18
+ description="This component's code examples are currently unavailable. Please check again later."
19
19
  ></dx-error-fallback>
20
20
  </template>
@@ -8,6 +8,19 @@ 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
+
11
24
  get playgroundAvailable() {
12
25
  return (
13
26
  this.playgroundAppUrl &&
@@ -2,14 +2,19 @@ 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";
6
5
  export const OBSERVER_ATTACH_WAIT_TIME = 500;
7
6
 
8
7
  export default class LwcContentLayout extends ContentLayout {
9
8
  private rnbByTab: boolean = false;
10
9
 
10
+ // DOM element caches to avoid repeated queries
11
+ private tabPanelListCache: any = null;
12
+ private hasSpecContentCache: boolean | null = null;
13
+ private allTabsCache: any[] | null = null;
14
+ private mainSlotCache: any = null;
15
+
11
16
  private setRNBByTab() {
12
- const tabPanelListItem: any = this.getTabPanelList();
17
+ const tabPanelListItem = this.getTabPanelList();
13
18
  this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB ? true : false;
14
19
  }
15
20
 
@@ -17,29 +22,125 @@ export default class LwcContentLayout extends ContentLayout {
17
22
  return this.rnbByTab;
18
23
  }
19
24
 
25
+ /**
26
+ * Check if the main slot contains doc-specification-content
27
+ * Uses caching to avoid repeated DOM queries
28
+ */
29
+ private hasSpecificationContent(): boolean {
30
+ // Return cached result if available
31
+ if (this.hasSpecContentCache !== null) {
32
+ return this.hasSpecContentCache;
33
+ }
34
+
35
+ // Check if the main slot contains doc-specification-content
36
+ const mainSlot = this.getMainSlot();
37
+ if (mainSlot) {
38
+ const assignedElements = (mainSlot as any).assignedElements();
39
+
40
+ for (const element of assignedElements) {
41
+ // Check if the element itself is doc-specification-content
42
+ if (element.tagName === "doc-specification-content") {
43
+ this.hasSpecContentCache = true;
44
+ return true;
45
+ }
46
+ // Check if it contains doc-specification-content
47
+ const specContent = element.querySelector(
48
+ "doc-specification-content"
49
+ );
50
+ if (specContent) {
51
+ this.hasSpecContentCache = true;
52
+ return true;
53
+ }
54
+ // Also check in shadow root if it exists
55
+ if (element.shadowRoot) {
56
+ const shadowSpecContent = element.shadowRoot.querySelector(
57
+ "doc-specification-content"
58
+ );
59
+ if (shadowSpecContent) {
60
+ this.hasSpecContentCache = true;
61
+ return true;
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ // Fallback: check the entire document for doc-specification-content
68
+ const allSpecContent = document.querySelectorAll(
69
+ "doc-specification-content"
70
+ );
71
+ if (allSpecContent.length > 0) {
72
+ this.hasSpecContentCache = true;
73
+ return true;
74
+ }
75
+
76
+ this.hasSpecContentCache = false;
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Clear all caches when content changes
82
+ */
83
+ private clearAllCaches(): void {
84
+ this.hasSpecContentCache = null;
85
+ this.tabPanelListCache = null;
86
+ this.allTabsCache = null;
87
+ this.mainSlotCache = null;
88
+ }
89
+
90
+ /**
91
+ * Get the main slot element with caching
92
+ */
93
+ private getMainSlot(): any {
94
+ if (!this.mainSlotCache) {
95
+ this.mainSlotCache =
96
+ this.template.querySelector("slot:not([name])");
97
+ }
98
+ return this.mainSlotCache;
99
+ }
100
+
101
+ /**
102
+ * Get tab panel list with caching
103
+ */
104
+ private getTabPanelList(): any {
105
+ if (!this.tabPanelListCache) {
106
+ // eslint-disable-next-line @lwc/lwc/no-document-query
107
+ this.tabPanelListCache =
108
+ document.querySelector("dx-tab-panel-list");
109
+ }
110
+ return this.tabPanelListCache;
111
+ }
112
+
20
113
  onRNBClick = (event: CustomEvent) => {
21
114
  event.stopPropagation();
22
- const currentTab = this.getSelectedTabId();
23
- if (currentTab === SPECIFICATION_TAB_TITLE) {
115
+ if (this.hasSpecificationContent()) {
24
116
  this.didScrollToSelectedHash = false;
25
117
  }
26
118
  };
27
119
 
28
120
  onTabChanged = () => {
29
121
  this.updateRNB();
30
- };
31
122
 
32
- private getTabPanelList() {
33
- // eslint-disable-next-line @lwc/lwc/no-document-query
34
- return document.querySelector("dx-tab-panel-list");
35
- }
123
+ // Check if there's a hash in the URL and we have specification content
124
+ const { hash } = window.location;
125
+
126
+ if (this.hasSpecificationContent() && hash) {
127
+ // Reset the scroll flag to allow scrolling to the hash
128
+ this.didScrollToSelectedHash = false;
129
+
130
+ // Use requestAnimationFrame to ensure the DOM is ready
131
+ requestAnimationFrame(() => {
132
+ this.updateHeadingForRNB();
133
+ });
134
+ }
135
+ };
36
136
 
37
137
  protected getHeadingElements() {
38
138
  let headingElements = super.getHeadingElements();
39
139
  if (this.showTabBasedRNB) {
40
- const tabPanelListItem: any = this.getTabPanelList();
140
+ const tabPanelListItem = this.getTabPanelList();
41
141
  const tabPanels =
42
142
  tabPanelListItem?.querySelectorAll("dx-tab-panel");
143
+
43
144
  for (const tabPanelItem of tabPanels) {
44
145
  if (tabPanelItem.active) {
45
146
  // This is needed for Specification tab content
@@ -65,6 +166,7 @@ export default class LwcContentLayout extends ContentLayout {
65
166
  private updateURL() {
66
167
  const tabs = this.getAllTabs();
67
168
  const selectedTabId = this.getSelectedTabId();
169
+
68
170
  tabs.forEach((tab: any) => {
69
171
  if (tab.getAttribute("aria-selected") === "true") {
70
172
  const tabID = tab.getAttribute("aria-label");
@@ -101,22 +203,38 @@ export default class LwcContentLayout extends ContentLayout {
101
203
  const selectedTabId = this.getSelectedTabId();
102
204
  if (selectedTabId) {
103
205
  this.selectTabById(selectedTabId);
206
+
207
+ // If there's a hash and we have specification content,
208
+ // we need to wait for the content to load before scrolling
209
+ const { hash } = window.location;
210
+ if (this.hasSpecificationContent() && hash) {
211
+ // Reset the scroll flag to allow scrolling once content is loaded
212
+ this.didScrollToSelectedHash = false;
213
+ }
104
214
  }
105
215
  });
106
216
  }
107
217
 
108
218
  private getAllTabs(): any[] {
109
- const tabPanelListItem: any = this.getTabPanelList();
219
+ // Return cached result if available
220
+ if (this.allTabsCache) {
221
+ return this.allTabsCache;
222
+ }
223
+
224
+ const tabPanelListItem = this.getTabPanelList();
110
225
  if (tabPanelListItem?.shadowRoot) {
111
- return Array.from(
226
+ this.allTabsCache = Array.from(
112
227
  tabPanelListItem.shadowRoot.querySelectorAll(
113
228
  "dx-tab-panel-item"
114
229
  )
115
230
  ).map((tabPanelItem: any) =>
116
231
  tabPanelItem.shadowRoot.querySelector("button")
117
232
  );
233
+ } else {
234
+ this.allTabsCache = [];
118
235
  }
119
- return [];
236
+
237
+ return this.allTabsCache;
120
238
  }
121
239
 
122
240
  private selectTabById(tabId: string) {
@@ -158,6 +276,14 @@ export default class LwcContentLayout extends ContentLayout {
158
276
  }
159
277
  }
160
278
 
279
+ /**
280
+ * Override parent's onSlotChange to clear caches when slot content changes
281
+ */
282
+ onSlotChange(): void {
283
+ this.clearAllCaches();
284
+ super.onSlotChange();
285
+ }
286
+
161
287
  updateHeadingForRNB(): void {
162
288
  // We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
163
289
  if (this.showTabBasedRNB) {
@@ -73,9 +73,7 @@
73
73
  <template lwc:if={method.firstArgument}>
74
74
  <tr key={method.name}>
75
75
  <td rowspan={method.arguments.length}>
76
- <span class="code">
77
- {method.nameInKebabCase}
78
- </span>
76
+ <span class="code">{method.name}</span>
79
77
  </td>
80
78
  <td rowspan={method.arguments.length}>
81
79
  {method.description}
@@ -100,9 +98,7 @@
100
98
  <template lwc:else>
101
99
  <tr key={method.name}>
102
100
  <td>
103
- <span class="code">
104
- {method.nameInKebabCase}
105
- </span>
101
+ <span class="code">{method.name}</span>
106
102
  </td>
107
103
  <td>{method.description}</td>
108
104
  <td colspan="3"></td>
@@ -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 {
@@ -1,225 +0,0 @@
1
- .markdown-editor {
2
- border: 1px solid #e1e5e9;
3
- border-radius: 4px;
4
- overflow: hidden;
5
- background: #fff;
6
- }
7
-
8
- /* Editor Toolbar */
9
- .editor-toolbar {
10
- display: flex;
11
- align-items: center;
12
- justify-content: flex-end;
13
- gap: 0.5rem;
14
- padding: 0.75rem 1rem;
15
- background: #f8f9fa;
16
- border-bottom: 1px solid #e1e5e9;
17
- flex-wrap: wrap;
18
- }
19
-
20
- .edit-button,
21
- .cancel-button,
22
- .save-button {
23
- min-width: 80px;
24
- }
25
-
26
- .status-indicator {
27
- margin-left: 0.5rem;
28
- font-size: 0.875rem;
29
- }
30
-
31
- .status-saving {
32
- color: #0176d3;
33
- }
34
-
35
- .status-success {
36
- color: #04844b;
37
- }
38
-
39
- .status-error {
40
- color: #ea001e;
41
- }
42
-
43
- /* Content Viewer */
44
- .content-viewer {
45
- padding: 1rem;
46
- }
47
-
48
- .content-display {
49
- line-height: 1.6;
50
- color: #3e3e3c;
51
- }
52
-
53
- .content-display h1,
54
- .content-display h2,
55
- .content-display h3,
56
- .content-display h4,
57
- .content-display h5,
58
- .content-display h6 {
59
- margin-top: 1.5rem;
60
- margin-bottom: 0.5rem;
61
- color: #181818;
62
- }
63
-
64
- .content-display p {
65
- margin-bottom: 1rem;
66
- }
67
-
68
- .content-display ul,
69
- .content-display ol {
70
- margin-bottom: 1rem;
71
- padding-left: 2rem;
72
- }
73
-
74
- .content-display code {
75
- background-color: #f3f2f2;
76
- padding: 0.125rem 0.25rem;
77
- border-radius: 0.25rem;
78
- font-family: Monaco, Menlo, "Ubuntu Mono", monospace;
79
- font-size: 0.875rem;
80
- }
81
-
82
- .content-display pre {
83
- background-color: #f3f2f2;
84
- padding: 1rem;
85
- border-radius: 0.25rem;
86
- overflow-x: auto;
87
- margin-bottom: 1rem;
88
- }
89
-
90
- .content-display pre code {
91
- background-color: transparent;
92
- padding: 0;
93
- }
94
-
95
- /* HTML Content Styling */
96
- .html-content {
97
- line-height: 1.6;
98
- color: #3e3e3c;
99
- }
100
-
101
- .html-content h1,
102
- .html-content h2,
103
- .html-content h3,
104
- .html-content h4,
105
- .html-content h5,
106
- .html-content h6 {
107
- margin-top: 1.5rem;
108
- margin-bottom: 0.5rem;
109
- color: #181818;
110
- }
111
-
112
- .html-content p {
113
- margin-bottom: 1rem;
114
- }
115
-
116
- .html-content ul,
117
- .html-content ol {
118
- margin-bottom: 1rem;
119
- padding-left: 2rem;
120
- }
121
-
122
- .html-content code {
123
- background-color: #f3f2f2;
124
- padding: 0.125rem 0.25rem;
125
- border-radius: 0.25rem;
126
- font-family: Monaco, Menlo, "Ubuntu Mono", monospace;
127
- font-size: 0.875rem;
128
- }
129
-
130
- .html-content pre {
131
- background-color: #f3f2f2;
132
- padding: 1rem;
133
- border-radius: 0.25rem;
134
- overflow-x: auto;
135
- margin-bottom: 1rem;
136
- }
137
-
138
- .html-content pre code {
139
- background-color: transparent;
140
- padding: 0;
141
- }
142
-
143
- /* No Content Message */
144
- .no-content {
145
- color: #706e6b;
146
- font-style: italic;
147
- text-align: center;
148
- padding: 2rem;
149
- background-color: #f8f9fa;
150
- border: 1px dashed #e1e5e9;
151
- border-radius: 4px;
152
- }
153
-
154
- /* Editor Wrapper */
155
- .editor-wrapper {
156
- position: relative;
157
- min-height: 300px;
158
- }
159
-
160
- .simple-editor {
161
- width: 100%;
162
- min-height: 300px;
163
- padding: 1rem;
164
- border: none;
165
- outline: none;
166
- font-family: Monaco, Menlo, "Ubuntu Mono", monospace;
167
- font-size: 0.875rem;
168
- line-height: 1.5;
169
- resize: vertical;
170
- background: #fff;
171
- color: #3e3e3c;
172
- }
173
-
174
- .simple-editor:focus {
175
- outline: none;
176
- }
177
-
178
- .simple-editor::placeholder {
179
- color: #706e6b;
180
- }
181
-
182
- /* Loading Overlay */
183
- .loading-overlay {
184
- position: absolute;
185
- top: 0;
186
- left: 0;
187
- right: 0;
188
- bottom: 0;
189
- background: rgb(255 255 255 / 80%);
190
- display: flex;
191
- align-items: center;
192
- justify-content: center;
193
- z-index: 1000;
194
- }
195
-
196
- /* Responsive Design */
197
- @media (max-width: 768px) {
198
- .editor-toolbar {
199
- flex-wrap: wrap;
200
- gap: 0.25rem;
201
- justify-content: flex-end;
202
- }
203
-
204
- .status-indicator {
205
- margin-left: 0.25rem;
206
- width: auto;
207
- text-align: right;
208
- margin-top: 0;
209
- }
210
-
211
- .simple-editor {
212
- min-height: 250px;
213
- }
214
-
215
- .content-viewer {
216
- padding: 0.75rem;
217
- }
218
- }
219
-
220
- /* Empty state */
221
- .content-display:empty::before {
222
- content: "No content to display";
223
- color: #706e6b;
224
- font-style: italic;
225
- }