@salesforcedevs/docs-components 1.3.170 → 1.3.171
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/LICENSE +12 -0
- package/package.json +2 -2
- package/src/modules/doc/amfReference/amfReference.ts +61 -80
- package/src/modules/doc/amfReference/utils.ts +5 -10
- package/src/modules/doc/amfTopic/amfTopic.ts +7 -12
- package/src/modules/doc/amfTopic/types.ts +12 -14
- package/src/modules/doc/amfTopic/utils.ts +6 -12
- package/src/modules/doc/content/content.ts +11 -10
- package/src/modules/doc/contentLayout/contentLayout.ts +34 -38
- package/src/modules/doc/heading/heading.ts +0 -2
- package/src/modules/doc/toc/toc.ts +1 -1
- package/src/modules/doc/xmlContent/types.ts +1 -1
- package/src/modules/doc/xmlContent/xmlContent.ts +38 -43
- package/src/modules/docUtils/{searchSyncer/searchSyncer.ts → SearchSyncer/SearchSyncer.ts} +6 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.171",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@types/lodash.orderby": "^4.6.7",
|
|
25
25
|
"@types/lodash.uniqby": "^4.7.7"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "949dbf90a356a61047657e2e15dd723f04063759"
|
|
28
28
|
}
|
|
@@ -2,7 +2,7 @@ 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 "
|
|
5
|
+
import { AmfModelParser } from "./utils";
|
|
6
6
|
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
7
7
|
import { CoveoAnalyticsClient } from "coveo.analytics";
|
|
8
8
|
import type {
|
|
@@ -30,26 +30,18 @@ import { restoreScroll } from "dx/scrollManager";
|
|
|
30
30
|
import { DocPhaseInfo } from "typings/custom";
|
|
31
31
|
import { oldVersionDocInfo } from "docUtils/utils";
|
|
32
32
|
|
|
33
|
-
type NavigationItem = {
|
|
34
|
-
label: string;
|
|
35
|
-
name: string;
|
|
36
|
-
isExpanded: boolean;
|
|
37
|
-
children: ParsedMarkdownTopic[];
|
|
38
|
-
isChildrenLoading: boolean;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
33
|
export default class AmfReference extends LightningElement {
|
|
42
|
-
@api breadcrumbs
|
|
34
|
+
@api breadcrumbs?: string | null | undefined = null;
|
|
43
35
|
@api sidebarHeader!: string;
|
|
44
36
|
@api coveoOrganizationId!: string;
|
|
45
37
|
@api coveoPublicAccessToken!: string;
|
|
46
38
|
@api coveoAnalyticsToken!: string;
|
|
47
39
|
@api coveoAdvancedQueryConfig!: string;
|
|
48
40
|
@api coveoSearchHub!: string;
|
|
49
|
-
@api useOldSidebar
|
|
41
|
+
@api useOldSidebar?: boolean = false;
|
|
50
42
|
@api tocTitle?: string;
|
|
51
43
|
@api tocOptions?: string;
|
|
52
|
-
@track navigation = []
|
|
44
|
+
@track navigation = [];
|
|
53
45
|
@track versions: Array<ReferenceVersion> = [];
|
|
54
46
|
@track showVersionBanner = false;
|
|
55
47
|
|
|
@@ -133,8 +125,8 @@ export default class AmfReference extends LightningElement {
|
|
|
133
125
|
}
|
|
134
126
|
|
|
135
127
|
@api
|
|
136
|
-
get docPhaseInfo()
|
|
137
|
-
return this.selectedReferenceDocPhase
|
|
128
|
+
get docPhaseInfo() {
|
|
129
|
+
return this.selectedReferenceDocPhase;
|
|
138
130
|
}
|
|
139
131
|
|
|
140
132
|
set docPhaseInfo(value: string) {
|
|
@@ -159,12 +151,12 @@ export default class AmfReference extends LightningElement {
|
|
|
159
151
|
protected _referenceSetConfig!: ReferenceSetConfig;
|
|
160
152
|
protected _currentReferenceId = "";
|
|
161
153
|
|
|
162
|
-
protected parentReferenceUrls = []
|
|
154
|
+
protected parentReferenceUrls = [];
|
|
163
155
|
protected amfMap: Record<string, AmfModelRecord> = {};
|
|
164
|
-
protected amfFetchPromiseMap = {}
|
|
156
|
+
protected amfFetchPromiseMap = {};
|
|
165
157
|
protected metadata: { [key: string]: AmfMetadataTopic } = {};
|
|
166
158
|
protected selectedTopic?: AmfMetaTopicType = undefined;
|
|
167
|
-
protected selectedSidebarValue
|
|
159
|
+
protected selectedSidebarValue = undefined;
|
|
168
160
|
|
|
169
161
|
protected selectedVersion: ReferenceVersion | null = null;
|
|
170
162
|
|
|
@@ -355,13 +347,13 @@ export default class AmfReference extends LightningElement {
|
|
|
355
347
|
/**
|
|
356
348
|
* Returns the selected version or the first available version.
|
|
357
349
|
*/
|
|
358
|
-
private getSelectedVersion(): ReferenceVersion
|
|
350
|
+
private getSelectedVersion(): ReferenceVersion {
|
|
359
351
|
const versions = this._referenceSetConfig?.versions || [];
|
|
360
352
|
const selectedVersion = versions.find(
|
|
361
353
|
(v: ReferenceVersion) => v.selected
|
|
362
354
|
);
|
|
363
355
|
// return a selected version if there is one, else return the first one.
|
|
364
|
-
return selectedVersion || (versions.length && versions[0])
|
|
356
|
+
return selectedVersion || (versions.length && versions[0]);
|
|
365
357
|
}
|
|
366
358
|
|
|
367
359
|
private updateAmfConfigInView(): void {
|
|
@@ -375,11 +367,9 @@ export default class AmfReference extends LightningElement {
|
|
|
375
367
|
}
|
|
376
368
|
}
|
|
377
369
|
|
|
378
|
-
private async fetchAmf(
|
|
379
|
-
amfConfig: AmfConfig
|
|
380
|
-
): Promise<AmfModel | AmfModel[]> {
|
|
370
|
+
private async fetchAmf(amfConfig): Promise<AmfModel | AmfModel[]> {
|
|
381
371
|
const { amf } = amfConfig;
|
|
382
|
-
const response = await fetch(amf
|
|
372
|
+
const response = await fetch(amf, {
|
|
383
373
|
headers: {
|
|
384
374
|
"Cache-Control": `max-age=86400`
|
|
385
375
|
}
|
|
@@ -398,7 +388,7 @@ export default class AmfReference extends LightningElement {
|
|
|
398
388
|
/**
|
|
399
389
|
* Returns whether given url is parent reference path like ../example-project/references/reference-id
|
|
400
390
|
*/
|
|
401
|
-
private isParentReferencePath(urlPath
|
|
391
|
+
private isParentReferencePath(urlPath: string): boolean {
|
|
402
392
|
if (!urlPath) {
|
|
403
393
|
return false;
|
|
404
394
|
}
|
|
@@ -429,9 +419,9 @@ export default class AmfReference extends LightningElement {
|
|
|
429
419
|
* Populates reference Items from amfConfigList and assigns it to navigation for sidebar
|
|
430
420
|
*/
|
|
431
421
|
private populateReferenceItems(): void {
|
|
432
|
-
const navAmfOrder = []
|
|
422
|
+
const navAmfOrder = [];
|
|
433
423
|
for (const [index, amfConfig] of this._amfConfigList.entries()) {
|
|
434
|
-
let navItemChildren = []
|
|
424
|
+
let navItemChildren = [];
|
|
435
425
|
let isChildrenLoading = false;
|
|
436
426
|
if (amfConfig.referenceType !== REFERENCE_TYPES.markdown) {
|
|
437
427
|
if (amfConfig.isSelected) {
|
|
@@ -451,10 +441,10 @@ export default class AmfReference extends LightningElement {
|
|
|
451
441
|
// check whether we should expand all the child nodes, this is required for Coveo to crawl.
|
|
452
442
|
if (isExpandChildrenEnabled) {
|
|
453
443
|
this.expandChildrenForMarkdownReferences(
|
|
454
|
-
amfConfig.topic
|
|
444
|
+
amfConfig.topic.children
|
|
455
445
|
);
|
|
456
446
|
}
|
|
457
|
-
navItemChildren = amfConfig.topic
|
|
447
|
+
navItemChildren = amfConfig.topic.children;
|
|
458
448
|
}
|
|
459
449
|
// store nav items for each spec in order
|
|
460
450
|
navAmfOrder[index] = {
|
|
@@ -475,9 +465,7 @@ export default class AmfReference extends LightningElement {
|
|
|
475
465
|
* Returns a boolean indicating whether the children should be expanded or not.
|
|
476
466
|
*/
|
|
477
467
|
private isExpandChildrenEnabled(referenceId: string): boolean {
|
|
478
|
-
return
|
|
479
|
-
!!this.expandChildren && this._currentReferenceId === referenceId
|
|
480
|
-
);
|
|
468
|
+
return this.expandChildren && this._currentReferenceId === referenceId;
|
|
481
469
|
}
|
|
482
470
|
|
|
483
471
|
/**
|
|
@@ -521,12 +509,12 @@ export default class AmfReference extends LightningElement {
|
|
|
521
509
|
referenceId: string,
|
|
522
510
|
items: ParsedTopicModel[]
|
|
523
511
|
): NavItem[] {
|
|
524
|
-
const methodList = []
|
|
512
|
+
const methodList = [];
|
|
525
513
|
|
|
526
514
|
items.forEach((item) => {
|
|
527
515
|
item.methods?.forEach((method) => {
|
|
528
516
|
const title =
|
|
529
|
-
this.getTitleForLabel(method.label
|
|
517
|
+
this.getTitleForLabel(method.label) || method.method;
|
|
530
518
|
const meta = this.addToMetadata(
|
|
531
519
|
parentReferencePath,
|
|
532
520
|
referenceId,
|
|
@@ -574,7 +562,7 @@ export default class AmfReference extends LightningElement {
|
|
|
574
562
|
const parentReferencePath = amfConfig.href;
|
|
575
563
|
const model = this.amfMap[referenceId].parser.parsedModel;
|
|
576
564
|
|
|
577
|
-
const children
|
|
565
|
+
const children = [];
|
|
578
566
|
const expandChildren = this.isExpandChildrenEnabled(referenceId);
|
|
579
567
|
|
|
580
568
|
NAVIGATION_ITEMS.forEach(
|
|
@@ -601,8 +589,8 @@ export default class AmfReference extends LightningElement {
|
|
|
601
589
|
}
|
|
602
590
|
case "endpoint":
|
|
603
591
|
if (
|
|
604
|
-
model[childrenPropertyName
|
|
605
|
-
model[childrenPropertyName
|
|
592
|
+
model[childrenPropertyName] &&
|
|
593
|
+
model[childrenPropertyName].length
|
|
606
594
|
) {
|
|
607
595
|
const amfTopicId = this.getFormattedIdentifier(
|
|
608
596
|
referenceId,
|
|
@@ -611,7 +599,7 @@ export default class AmfReference extends LightningElement {
|
|
|
611
599
|
const childTopics = this.assignEndpointNavItems(
|
|
612
600
|
parentReferencePath,
|
|
613
601
|
referenceId,
|
|
614
|
-
model[childrenPropertyName
|
|
602
|
+
model[childrenPropertyName]
|
|
615
603
|
);
|
|
616
604
|
children.push({
|
|
617
605
|
label,
|
|
@@ -626,25 +614,23 @@ export default class AmfReference extends LightningElement {
|
|
|
626
614
|
break;
|
|
627
615
|
case "security":
|
|
628
616
|
case "type":
|
|
629
|
-
if (model[childrenPropertyName
|
|
617
|
+
if (model[childrenPropertyName]?.length) {
|
|
630
618
|
// Sorting the types alphabetically
|
|
631
|
-
model[childrenPropertyName
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
);
|
|
619
|
+
model[childrenPropertyName].sort((typeA, typeB) => {
|
|
620
|
+
const typeALbl = typeA.label.toLowerCase();
|
|
621
|
+
const typeBLbl = typeB.label.toLowerCase();
|
|
622
|
+
return typeALbl < typeBLbl
|
|
623
|
+
? -1
|
|
624
|
+
: typeALbl > typeBLbl
|
|
625
|
+
? 1
|
|
626
|
+
: 0;
|
|
627
|
+
});
|
|
642
628
|
}
|
|
643
629
|
// eslint-disable-next-line no-fallthrough
|
|
644
630
|
default:
|
|
645
631
|
if (
|
|
646
|
-
model[childrenPropertyName
|
|
647
|
-
model[childrenPropertyName
|
|
632
|
+
model[childrenPropertyName] &&
|
|
633
|
+
model[childrenPropertyName].length
|
|
648
634
|
) {
|
|
649
635
|
const amfTopicId = this.getFormattedIdentifier(
|
|
650
636
|
referenceId,
|
|
@@ -657,8 +643,8 @@ export default class AmfReference extends LightningElement {
|
|
|
657
643
|
this.metadata[amfTopicId]?.meta
|
|
658
644
|
),
|
|
659
645
|
isExpanded: expandChildren,
|
|
660
|
-
children: model[childrenPropertyName
|
|
661
|
-
(topic
|
|
646
|
+
children: model[childrenPropertyName].map(
|
|
647
|
+
(topic) => {
|
|
662
648
|
const meta = this.addToMetadata(
|
|
663
649
|
parentReferencePath,
|
|
664
650
|
referenceId,
|
|
@@ -695,18 +681,12 @@ export default class AmfReference extends LightningElement {
|
|
|
695
681
|
type: string,
|
|
696
682
|
topic: { id: string; domId: string },
|
|
697
683
|
navTitle: string
|
|
698
|
-
): string {
|
|
699
|
-
const
|
|
700
|
-
const urlIdentifer = config.urlIdentifer;
|
|
701
|
-
let prefix = null;
|
|
702
|
-
if ("prefix" in config) {
|
|
703
|
-
prefix = config.prefix;
|
|
704
|
-
}
|
|
684
|
+
): string | undefined {
|
|
685
|
+
const { urlIdentifer, prefix } = URL_CONFIG[type];
|
|
705
686
|
|
|
706
687
|
// encodeURI to avoid special characters in the URL meta.
|
|
707
688
|
const identifier =
|
|
708
|
-
urlIdentifer
|
|
709
|
-
this.encodeIdentifier(topic[urlIdentifer as keyof typeof topic]);
|
|
689
|
+
topic[urlIdentifer] && this.encodeIdentifier(topic[urlIdentifer]);
|
|
710
690
|
let meta;
|
|
711
691
|
// Assuming that there will be an identifier always
|
|
712
692
|
if (identifier) {
|
|
@@ -722,7 +702,7 @@ export default class AmfReference extends LightningElement {
|
|
|
722
702
|
navTitle
|
|
723
703
|
};
|
|
724
704
|
}
|
|
725
|
-
return meta
|
|
705
|
+
return meta;
|
|
726
706
|
}
|
|
727
707
|
|
|
728
708
|
/**
|
|
@@ -733,7 +713,7 @@ export default class AmfReference extends LightningElement {
|
|
|
733
713
|
(metadata: AmfMetadataTopic) => {
|
|
734
714
|
return routeMeta.meta === metadata.meta;
|
|
735
715
|
}
|
|
736
|
-
)
|
|
716
|
+
);
|
|
737
717
|
}
|
|
738
718
|
|
|
739
719
|
/**
|
|
@@ -747,7 +727,7 @@ export default class AmfReference extends LightningElement {
|
|
|
747
727
|
return Object.values(this.metadata).find(
|
|
748
728
|
(metadata: AmfMetadataTopic) =>
|
|
749
729
|
referenceId === metadata.referenceId && amfId === metadata.amfId
|
|
750
|
-
)
|
|
730
|
+
);
|
|
751
731
|
}
|
|
752
732
|
|
|
753
733
|
/**
|
|
@@ -762,7 +742,7 @@ export default class AmfReference extends LightningElement {
|
|
|
762
742
|
(metadata: AmfMetadataTopic) =>
|
|
763
743
|
referenceId === metadata.referenceId &&
|
|
764
744
|
identifier === metadata.identifier
|
|
765
|
-
)
|
|
745
|
+
);
|
|
766
746
|
}
|
|
767
747
|
|
|
768
748
|
/**
|
|
@@ -776,7 +756,7 @@ export default class AmfReference extends LightningElement {
|
|
|
776
756
|
return Object.values(this.metadata).find(
|
|
777
757
|
(metadata: AmfMetadataTopic) =>
|
|
778
758
|
referenceId === metadata.referenceId && type === metadata.type
|
|
779
|
-
)
|
|
759
|
+
);
|
|
780
760
|
}
|
|
781
761
|
|
|
782
762
|
/**
|
|
@@ -853,8 +833,9 @@ export default class AmfReference extends LightningElement {
|
|
|
853
833
|
this._currentReferenceId
|
|
854
834
|
);
|
|
855
835
|
if (specBasedReference) {
|
|
856
|
-
const currentMeta: RouteMeta |
|
|
857
|
-
|
|
836
|
+
const currentMeta: RouteMeta | null = this.getReferenceMetaInfo(
|
|
837
|
+
window.location.href
|
|
838
|
+
);
|
|
858
839
|
const metadata =
|
|
859
840
|
currentMeta && this.getMetadataByUrlQuery(currentMeta);
|
|
860
841
|
if (metadata) {
|
|
@@ -890,7 +871,7 @@ export default class AmfReference extends LightningElement {
|
|
|
890
871
|
this._currentReferenceId
|
|
891
872
|
);
|
|
892
873
|
if (specBasedReference) {
|
|
893
|
-
const { meta } = this.selectedTopic
|
|
874
|
+
const { meta } = this.selectedTopic;
|
|
894
875
|
const metadata = this.metadata[meta];
|
|
895
876
|
if (metadata) {
|
|
896
877
|
const {
|
|
@@ -1007,7 +988,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1007
988
|
* 1. If the url is encoded already
|
|
1008
989
|
* 2. If the url is decoded
|
|
1009
990
|
*/
|
|
1010
|
-
getUrlEncoded(url: string)
|
|
991
|
+
getUrlEncoded(url: string) {
|
|
1011
992
|
// if url matches, then return the encoded url.
|
|
1012
993
|
if (decodeURIComponent(url) === url) {
|
|
1013
994
|
return encodeURIComponent(url);
|
|
@@ -1023,7 +1004,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1023
1004
|
* For spec based references gets meta parm from url and then topicId & type from meta
|
|
1024
1005
|
* For markdown based references gets topicId as last html path in the name, meta & type will be empty
|
|
1025
1006
|
*/
|
|
1026
|
-
getReferenceMetaInfo(referenceUrl: string
|
|
1007
|
+
getReferenceMetaInfo(referenceUrl: string): RouteMeta | undefined {
|
|
1027
1008
|
let metaReferenceInfo;
|
|
1028
1009
|
if (referenceUrl) {
|
|
1029
1010
|
const referenceId = this.getReferenceIdFromUrl(referenceUrl);
|
|
@@ -1065,10 +1046,10 @@ export default class AmfReference extends LightningElement {
|
|
|
1065
1046
|
let topicTitle = "";
|
|
1066
1047
|
for (let i = 0; i < topics.length; i++) {
|
|
1067
1048
|
const topic = topics[i];
|
|
1068
|
-
const meta = this.getMarkdownReferenceMeta(topic.link
|
|
1049
|
+
const meta = this.getMarkdownReferenceMeta(topic.link.href);
|
|
1069
1050
|
const childTopics = topic.children;
|
|
1070
1051
|
if (meta === topicMeta) {
|
|
1071
|
-
referenceUrl = topic.link
|
|
1052
|
+
referenceUrl = topic.link.href;
|
|
1072
1053
|
topicTitle = topic.label;
|
|
1073
1054
|
} else if (childTopics && childTopics.length) {
|
|
1074
1055
|
const referenceDetails = this.getReferenceDetailsInGivenTopics(
|
|
@@ -1179,7 +1160,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1179
1160
|
}
|
|
1180
1161
|
});
|
|
1181
1162
|
} else {
|
|
1182
|
-
let invalidTopicReferenceUrl
|
|
1163
|
+
let invalidTopicReferenceUrl = "";
|
|
1183
1164
|
if (topicId) {
|
|
1184
1165
|
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1185
1166
|
referenceId,
|
|
@@ -1215,7 +1196,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1215
1196
|
* set selected sidebar value as a pathname
|
|
1216
1197
|
*/
|
|
1217
1198
|
|
|
1218
|
-
private loadMarkdownBasedReference(referenceUrl?: string
|
|
1199
|
+
private loadMarkdownBasedReference(referenceUrl?: string): void {
|
|
1219
1200
|
let referenceId = "";
|
|
1220
1201
|
const currentUrl = window.location.href;
|
|
1221
1202
|
if (this.isProjectRootPath()) {
|
|
@@ -1229,7 +1210,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1229
1210
|
* CASE2: This case is to navigate to respective reference when the user clicked on root item
|
|
1230
1211
|
* Ex: .../references/markdown-ref should navigate to first topic.
|
|
1231
1212
|
*/
|
|
1232
|
-
referenceId = this.getReferenceIdFromUrl(referenceUrl
|
|
1213
|
+
referenceId = this.getReferenceIdFromUrl(referenceUrl);
|
|
1233
1214
|
} else if (this.isParentReferencePath(currentUrl)) {
|
|
1234
1215
|
/**
|
|
1235
1216
|
* CASE3: This case is to navigate to respective reference when the user entered url with reference id
|
|
@@ -1258,9 +1239,9 @@ export default class AmfReference extends LightningElement {
|
|
|
1258
1239
|
const amfConfig = this.getAmfConfigWithId(referenceId);
|
|
1259
1240
|
let redirectReferenceUrl = "";
|
|
1260
1241
|
if (amfConfig) {
|
|
1261
|
-
const childrenItems = amfConfig.topic
|
|
1242
|
+
const childrenItems = amfConfig.topic.children;
|
|
1262
1243
|
if (childrenItems.length > 0) {
|
|
1263
|
-
redirectReferenceUrl = childrenItems[0].link
|
|
1244
|
+
redirectReferenceUrl = childrenItems[0].link.href;
|
|
1264
1245
|
}
|
|
1265
1246
|
}
|
|
1266
1247
|
if (redirectReferenceUrl) {
|
|
@@ -1394,7 +1375,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1394
1375
|
|
|
1395
1376
|
handleSelectedItem(): void {
|
|
1396
1377
|
// update topic view
|
|
1397
|
-
const { referenceId, amfId, type } = this.selectedTopic
|
|
1378
|
+
const { referenceId, amfId, type } = this.selectedTopic;
|
|
1398
1379
|
|
|
1399
1380
|
// This updates the component in the content section.
|
|
1400
1381
|
this.topicModel = {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
AmfHelperMixin,
|
|
4
|
-
EndPoint,
|
|
5
|
-
Operation
|
|
6
|
-
} from "@api-components/amf-helper-mixin";
|
|
1
|
+
import { AmfHelperMixin } from "@api-components/amf-helper-mixin";
|
|
7
2
|
import { normalizeDomId } from "dxUtils/normalizers";
|
|
8
3
|
|
|
9
4
|
const ID_PROPERTY = "@id";
|
|
@@ -12,7 +7,7 @@ const TYPE_PROPERTY = "@type";
|
|
|
12
7
|
export class AmfModelParser extends AmfHelperMixin(Object) {
|
|
13
8
|
_parsedModel = null;
|
|
14
9
|
|
|
15
|
-
constructor(api
|
|
10
|
+
constructor(api) {
|
|
16
11
|
super();
|
|
17
12
|
if (api) {
|
|
18
13
|
this.amf = Array.isArray(api) ? api[0] : api;
|
|
@@ -522,7 +517,7 @@ export class AmfModelParser extends AmfHelperMixin(Object) {
|
|
|
522
517
|
* @param {string} selected Currently selected `@id`.
|
|
523
518
|
* @return {any|undefined} Model definition for an endpoint fragment.
|
|
524
519
|
*/
|
|
525
|
-
computeEndpointApiModel(model, selectedId)
|
|
520
|
+
computeEndpointApiModel(model, selectedId) {
|
|
526
521
|
const webApi = this._computeApi(model);
|
|
527
522
|
return this._computeEndpointModel(webApi, selectedId);
|
|
528
523
|
}
|
|
@@ -534,7 +529,7 @@ export class AmfModelParser extends AmfHelperMixin(Object) {
|
|
|
534
529
|
* @param {string} selected Currently selected `@id`.
|
|
535
530
|
* @return {any|undefined} Model definition for an endpoint fragment.
|
|
536
531
|
*/
|
|
537
|
-
computeMethodApiModel(model, selected)
|
|
532
|
+
computeMethodApiModel(model, selected) {
|
|
538
533
|
const webApi = this._computeApi(model);
|
|
539
534
|
return this._computeMethodModel(webApi, selected);
|
|
540
535
|
}
|
|
@@ -546,7 +541,7 @@ export class AmfModelParser extends AmfHelperMixin(Object) {
|
|
|
546
541
|
* @param {string} selected Currently selected `@id`.
|
|
547
542
|
* @return {any|undefined} Model definition for an endpoint fragment.
|
|
548
543
|
*/
|
|
549
|
-
computeEndpointApiMethodModel(model, selected)
|
|
544
|
+
computeEndpointApiMethodModel(model, selected) {
|
|
550
545
|
const webApi = this._computeApi(model);
|
|
551
546
|
return this._computeMethodEndpoint(webApi, selected);
|
|
552
547
|
}
|
|
@@ -8,15 +8,14 @@ import {
|
|
|
8
8
|
createTypeElement
|
|
9
9
|
} from "./utils";
|
|
10
10
|
import type { TopicModel } from "./types";
|
|
11
|
-
import { Json } from "typings/custom";
|
|
12
11
|
|
|
13
12
|
export default class AmfTopic extends LightningElement {
|
|
14
|
-
private _model
|
|
15
|
-
private amf
|
|
16
|
-
private type
|
|
13
|
+
private _model;
|
|
14
|
+
private amf;
|
|
15
|
+
private type;
|
|
17
16
|
|
|
18
17
|
@api
|
|
19
|
-
get model(): TopicModel
|
|
18
|
+
get model(): TopicModel {
|
|
20
19
|
return this._model;
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -42,11 +41,7 @@ export default class AmfTopic extends LightningElement {
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
update(): void {
|
|
45
|
-
|
|
46
|
-
throw new Error("Amf TopicModel undefined when trying to update");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const container = this.template.querySelector("div.topic-container")!;
|
|
44
|
+
const container = this.template.querySelector("div.topic-container");
|
|
50
45
|
const { id } = this.model;
|
|
51
46
|
const type = this.type;
|
|
52
47
|
const amf = this.amf;
|
|
@@ -84,7 +79,7 @@ export default class AmfTopic extends LightningElement {
|
|
|
84
79
|
if (container.firstChild) {
|
|
85
80
|
container.firstChild.remove();
|
|
86
81
|
}
|
|
87
|
-
container.appendChild(element
|
|
82
|
+
container.appendChild(element);
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
|
|
@@ -94,6 +89,6 @@ export default class AmfTopic extends LightningElement {
|
|
|
94
89
|
* @param value JSON Serializable object to clone.
|
|
95
90
|
* @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
|
|
96
91
|
*/
|
|
97
|
-
function clone(value
|
|
92
|
+
function clone(value): object {
|
|
98
93
|
return JSON.parse(JSON.stringify(value));
|
|
99
94
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { Json } from "typings/custom";
|
|
2
|
-
import { AmfModelParser } from "docUtils/amf";
|
|
3
|
-
import {
|
|
4
|
-
DomainElement,
|
|
5
|
-
EndPoint,
|
|
6
|
-
Operation,
|
|
7
|
-
Shape
|
|
8
|
-
} from "@api-components/amf-helper-mixin";
|
|
9
2
|
|
|
10
3
|
export type ApiSummaryElement = HTMLElement & {
|
|
11
4
|
amf: Json;
|
|
@@ -18,39 +11,44 @@ export type ApiEndpointElement = HTMLElement & {
|
|
|
18
11
|
inlineMethods: boolean;
|
|
19
12
|
noNavigation: boolean;
|
|
20
13
|
selected: string;
|
|
21
|
-
endpoint:
|
|
14
|
+
endpoint: Json;
|
|
22
15
|
noTryIt: boolean;
|
|
23
16
|
};
|
|
24
17
|
|
|
25
18
|
export type ApiMethodElement = HTMLElement & {
|
|
26
19
|
amf: Json;
|
|
27
20
|
noNavigation: boolean;
|
|
28
|
-
endpoint:
|
|
29
|
-
method:
|
|
21
|
+
endpoint: Json;
|
|
22
|
+
method: Json;
|
|
30
23
|
noTryIt: boolean;
|
|
31
24
|
};
|
|
32
25
|
|
|
33
26
|
export type ApiSecurityElement = HTMLElement & {
|
|
34
27
|
amf: Json;
|
|
35
|
-
security:
|
|
28
|
+
security: Json;
|
|
36
29
|
};
|
|
37
30
|
|
|
38
31
|
export type ApiTypeElement = HTMLElement & {
|
|
39
32
|
amf: Json;
|
|
40
|
-
type
|
|
33
|
+
type: Json;
|
|
41
34
|
mediaTypes: Json;
|
|
42
35
|
};
|
|
43
36
|
|
|
44
37
|
export type ApiDocElement = HTMLElement & {
|
|
45
38
|
amf: Json;
|
|
46
|
-
shape:
|
|
39
|
+
shape: Json;
|
|
47
40
|
};
|
|
48
41
|
|
|
49
42
|
export type AmfModel = Json;
|
|
50
43
|
|
|
44
|
+
export interface AmfParser {
|
|
45
|
+
parse(): void;
|
|
46
|
+
parsedModel: any;
|
|
47
|
+
}
|
|
48
|
+
|
|
51
49
|
export interface TopicModel {
|
|
52
50
|
id: string;
|
|
53
51
|
type: string;
|
|
54
52
|
amf: AmfModel;
|
|
55
|
-
parser:
|
|
53
|
+
parser: AmfParser;
|
|
56
54
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DomainElement,
|
|
3
|
-
EndPoint,
|
|
4
|
-
Operation,
|
|
5
|
-
Shape
|
|
6
|
-
} from "@api-components/amf-helper-mixin";
|
|
7
1
|
import type {
|
|
8
2
|
ApiDocElement,
|
|
9
3
|
ApiEndpointElement,
|
|
@@ -43,7 +37,7 @@ export function createSummaryElement(amf: Json): HTMLElement {
|
|
|
43
37
|
*/
|
|
44
38
|
export function createEndpointElement(
|
|
45
39
|
amf: Json,
|
|
46
|
-
endpointModel:
|
|
40
|
+
endpointModel: Json,
|
|
47
41
|
selected: string
|
|
48
42
|
): HTMLElement {
|
|
49
43
|
const el: ApiEndpointElement = document.createElement(
|
|
@@ -63,8 +57,8 @@ export function createEndpointElement(
|
|
|
63
57
|
*/
|
|
64
58
|
export function createMethodElement(
|
|
65
59
|
amf: Json,
|
|
66
|
-
endpointMethodModel:
|
|
67
|
-
methodModel:
|
|
60
|
+
endpointMethodModel: Json,
|
|
61
|
+
methodModel: Json
|
|
68
62
|
): HTMLElement {
|
|
69
63
|
const el: ApiMethodElement = document.createElement(
|
|
70
64
|
"api-method-documentation"
|
|
@@ -85,7 +79,7 @@ export function createMethodElement(
|
|
|
85
79
|
*/
|
|
86
80
|
export function createSecurityElement(
|
|
87
81
|
amf: Json,
|
|
88
|
-
securityModel:
|
|
82
|
+
securityModel: Json
|
|
89
83
|
): HTMLElement {
|
|
90
84
|
const el: ApiSecurityElement = document.createElement(
|
|
91
85
|
"api-security-documentation"
|
|
@@ -104,7 +98,7 @@ export function createSecurityElement(
|
|
|
104
98
|
*/
|
|
105
99
|
export function createTypeElement(
|
|
106
100
|
amf: Json,
|
|
107
|
-
typeModel:
|
|
101
|
+
typeModel: Json,
|
|
108
102
|
mediaTypes: Json
|
|
109
103
|
): HTMLElement {
|
|
110
104
|
const el: ApiTypeElement = document.createElement(
|
|
@@ -125,7 +119,7 @@ export function createTypeElement(
|
|
|
125
119
|
*/
|
|
126
120
|
export function createDocumentationElement(
|
|
127
121
|
amf: Json,
|
|
128
|
-
docsModel:
|
|
122
|
+
docsModel: Json
|
|
129
123
|
): HTMLElement {
|
|
130
124
|
const el: ApiDocElement = document.createElement(
|
|
131
125
|
"api-documentation-document"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-inner-html */
|
|
2
2
|
import { createElement, LightningElement, api, track } from "lwc";
|
|
3
3
|
import { DocContent, PageReference } from "typings/custom";
|
|
4
|
+
import ContentCallout from "doc/contentCallout";
|
|
4
5
|
import CodeBlock from "dx/codeBlock";
|
|
6
|
+
import ContentMedia from "doc/contentMedia";
|
|
5
7
|
import Button from "dx/button";
|
|
6
8
|
import { highlightTerms } from "dxUtils/highlight";
|
|
7
|
-
import ContentCallout from "doc/contentCallout";
|
|
8
|
-
import ContentMedia from "doc/contentMedia";
|
|
9
9
|
|
|
10
10
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
11
|
"p",
|
|
@@ -86,7 +86,7 @@ export default class Content extends LightningElement {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
renderPaginationButton(anchorEl: HTMLElement) {
|
|
89
|
-
const isNext = anchorEl.textContent
|
|
89
|
+
const isNext = anchorEl.textContent.includes("Next →");
|
|
90
90
|
anchorEl.innerHTML = "";
|
|
91
91
|
const buttonEl = createElement("dx-button", { is: Button });
|
|
92
92
|
const params = isNext
|
|
@@ -116,7 +116,7 @@ export default class Content extends LightningElement {
|
|
|
116
116
|
const codeBlockEls = divEl.querySelectorAll(".codeSection");
|
|
117
117
|
codeBlockEls.forEach((codeBlockEl) => {
|
|
118
118
|
codeBlockEl.setAttribute("lwc:dom", "manual");
|
|
119
|
-
const classList =
|
|
119
|
+
const classList = codeBlockEl.firstChild.classList;
|
|
120
120
|
let language = "";
|
|
121
121
|
for (const key in classList) {
|
|
122
122
|
if (typeof classList[key] === "string") {
|
|
@@ -160,7 +160,7 @@ export default class Content extends LightningElement {
|
|
|
160
160
|
|
|
161
161
|
let flag = 1;
|
|
162
162
|
for (let i: number = 0; i < detailEls.length; i++) {
|
|
163
|
-
flag &=
|
|
163
|
+
flag &= detailEls[i].innerHTML.trim() === "";
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
if (flag) {
|
|
@@ -170,7 +170,7 @@ export default class Content extends LightningElement {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
const type = calloutEl.querySelector("h4")
|
|
173
|
+
const type = calloutEl.querySelector("h4").textContent;
|
|
174
174
|
const typeLower = type.toLowerCase();
|
|
175
175
|
Object.assign(calloutCompEl, {
|
|
176
176
|
title: type,
|
|
@@ -184,10 +184,10 @@ export default class Content extends LightningElement {
|
|
|
184
184
|
// Modify links to work with any domain, links that start with "#" are excluded
|
|
185
185
|
const anchorEls = divEl.querySelectorAll("a:not([href^='#'])");
|
|
186
186
|
|
|
187
|
-
anchorEls.forEach((anchorEl
|
|
187
|
+
anchorEls.forEach((anchorEl) => {
|
|
188
188
|
if (
|
|
189
|
-
anchorEl.textContent
|
|
190
|
-
anchorEl.textContent
|
|
189
|
+
anchorEl.textContent.includes("Next →") ||
|
|
190
|
+
anchorEl.textContent.includes("← Previous")
|
|
191
191
|
) {
|
|
192
192
|
if (this.showPaginationButtons) {
|
|
193
193
|
this.renderPaginationButton(anchorEl);
|
|
@@ -326,7 +326,8 @@ export default class Content extends LightningElement {
|
|
|
326
326
|
|
|
327
327
|
handleNavClick(event: InputEvent) {
|
|
328
328
|
event.preventDefault();
|
|
329
|
-
|
|
329
|
+
// eslint-disable-next-line no-use-before-define
|
|
330
|
+
const target = event.currentTarget.dataset.id;
|
|
330
331
|
const [page, docId, deliverable, tempContentDocumentId] =
|
|
331
332
|
target.split("/");
|
|
332
333
|
const [contentDocumentId, hash] = tempContentDocumentId.split("#");
|
|
@@ -3,7 +3,7 @@ import { LightningElement, api, track } from "lwc";
|
|
|
3
3
|
import { closest } from "kagekiri";
|
|
4
4
|
import { toJson } from "dxUtils/normalizers";
|
|
5
5
|
import { highlightTerms } from "dxUtils/highlight";
|
|
6
|
-
import { SearchSyncer } from "docUtils/
|
|
6
|
+
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
7
7
|
|
|
8
8
|
type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
|
|
9
9
|
|
|
@@ -26,9 +26,9 @@ const HIGHLIGHTABLE_SELECTOR = [
|
|
|
26
26
|
export const OBSERVER_ATTACH_WAIT_TIME = 500;
|
|
27
27
|
|
|
28
28
|
export default class ContentLayout extends LightningElement {
|
|
29
|
-
@api sidebarValue
|
|
30
|
-
@api sidebarHeader
|
|
31
|
-
@api tocTitle
|
|
29
|
+
@api sidebarValue: string;
|
|
30
|
+
@api sidebarHeader: string;
|
|
31
|
+
@api tocTitle: string;
|
|
32
32
|
@api enableSlotChange = false;
|
|
33
33
|
@api coveoOrganizationId!: string;
|
|
34
34
|
@api coveoPublicAccessToken!: string;
|
|
@@ -41,7 +41,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
41
41
|
return this._breadcrumbs;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
set breadcrumbs(value) {
|
|
44
|
+
set breadcrumbs(value): [] {
|
|
45
45
|
if (value) {
|
|
46
46
|
this._breadcrumbs = toJson(value);
|
|
47
47
|
}
|
|
@@ -52,7 +52,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
52
52
|
return this._sidebarContent;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
set sidebarContent(value
|
|
55
|
+
set sidebarContent(value) {
|
|
56
56
|
this._sidebarContent = toJson(value);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -67,9 +67,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
67
67
|
|
|
68
68
|
@api
|
|
69
69
|
setSidebarInputValue(searchTerm: string): void {
|
|
70
|
-
|
|
71
|
-
searchTerm
|
|
72
|
-
);
|
|
70
|
+
this.template.querySelector("dx-sidebar")?.setInputValue(searchTerm);
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
@track
|
|
@@ -78,11 +76,11 @@ export default class ContentLayout extends LightningElement {
|
|
|
78
76
|
private _breadcrumbs = null;
|
|
79
77
|
|
|
80
78
|
@track
|
|
81
|
-
private _tocOptions
|
|
79
|
+
private _tocOptions: Array<unknown>;
|
|
82
80
|
|
|
83
81
|
private tocOptionIdsSet = new Set();
|
|
84
82
|
private anchoredElements: AnchorMap = {};
|
|
85
|
-
private lastScrollPosition
|
|
83
|
+
private lastScrollPosition: number;
|
|
86
84
|
private observer?: IntersectionObserver;
|
|
87
85
|
private hasRendered: boolean = false;
|
|
88
86
|
private contentLoaded: boolean = false;
|
|
@@ -107,8 +105,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
107
105
|
target: window
|
|
108
106
|
});
|
|
109
107
|
private tocValue?: string = undefined;
|
|
110
|
-
|
|
111
|
-
private observerTimerId?: NodeJS.Timeout;
|
|
108
|
+
private observerTimerId = null;
|
|
112
109
|
private didScrollToSelectedHash = false;
|
|
113
110
|
private _scrollInterval = 0;
|
|
114
111
|
|
|
@@ -206,9 +203,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
206
203
|
".sticky-doc-header"
|
|
207
204
|
) as HTMLElement;
|
|
208
205
|
|
|
209
|
-
const docPhaseEl =
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
const docPhaseEl = this.template
|
|
207
|
+
.querySelector("[name=doc-phase]")!
|
|
208
|
+
.assignedElements()[0] as HTMLSlotElement;
|
|
212
209
|
|
|
213
210
|
if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
|
|
214
211
|
console.warn("One or more required elements are missing.");
|
|
@@ -250,7 +247,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
250
247
|
document.querySelectorAll("doc-heading")
|
|
251
248
|
);
|
|
252
249
|
docHeadingEls.forEach((docHeadingEl) => {
|
|
253
|
-
|
|
250
|
+
docHeadingEl.style.scrollMarginTop = `${
|
|
254
251
|
globalNavHeight +
|
|
255
252
|
docHeaderHeight +
|
|
256
253
|
docPhaseEl.getBoundingClientRect().height
|
|
@@ -258,8 +255,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
258
255
|
});
|
|
259
256
|
|
|
260
257
|
// Adjust right nav bar position when doc phase is present
|
|
261
|
-
const rightNavBarEl =
|
|
262
|
-
|
|
258
|
+
const rightNavBarEl = this.template.querySelector(
|
|
259
|
+
".right-nav-bar"
|
|
260
|
+
);
|
|
263
261
|
|
|
264
262
|
if (rightNavBarEl) {
|
|
265
263
|
rightNavBarEl.style.top = `${
|
|
@@ -293,7 +291,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
293
291
|
entries.forEach(
|
|
294
292
|
(entry) =>
|
|
295
293
|
(this.anchoredElements[
|
|
296
|
-
entry.target.getAttribute("id")
|
|
294
|
+
entry.target.getAttribute("id")
|
|
297
295
|
].intersect = entry.isIntersecting)
|
|
298
296
|
);
|
|
299
297
|
this.calculateActualSection();
|
|
@@ -305,9 +303,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
305
303
|
|
|
306
304
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
307
305
|
const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
308
|
-
|
|
306
|
+
|
|
307
|
+
for (const headingElement of headingElements) {
|
|
309
308
|
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
310
|
-
const id = headingElement.getAttribute("id")
|
|
309
|
+
const id = headingElement.getAttribute("id");
|
|
311
310
|
this.anchoredElements[id] = {
|
|
312
311
|
id,
|
|
313
312
|
intersect: false
|
|
@@ -321,26 +320,23 @@ export default class ContentLayout extends LightningElement {
|
|
|
321
320
|
};
|
|
322
321
|
|
|
323
322
|
onSlotChange(event: Event): void {
|
|
324
|
-
const slotElements = (
|
|
325
|
-
event.target as HTMLSlotElement
|
|
326
|
-
).assignedElements();
|
|
323
|
+
const slotElements = (event.target as HTMLSlotElement).assignedElements();
|
|
327
324
|
|
|
328
325
|
if (slotElements.length) {
|
|
329
326
|
this.contentLoaded = true;
|
|
330
327
|
const slotContentElement = slotElements[0];
|
|
331
|
-
const headingElements =
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
);
|
|
328
|
+
const headingElements = slotContentElement.ownerDocument?.getElementsByTagName(
|
|
329
|
+
TOC_HEADER_TAG
|
|
330
|
+
);
|
|
335
331
|
|
|
336
|
-
for (const headingElement of headingElements
|
|
332
|
+
for (const headingElement of headingElements) {
|
|
337
333
|
// Sometimes elements hash is not being set when slot content is wrapped with div
|
|
338
334
|
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
339
335
|
}
|
|
340
336
|
|
|
341
337
|
const tocOptions = [];
|
|
342
338
|
|
|
343
|
-
for (const headingElement of headingElements
|
|
339
|
+
for (const headingElement of headingElements) {
|
|
344
340
|
headingElement.id = headingElement.hash;
|
|
345
341
|
|
|
346
342
|
// Update tocOptions from anchorTags only for H2, consider default as 2 as per component
|
|
@@ -366,7 +362,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
366
362
|
private disconnectObserver(): void {
|
|
367
363
|
if (this.observer) {
|
|
368
364
|
this.observer.disconnect();
|
|
369
|
-
this.observer =
|
|
365
|
+
this.observer = null;
|
|
370
366
|
}
|
|
371
367
|
}
|
|
372
368
|
|
|
@@ -391,15 +387,15 @@ export default class ContentLayout extends LightningElement {
|
|
|
391
387
|
globalNavEl.offsetHeight +
|
|
392
388
|
contextNavEl.offsetHeight;
|
|
393
389
|
|
|
394
|
-
const docPhaseEl =
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
const docPhaseEl = this.template
|
|
391
|
+
.querySelector("[name=doc-phase]")!
|
|
392
|
+
.assignedElements()[0] as HTMLSlotElement;
|
|
397
393
|
|
|
398
394
|
const offset = docPhaseEl
|
|
399
395
|
? headerHeight + docPhaseEl.offsetHeight
|
|
400
396
|
: headerHeight;
|
|
401
397
|
|
|
402
|
-
for (const headingElement of headingElements
|
|
398
|
+
for (const headingElement of headingElements) {
|
|
403
399
|
if (headingElement.getAttribute("id") === hash) {
|
|
404
400
|
this.scrollIntoViewWithOffset(headingElement, offset);
|
|
405
401
|
break;
|
|
@@ -436,14 +432,14 @@ export default class ContentLayout extends LightningElement {
|
|
|
436
432
|
this.lastScrollPosition = currentScrollPosition;
|
|
437
433
|
}
|
|
438
434
|
|
|
439
|
-
private calculatePreviousElementId(): string
|
|
435
|
+
private calculatePreviousElementId(): string {
|
|
440
436
|
const keys = Object.keys(this.anchoredElements);
|
|
441
437
|
const currentIndex = keys.findIndex((id) => this.tocValue === id);
|
|
442
438
|
|
|
443
439
|
return currentIndex > 0 ? keys[currentIndex - 1] : undefined;
|
|
444
440
|
}
|
|
445
441
|
|
|
446
|
-
private assignElementId(id: string
|
|
442
|
+
private assignElementId(id: string): void {
|
|
447
443
|
// Change toc(RNB) highlight only for H2
|
|
448
444
|
if (this.tocOptionIdsSet.has(id)) {
|
|
449
445
|
this.tocValue = id;
|
|
@@ -11,14 +11,12 @@ export const ariaLevels = Object.keys(ariaDisplayLevels);
|
|
|
11
11
|
|
|
12
12
|
export const displayLevels = Object.values(ariaDisplayLevels);
|
|
13
13
|
|
|
14
|
-
// @ts-ignore: Really Dark Magic (TM) to do with ariaLevel needing explicit getter/setters
|
|
15
14
|
export default class Heading extends LightningElement {
|
|
16
15
|
@api title: string = "";
|
|
17
16
|
@api hash: string | null = null;
|
|
18
17
|
|
|
19
18
|
@api
|
|
20
19
|
private get ariaLevel(): string {
|
|
21
|
-
// Really Dark Magic (TM)
|
|
22
20
|
return this._ariaLevel || "2";
|
|
23
21
|
}
|
|
24
22
|
private set ariaLevel(value: string | null) {
|
|
@@ -11,7 +11,7 @@ export default class Toc extends LightningElement {
|
|
|
11
11
|
const newPageReference = { ...this.pageReference };
|
|
12
12
|
// When moving to the new navigation component
|
|
13
13
|
//const target = event.detail.name.split('-')
|
|
14
|
-
const target =
|
|
14
|
+
const target = event.currentTarget.dataset.id.split("-");
|
|
15
15
|
newPageReference.contentDocumentId = target[0] + ".htm";
|
|
16
16
|
newPageReference.hash = target[1];
|
|
17
17
|
this.dispatchEvent(
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
PageReference,
|
|
13
13
|
TocMap
|
|
14
14
|
} from "./types";
|
|
15
|
+
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
15
16
|
import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
|
|
16
17
|
import { oldVersionDocInfo } from "docUtils/utils";
|
|
17
18
|
import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
|
|
18
19
|
import { track as trackGTM } from "dxUtils/analytics";
|
|
19
20
|
import { CoveoAnalyticsClient } from "coveo.analytics";
|
|
20
|
-
import { SearchSyncer } from "docUtils/searchSyncer";
|
|
21
21
|
|
|
22
22
|
// TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
|
|
23
|
-
const handleContentError = (error
|
|
23
|
+
const handleContentError = (error): void => console.log(error);
|
|
24
24
|
|
|
25
25
|
const PIXEL_PER_CHARACTER_MAP: { [key: string]: number } = {
|
|
26
26
|
default: 7.7,
|
|
@@ -31,7 +31,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
31
31
|
isFetchingDocument: boolean;
|
|
32
32
|
isFetchingContent: boolean;
|
|
33
33
|
lastHighlightedSearch: string;
|
|
34
|
-
internalLinkClicked: boolean;
|
|
35
34
|
}> {
|
|
36
35
|
@api apiDomain = "https://developer.salesforce.com";
|
|
37
36
|
@api coveoOrganizationId!: string;
|
|
@@ -61,14 +60,14 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
61
60
|
|
|
62
61
|
private availableLanguages: Array<DocLanguage> = [];
|
|
63
62
|
private availableVersions: Array<DocVersion> = [];
|
|
64
|
-
private contentProvider
|
|
63
|
+
private contentProvider: FetchContent;
|
|
65
64
|
private docContent = "";
|
|
66
|
-
private language
|
|
65
|
+
private language: DocLanguage = null;
|
|
67
66
|
private loaded = false;
|
|
68
67
|
private pdfUrl = "";
|
|
69
68
|
private tocMap: TocMap = {};
|
|
70
|
-
private sidebarContent: Array<TreeNode>
|
|
71
|
-
private version: DocVersion
|
|
69
|
+
private sidebarContent: Array<TreeNode> = null;
|
|
70
|
+
private version: DocVersion = null;
|
|
72
71
|
private docTitle = "";
|
|
73
72
|
private _pathName = "";
|
|
74
73
|
private _pageHeader?: Header;
|
|
@@ -175,8 +174,8 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
175
174
|
renderedCallback(): void {
|
|
176
175
|
this.setState({ internalLinkClicked: true });
|
|
177
176
|
const urlSectionLink =
|
|
178
|
-
this.pageReference?.hash?.split("#").length
|
|
179
|
-
? this.pageReference.hash
|
|
177
|
+
this.pageReference?.hash?.split("#").length > 1
|
|
178
|
+
? this.pageReference.hash.split("#")[1]
|
|
180
179
|
: this.pageReference?.hash;
|
|
181
180
|
|
|
182
181
|
const contentEl = this.template.querySelector("doc-content");
|
|
@@ -224,15 +223,15 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
224
223
|
}
|
|
225
224
|
}
|
|
226
225
|
|
|
227
|
-
private get languageId(): string
|
|
228
|
-
return this.language
|
|
226
|
+
private get languageId(): string {
|
|
227
|
+
return this.language.id.replace("-", "_");
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
private get releaseVersionId(): string
|
|
232
|
-
return this.version
|
|
230
|
+
private get releaseVersionId(): string {
|
|
231
|
+
return this.version.id;
|
|
233
232
|
}
|
|
234
233
|
|
|
235
|
-
private get deliverable(): string
|
|
234
|
+
private get deliverable(): string {
|
|
236
235
|
return this.pageReference.deliverable;
|
|
237
236
|
}
|
|
238
237
|
|
|
@@ -253,11 +252,10 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
253
252
|
}
|
|
254
253
|
|
|
255
254
|
private get coveoAdvancedQueryConfig(): CoveoAdvancedQueryXMLConfig {
|
|
256
|
-
const config: { locale
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
};
|
|
255
|
+
const config: { locale: string; topicid: string; version?: string } = {
|
|
256
|
+
locale: this.languageId,
|
|
257
|
+
topicid: this.deliverable
|
|
258
|
+
};
|
|
261
259
|
|
|
262
260
|
if (this.releaseVersionId && this.releaseVersionId !== "noversion") {
|
|
263
261
|
config.version = this.releaseVersionId;
|
|
@@ -268,7 +266,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
268
266
|
|
|
269
267
|
private get pageHeader(): Header {
|
|
270
268
|
if (!this._pageHeader) {
|
|
271
|
-
this._pageHeader = document.querySelector("doc-header")
|
|
269
|
+
this._pageHeader = document.querySelector("doc-header");
|
|
272
270
|
}
|
|
273
271
|
|
|
274
272
|
return this._pageHeader;
|
|
@@ -311,7 +309,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
311
309
|
|
|
312
310
|
private get breadcrumbPixelPerCharacter() {
|
|
313
311
|
return (
|
|
314
|
-
PIXEL_PER_CHARACTER_MAP[this.language
|
|
312
|
+
PIXEL_PER_CHARACTER_MAP[this.language.id] ||
|
|
315
313
|
PIXEL_PER_CHARACTER_MAP.default
|
|
316
314
|
);
|
|
317
315
|
}
|
|
@@ -360,7 +358,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
360
358
|
this.updateUrl();
|
|
361
359
|
}
|
|
362
360
|
|
|
363
|
-
handleLanguageChange = (event:
|
|
361
|
+
handleLanguageChange = (event: CustomEvent<string>): Promise<void> => {
|
|
364
362
|
if (this.language && this.language.id === event.detail) {
|
|
365
363
|
return;
|
|
366
364
|
}
|
|
@@ -368,7 +366,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
368
366
|
this.language = this.availableLanguages.find(
|
|
369
367
|
({ id }) => id === event.detail
|
|
370
368
|
);
|
|
371
|
-
this.pageReference.docId = this.language
|
|
369
|
+
this.pageReference.docId = this.language.url;
|
|
372
370
|
|
|
373
371
|
trackGTM(event.target!, "custEv_ctaLinkClick", {
|
|
374
372
|
click_text: event.detail,
|
|
@@ -455,8 +453,8 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
455
453
|
this.setState({
|
|
456
454
|
isFetchingDocument: true
|
|
457
455
|
});
|
|
458
|
-
const data = await this.contentProvider
|
|
459
|
-
this.pageReference.docId
|
|
456
|
+
const data = await this.contentProvider.fetchDocumentData(
|
|
457
|
+
this.pageReference.docId
|
|
460
458
|
);
|
|
461
459
|
|
|
462
460
|
// This could be a 404 scenario.
|
|
@@ -519,12 +517,12 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
519
517
|
this.setState({
|
|
520
518
|
isFetchingContent: true
|
|
521
519
|
});
|
|
522
|
-
const data = await this.contentProvider
|
|
523
|
-
this.pageReference.deliverable
|
|
524
|
-
this.pageReference.contentDocumentId
|
|
520
|
+
const data = await this.contentProvider.fetchContent(
|
|
521
|
+
this.pageReference.deliverable,
|
|
522
|
+
this.pageReference.contentDocumentId,
|
|
525
523
|
{
|
|
526
|
-
language: this.language
|
|
527
|
-
version: this.version
|
|
524
|
+
language: this.language.id,
|
|
525
|
+
version: this.version.id
|
|
528
526
|
}
|
|
529
527
|
);
|
|
530
528
|
|
|
@@ -588,26 +586,23 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
588
586
|
}
|
|
589
587
|
|
|
590
588
|
private updateSearchInput(searchParam: string): void {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
589
|
+
this.template
|
|
590
|
+
.querySelector("doc-content-layout")
|
|
591
|
+
?.setSidebarInputValue(searchParam);
|
|
594
592
|
}
|
|
595
593
|
|
|
596
594
|
private pageReferenceToString(reference: PageReference): string {
|
|
597
595
|
const { page, docId, deliverable, contentDocumentId, hash, search } =
|
|
598
596
|
reference;
|
|
599
597
|
return `/${page}/${docId}/${deliverable}/${contentDocumentId}${this.normalizeSearch(
|
|
600
|
-
search
|
|
598
|
+
search
|
|
601
599
|
)}${this.normalizeHash(hash)}`;
|
|
602
600
|
}
|
|
603
601
|
|
|
604
|
-
private normalizeUrlPart(
|
|
605
|
-
part: string | undefined,
|
|
606
|
-
sentinel: string
|
|
607
|
-
): string {
|
|
602
|
+
private normalizeUrlPart(part: string, sentinel: string): string {
|
|
608
603
|
return (
|
|
609
604
|
(part &&
|
|
610
|
-
(part.startsWith(sentinel
|
|
605
|
+
(part.startsWith(sentinel) ? part : `${sentinel}${part}`)) ||
|
|
611
606
|
""
|
|
612
607
|
);
|
|
613
608
|
}
|
|
@@ -616,16 +611,16 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
616
611
|
return this.normalizeUrlPart(search, "?");
|
|
617
612
|
}
|
|
618
613
|
|
|
619
|
-
private normalizeHash(hash
|
|
614
|
+
private normalizeHash(hash: string): string {
|
|
620
615
|
return this.normalizeUrlPart(hash, "#");
|
|
621
616
|
}
|
|
622
617
|
|
|
623
618
|
private getComposedTitle(
|
|
624
|
-
topicTitle: string |
|
|
619
|
+
topicTitle: string | undefined,
|
|
625
620
|
docTitle: string | undefined
|
|
626
621
|
): string {
|
|
627
622
|
// map to avoid duplicates
|
|
628
|
-
const titleMap
|
|
623
|
+
const titleMap = {};
|
|
629
624
|
if (topicTitle) {
|
|
630
625
|
// sometimes the h1 tag text (which is docSubTitle) contains text with new line character. For e.g, "Bulk API 2.0 Older\n Documentation",
|
|
631
626
|
// here it contains \n in the text context which needs to be removed
|
|
@@ -762,7 +757,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
762
757
|
const headTag = document.getElementsByTagName("head");
|
|
763
758
|
// this checks if the selected version is not the latest version,
|
|
764
759
|
// then it adds the noindex, follow meta tag to the older version pages.
|
|
765
|
-
const versionId = this.version
|
|
760
|
+
const versionId = this.version.id;
|
|
766
761
|
const docId = this.pageReference.docId;
|
|
767
762
|
|
|
768
763
|
// SEO fix:
|
|
@@ -4,12 +4,12 @@ export interface SearchSyncerConstructorArgs {
|
|
|
4
4
|
onUrlChange?: (nextSearchString: string) => unknown;
|
|
5
5
|
};
|
|
6
6
|
eventName: string;
|
|
7
|
-
historyMethod
|
|
7
|
+
historyMethod?:
|
|
8
8
|
| typeof window.history.pushState
|
|
9
9
|
| typeof window.history.replaceState;
|
|
10
10
|
searchParam: string;
|
|
11
11
|
shouldStopPropagation?: boolean;
|
|
12
|
-
target: EventTarget
|
|
12
|
+
target: EventTarget;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class SearchSyncer {
|
|
@@ -37,16 +37,16 @@ export class SearchSyncer {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
public init = (): void => {
|
|
40
|
-
this.target
|
|
41
|
-
this.target
|
|
40
|
+
this.target.addEventListener(this.eventName, this.handleSearchChange);
|
|
41
|
+
this.target.addEventListener("popstate", this.handlePopState);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
public dispose = (): void => {
|
|
45
|
-
this.target
|
|
45
|
+
this.target.removeEventListener(
|
|
46
46
|
this.eventName,
|
|
47
47
|
this.handleSearchChange
|
|
48
48
|
);
|
|
49
|
-
this.target
|
|
49
|
+
this.target.removeEventListener("popstate", this.handlePopState);
|
|
50
50
|
this.target = undefined;
|
|
51
51
|
this.callbacks.onSearchChange = undefined;
|
|
52
52
|
this.callbacks.onUrlChange = undefined;
|