@salesforcedevs/docs-components 1.2.22-alpha → 1.3.4-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 +10 -2
- package/package.json +12 -12
- package/src/modules/doc/{amfReference/utils.ts → amfModelParser/amfModelParser.ts} +10 -5
- package/src/modules/doc/amfReference/amfReference.css +23 -3
- package/src/modules/doc/amfReference/amfReference.html +34 -21
- package/src/modules/doc/amfReference/amfReference.ts +225 -92
- package/src/modules/doc/amfReference/types.ts +3 -11
- package/src/modules/doc/amfTopic/amfTopic.css +20 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +35 -18
- package/src/modules/doc/amfTopic/types.ts +15 -13
- package/src/modules/doc/amfTopic/utils.ts +12 -6
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +17 -10
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +7 -9
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +30 -34
- package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +15 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +20 -0
- package/src/modules/doc/content/content.css +70 -76
- package/src/modules/doc/content/content.ts +18 -14
- package/src/modules/doc/contentCallout/contentCallout.css +12 -1
- package/src/modules/doc/contentCallout/contentCallout.html +11 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +8 -1
- package/src/modules/doc/contentLayout/contentLayout.css +1 -98
- package/src/modules/doc/contentLayout/contentLayout.html +25 -11
- package/src/modules/doc/contentLayout/contentLayout.ts +296 -89
- package/src/modules/doc/doDont/doDont.css +47 -0
- package/src/modules/doc/doDont/doDont.html +27 -0
- package/src/modules/doc/doDont/doDont.ts +17 -0
- package/src/modules/doc/header/header.css +65 -36
- package/src/modules/doc/header/header.html +40 -139
- package/src/modules/doc/header/header.ts +32 -77
- package/src/modules/doc/heading/heading.css +16 -37
- package/src/modules/doc/heading/heading.html +4 -4
- package/src/modules/doc/heading/heading.ts +12 -10
- package/src/modules/doc/headingAnchor/headingAnchor.css +2 -2
- package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
- package/src/modules/doc/headingContent/headingContent.css +1 -1
- package/src/modules/doc/headingContent/headingContent.html +2 -2
- package/src/modules/doc/headingContent/headingContent.ts +2 -2
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +64 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +168 -0
- package/src/modules/doc/overview/overview.css +40 -0
- package/src/modules/doc/overview/overview.html +34 -0
- package/src/modules/doc/overview/overview.ts +12 -0
- package/src/modules/doc/phase/phase.css +18 -3
- package/src/modules/doc/phase/phase.html +12 -2
- package/src/modules/doc/phase/phase.ts +44 -8
- package/src/modules/doc/specificationContent/specificationContent.css +31 -0
- package/src/modules/doc/specificationContent/specificationContent.html +164 -0
- package/src/modules/doc/specificationContent/specificationContent.ts +114 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/toc/toc.html +1 -3
- package/src/modules/doc/toc/toc.ts +1 -1
- package/src/modules/doc/toolbar/toolbar.ts +6 -6
- package/src/modules/doc/versionPicker/versionPicker.css +64 -0
- package/src/modules/doc/versionPicker/versionPicker.html +38 -0
- package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
- package/src/modules/doc/xmlContent/types.ts +9 -3
- package/src/modules/doc/xmlContent/utils.ts +3 -1
- package/src/modules/doc/xmlContent/xmlContent.css +25 -3
- package/src/modules/doc/xmlContent/xmlContent.html +29 -17
- package/src/modules/doc/xmlContent/xmlContent.ts +186 -74
- package/src/modules/docHelpers/amfStyle/amfStyle.css +6 -6
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
- package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
- package/src/modules/docHelpers/status/status.css +1 -1
- package/src/modules/docUtils/{SearchSyncer/SearchSyncer.ts → searchSyncer/searchSyncer.ts} +1 -0
- package/src/modules/docUtils/utils/utils.ts +32 -0
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +0 -93
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +0 -39
|
@@ -2,8 +2,9 @@ import { LightningElement, api, track } from "lwc";
|
|
|
2
2
|
import { noCase } from "no-case";
|
|
3
3
|
import { sentenceCase } from "sentence-case";
|
|
4
4
|
import qs from "query-string";
|
|
5
|
-
import { AmfModelParser } from "
|
|
6
|
-
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
5
|
+
import { AmfModelParser } from "doc/amfModelParser";
|
|
6
|
+
import { normalizeBoolean, toJson } from "dxUtils/normalizers";
|
|
7
|
+
import type { OptionWithLink } from "typings/custom";
|
|
7
8
|
import type {
|
|
8
9
|
AmfConfig,
|
|
9
10
|
AmfMetadataTopic,
|
|
@@ -25,19 +26,35 @@ import {
|
|
|
25
26
|
REFERENCE_TYPES,
|
|
26
27
|
oldReferenceIdNewReferenceIdMap
|
|
27
28
|
} from "./constants";
|
|
29
|
+
import { restoreScroll } from "dx/scrollManager";
|
|
30
|
+
import { DocPhaseInfo } from "typings/custom";
|
|
31
|
+
import { logCoveoPageView, oldVersionDocInfo } from "docUtils/utils";
|
|
32
|
+
|
|
33
|
+
type NavigationItem = {
|
|
34
|
+
label: string;
|
|
35
|
+
name: string;
|
|
36
|
+
isExpanded: boolean;
|
|
37
|
+
children: ParsedMarkdownTopic[];
|
|
38
|
+
isChildrenLoading: boolean;
|
|
39
|
+
};
|
|
28
40
|
|
|
29
41
|
export default class AmfReference extends LightningElement {
|
|
30
|
-
@api breadcrumbs
|
|
42
|
+
@api breadcrumbs: string | null = null;
|
|
31
43
|
@api sidebarHeader!: string;
|
|
32
44
|
@api coveoOrganizationId!: string;
|
|
33
45
|
@api coveoPublicAccessToken!: string;
|
|
34
|
-
@api
|
|
46
|
+
@api coveoAnalyticsToken!: string;
|
|
35
47
|
@api coveoSearchHub!: string;
|
|
36
|
-
@api useOldSidebar
|
|
48
|
+
@api useOldSidebar: boolean = false;
|
|
37
49
|
@api tocTitle?: string;
|
|
38
50
|
@api tocOptions?: string;
|
|
39
|
-
@
|
|
51
|
+
@api languages!: OptionWithLink[];
|
|
52
|
+
@api language!: string;
|
|
53
|
+
@api hideFooter = false;
|
|
54
|
+
@track navigation = [] as NavigationItem[];
|
|
40
55
|
@track versions: Array<ReferenceVersion> = [];
|
|
56
|
+
@track showVersionBanner = false;
|
|
57
|
+
@track _coveoAdvancedQueryConfig!: { [key: string]: any };
|
|
41
58
|
|
|
42
59
|
// Update this to update what component gets rendered in the content block
|
|
43
60
|
@track
|
|
@@ -101,6 +118,16 @@ export default class AmfReference extends LightningElement {
|
|
|
101
118
|
this.versions = this.getVersions();
|
|
102
119
|
}
|
|
103
120
|
this.selectedVersion = selectedVersion;
|
|
121
|
+
if (this.isSpecBasedReference(this._currentReferenceId)) {
|
|
122
|
+
this.isVersionFetched = true;
|
|
123
|
+
if (this.oldVersionInfo) {
|
|
124
|
+
this.showVersionBanner = true;
|
|
125
|
+
} else {
|
|
126
|
+
this.latestVersion = true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
this.isVersionFetched = true;
|
|
104
131
|
}
|
|
105
132
|
|
|
106
133
|
// This is to check if the url is hash based and redirect if needed
|
|
@@ -113,8 +140,8 @@ export default class AmfReference extends LightningElement {
|
|
|
113
140
|
}
|
|
114
141
|
|
|
115
142
|
@api
|
|
116
|
-
get docPhaseInfo() {
|
|
117
|
-
return this.selectedReferenceDocPhase;
|
|
143
|
+
get docPhaseInfo(): string | null {
|
|
144
|
+
return this.selectedReferenceDocPhase || null;
|
|
118
145
|
}
|
|
119
146
|
|
|
120
147
|
set docPhaseInfo(value: string) {
|
|
@@ -133,19 +160,47 @@ export default class AmfReference extends LightningElement {
|
|
|
133
160
|
this._expandChildren = normalizeBoolean(value);
|
|
134
161
|
}
|
|
135
162
|
|
|
163
|
+
/*
|
|
164
|
+
* The get coveoAdvancedQueryConfig() method returns this._coveoAdvancedQueryConfig,
|
|
165
|
+
* but before returning it, it checks if there are multiple versions (this.versions.length > 1)
|
|
166
|
+
* and if a version is selected (this.selectedVersion). If both conditions are met,
|
|
167
|
+
* it updates the version property of this._coveoAdvancedQueryConfig with the selected version.
|
|
168
|
+
*/
|
|
169
|
+
@api
|
|
170
|
+
get coveoAdvancedQueryConfig(): { [key: string]: any } {
|
|
171
|
+
const coveoConfig = this._coveoAdvancedQueryConfig;
|
|
172
|
+
if (this.versions.length > 1 && this.selectedVersion) {
|
|
173
|
+
const currentGAVersionRef = this.versions[0];
|
|
174
|
+
if (this.selectedVersion.id !== currentGAVersionRef.id) {
|
|
175
|
+
// Currently Coveo only supports query without "v"
|
|
176
|
+
const version = this.selectedVersion.id.replace("v", "");
|
|
177
|
+
coveoConfig.version = version;
|
|
178
|
+
this._coveoAdvancedQueryConfig = coveoConfig;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return this._coveoAdvancedQueryConfig;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
set coveoAdvancedQueryConfig(config) {
|
|
185
|
+
this._coveoAdvancedQueryConfig = toJson(config);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private get enableFooter(): boolean {
|
|
189
|
+
return !this.hideFooter;
|
|
190
|
+
}
|
|
191
|
+
|
|
136
192
|
// model
|
|
137
193
|
protected _amfConfigList: AmfConfig[] = [];
|
|
138
194
|
protected _amfConfigMap: Map<string, AmfConfig> = new Map();
|
|
139
195
|
protected _referenceSetConfig!: ReferenceSetConfig;
|
|
140
196
|
protected _currentReferenceId = "";
|
|
141
|
-
protected _scrollInterval = 0;
|
|
142
197
|
|
|
143
|
-
protected parentReferenceUrls = [];
|
|
198
|
+
protected parentReferenceUrls = [] as string[];
|
|
144
199
|
protected amfMap: Record<string, AmfModelRecord> = {};
|
|
145
|
-
protected amfFetchPromiseMap = {};
|
|
200
|
+
protected amfFetchPromiseMap = {} as any;
|
|
146
201
|
protected metadata: { [key: string]: AmfMetadataTopic } = {};
|
|
147
202
|
protected selectedTopic?: AmfMetaTopicType = undefined;
|
|
148
|
-
protected selectedSidebarValue = undefined;
|
|
203
|
+
protected selectedSidebarValue: string | undefined = undefined;
|
|
149
204
|
|
|
150
205
|
protected selectedVersion: ReferenceVersion | null = null;
|
|
151
206
|
|
|
@@ -154,6 +209,8 @@ export default class AmfReference extends LightningElement {
|
|
|
154
209
|
private isParentLevelDocPhaseEnabled = false;
|
|
155
210
|
private selectedReferenceDocPhase?: string | null = null;
|
|
156
211
|
private _expandChildren?: boolean = false;
|
|
212
|
+
private isVersionFetched = false;
|
|
213
|
+
private latestVersion = false;
|
|
157
214
|
|
|
158
215
|
/**
|
|
159
216
|
* Key for storing the currently selected reference url. This will be used to save the
|
|
@@ -182,9 +239,6 @@ export default class AmfReference extends LightningElement {
|
|
|
182
239
|
"popstate",
|
|
183
240
|
this._boundUpdateSelectedItemFromUrlQuery
|
|
184
241
|
);
|
|
185
|
-
this._scrollInterval = window.setInterval(() => {
|
|
186
|
-
this.saveScroll();
|
|
187
|
-
}, 1000);
|
|
188
242
|
}
|
|
189
243
|
|
|
190
244
|
disconnectedCallback(): void {
|
|
@@ -196,20 +250,6 @@ export default class AmfReference extends LightningElement {
|
|
|
196
250
|
"popstate",
|
|
197
251
|
this._boundUpdateSelectedItemFromUrlQuery
|
|
198
252
|
);
|
|
199
|
-
window.clearInterval(this._scrollInterval);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
saveScroll() {
|
|
203
|
-
window.history.replaceState(
|
|
204
|
-
{ scrollValue: document.body.scrollTop },
|
|
205
|
-
"",
|
|
206
|
-
window.location.href
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
restoreScroll() {
|
|
211
|
-
document.body.scrollTop = document.documentElement.scrollTop =
|
|
212
|
-
window.history.state?.scrollValue;
|
|
213
253
|
}
|
|
214
254
|
|
|
215
255
|
renderedCallback(): void {
|
|
@@ -299,6 +339,17 @@ export default class AmfReference extends LightningElement {
|
|
|
299
339
|
return referenceId;
|
|
300
340
|
}
|
|
301
341
|
|
|
342
|
+
private get oldVersionInfo(): DocPhaseInfo | null {
|
|
343
|
+
let info = null;
|
|
344
|
+
if (this.versions.length > 1 && this.selectedVersion) {
|
|
345
|
+
const currentGAVersionRef = this.versions[0];
|
|
346
|
+
if (this.selectedVersion.id !== currentGAVersionRef.id) {
|
|
347
|
+
info = oldVersionDocInfo(currentGAVersionRef.link.href);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return info;
|
|
351
|
+
}
|
|
352
|
+
|
|
302
353
|
/**
|
|
303
354
|
* @returns versions to be shown in the dropdown
|
|
304
355
|
* For markdown based specs, Adds selected markdown topic url to same references
|
|
@@ -329,13 +380,13 @@ export default class AmfReference extends LightningElement {
|
|
|
329
380
|
/**
|
|
330
381
|
* Returns the selected version or the first available version.
|
|
331
382
|
*/
|
|
332
|
-
private getSelectedVersion(): ReferenceVersion {
|
|
383
|
+
private getSelectedVersion(): ReferenceVersion | null {
|
|
333
384
|
const versions = this._referenceSetConfig?.versions || [];
|
|
334
385
|
const selectedVersion = versions.find(
|
|
335
386
|
(v: ReferenceVersion) => v.selected
|
|
336
387
|
);
|
|
337
388
|
// return a selected version if there is one, else return the first one.
|
|
338
|
-
return selectedVersion || (versions.length && versions[0]);
|
|
389
|
+
return selectedVersion || (versions.length && versions[0]) || null;
|
|
339
390
|
}
|
|
340
391
|
|
|
341
392
|
private updateAmfConfigInView(): void {
|
|
@@ -349,9 +400,11 @@ export default class AmfReference extends LightningElement {
|
|
|
349
400
|
}
|
|
350
401
|
}
|
|
351
402
|
|
|
352
|
-
private async fetchAmf(
|
|
403
|
+
private async fetchAmf(
|
|
404
|
+
amfConfig: AmfConfig
|
|
405
|
+
): Promise<AmfModel | AmfModel[]> {
|
|
353
406
|
const { amf } = amfConfig;
|
|
354
|
-
const response = await fetch(amf
|
|
407
|
+
const response = await fetch(amf!, {
|
|
355
408
|
headers: {
|
|
356
409
|
"Cache-Control": `max-age=86400`
|
|
357
410
|
}
|
|
@@ -370,7 +423,7 @@ export default class AmfReference extends LightningElement {
|
|
|
370
423
|
/**
|
|
371
424
|
* Returns whether given url is parent reference path like ../example-project/references/reference-id
|
|
372
425
|
*/
|
|
373
|
-
private isParentReferencePath(urlPath
|
|
426
|
+
private isParentReferencePath(urlPath?: string | null): boolean {
|
|
374
427
|
if (!urlPath) {
|
|
375
428
|
return false;
|
|
376
429
|
}
|
|
@@ -401,9 +454,9 @@ export default class AmfReference extends LightningElement {
|
|
|
401
454
|
* Populates reference Items from amfConfigList and assigns it to navigation for sidebar
|
|
402
455
|
*/
|
|
403
456
|
private populateReferenceItems(): void {
|
|
404
|
-
const navAmfOrder = [];
|
|
457
|
+
const navAmfOrder = [] as NavigationItem[];
|
|
405
458
|
for (const [index, amfConfig] of this._amfConfigList.entries()) {
|
|
406
|
-
let navItemChildren = [];
|
|
459
|
+
let navItemChildren = [] as ParsedMarkdownTopic[];
|
|
407
460
|
let isChildrenLoading = false;
|
|
408
461
|
if (amfConfig.referenceType !== REFERENCE_TYPES.markdown) {
|
|
409
462
|
if (amfConfig.isSelected) {
|
|
@@ -423,10 +476,10 @@ export default class AmfReference extends LightningElement {
|
|
|
423
476
|
// check whether we should expand all the child nodes, this is required for Coveo to crawl.
|
|
424
477
|
if (isExpandChildrenEnabled) {
|
|
425
478
|
this.expandChildrenForMarkdownReferences(
|
|
426
|
-
amfConfig.topic
|
|
479
|
+
amfConfig.topic!.children
|
|
427
480
|
);
|
|
428
481
|
}
|
|
429
|
-
navItemChildren = amfConfig.topic
|
|
482
|
+
navItemChildren = amfConfig.topic!.children;
|
|
430
483
|
}
|
|
431
484
|
// store nav items for each spec in order
|
|
432
485
|
navAmfOrder[index] = {
|
|
@@ -447,7 +500,9 @@ export default class AmfReference extends LightningElement {
|
|
|
447
500
|
* Returns a boolean indicating whether the children should be expanded or not.
|
|
448
501
|
*/
|
|
449
502
|
private isExpandChildrenEnabled(referenceId: string): boolean {
|
|
450
|
-
return
|
|
503
|
+
return (
|
|
504
|
+
!!this.expandChildren && this._currentReferenceId === referenceId
|
|
505
|
+
);
|
|
451
506
|
}
|
|
452
507
|
|
|
453
508
|
/**
|
|
@@ -491,12 +546,12 @@ export default class AmfReference extends LightningElement {
|
|
|
491
546
|
referenceId: string,
|
|
492
547
|
items: ParsedTopicModel[]
|
|
493
548
|
): NavItem[] {
|
|
494
|
-
const methodList = [];
|
|
549
|
+
const methodList = [] as NavItem[];
|
|
495
550
|
|
|
496
551
|
items.forEach((item) => {
|
|
497
552
|
item.methods?.forEach((method) => {
|
|
498
553
|
const title =
|
|
499
|
-
this.getTitleForLabel(method.label) || method.method;
|
|
554
|
+
this.getTitleForLabel(method.label!) || method.method;
|
|
500
555
|
const meta = this.addToMetadata(
|
|
501
556
|
parentReferencePath,
|
|
502
557
|
referenceId,
|
|
@@ -544,7 +599,7 @@ export default class AmfReference extends LightningElement {
|
|
|
544
599
|
const parentReferencePath = amfConfig.href;
|
|
545
600
|
const model = this.amfMap[referenceId].parser.parsedModel;
|
|
546
601
|
|
|
547
|
-
const children = [];
|
|
602
|
+
const children: any[] = [];
|
|
548
603
|
const expandChildren = this.isExpandChildrenEnabled(referenceId);
|
|
549
604
|
|
|
550
605
|
NAVIGATION_ITEMS.forEach(
|
|
@@ -571,8 +626,8 @@ export default class AmfReference extends LightningElement {
|
|
|
571
626
|
}
|
|
572
627
|
case "endpoint":
|
|
573
628
|
if (
|
|
574
|
-
model[childrenPropertyName] &&
|
|
575
|
-
model[childrenPropertyName].length
|
|
629
|
+
model[childrenPropertyName!] &&
|
|
630
|
+
model[childrenPropertyName!].length
|
|
576
631
|
) {
|
|
577
632
|
const amfTopicId = this.getFormattedIdentifier(
|
|
578
633
|
referenceId,
|
|
@@ -581,7 +636,7 @@ export default class AmfReference extends LightningElement {
|
|
|
581
636
|
const childTopics = this.assignEndpointNavItems(
|
|
582
637
|
parentReferencePath,
|
|
583
638
|
referenceId,
|
|
584
|
-
model[childrenPropertyName]
|
|
639
|
+
model[childrenPropertyName!]
|
|
585
640
|
);
|
|
586
641
|
children.push({
|
|
587
642
|
label,
|
|
@@ -596,23 +651,25 @@ export default class AmfReference extends LightningElement {
|
|
|
596
651
|
break;
|
|
597
652
|
case "security":
|
|
598
653
|
case "type":
|
|
599
|
-
if (model[childrenPropertyName]?.length) {
|
|
654
|
+
if (model[childrenPropertyName!]?.length) {
|
|
600
655
|
// Sorting the types alphabetically
|
|
601
|
-
model[childrenPropertyName].sort(
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
656
|
+
model[childrenPropertyName!].sort(
|
|
657
|
+
(typeA: any, typeB: any) => {
|
|
658
|
+
const typeALbl = typeA.label.toLowerCase();
|
|
659
|
+
const typeBLbl = typeB.label.toLowerCase();
|
|
660
|
+
return typeALbl < typeBLbl
|
|
661
|
+
? -1
|
|
662
|
+
: typeALbl > typeBLbl
|
|
663
|
+
? 1
|
|
664
|
+
: 0;
|
|
665
|
+
}
|
|
666
|
+
);
|
|
610
667
|
}
|
|
611
668
|
// eslint-disable-next-line no-fallthrough
|
|
612
669
|
default:
|
|
613
670
|
if (
|
|
614
|
-
model[childrenPropertyName] &&
|
|
615
|
-
model[childrenPropertyName].length
|
|
671
|
+
model[childrenPropertyName!] &&
|
|
672
|
+
model[childrenPropertyName!].length
|
|
616
673
|
) {
|
|
617
674
|
const amfTopicId = this.getFormattedIdentifier(
|
|
618
675
|
referenceId,
|
|
@@ -625,8 +682,8 @@ export default class AmfReference extends LightningElement {
|
|
|
625
682
|
this.metadata[amfTopicId]?.meta
|
|
626
683
|
),
|
|
627
684
|
isExpanded: expandChildren,
|
|
628
|
-
children: model[childrenPropertyName].map(
|
|
629
|
-
(topic) => {
|
|
685
|
+
children: model[childrenPropertyName!].map(
|
|
686
|
+
(topic: any) => {
|
|
630
687
|
const meta = this.addToMetadata(
|
|
631
688
|
parentReferencePath,
|
|
632
689
|
referenceId,
|
|
@@ -663,12 +720,18 @@ export default class AmfReference extends LightningElement {
|
|
|
663
720
|
type: string,
|
|
664
721
|
topic: { id: string; domId: string },
|
|
665
722
|
navTitle: string
|
|
666
|
-
): string
|
|
667
|
-
const
|
|
723
|
+
): string {
|
|
724
|
+
const config = URL_CONFIG[type as keyof typeof URL_CONFIG];
|
|
725
|
+
const urlIdentifer = config.urlIdentifer;
|
|
726
|
+
let prefix = null;
|
|
727
|
+
if ("prefix" in config) {
|
|
728
|
+
prefix = config.prefix;
|
|
729
|
+
}
|
|
668
730
|
|
|
669
731
|
// encodeURI to avoid special characters in the URL meta.
|
|
670
732
|
const identifier =
|
|
671
|
-
|
|
733
|
+
urlIdentifer in topic &&
|
|
734
|
+
this.encodeIdentifier(topic[urlIdentifer as keyof typeof topic]);
|
|
672
735
|
let meta;
|
|
673
736
|
// Assuming that there will be an identifier always
|
|
674
737
|
if (identifier) {
|
|
@@ -684,7 +747,7 @@ export default class AmfReference extends LightningElement {
|
|
|
684
747
|
navTitle
|
|
685
748
|
};
|
|
686
749
|
}
|
|
687
|
-
return meta
|
|
750
|
+
return meta!;
|
|
688
751
|
}
|
|
689
752
|
|
|
690
753
|
/**
|
|
@@ -695,7 +758,7 @@ export default class AmfReference extends LightningElement {
|
|
|
695
758
|
(metadata: AmfMetadataTopic) => {
|
|
696
759
|
return routeMeta.meta === metadata.meta;
|
|
697
760
|
}
|
|
698
|
-
)
|
|
761
|
+
)!;
|
|
699
762
|
}
|
|
700
763
|
|
|
701
764
|
/**
|
|
@@ -709,7 +772,7 @@ export default class AmfReference extends LightningElement {
|
|
|
709
772
|
return Object.values(this.metadata).find(
|
|
710
773
|
(metadata: AmfMetadataTopic) =>
|
|
711
774
|
referenceId === metadata.referenceId && amfId === metadata.amfId
|
|
712
|
-
)
|
|
775
|
+
)!;
|
|
713
776
|
}
|
|
714
777
|
|
|
715
778
|
/**
|
|
@@ -724,7 +787,7 @@ export default class AmfReference extends LightningElement {
|
|
|
724
787
|
(metadata: AmfMetadataTopic) =>
|
|
725
788
|
referenceId === metadata.referenceId &&
|
|
726
789
|
identifier === metadata.identifier
|
|
727
|
-
)
|
|
790
|
+
)!;
|
|
728
791
|
}
|
|
729
792
|
|
|
730
793
|
/**
|
|
@@ -738,7 +801,7 @@ export default class AmfReference extends LightningElement {
|
|
|
738
801
|
return Object.values(this.metadata).find(
|
|
739
802
|
(metadata: AmfMetadataTopic) =>
|
|
740
803
|
referenceId === metadata.referenceId && type === metadata.type
|
|
741
|
-
)
|
|
804
|
+
)!;
|
|
742
805
|
}
|
|
743
806
|
|
|
744
807
|
/**
|
|
@@ -798,6 +861,7 @@ export default class AmfReference extends LightningElement {
|
|
|
798
861
|
if (meta) {
|
|
799
862
|
// update the encoded url meta param
|
|
800
863
|
const encodedMeta = this.getUrlEncoded(meta);
|
|
864
|
+
|
|
801
865
|
window.history.replaceState(
|
|
802
866
|
window.history.state,
|
|
803
867
|
"",
|
|
@@ -815,9 +879,8 @@ export default class AmfReference extends LightningElement {
|
|
|
815
879
|
this._currentReferenceId
|
|
816
880
|
);
|
|
817
881
|
if (specBasedReference) {
|
|
818
|
-
const currentMeta: RouteMeta |
|
|
819
|
-
window.location.href
|
|
820
|
-
);
|
|
882
|
+
const currentMeta: RouteMeta | undefined =
|
|
883
|
+
this.getReferenceMetaInfo(window.location.href);
|
|
821
884
|
const metadata =
|
|
822
885
|
currentMeta && this.getMetadataByUrlQuery(currentMeta);
|
|
823
886
|
if (metadata) {
|
|
@@ -841,7 +904,7 @@ export default class AmfReference extends LightningElement {
|
|
|
841
904
|
this.loadMarkdownBasedReference();
|
|
842
905
|
}
|
|
843
906
|
|
|
844
|
-
|
|
907
|
+
restoreScroll(); // don't try this at home kids
|
|
845
908
|
}
|
|
846
909
|
|
|
847
910
|
/**
|
|
@@ -849,13 +912,11 @@ export default class AmfReference extends LightningElement {
|
|
|
849
912
|
* @param event
|
|
850
913
|
*/
|
|
851
914
|
protected onApiNavigationChanged(): void {
|
|
852
|
-
this.saveScroll();
|
|
853
|
-
|
|
854
915
|
const specBasedReference = this.isSpecBasedReference(
|
|
855
916
|
this._currentReferenceId
|
|
856
917
|
);
|
|
857
918
|
if (specBasedReference) {
|
|
858
|
-
const { meta } = this.selectedTopic
|
|
919
|
+
const { meta } = this.selectedTopic!;
|
|
859
920
|
const metadata = this.metadata[meta];
|
|
860
921
|
if (metadata) {
|
|
861
922
|
const {
|
|
@@ -970,7 +1031,7 @@ export default class AmfReference extends LightningElement {
|
|
|
970
1031
|
* 1. If the url is encoded already
|
|
971
1032
|
* 2. If the url is decoded
|
|
972
1033
|
*/
|
|
973
|
-
getUrlEncoded(url: string) {
|
|
1034
|
+
getUrlEncoded(url: string): string {
|
|
974
1035
|
// if url matches, then return the encoded url.
|
|
975
1036
|
if (decodeURIComponent(url) === url) {
|
|
976
1037
|
return encodeURIComponent(url);
|
|
@@ -986,7 +1047,7 @@ export default class AmfReference extends LightningElement {
|
|
|
986
1047
|
* For spec based references gets meta parm from url and then topicId & type from meta
|
|
987
1048
|
* For markdown based references gets topicId as last html path in the name, meta & type will be empty
|
|
988
1049
|
*/
|
|
989
|
-
getReferenceMetaInfo(referenceUrl: string): RouteMeta | undefined {
|
|
1050
|
+
getReferenceMetaInfo(referenceUrl: string | null): RouteMeta | undefined {
|
|
990
1051
|
let metaReferenceInfo;
|
|
991
1052
|
if (referenceUrl) {
|
|
992
1053
|
const referenceId = this.getReferenceIdFromUrl(referenceUrl);
|
|
@@ -1028,10 +1089,10 @@ export default class AmfReference extends LightningElement {
|
|
|
1028
1089
|
let topicTitle = "";
|
|
1029
1090
|
for (let i = 0; i < topics.length; i++) {
|
|
1030
1091
|
const topic = topics[i];
|
|
1031
|
-
const meta = this.getMarkdownReferenceMeta(topic.link
|
|
1092
|
+
const meta = this.getMarkdownReferenceMeta(topic.link!.href);
|
|
1032
1093
|
const childTopics = topic.children;
|
|
1033
1094
|
if (meta === topicMeta) {
|
|
1034
|
-
referenceUrl = topic.link
|
|
1095
|
+
referenceUrl = topic.link!.href;
|
|
1035
1096
|
topicTitle = topic.label;
|
|
1036
1097
|
} else if (childTopics && childTopics.length) {
|
|
1037
1098
|
const referenceDetails = this.getReferenceDetailsInGivenTopics(
|
|
@@ -1134,15 +1195,16 @@ export default class AmfReference extends LightningElement {
|
|
|
1134
1195
|
"",
|
|
1135
1196
|
selectedItemMetaData.meta
|
|
1136
1197
|
);
|
|
1198
|
+
|
|
1137
1199
|
this.updateUrlWithSelected(
|
|
1138
1200
|
selectedItemMetaData.parentReferencePath,
|
|
1139
1201
|
selectedItemMetaData.meta
|
|
1140
1202
|
);
|
|
1141
|
-
this.
|
|
1203
|
+
this.updateTags(selectedItemMetaData.navTitle);
|
|
1142
1204
|
}
|
|
1143
1205
|
});
|
|
1144
1206
|
} else {
|
|
1145
|
-
let invalidTopicReferenceUrl = "";
|
|
1207
|
+
let invalidTopicReferenceUrl: string | null = "";
|
|
1146
1208
|
if (topicId) {
|
|
1147
1209
|
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1148
1210
|
referenceId,
|
|
@@ -1176,7 +1238,10 @@ export default class AmfReference extends LightningElement {
|
|
|
1176
1238
|
* set selected sidebar value as a pathname
|
|
1177
1239
|
*/
|
|
1178
1240
|
|
|
1179
|
-
private loadMarkdownBasedReference(referenceUrl?: string): void {
|
|
1241
|
+
private loadMarkdownBasedReference(referenceUrl?: string | null): void {
|
|
1242
|
+
// MILES TODO: figure out if we ever need to log a coveo page view in here
|
|
1243
|
+
// this would be the case if at some point we 'load' a new 'markdown based reference'
|
|
1244
|
+
// without actually triggering a page load
|
|
1180
1245
|
let referenceId = "";
|
|
1181
1246
|
const currentUrl = window.location.href;
|
|
1182
1247
|
if (this.isProjectRootPath()) {
|
|
@@ -1190,7 +1255,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1190
1255
|
* CASE2: This case is to navigate to respective reference when the user clicked on root item
|
|
1191
1256
|
* Ex: .../references/markdown-ref should navigate to first topic.
|
|
1192
1257
|
*/
|
|
1193
|
-
referenceId = this.getReferenceIdFromUrl(referenceUrl);
|
|
1258
|
+
referenceId = this.getReferenceIdFromUrl(referenceUrl!);
|
|
1194
1259
|
} else if (this.isParentReferencePath(currentUrl)) {
|
|
1195
1260
|
/**
|
|
1196
1261
|
* CASE3: This case is to navigate to respective reference when the user entered url with reference id
|
|
@@ -1219,9 +1284,9 @@ export default class AmfReference extends LightningElement {
|
|
|
1219
1284
|
const amfConfig = this.getAmfConfigWithId(referenceId);
|
|
1220
1285
|
let redirectReferenceUrl = "";
|
|
1221
1286
|
if (amfConfig) {
|
|
1222
|
-
const childrenItems = amfConfig.topic
|
|
1287
|
+
const childrenItems = amfConfig.topic!.children;
|
|
1223
1288
|
if (childrenItems.length > 0) {
|
|
1224
|
-
redirectReferenceUrl = childrenItems[0].link
|
|
1289
|
+
redirectReferenceUrl = childrenItems[0].link!.href;
|
|
1225
1290
|
}
|
|
1226
1291
|
}
|
|
1227
1292
|
if (redirectReferenceUrl) {
|
|
@@ -1250,10 +1315,17 @@ export default class AmfReference extends LightningElement {
|
|
|
1250
1315
|
referenceMeta
|
|
1251
1316
|
);
|
|
1252
1317
|
if (referenceDetails) {
|
|
1253
|
-
this.
|
|
1318
|
+
this.updateTags(referenceDetails.topicTitle);
|
|
1254
1319
|
}
|
|
1255
1320
|
|
|
1256
1321
|
this.versions = this.getVersions();
|
|
1322
|
+
if (this.oldVersionInfo) {
|
|
1323
|
+
this.showVersionBanner = true;
|
|
1324
|
+
} else {
|
|
1325
|
+
this.latestVersion = true;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
this.isVersionFetched = true;
|
|
1257
1329
|
this.updateDocPhase();
|
|
1258
1330
|
this.selectedSidebarValue = window.location.pathname;
|
|
1259
1331
|
}
|
|
@@ -1270,18 +1342,66 @@ export default class AmfReference extends LightningElement {
|
|
|
1270
1342
|
);
|
|
1271
1343
|
}
|
|
1272
1344
|
|
|
1273
|
-
|
|
1345
|
+
handleDismissVersionBanner() {
|
|
1346
|
+
this.showVersionBanner = false;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
private updateTags(navTitle = ""): void {
|
|
1350
|
+
if (!navTitle) {
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1274
1354
|
// this is required to update the nav title meta tag.
|
|
1275
1355
|
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
1276
1356
|
const metaNavTitle = document.querySelector('meta[name="nav-title"]');
|
|
1277
|
-
|
|
1357
|
+
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
1358
|
+
const titleTag = document.querySelector("title");
|
|
1359
|
+
const TITLE_SEPARATOR = " | ";
|
|
1360
|
+
|
|
1361
|
+
if (metaNavTitle) {
|
|
1278
1362
|
metaNavTitle.setAttribute("content", navTitle);
|
|
1279
1363
|
}
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* Right now, the title tag only changes when you pick a Ref spec,
|
|
1367
|
+
* not every time you choose a subsection of the Ref spec.
|
|
1368
|
+
* This update aims to refresh the title tag with each selection.
|
|
1369
|
+
* If a Ref spec is chosen, we add the value of the <selected topic> to the title.
|
|
1370
|
+
* If a subsection is selected, we update the first part of the current
|
|
1371
|
+
* title with the new <selected topic>.
|
|
1372
|
+
* Example: Following is a sample project structure.
|
|
1373
|
+
* - Project Name
|
|
1374
|
+
* - Ref Spec1
|
|
1375
|
+
* - Summary
|
|
1376
|
+
* - Endpoints
|
|
1377
|
+
* - E1
|
|
1378
|
+
* - E2
|
|
1379
|
+
* - Ref Spec2
|
|
1380
|
+
* - Summary
|
|
1381
|
+
* - Endpoints
|
|
1382
|
+
* - E1 (Selected)
|
|
1383
|
+
* - E2
|
|
1384
|
+
* Previous Title: Ref Spec2 | Project Name | Salesforce Developer
|
|
1385
|
+
* New Title: E1 | Ref Spec2 | Project Name | Salesforce Developer
|
|
1386
|
+
*
|
|
1387
|
+
*/
|
|
1388
|
+
if (titleTag) {
|
|
1389
|
+
let titleTagValue = titleTag.textContent;
|
|
1390
|
+
const titleTagSectionValues: string[] =
|
|
1391
|
+
titleTagValue?.split(TITLE_SEPARATOR);
|
|
1392
|
+
if (titleTagSectionValues) {
|
|
1393
|
+
if (titleTagSectionValues.length <= 3) {
|
|
1394
|
+
titleTagValue = navTitle + TITLE_SEPARATOR + titleTagValue;
|
|
1395
|
+
} else {
|
|
1396
|
+
titleTagSectionValues[0] = navTitle;
|
|
1397
|
+
titleTagValue = titleTagSectionValues.join(TITLE_SEPARATOR);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
titleTag.textContent = titleTagValue;
|
|
1401
|
+
}
|
|
1280
1402
|
}
|
|
1281
1403
|
|
|
1282
1404
|
onNavSelect(event: CustomEvent): void {
|
|
1283
|
-
this.saveScroll();
|
|
1284
|
-
|
|
1285
1405
|
const name = event.detail.name;
|
|
1286
1406
|
if (name) {
|
|
1287
1407
|
const urlReferenceId = this.getReferenceIdFromUrl(name);
|
|
@@ -1315,8 +1435,13 @@ export default class AmfReference extends LightningElement {
|
|
|
1315
1435
|
elementId,
|
|
1316
1436
|
metaVal
|
|
1317
1437
|
);
|
|
1438
|
+
|
|
1439
|
+
logCoveoPageView(
|
|
1440
|
+
this.coveoOrganizationId,
|
|
1441
|
+
this.coveoAnalyticsToken
|
|
1442
|
+
);
|
|
1318
1443
|
this.updateUrlWithSelected(parentReferencePath, metaVal);
|
|
1319
|
-
this.
|
|
1444
|
+
this.updateTags(metadata.navTitle);
|
|
1320
1445
|
} else {
|
|
1321
1446
|
if (this.isParentReferencePath(name)) {
|
|
1322
1447
|
this.loadNewReferenceItem(name);
|
|
@@ -1348,12 +1473,20 @@ export default class AmfReference extends LightningElement {
|
|
|
1348
1473
|
|
|
1349
1474
|
handleSelectedItem(): void {
|
|
1350
1475
|
// update topic view
|
|
1351
|
-
const { referenceId, amfId, type } = this.selectedTopic
|
|
1476
|
+
const { referenceId, amfId, type } = this.selectedTopic!;
|
|
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
|
+
}
|
|
1352
1485
|
|
|
1353
1486
|
// This updates the component in the content section.
|
|
1354
1487
|
this.topicModel = {
|
|
1355
1488
|
type,
|
|
1356
|
-
amf:
|
|
1489
|
+
amf: amfModelString,
|
|
1357
1490
|
parser: this.amfMap[referenceId].parser,
|
|
1358
1491
|
id: amfId
|
|
1359
1492
|
};
|