@salesforcedevs/docs-components 1.3.194-search2-alpha → 1.3.196-alpha.10

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.194-search2-alpha",
3
+ "version": "1.3.196-alpha.10",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -185,10 +185,12 @@ export default class AmfReference extends LightningElement {
185
185
  constructor() {
186
186
  super();
187
187
 
188
- this._boundOnApiNavigationChanged =
189
- this.onApiNavigationChanged.bind(this);
190
- this._boundUpdateSelectedItemFromUrlQuery =
191
- this.updateSelectedItemFromUrlQuery.bind(this);
188
+ this._boundOnApiNavigationChanged = this.onApiNavigationChanged.bind(
189
+ this
190
+ );
191
+ this._boundUpdateSelectedItemFromUrlQuery = this.updateSelectedItemFromUrlQuery.bind(
192
+ this
193
+ );
192
194
  }
193
195
 
194
196
  connectedCallback(): void {
@@ -244,8 +246,9 @@ export default class AmfReference extends LightningElement {
244
246
  const updatedReferenceId =
245
247
  oldReferenceIdNewReferenceIdMap[referenceId];
246
248
  const newReferenceId = updatedReferenceId || referenceId;
247
- const referenceItemConfig =
248
- this.getAmfConfigWithId(newReferenceId);
249
+ const referenceItemConfig = this.getAmfConfigWithId(
250
+ newReferenceId
251
+ );
249
252
  if (referenceItemConfig) {
250
253
  hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${encodedMeta}`;
251
254
  }
@@ -325,8 +328,9 @@ export default class AmfReference extends LightningElement {
325
328
  for (let i = 0; i < allVersions.length; i++) {
326
329
  const versionItem = allVersions[i];
327
330
  const referenceLink = versionItem.link.href;
328
- const referenceId =
329
- this.getReferenceIdFromUrl(referenceLink);
331
+ const referenceId = this.getReferenceIdFromUrl(
332
+ referenceLink
333
+ );
330
334
  if (this._currentReferenceId === referenceId) {
331
335
  // This is to navigate to respective topic in the changed version
332
336
  versionItem.link.href = `${referenceLink}/${currentRefMeta}`;
@@ -840,8 +844,9 @@ export default class AmfReference extends LightningElement {
840
844
  this._currentReferenceId
841
845
  );
842
846
  if (specBasedReference) {
843
- const currentMeta: RouteMeta | undefined =
844
- this.getReferenceMetaInfo(window.location.href);
847
+ const currentMeta:
848
+ | RouteMeta
849
+ | undefined = this.getReferenceMetaInfo(window.location.href);
845
850
  const metadata =
846
851
  currentMeta && this.getMetadataByUrlQuery(currentMeta);
847
852
  if (metadata) {
@@ -1161,7 +1166,7 @@ export default class AmfReference extends LightningElement {
1161
1166
  selectedItemMetaData.parentReferencePath,
1162
1167
  selectedItemMetaData.meta
1163
1168
  );
1164
- this.updateTags(selectedItemMetaData.navTitle);
1169
+ this.updateNavTitleMetaTag(selectedItemMetaData.navTitle);
1165
1170
  }
1166
1171
  });
1167
1172
  } else {
@@ -1267,16 +1272,18 @@ export default class AmfReference extends LightningElement {
1267
1272
  }
1268
1273
  if (!isRedirecting) {
1269
1274
  const currentReferenceUrl = window.location.href;
1270
- const referenceMeta =
1271
- this.getMarkdownReferenceMeta(currentReferenceUrl);
1272
- const selectedItemRefId =
1273
- this.getReferenceIdFromUrl(currentReferenceUrl);
1275
+ const referenceMeta = this.getMarkdownReferenceMeta(
1276
+ currentReferenceUrl
1277
+ );
1278
+ const selectedItemRefId = this.getReferenceIdFromUrl(
1279
+ currentReferenceUrl
1280
+ );
1274
1281
  const referenceDetails = this.getRefDetailsForGivenTopicMeta(
1275
1282
  selectedItemRefId,
1276
1283
  referenceMeta
1277
1284
  );
1278
1285
  if (referenceDetails) {
1279
- this.updateTags(referenceDetails.topicTitle);
1286
+ this.updateNavTitleMetaTag(referenceDetails.topicTitle);
1280
1287
  }
1281
1288
 
1282
1289
  this.versions = this.getVersions();
@@ -1304,67 +1311,22 @@ export default class AmfReference extends LightningElement {
1304
1311
  this.showVersionBanner = false;
1305
1312
  }
1306
1313
 
1307
- private updateTags(navTitle = ""): void {
1308
- if (!navTitle) {
1309
- return;
1310
- }
1311
-
1314
+ private updateNavTitleMetaTag(navTitle = ""): void {
1312
1315
  // this is required to update the nav title meta tag.
1313
1316
  // eslint-disable-next-line @lwc/lwc/no-document-query
1314
1317
  const metaNavTitle = document.querySelector('meta[name="nav-title"]');
1315
- // eslint-disable-next-line @lwc/lwc/no-document-query
1316
- const titleTag = document.querySelector("title");
1317
- const TITLE_SEPARATOR = " | ";
1318
-
1319
- if (metaNavTitle) {
1318
+ if (metaNavTitle && navTitle) {
1320
1319
  metaNavTitle.setAttribute("content", navTitle);
1321
1320
  }
1322
-
1323
- /**
1324
- * Right now, the title tag only changes when you pick a Ref spec,
1325
- * not every time you choose a subsection of the Ref spec.
1326
- * This update aims to refresh the title tag with each selection.
1327
- * If a Ref spec is chosen, we add the value of the <selected topic> to the title.
1328
- * If a subsection is selected, we update the first part of the current
1329
- * title with the new <selected topic>.
1330
- * Example: Following is a sample project structure.
1331
- * - Project Name
1332
- * - Ref Spec1
1333
- * - Summary
1334
- * - Endpoints
1335
- * - E1
1336
- * - E2
1337
- * - Ref Spec2
1338
- * - Summary
1339
- * - Endpoints
1340
- * - E1 (Selected)
1341
- * - E2
1342
- * Previous Title: Ref Spec2 | Project Name | Salesforce Developer
1343
- * New Title: E1 | Ref Spec2 | Project Name | Salesforce Developer
1344
- *
1345
- */
1346
- if (titleTag) {
1347
- let titleTagValue = titleTag.textContent;
1348
- const titleTagSectionValues: string[] =
1349
- titleTagValue?.split(TITLE_SEPARATOR);
1350
- if (titleTagSectionValues) {
1351
- if (titleTagSectionValues.length <= 3) {
1352
- titleTagValue = navTitle + TITLE_SEPARATOR + titleTagValue;
1353
- } else {
1354
- titleTagSectionValues[0] = navTitle;
1355
- titleTagValue = titleTagSectionValues.join(TITLE_SEPARATOR);
1356
- }
1357
- }
1358
- titleTag.textContent = titleTagValue;
1359
- }
1360
1321
  }
1361
1322
 
1362
1323
  onNavSelect(event: CustomEvent): void {
1363
1324
  const name = event.detail.name;
1364
1325
  if (name) {
1365
1326
  const urlReferenceId = this.getReferenceIdFromUrl(name);
1366
- const specBasedReference =
1367
- this.isSpecBasedReference(urlReferenceId);
1327
+ const specBasedReference = this.isSpecBasedReference(
1328
+ urlReferenceId
1329
+ );
1368
1330
  if (specBasedReference) {
1369
1331
  const metaVal = this.getMetaFromUrl(name);
1370
1332
  const currentSelectedMeta = this.selectedTopic
@@ -1399,7 +1361,7 @@ export default class AmfReference extends LightningElement {
1399
1361
  this.coveoAnalyticsToken
1400
1362
  );
1401
1363
  this.updateUrlWithSelected(parentReferencePath, metaVal);
1402
- this.updateTags(metadata.navTitle);
1364
+ this.updateNavTitleMetaTag(metadata.navTitle);
1403
1365
  } else {
1404
1366
  if (this.isParentReferencePath(name)) {
1405
1367
  this.loadNewReferenceItem(name);
@@ -1419,8 +1381,9 @@ export default class AmfReference extends LightningElement {
1419
1381
  const currentReferenceId = this.getReferenceIdFromUrl(currentUrl);
1420
1382
  //No need to do anything if user is expanding currently selected reference
1421
1383
  if (referenceId !== currentReferenceId) {
1422
- const isSpecBasedReference =
1423
- this.isSpecBasedReference(referenceId);
1384
+ const isSpecBasedReference = this.isSpecBasedReference(
1385
+ referenceId
1386
+ );
1424
1387
  if (isSpecBasedReference) {
1425
1388
  // Perform functionality same as item selection
1426
1389
  this.onNavSelect(event);
@@ -207,9 +207,9 @@ export default class ContentLayout extends LightningElement {
207
207
  ".sticky-doc-header"
208
208
  ) as HTMLElement;
209
209
 
210
- const docPhaseEl = (this.template.querySelector(
211
- "[name=doc-phase]"
212
- )! as any).assignedElements()[0] as HTMLSlotElement;
210
+ const docPhaseEl = (
211
+ this.template.querySelector("[name=doc-phase]")! as any
212
+ ).assignedElements()[0] as HTMLSlotElement;
213
213
 
214
214
  if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
215
215
  console.warn("One or more required elements are missing.");
@@ -259,9 +259,8 @@ export default class ContentLayout extends LightningElement {
259
259
  });
260
260
 
261
261
  // Adjust right nav bar position when doc phase is present
262
- const rightNavBarEl = this.template.querySelector(
263
- ".right-nav-bar"
264
- );
262
+ const rightNavBarEl =
263
+ this.template.querySelector(".right-nav-bar");
265
264
 
266
265
  if (rightNavBarEl) {
267
266
  rightNavBarEl.style.top = `${
@@ -323,14 +322,17 @@ export default class ContentLayout extends LightningElement {
323
322
  };
324
323
 
325
324
  onSlotChange(event: Event): void {
326
- const slotElements = (event.target as HTMLSlotElement).assignedElements();
325
+ const slotElements = (
326
+ event.target as HTMLSlotElement
327
+ ).assignedElements();
327
328
 
328
329
  if (slotElements.length) {
329
330
  this.contentLoaded = true;
330
331
  const slotContentElement = slotElements[0];
331
- const headingElements = slotContentElement.ownerDocument?.getElementsByTagName(
332
- TOC_HEADER_TAG
333
- );
332
+ const headingElements =
333
+ slotContentElement.ownerDocument?.getElementsByTagName(
334
+ TOC_HEADER_TAG
335
+ );
334
336
 
335
337
  for (const headingElement of headingElements as any) {
336
338
  // Sometimes elements hash is not being set when slot content is wrapped with div
@@ -390,9 +392,9 @@ export default class ContentLayout extends LightningElement {
390
392
  globalNavEl?.offsetHeight +
391
393
  contextNavEl?.offsetHeight;
392
394
 
393
- const docPhaseEl = (this.template.querySelector(
394
- "[name=doc-phase]"
395
- )! as any).assignedElements()[0] as HTMLSlotElement;
395
+ const docPhaseEl = (
396
+ this.template.querySelector("[name=doc-phase]")! as any
397
+ ).assignedElements()[0] as HTMLSlotElement;
396
398
 
397
399
  const offset = docPhaseEl
398
400
  ? headerHeight + docPhaseEl.offsetHeight