@salesforcedevs/docs-components 0.53.6 → 0.54.0-alpha03
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 +6 -2
- package/package.json +16 -2
- package/src/modules/doc/amfReference/amfReference.css +5 -0
- package/src/modules/doc/amfReference/amfReference.html +39 -0
- package/src/modules/doc/amfReference/amfReference.ts +874 -0
- package/src/modules/doc/amfReference/route-meta.ts +22 -0
- package/src/modules/doc/amfReference/types.ts +88 -0
- package/src/modules/doc/amfReference/utils.ts +669 -0
- package/src/modules/doc/amfTopic/amfTopic.css +1 -0
- package/src/modules/doc/amfTopic/amfTopic.html +3 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +94 -0
- package/src/modules/doc/amfTopic/types.ts +54 -0
- package/src/modules/doc/amfTopic/utils.ts +117 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +2 -2
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +2 -2
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +1 -1
- package/src/modules/doc/content/content.css +4 -4
- package/src/modules/doc/content/content.ts +1 -1
- package/src/modules/doc/contentCallout/contentCallout.css +3 -3
- package/src/modules/doc/contentLayout/contentLayout.css +100 -0
- package/src/modules/doc/contentLayout/contentLayout.html +55 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +242 -0
- package/src/modules/doc/header/header.css +1 -1
- package/src/modules/doc/header/header.ts +2 -2
- package/src/modules/doc/headingAnchor/headingAnchor.css +1 -1
- package/src/modules/doc/headingContent/headingContent.css +1 -1
- package/src/modules/doc/phase/phase.css +3 -3
- package/src/modules/doc/phase/phase.ts +1 -1
- package/src/modules/doc/xmlContent/types.ts +119 -0
- package/src/modules/doc/xmlContent/utils.ts +163 -0
- package/src/modules/doc/xmlContent/xmlContent.css +25 -0
- package/src/modules/doc/xmlContent/xmlContent.html +34 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +553 -0
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +390 -0
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +37 -0
- package/src/modules/{helpers → docHelpers}/status/status.css +0 -0
- package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +80 -0
- package/LICENSE +0 -12
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { LightningElement, api, track } from "lwc";
|
|
2
|
+
import { closest } from "kagekiri";
|
|
3
|
+
import { toJson } from "dxUtils/normalizers";
|
|
4
|
+
import { highlightTerms } from "dxUtils/highlight";
|
|
5
|
+
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
6
|
+
|
|
7
|
+
type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
|
|
8
|
+
|
|
9
|
+
const TOC_HEADER_TAG = "DOC-HEADING";
|
|
10
|
+
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
|
+
"p",
|
|
12
|
+
"h1",
|
|
13
|
+
"h2",
|
|
14
|
+
"h3",
|
|
15
|
+
"h4",
|
|
16
|
+
"h5",
|
|
17
|
+
"h6",
|
|
18
|
+
"li",
|
|
19
|
+
"dl",
|
|
20
|
+
"th",
|
|
21
|
+
"td"
|
|
22
|
+
].join(",");
|
|
23
|
+
|
|
24
|
+
export default class ContentLayout extends LightningElement {
|
|
25
|
+
@api sidebarValue: string;
|
|
26
|
+
@api sidebarHeader: string;
|
|
27
|
+
@api tocTitle: string;
|
|
28
|
+
@api enableSlotChange = false;
|
|
29
|
+
@api coveoOrganizationId!: string;
|
|
30
|
+
@api coveoPublicAccessToken!: string;
|
|
31
|
+
@api coveoSearchHub!: string;
|
|
32
|
+
@api coveoAdvancedQueryConfig!: string;
|
|
33
|
+
@api useOldSidebar?: boolean = false;
|
|
34
|
+
|
|
35
|
+
@api
|
|
36
|
+
get breadcrumbs() {
|
|
37
|
+
return this._breadcrumbs;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
set breadcrumbs(value) {
|
|
41
|
+
if (value) {
|
|
42
|
+
this._breadcrumbs = toJson(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@api
|
|
47
|
+
get sidebarContent() {
|
|
48
|
+
return this._sidebarContent;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
set sidebarContent(value) {
|
|
52
|
+
this._sidebarContent = toJson(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@api
|
|
56
|
+
get tocOptions() {
|
|
57
|
+
return this._tocOptions;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
set tocOptions(value) {
|
|
61
|
+
this._tocOptions = toJson(value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@api
|
|
65
|
+
setSidebarInputValue(searchTerm: string): void {
|
|
66
|
+
this.template.querySelector("dx-sidebar")?.setInputValue(searchTerm);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@track
|
|
70
|
+
private _sidebarContent: unknown;
|
|
71
|
+
|
|
72
|
+
private _breadcrumbs = null;
|
|
73
|
+
|
|
74
|
+
@track
|
|
75
|
+
private _tocOptions: Array<unknown>;
|
|
76
|
+
|
|
77
|
+
private anchoredElements: AnchorMap = {};
|
|
78
|
+
private lastScrollPosition: number;
|
|
79
|
+
private observer?: IntersectionObserver;
|
|
80
|
+
private searchSyncer = new SearchSyncer({
|
|
81
|
+
callbacks: {
|
|
82
|
+
onUrlChange: (nextSearchString: string): void => {
|
|
83
|
+
this.updateHighlightsAndSearch(nextSearchString);
|
|
84
|
+
},
|
|
85
|
+
onSearchChange: (nextSearchString: string): void => {
|
|
86
|
+
this.dispatchHighlightChange(
|
|
87
|
+
new URLSearchParams(nextSearchString).get("q") || ""
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
eventName: "sidebarsearchchange",
|
|
92
|
+
historyMethod: window.history.pushState,
|
|
93
|
+
searchParam: "q",
|
|
94
|
+
shouldStopPropagation: true,
|
|
95
|
+
target: window
|
|
96
|
+
});
|
|
97
|
+
private tocValue?: string = undefined;
|
|
98
|
+
|
|
99
|
+
get showToc(): boolean {
|
|
100
|
+
return this.tocOptions && this.tocOptions.length > 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ? This could be a good default for pathname in dx-breadcrumbs. Using this getter for now as a workaround.
|
|
104
|
+
get pathname(): string {
|
|
105
|
+
return window.location.pathname;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
connectedCallback(): void {
|
|
109
|
+
const hasParentHighlightListener = closest(
|
|
110
|
+
"doc-xml-content",
|
|
111
|
+
this.template.host
|
|
112
|
+
);
|
|
113
|
+
if (!hasParentHighlightListener) {
|
|
114
|
+
window.addEventListener(
|
|
115
|
+
"highlightedtermchange",
|
|
116
|
+
this.updateHighlighted
|
|
117
|
+
);
|
|
118
|
+
this.searchSyncer.init();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
disconnectedCallback(): void {
|
|
123
|
+
this.disconnectObserver();
|
|
124
|
+
window.removeEventListener(
|
|
125
|
+
"highlightedtermchange",
|
|
126
|
+
this.updateHighlighted
|
|
127
|
+
);
|
|
128
|
+
this.searchSyncer.dispose();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
updateHighlighted = (event: Event): void =>
|
|
132
|
+
highlightTerms(
|
|
133
|
+
this.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
134
|
+
(event as CustomEvent<string>).detail
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
onSlotChange(event: Event): void {
|
|
138
|
+
if (!this.enableSlotChange) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.disconnectObserver();
|
|
143
|
+
this.observer = new IntersectionObserver((entries) => {
|
|
144
|
+
entries.forEach(
|
|
145
|
+
(entry) =>
|
|
146
|
+
(this.anchoredElements[
|
|
147
|
+
entry.target.getAttribute("id")
|
|
148
|
+
].intersect = entry.isIntersecting)
|
|
149
|
+
);
|
|
150
|
+
this.calculateActualSection();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const anchoredTags = (event.target as HTMLSlotElement)
|
|
154
|
+
.assignedElements()
|
|
155
|
+
.filter(({ tagName }) => tagName === TOC_HEADER_TAG)
|
|
156
|
+
.map((tag) => {
|
|
157
|
+
tag.id = tag.hash;
|
|
158
|
+
return tag;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
this._tocOptions = anchoredTags.map((tag) => ({
|
|
162
|
+
anchor: `#${tag.hash}`,
|
|
163
|
+
id: tag.id,
|
|
164
|
+
label: tag.title
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
this.scrollToHash(anchoredTags);
|
|
168
|
+
|
|
169
|
+
anchoredTags.forEach((section) => {
|
|
170
|
+
const id = section.getAttribute("id");
|
|
171
|
+
this.anchoredElements[id] = {
|
|
172
|
+
id,
|
|
173
|
+
intersect: false
|
|
174
|
+
};
|
|
175
|
+
this.observer.observe(section);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private disconnectObserver(): void {
|
|
180
|
+
if (this.observer) {
|
|
181
|
+
this.observer.disconnect();
|
|
182
|
+
this.observer = null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private scrollToHash(anchoredTags: Array<Element>): void {
|
|
187
|
+
let { hash } = window.location;
|
|
188
|
+
|
|
189
|
+
if (hash) {
|
|
190
|
+
hash = hash.substr(1);
|
|
191
|
+
const toScrollElement = anchoredTags.find(
|
|
192
|
+
(element) => element.getAttribute("id") === hash
|
|
193
|
+
);
|
|
194
|
+
if (toScrollElement) {
|
|
195
|
+
toScrollElement.scrollIntoView({ behavior: "auto" });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private calculateActualSection(): void {
|
|
201
|
+
const currentScrollPosition = document.documentElement.scrollTop;
|
|
202
|
+
const id = Object.keys(this.anchoredElements).find(
|
|
203
|
+
(_id) => this.anchoredElements[_id].intersect
|
|
204
|
+
);
|
|
205
|
+
if (id) {
|
|
206
|
+
this.assignElementId(id);
|
|
207
|
+
} else if (currentScrollPosition < this.lastScrollPosition) {
|
|
208
|
+
// The user has scroll up since last update
|
|
209
|
+
this.assignElementId(this.calculatePreviousElementId());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this.lastScrollPosition = currentScrollPosition;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private calculatePreviousElementId(): string {
|
|
216
|
+
const keys = Object.keys(this.anchoredElements);
|
|
217
|
+
const currentIndex = keys.findIndex((id) => this.tocValue === id);
|
|
218
|
+
|
|
219
|
+
return currentIndex > 0 ? keys[currentIndex - 1] : undefined;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private assignElementId(id: string): void {
|
|
223
|
+
this.tocValue = id;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private dispatchHighlightChange(term: string): void {
|
|
227
|
+
this.dispatchEvent(
|
|
228
|
+
new CustomEvent("highlightedtermchange", {
|
|
229
|
+
detail: term,
|
|
230
|
+
bubbles: true,
|
|
231
|
+
composed: true
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private updateHighlightsAndSearch(nextSearchString: string): void {
|
|
237
|
+
const nextSearchParam =
|
|
238
|
+
new URLSearchParams(nextSearchString).get("q") || "";
|
|
239
|
+
this.setSidebarInputValue(nextSearchParam);
|
|
240
|
+
this.dispatchHighlightChange(nextSearchParam);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import type { Option } from "typings/custom";
|
|
4
|
-
import { HeaderBase } from "
|
|
5
|
-
import { toJson } from "
|
|
4
|
+
import { HeaderBase } from "dxBaseElements/headerBase";
|
|
5
|
+
import { toJson } from "dxUtils/normalizers";
|
|
6
6
|
import get from "lodash.get";
|
|
7
7
|
|
|
8
8
|
const TABLET_MATCH = "980px";
|
|
@@ -2,7 +2,7 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
|
|
4
4
|
import { DocPhaseInfo } from "typings/custom";
|
|
5
|
-
import { toJson } from "
|
|
5
|
+
import { toJson } from "dxUtils/normalizers";
|
|
6
6
|
|
|
7
7
|
export default class Phase extends LightningElement {
|
|
8
8
|
_docPhaseInfo: DocPhaseInfo | null = null;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export type CoveoAdvancedQueryXMLConfig = {
|
|
2
|
+
objecttype?: string;
|
|
3
|
+
sflocale__c?: string;
|
|
4
|
+
sfrelease__c?: string;
|
|
5
|
+
sfdelivarable__c?: string;
|
|
6
|
+
source?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type PageReference = {
|
|
10
|
+
domain?: string;
|
|
11
|
+
page?: string;
|
|
12
|
+
docId?: string;
|
|
13
|
+
deliverable?: string;
|
|
14
|
+
contentDocumentId?: string;
|
|
15
|
+
hash?: string;
|
|
16
|
+
search?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export enum HistoryState {
|
|
20
|
+
PUSH_STATE = "pushState",
|
|
21
|
+
REPLACE_STATE = "replaceState"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type Labels = {
|
|
25
|
+
language_english: string;
|
|
26
|
+
language_japanese: string;
|
|
27
|
+
toc_title: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type TreeNode = {
|
|
31
|
+
label: string;
|
|
32
|
+
name: string;
|
|
33
|
+
children?: Array<TreeNode>;
|
|
34
|
+
isExpanded?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type DropdownOption = {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type DocVersion = DropdownOption & {
|
|
43
|
+
releaseVersion: string;
|
|
44
|
+
url: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type DocLanguage = DropdownOption & {
|
|
48
|
+
code: string;
|
|
49
|
+
url: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type ApiDocVersion = {
|
|
53
|
+
version_text: string;
|
|
54
|
+
release_version: string;
|
|
55
|
+
doc_version: string;
|
|
56
|
+
version_url: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type ApiDocLanguage = {
|
|
60
|
+
code: string;
|
|
61
|
+
label: string;
|
|
62
|
+
locale: string;
|
|
63
|
+
url: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export interface Header extends Element {
|
|
67
|
+
subtitle: string;
|
|
68
|
+
bailHref: string;
|
|
69
|
+
bailLabel: string;
|
|
70
|
+
languages: Array<DocLanguage>;
|
|
71
|
+
language: string;
|
|
72
|
+
headerHref: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type ApiNavItem = {
|
|
76
|
+
children: Array<ApiNavItem>;
|
|
77
|
+
text: string;
|
|
78
|
+
a_attr: {
|
|
79
|
+
href: string;
|
|
80
|
+
};
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type ApiDocData = {
|
|
85
|
+
available_languages: Array<ApiDocLanguage>;
|
|
86
|
+
available_versions: Array<ApiDocVersion>;
|
|
87
|
+
content: string;
|
|
88
|
+
content_document_id: string;
|
|
89
|
+
deliverable: string;
|
|
90
|
+
doc_title: string;
|
|
91
|
+
language: ApiDocLanguage;
|
|
92
|
+
title: string;
|
|
93
|
+
toc: Array<ApiNavItem>;
|
|
94
|
+
version: ApiDocVersion;
|
|
95
|
+
pdf_url: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type ContentData = {
|
|
99
|
+
content: string;
|
|
100
|
+
id: string;
|
|
101
|
+
title: string;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type DocumentData = ContentData & {
|
|
105
|
+
availableLanguages: Array<DocLanguage>;
|
|
106
|
+
availableVersions: Array<DocVersion>;
|
|
107
|
+
deliverable: string;
|
|
108
|
+
docTitle: string;
|
|
109
|
+
language: DocLanguage;
|
|
110
|
+
toc: Array<TreeNode>;
|
|
111
|
+
tocMap: { [key: string]: TreeNode };
|
|
112
|
+
version: DocVersion;
|
|
113
|
+
pdfUrl: string;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type ContentApiOptions = {
|
|
117
|
+
version: string;
|
|
118
|
+
language: string;
|
|
119
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ApiDocData,
|
|
3
|
+
ApiDocLanguage,
|
|
4
|
+
ApiDocVersion,
|
|
5
|
+
ApiNavItem,
|
|
6
|
+
ContentApiOptions,
|
|
7
|
+
ContentData,
|
|
8
|
+
DocumentData,
|
|
9
|
+
DocLanguage,
|
|
10
|
+
DocVersion,
|
|
11
|
+
Labels,
|
|
12
|
+
TreeNode
|
|
13
|
+
} from "./types";
|
|
14
|
+
|
|
15
|
+
const LOCALE_TO_LABEL = {
|
|
16
|
+
"en-us": "language_english",
|
|
17
|
+
"ja-jp": "language_japanese"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export class FetchContent {
|
|
21
|
+
private apiDomain: string;
|
|
22
|
+
private labels: Labels;
|
|
23
|
+
|
|
24
|
+
constructor(apiDomain: string, labels: Labels) {
|
|
25
|
+
this.apiDomain = apiDomain;
|
|
26
|
+
this.labels = labels;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async fetchDocumentData(docId: string): Promise<DocumentData | null> {
|
|
30
|
+
try {
|
|
31
|
+
const {
|
|
32
|
+
available_languages,
|
|
33
|
+
available_versions,
|
|
34
|
+
toc,
|
|
35
|
+
content,
|
|
36
|
+
version,
|
|
37
|
+
language,
|
|
38
|
+
content_document_id,
|
|
39
|
+
title,
|
|
40
|
+
doc_title,
|
|
41
|
+
pdf_url,
|
|
42
|
+
deliverable
|
|
43
|
+
} = await this.fetchResource<ApiDocData>(
|
|
44
|
+
`${this.apiDomain}/docs/get_document/${docId}`
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const { normalizedToc, tocMap } = this.normalizeToc(toc);
|
|
48
|
+
return {
|
|
49
|
+
availableLanguages:
|
|
50
|
+
available_languages &&
|
|
51
|
+
available_languages.map(this.normalizeLanguage.bind(this)),
|
|
52
|
+
availableVersions:
|
|
53
|
+
available_versions &&
|
|
54
|
+
available_versions.map(this.normalizeVersion.bind(this)),
|
|
55
|
+
content,
|
|
56
|
+
version: this.normalizeVersion(version),
|
|
57
|
+
id: content_document_id,
|
|
58
|
+
language: this.normalizeLanguage(language),
|
|
59
|
+
title,
|
|
60
|
+
toc: normalizedToc,
|
|
61
|
+
tocMap,
|
|
62
|
+
docTitle: doc_title,
|
|
63
|
+
pdfUrl: pdf_url,
|
|
64
|
+
deliverable
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.log(error);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fetchContent(
|
|
73
|
+
deliverable: string,
|
|
74
|
+
contentId: string,
|
|
75
|
+
options: ContentApiOptions
|
|
76
|
+
): Promise<ContentData> {
|
|
77
|
+
return this.fetchResource<ContentData>(
|
|
78
|
+
`${this.apiDomain}/docs/get_document_content/${deliverable}/${contentId}/${options.language}/${options.version}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private async fetchResource<T>(url: string): Promise<T> {
|
|
83
|
+
const response = await fetch(url);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
throw new Error(response.statusText);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const json = await response.json();
|
|
89
|
+
|
|
90
|
+
return json;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private normalizeToc(apiToc: Array<ApiNavItem>): {
|
|
94
|
+
tocMap: { [key: string]: TreeNode };
|
|
95
|
+
normalizedToc: Array<TreeNode>;
|
|
96
|
+
} {
|
|
97
|
+
const tocMap = {};
|
|
98
|
+
const normalizedToc =
|
|
99
|
+
apiToc &&
|
|
100
|
+
apiToc.map((navItem) => this.normalizeNavItem(navItem, tocMap));
|
|
101
|
+
|
|
102
|
+
return { normalizedToc, tocMap };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private normalizeNavItem(
|
|
106
|
+
navItem: ApiNavItem,
|
|
107
|
+
tocMap: { [key: string]: TreeNode }
|
|
108
|
+
): TreeNode {
|
|
109
|
+
const name = this.calculateNavItemName(navItem, tocMap);
|
|
110
|
+
const node: TreeNode = {
|
|
111
|
+
label: navItem.text,
|
|
112
|
+
name
|
|
113
|
+
};
|
|
114
|
+
if (name) {
|
|
115
|
+
tocMap[name] = node;
|
|
116
|
+
}
|
|
117
|
+
node.children = navItem.children?.map((child) =>
|
|
118
|
+
this.normalizeNavItem(child, tocMap)
|
|
119
|
+
);
|
|
120
|
+
return node;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private calculateNavItemName(
|
|
124
|
+
navItem: ApiNavItem,
|
|
125
|
+
tocMap: { [key: string]: TreeNode }
|
|
126
|
+
): string {
|
|
127
|
+
let href = navItem.a_attr?.href || "";
|
|
128
|
+
if (href.includes("#")) {
|
|
129
|
+
const [pathUrl] = href.split("#");
|
|
130
|
+
href = pathUrl in tocMap ? href : pathUrl;
|
|
131
|
+
}
|
|
132
|
+
return href || navItem.id;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private normalizeVersion(version: ApiDocVersion): DocVersion {
|
|
136
|
+
return (
|
|
137
|
+
version && {
|
|
138
|
+
label: version.version_text,
|
|
139
|
+
releaseVersion:
|
|
140
|
+
version.release_version &&
|
|
141
|
+
!version.release_version.startsWith("v")
|
|
142
|
+
? `v${version.release_version}`
|
|
143
|
+
: version.release_version,
|
|
144
|
+
id: version.doc_version,
|
|
145
|
+
url: version.version_url
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private normalizeLanguage(language: ApiDocLanguage): DocLanguage {
|
|
151
|
+
const labelKey = language.locale && LOCALE_TO_LABEL[language.locale];
|
|
152
|
+
return (
|
|
153
|
+
language && {
|
|
154
|
+
label:
|
|
155
|
+
(labelKey && this.labels && this.labels[labelKey]) ||
|
|
156
|
+
language.label,
|
|
157
|
+
id: language.locale,
|
|
158
|
+
code: language.code,
|
|
159
|
+
url: language.url
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--button-primary-color: var(--dx-g-blue-vibrant-50);
|
|
3
|
+
--button-primary-color-hover: var(--dx-g-blue-vibrant-40);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
dx-dropdown {
|
|
7
|
+
--dx-c-dropdown-option-font-size: var(--dx-g-text-sm);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dx-dropdown > dx-button {
|
|
11
|
+
--dx-c-button-primary-color: var(--button-primary-color);
|
|
12
|
+
--dx-c-button-primary-color-hover: var(--button-primary-color-hover);
|
|
13
|
+
--border-color: var(--button-primary-color);
|
|
14
|
+
|
|
15
|
+
border-bottom: 1px dashed var(--border-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
dx-dropdown > dx-button:hover {
|
|
19
|
+
--border-color: var(--button-primary-color-hover);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.document-pickers {
|
|
23
|
+
margin-left: auto;
|
|
24
|
+
margin-right: var(--dx-g-spacing-sm);
|
|
25
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<doc-content-layout
|
|
3
|
+
if:true={loaded}
|
|
4
|
+
coveo-organization-id={coveoOrganizationId}
|
|
5
|
+
coveo-public-access-token={coveoPublicAccessToken}
|
|
6
|
+
coveo-search-hub="Developer_Docs_SS"
|
|
7
|
+
coveo-advanced-query-config={coveoAdvancedQueryConfig}
|
|
8
|
+
sidebar-header="Pages"
|
|
9
|
+
sidebar-content={sidebarContent}
|
|
10
|
+
sidebar-value={sidebarValue}
|
|
11
|
+
onselect={handleSelect}
|
|
12
|
+
use-old-sidebar
|
|
13
|
+
>
|
|
14
|
+
<div slot="sidebar-header" class="document-pickers">
|
|
15
|
+
<dx-dropdown
|
|
16
|
+
data-type="version"
|
|
17
|
+
suppress-gtm-nav-headings
|
|
18
|
+
analytics-event={analyticsEvent}
|
|
19
|
+
options={versionOptions}
|
|
20
|
+
value={version.id}
|
|
21
|
+
width="290px"
|
|
22
|
+
>
|
|
23
|
+
<dx-button variant="inline" disabled={disableVersion}>
|
|
24
|
+
{version.releaseVersion}
|
|
25
|
+
</dx-button>
|
|
26
|
+
</dx-dropdown>
|
|
27
|
+
</div>
|
|
28
|
+
<doc-content
|
|
29
|
+
docs-data={docContent}
|
|
30
|
+
page-reference={pageReference}
|
|
31
|
+
onnavclick={handleNavClick}
|
|
32
|
+
></doc-content>
|
|
33
|
+
</doc-content-layout>
|
|
34
|
+
</template>
|