@salesforcedevs/docs-components 0.55.9-docs-more-locales-1 → 0.56.2-comp-flex-ref-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/modules/doc/amfReference/amfReference.html +13 -5
- package/src/modules/doc/amfReference/amfReference.ts +693 -296
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +42 -3
- package/src/modules/doc/contentLayout/contentLayout.ts +73 -29
- package/src/modules/doc/xmlContent/xmlContent.ts +7 -2
- package/src/modules/doc/amfReference/route-meta.ts +0 -22
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const NAVIGATION_ITEMS = [
|
|
2
|
+
{
|
|
3
|
+
label: "Summary",
|
|
4
|
+
name: "summary",
|
|
5
|
+
childrenPropertyName: undefined,
|
|
6
|
+
type: "summary"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
label: "Endpoints",
|
|
10
|
+
name: "endpoints",
|
|
11
|
+
childrenPropertyName: "endpoints",
|
|
12
|
+
type: "endpoint"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Documentation",
|
|
16
|
+
name: "documentation",
|
|
17
|
+
childrenPropertyName: "docs",
|
|
18
|
+
type: "documentation"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Types",
|
|
22
|
+
name: "types",
|
|
23
|
+
childrenPropertyName: "types",
|
|
24
|
+
type: "type"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Security",
|
|
28
|
+
name: "security",
|
|
29
|
+
childrenPropertyName: "security",
|
|
30
|
+
type: "security"
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const URL_CONFIG = {
|
|
35
|
+
summary: {
|
|
36
|
+
urlIdentifer: "label"
|
|
37
|
+
},
|
|
38
|
+
endpoint: {
|
|
39
|
+
urlIdentifer: "path"
|
|
40
|
+
},
|
|
41
|
+
method: {
|
|
42
|
+
urlIdentifer: "label"
|
|
43
|
+
},
|
|
44
|
+
documentation: {
|
|
45
|
+
urlIdentifer: "label"
|
|
46
|
+
},
|
|
47
|
+
type: {
|
|
48
|
+
urlIdentifer: "label",
|
|
49
|
+
prefix: "type:"
|
|
50
|
+
},
|
|
51
|
+
security: {
|
|
52
|
+
urlIdentifer: "label",
|
|
53
|
+
prefix: "security:"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const REFERENCE_TYPES = {
|
|
58
|
+
markdown: "markdown",
|
|
59
|
+
raml: "rest-raml",
|
|
60
|
+
oa2: "rest-oa2",
|
|
61
|
+
oa3: "rest-oa3"
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const oldReferenceIdNewReferenceIdMap: Record<string, string> = {
|
|
65
|
+
"commerce-api-assignments": "assignments",
|
|
66
|
+
"commerce-api-campaigns": "campaigns",
|
|
67
|
+
"commerce-api-catalogs": "catalogs",
|
|
68
|
+
"cdn-zones": "cdn-api-process-apis",
|
|
69
|
+
"inventory-impex": "impex",
|
|
70
|
+
"inventory-reservations": "inventory-reservation-service",
|
|
71
|
+
"shopper-login-and-api-access-service": "shopper-login",
|
|
72
|
+
"shopper-login-and-api-access-service-admin": "slas-admin",
|
|
73
|
+
"einstein-recommendations": "einstein-api-quick-start-guide"
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { NAVIGATION_ITEMS, URL_CONFIG, oldReferenceIdNewReferenceIdMap };
|
|
@@ -2,6 +2,7 @@ import { Json } from "typings/custom";
|
|
|
2
2
|
|
|
3
3
|
export interface AmfTopicType {
|
|
4
4
|
referenceId: string;
|
|
5
|
+
parentReferencePath: string;
|
|
5
6
|
amfId: string;
|
|
6
7
|
elementId: string;
|
|
7
8
|
type: string;
|
|
@@ -53,11 +54,37 @@ export type DocPhaseEntry = {
|
|
|
53
54
|
body: string;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
export
|
|
57
|
+
export type ReferenceType = "markdown" | "rest-raml" | "rest-oa2" | "rest-oa3";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Represents parsed topic for the sidebar.
|
|
61
|
+
*/
|
|
62
|
+
export interface ParsedMarkdownTopic {
|
|
63
|
+
label: string;
|
|
64
|
+
name: string;
|
|
65
|
+
children: ParsedMarkdownTopic[];
|
|
66
|
+
link?: {
|
|
67
|
+
href: string;
|
|
68
|
+
target?: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface AmfConfig {
|
|
57
73
|
id: string;
|
|
58
|
-
amf: string;
|
|
59
74
|
version?: string;
|
|
60
75
|
docPhase?: DocPhaseEntry;
|
|
76
|
+
title: string;
|
|
77
|
+
href: string;
|
|
78
|
+
referenceType: ReferenceType;
|
|
79
|
+
|
|
80
|
+
// determines if a reference config is the current active and selected one.
|
|
81
|
+
isSelected: boolean;
|
|
82
|
+
|
|
83
|
+
// required for spec based references
|
|
84
|
+
amf?: string;
|
|
85
|
+
|
|
86
|
+
// required for markdown based references
|
|
87
|
+
topic?: ParsedMarkdownTopic;
|
|
61
88
|
}
|
|
62
89
|
|
|
63
90
|
export interface ParsedTopicModel {
|
|
@@ -84,10 +111,22 @@ export interface ReferenceVersion {
|
|
|
84
111
|
label: string;
|
|
85
112
|
deprecated?: boolean;
|
|
86
113
|
selected?: boolean;
|
|
114
|
+
link: {
|
|
115
|
+
href: string;
|
|
116
|
+
};
|
|
87
117
|
}
|
|
88
118
|
|
|
89
119
|
export interface ReferenceSetConfig {
|
|
120
|
+
refId?: string;
|
|
90
121
|
versionToRefMap?: Map<string, Array<AmfConfig>>;
|
|
91
122
|
refList: Array<AmfConfig>;
|
|
92
|
-
versions
|
|
123
|
+
versions: Array<ReferenceVersion>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface RouteMeta {
|
|
127
|
+
meta: string;
|
|
128
|
+
referenceId: string;
|
|
129
|
+
topicId: string;
|
|
130
|
+
//type is only for spec based references
|
|
131
|
+
type?: string;
|
|
93
132
|
}
|
|
@@ -20,6 +20,7 @@ const HIGHLIGHTABLE_SELECTOR = [
|
|
|
20
20
|
"th",
|
|
21
21
|
"td"
|
|
22
22
|
].join(",");
|
|
23
|
+
const OBSERVER_ATTACH_WAIT_TIME = 500;
|
|
23
24
|
|
|
24
25
|
export default class ContentLayout extends LightningElement {
|
|
25
26
|
@api sidebarValue: string;
|
|
@@ -95,6 +96,8 @@ export default class ContentLayout extends LightningElement {
|
|
|
95
96
|
target: window
|
|
96
97
|
});
|
|
97
98
|
private tocValue?: string = undefined;
|
|
99
|
+
private observerTimerId = null;
|
|
100
|
+
private didScrollToSelectedHash = false;
|
|
98
101
|
|
|
99
102
|
get showToc(): boolean {
|
|
100
103
|
return this.tocOptions && this.tocOptions.length > 0;
|
|
@@ -119,6 +122,18 @@ export default class ContentLayout extends LightningElement {
|
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
renderedCallback(): void {
|
|
126
|
+
/**
|
|
127
|
+
* Note: We are adding timeout because chrome is optimizing and not triggering recent renderedCallback though elements reference is changed
|
|
128
|
+
* Also we are considering recent renderedCallback
|
|
129
|
+
*/
|
|
130
|
+
this.clearRenderObserverTimer();
|
|
131
|
+
this.observerTimerId = setTimeout(
|
|
132
|
+
this.attachInteractionObserver,
|
|
133
|
+
OBSERVER_ATTACH_WAIT_TIME
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
122
137
|
disconnectedCallback(): void {
|
|
123
138
|
this.disconnectObserver();
|
|
124
139
|
window.removeEventListener(
|
|
@@ -126,19 +141,25 @@ export default class ContentLayout extends LightningElement {
|
|
|
126
141
|
this.updateHighlighted
|
|
127
142
|
);
|
|
128
143
|
this.searchSyncer.dispose();
|
|
144
|
+
this.clearRenderObserverTimer();
|
|
129
145
|
}
|
|
130
146
|
|
|
147
|
+
clearRenderObserverTimer = () => {
|
|
148
|
+
if (this.observerTimerId) {
|
|
149
|
+
clearTimeout(this.observerTimerId);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
131
153
|
updateHighlighted = (event: Event): void =>
|
|
132
154
|
highlightTerms(
|
|
133
155
|
this.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
134
156
|
(event as CustomEvent<string>).detail
|
|
135
157
|
);
|
|
136
158
|
|
|
137
|
-
|
|
159
|
+
attachInteractionObserver = (): void => {
|
|
138
160
|
if (!this.enableSlotChange) {
|
|
139
161
|
return;
|
|
140
162
|
}
|
|
141
|
-
|
|
142
163
|
this.disconnectObserver();
|
|
143
164
|
this.observer = new IntersectionObserver((entries) => {
|
|
144
165
|
entries.forEach(
|
|
@@ -150,30 +171,54 @@ export default class ContentLayout extends LightningElement {
|
|
|
150
171
|
this.calculateActualSection();
|
|
151
172
|
});
|
|
152
173
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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");
|
|
174
|
+
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
175
|
+
const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
176
|
+
for (const headingElement of headingElements) {
|
|
177
|
+
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
178
|
+
const id = headingElement.getAttribute("id");
|
|
171
179
|
this.anchoredElements[id] = {
|
|
172
180
|
id,
|
|
173
181
|
intersect: false
|
|
174
182
|
};
|
|
175
|
-
this.observer.observe(
|
|
176
|
-
}
|
|
183
|
+
this.observer.observe(headingElement);
|
|
184
|
+
}
|
|
185
|
+
if (!this.didScrollToSelectedHash) {
|
|
186
|
+
this.didScrollToSelectedHash = true;
|
|
187
|
+
this.scrollToHash(headingElements);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
onSlotChange(event: Event): void {
|
|
192
|
+
const slotElements = (
|
|
193
|
+
event.target as HTMLSlotElement
|
|
194
|
+
).assignedElements();
|
|
195
|
+
|
|
196
|
+
if (slotElements.length) {
|
|
197
|
+
const slotContentElement = slotElements[0];
|
|
198
|
+
const headingElements =
|
|
199
|
+
slotContentElement.ownerDocument?.getElementsByTagName(
|
|
200
|
+
TOC_HEADER_TAG
|
|
201
|
+
);
|
|
202
|
+
for (const headingElement of headingElements) {
|
|
203
|
+
// Sometimes elements hash is not being set when slot content is wrapped with div
|
|
204
|
+
headingElement.hash =
|
|
205
|
+
headingElement.attributes["hash"]?.nodeValue;
|
|
206
|
+
}
|
|
207
|
+
const tocOptions = [];
|
|
208
|
+
for (const headingElement of headingElements) {
|
|
209
|
+
headingElement.id = headingElement.hash;
|
|
210
|
+
|
|
211
|
+
// Update tocOptions from anchorTags
|
|
212
|
+
const tocItem = {
|
|
213
|
+
anchor: `#${headingElement.hash}`,
|
|
214
|
+
id: headingElement.id,
|
|
215
|
+
label: headingElement.title
|
|
216
|
+
};
|
|
217
|
+
tocOptions.push(tocItem);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this._tocOptions = tocOptions;
|
|
221
|
+
}
|
|
177
222
|
}
|
|
178
223
|
|
|
179
224
|
private disconnectObserver(): void {
|
|
@@ -183,16 +228,15 @@ export default class ContentLayout extends LightningElement {
|
|
|
183
228
|
}
|
|
184
229
|
}
|
|
185
230
|
|
|
186
|
-
private scrollToHash(
|
|
231
|
+
private scrollToHash(headingElements: NodeListOf<Element>): void {
|
|
187
232
|
let { hash } = window.location;
|
|
188
|
-
|
|
189
233
|
if (hash) {
|
|
190
234
|
hash = hash.substr(1);
|
|
191
|
-
const
|
|
192
|
-
(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
235
|
+
for (const headingElement of headingElements) {
|
|
236
|
+
if (headingElement.getAttribute("id") === hash) {
|
|
237
|
+
headingElement.scrollIntoView({ behavior: "auto" });
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
196
240
|
}
|
|
197
241
|
}
|
|
198
242
|
}
|
|
@@ -213,11 +213,16 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
private get coveoAdvancedQueryConfig(): CoveoAdvancedQueryXMLConfig {
|
|
216
|
-
|
|
216
|
+
const config: { locale: string; topicid: string; version?: string } = {
|
|
217
217
|
locale: this.languageId,
|
|
218
|
-
version: this.releaseVersionId,
|
|
219
218
|
topicid: this.deliverable
|
|
220
219
|
};
|
|
220
|
+
|
|
221
|
+
if (this.releaseVersionId && this.releaseVersionId !== "noversion") {
|
|
222
|
+
config.version = this.releaseVersionId;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return config;
|
|
221
226
|
}
|
|
222
227
|
|
|
223
228
|
private get pageHeader(): Header {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the URL reference meta on Reference page.
|
|
3
|
-
* Contains information on selected Reference ID, Topic ID, and Topic Type
|
|
4
|
-
* separated by ":"
|
|
5
|
-
*/
|
|
6
|
-
export class RouteMeta {
|
|
7
|
-
meta: string;
|
|
8
|
-
referenceId = "";
|
|
9
|
-
topicId = "";
|
|
10
|
-
type = "";
|
|
11
|
-
|
|
12
|
-
constructor(meta: string) {
|
|
13
|
-
this.meta = meta;
|
|
14
|
-
|
|
15
|
-
if (meta && meta.includes(":")) {
|
|
16
|
-
const [referenceId, type, topicId] = meta.split(":");
|
|
17
|
-
this.referenceId = referenceId;
|
|
18
|
-
this.topicId = topicId || type;
|
|
19
|
-
this.type = type;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|