@salesforcedevs/docs-components 1.3.304-ww-fix-alpha1 → 1.3.319-scroll-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.304-ww-fix-alpha1",
3
+ "version": "1.3.319-scroll-alpha",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -1475,10 +1475,18 @@ export default class AmfReference extends LightningElement {
1475
1475
  // update topic view
1476
1476
  const { referenceId, amfId, type } = this.selectedTopic!;
1477
1477
 
1478
+ // Adding stringify inside try/catch
1479
+ let amfModelString = "";
1480
+ try {
1481
+ amfModelString = JSON.stringify(this.amfMap[referenceId].model);
1482
+ } catch (error) {
1483
+ console.error(`Error stringifying amf model: ${error}`);
1484
+ }
1485
+
1478
1486
  // This updates the component in the content section.
1479
1487
  this.topicModel = {
1480
1488
  type,
1481
- amf: this.amfMap[referenceId].model,
1489
+ amf: amfModelString,
1482
1490
  parser: this.amfMap[referenceId].parser,
1483
1491
  id: amfId
1484
1492
  };
@@ -95,7 +95,7 @@ export interface ParsedTopicModel {
95
95
  export interface TopicModel {
96
96
  id: string;
97
97
  type: string;
98
- amf: AmfModel;
98
+ amf: string;
99
99
  parser: AmfParser;
100
100
  }
101
101
 
@@ -27,13 +27,17 @@ export default class AmfTopic extends LightningElement {
27
27
  !this.amf ||
28
28
  (value && this._model && value.amf !== this._model?.amf)
29
29
  ) {
30
- this.amf = value && clone(value.amf);
30
+ try {
31
+ this.amf = value && JSON.parse(value.amf);
32
+ } catch (error) {
33
+ console.error(`Error parsing amf model: ${error}`);
34
+ }
31
35
  }
32
36
  if (
33
37
  !this.type ||
34
38
  (value && this._model && value.type !== this._model?.type)
35
39
  ) {
36
- this.type = value && clone(value.type);
40
+ this.type = value && value.type;
37
41
  }
38
42
 
39
43
  this._model = value;
@@ -105,20 +109,3 @@ export default class AmfTopic extends LightningElement {
105
109
  }
106
110
  }
107
111
  }
108
-
109
- /**
110
- * The underlying web components we use from api-console mutate their models we pass in.
111
- * Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
112
- * @param value JSON Serializable object to clone.
113
- * @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
114
- */
115
- function clone(value: any): any {
116
- const worker = new Worker("./worker.js");
117
- worker.postMessage(value);
118
- return new Promise((resolve) => {
119
- worker.addEventListener("message", (event) => {
120
- resolve(event.data);
121
- worker.terminate();
122
- });
123
- });
124
- }
@@ -51,6 +51,6 @@ export type AmfModel = Json;
51
51
  export interface TopicModel {
52
52
  id: string;
53
53
  type: string;
54
- amf: AmfModel;
54
+ amf: string;
55
55
  parser: AmfModelParser;
56
56
  }
@@ -385,6 +385,7 @@ mark {
385
385
  /* offset page jump link due to fixed header */
386
386
  [id] {
387
387
  scroll-margin-top: calc(
388
- var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
388
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
389
+ var(--dx-g-spacing-2xl)
389
390
  );
390
391
  }
@@ -43,7 +43,8 @@ dx-toc {
43
43
  /* offset page jump link due to fixed header */
44
44
  ::slotted(doc-heading) {
45
45
  scroll-margin-top: calc(
46
- var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
46
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
47
+ var(--dx-g-spacing-2xl)
47
48
  );
48
49
  }
49
50
 
@@ -215,10 +215,16 @@ export default class ContentLayout extends LightningElement {
215
215
  ".sticky-doc-header"
216
216
  ) as HTMLElement;
217
217
 
218
- const docPhaseEl = (
218
+ let docPhaseEl = (
219
219
  this.template.querySelector("[name=doc-phase]")! as any
220
220
  ).assignedElements()[0] as HTMLSlotElement;
221
221
 
222
+ if (!docPhaseEl) {
223
+ docPhaseEl = (
224
+ this.template.querySelector("[name=version-banner]")! as any
225
+ ).assignedElements()[0] as HTMLSlotElement;
226
+ }
227
+
222
228
  if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
223
229
  console.warn("One or more required elements are missing.");
224
230
  return;
@@ -231,6 +237,14 @@ export default class ContentLayout extends LightningElement {
231
237
  (globalNavEl.getBoundingClientRect().height !== 72 ? 0 : 72) +
232
238
  contextNavEl.getBoundingClientRect().height;
233
239
  const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
240
+ const totalHeaderHeight = globalNavHeight + docHeaderHeight;
241
+
242
+ // Selecting the doc section heading and RNB here.
243
+ const docHeadingEls = Array.from(
244
+ document.querySelectorAll("doc-heading")
245
+ );
246
+ const rightNavBarEl = this.template.querySelector(".right-nav-bar");
247
+
234
248
  sidebarEl.style.setProperty(
235
249
  "--dx-c-content-sidebar-sticky-top",
236
250
  `${globalNavHeight + docHeaderHeight}px`
@@ -241,6 +255,27 @@ export default class ContentLayout extends LightningElement {
241
255
  `${globalNavHeight}px`
242
256
  );
243
257
 
258
+ // Adjusting the doc section heading on scroll.
259
+ docHeadingEls.forEach((docHeadingEl) => {
260
+ (docHeadingEl as any).style.scrollMarginTop = docPhaseEl
261
+ ? `${
262
+ totalHeaderHeight +
263
+ docPhaseEl.getBoundingClientRect().height +
264
+ 40
265
+ }px`
266
+ : `${totalHeaderHeight + 40}px`;
267
+ });
268
+
269
+ // Adjusting the right nav bar on scroll.
270
+ if (rightNavBarEl) {
271
+ rightNavBarEl.style.top = docPhaseEl
272
+ ? `${
273
+ totalHeaderHeight +
274
+ docPhaseEl.getBoundingClientRect().height
275
+ }px`
276
+ : `${totalHeaderHeight}px`;
277
+ }
278
+
244
279
  // If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
245
280
  if (docPhaseEl) {
246
281
  docPhaseEl.style.setProperty(
@@ -253,30 +288,6 @@ export default class ContentLayout extends LightningElement {
253
288
  : globalNavHeight + docHeaderHeight
254
289
  }px`
255
290
  );
256
-
257
- // Adjust scroll margin for doc headings when doc phase is present
258
- const docHeadingEls = Array.from(
259
- document.querySelectorAll("doc-heading")
260
- );
261
- docHeadingEls.forEach((docHeadingEl) => {
262
- (docHeadingEl as any).style.scrollMarginTop = `${
263
- globalNavHeight +
264
- docHeaderHeight +
265
- docPhaseEl.getBoundingClientRect().height
266
- }px`;
267
- });
268
-
269
- // Adjust right nav bar position when doc phase is present
270
- const rightNavBarEl =
271
- this.template.querySelector(".right-nav-bar");
272
-
273
- if (rightNavBarEl) {
274
- rightNavBarEl.style.top = `${
275
- globalNavHeight +
276
- docHeaderHeight +
277
- docPhaseEl.getBoundingClientRect().height
278
- }px`;
279
- }
280
291
  }
281
292
  });
282
293
  };
@@ -1,3 +0,0 @@
1
- onmessage = function (event) {
2
- postMessage(JSON.parse(JSON.stringify(event.data)));
3
- };