@salesforcedevs/docs-components 1.20.13-redocly → 1.20.13-rnb-issue1
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 +0 -1
- package/package.json +1 -1
- package/src/modules/doc/contentLayout/contentLayout.ts +3 -1
- package/src/modules/doc/redocReference/redocReference.css +0 -6
- package/src/modules/doc/redocReference/redocReference.html +0 -8
- package/src/modules/doc/redocReference/redocReference.ts +0 -256
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-document-query */
|
|
2
|
-
import { LightningElement, api } from "lwc";
|
|
2
|
+
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";
|
|
@@ -81,10 +81,12 @@ export default class ContentLayout extends LightningElement {
|
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
@track
|
|
84
85
|
protected _sidebarContent: unknown;
|
|
85
86
|
|
|
86
87
|
protected _breadcrumbs = null;
|
|
87
88
|
|
|
89
|
+
@track
|
|
88
90
|
protected _tocOptions!: Array<unknown>;
|
|
89
91
|
|
|
90
92
|
protected tocOptionIdsSet = new Set();
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @lwc/lwc/no-document-query */
|
|
2
|
-
import { createElement, LightningElement, api } from "lwc";
|
|
3
|
-
import DocPhase from "doc/phase";
|
|
4
|
-
import DxFooter from "dx/footer";
|
|
5
|
-
import SprigSurvey from "doc/sprigSurvey";
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
interface Window {
|
|
9
|
-
Redoc: any;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type ReferenceItem = {
|
|
14
|
-
source: string;
|
|
15
|
-
href: string;
|
|
16
|
-
isSelected?: boolean;
|
|
17
|
-
docPhase?: any;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type ReferenceConfig = {
|
|
21
|
-
refList: ReferenceItem[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default class RedocReference extends LightningElement {
|
|
25
|
-
private _referenceConfig: ReferenceConfig = { refList: [] };
|
|
26
|
-
private _parentDocPhaseInfo: string | null = null;
|
|
27
|
-
|
|
28
|
-
private layoutTimeoutId: number | null = null;
|
|
29
|
-
private isScrolling: boolean = false;
|
|
30
|
-
private previousTopValue = "";
|
|
31
|
-
private redocInitialized = false;
|
|
32
|
-
|
|
33
|
-
showError = false;
|
|
34
|
-
|
|
35
|
-
@api
|
|
36
|
-
get referenceConfig(): ReferenceConfig {
|
|
37
|
-
return this._referenceConfig;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
set referenceConfig(value: string | ReferenceConfig) {
|
|
41
|
-
try {
|
|
42
|
-
const refConfig =
|
|
43
|
-
typeof value === "string" ? JSON.parse(value) : value;
|
|
44
|
-
this._referenceConfig = refConfig;
|
|
45
|
-
} catch (e) {
|
|
46
|
-
this._referenceConfig = { refList: [] };
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@api
|
|
51
|
-
get docPhaseInfo(): string | null {
|
|
52
|
-
return this._parentDocPhaseInfo;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
set docPhaseInfo(value: string) {
|
|
56
|
-
this._parentDocPhaseInfo = value;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
connectedCallback(): void {
|
|
60
|
-
window.addEventListener("scroll", this.handleScrollWithThrottle);
|
|
61
|
-
window.addEventListener("resize", this.handleScrollWithThrottle);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
renderedCallback(): void {
|
|
65
|
-
if (!this.redocInitialized && window.Redoc) {
|
|
66
|
-
this.initializeRedoc();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
disconnectedCallback(): void {
|
|
71
|
-
if (this.layoutTimeoutId) {
|
|
72
|
-
clearTimeout(this.layoutTimeoutId);
|
|
73
|
-
this.layoutTimeoutId = null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
window.removeEventListener("scroll", this.handleScrollWithThrottle);
|
|
77
|
-
window.removeEventListener("resize", this.handleScrollWithThrottle);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@api
|
|
81
|
-
setDocPhaseInfo(docPhaseInfo: string): void {
|
|
82
|
-
this._parentDocPhaseInfo = docPhaseInfo;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private handleScrollWithThrottle = () => {
|
|
86
|
-
if (!this.isScrolling) {
|
|
87
|
-
this.isScrolling = true;
|
|
88
|
-
|
|
89
|
-
setTimeout(() => {
|
|
90
|
-
this.adjustPosition();
|
|
91
|
-
}, 200);
|
|
92
|
-
|
|
93
|
-
this.isScrolling = false;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
private adjustPosition = () => {
|
|
98
|
-
const redocContainer = this.getRedocContainer();
|
|
99
|
-
const sidebarMenuElement = redocContainer?.querySelector(
|
|
100
|
-
".redoc-wrap .menu-content"
|
|
101
|
-
) as HTMLElement;
|
|
102
|
-
|
|
103
|
-
requestAnimationFrame(() => {
|
|
104
|
-
const globalNavElement = document.querySelector("hgf-c360nav");
|
|
105
|
-
const contextNavElement =
|
|
106
|
-
document.querySelector("hgf-c360contextnav");
|
|
107
|
-
const docHeaderElement =
|
|
108
|
-
document.querySelector(".sticky-doc-header");
|
|
109
|
-
|
|
110
|
-
if (sidebarMenuElement) {
|
|
111
|
-
const globalNavHeight =
|
|
112
|
-
globalNavElement?.getBoundingClientRect().height || 0;
|
|
113
|
-
const contextNavHeight =
|
|
114
|
-
contextNavElement?.getBoundingClientRect().height || 0;
|
|
115
|
-
const docHeaderHeight =
|
|
116
|
-
docHeaderElement?.getBoundingClientRect().height || 0;
|
|
117
|
-
|
|
118
|
-
const calculatedTopValue = `${
|
|
119
|
-
globalNavHeight + contextNavHeight + docHeaderHeight
|
|
120
|
-
}px`;
|
|
121
|
-
|
|
122
|
-
if (calculatedTopValue !== this.previousTopValue) {
|
|
123
|
-
sidebarMenuElement.style.setProperty(
|
|
124
|
-
"--doc-c-redoc-sidebar-top",
|
|
125
|
-
calculatedTopValue
|
|
126
|
-
);
|
|
127
|
-
this.previousTopValue = calculatedTopValue;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
private getDocPhaseInfo(): string | null {
|
|
134
|
-
if (this._parentDocPhaseInfo) {
|
|
135
|
-
return this._parentDocPhaseInfo;
|
|
136
|
-
}
|
|
137
|
-
const selectedRef = this.getSelectedReference();
|
|
138
|
-
return selectedRef?.docPhase
|
|
139
|
-
? JSON.stringify(selectedRef.docPhase)
|
|
140
|
-
: null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private getSelectedReference(): ReferenceItem | null {
|
|
144
|
-
return this._referenceConfig?.refList?.length
|
|
145
|
-
? this._referenceConfig.refList.find((ref) => ref.isSelected) ||
|
|
146
|
-
this._referenceConfig.refList[0]
|
|
147
|
-
: null;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private getRedocContainer(): HTMLElement | null {
|
|
151
|
-
return document.querySelector(".redoc-container");
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
private updateUrlWithReference(selectedRef: ReferenceItem): void {
|
|
155
|
-
if (selectedRef?.href) {
|
|
156
|
-
const parentReferencePath = selectedRef.href;
|
|
157
|
-
const currentUrl = window.location;
|
|
158
|
-
const existingParams = currentUrl.search + currentUrl.hash;
|
|
159
|
-
|
|
160
|
-
window.history.pushState(
|
|
161
|
-
{},
|
|
162
|
-
"",
|
|
163
|
-
`${parentReferencePath}${existingParams}`
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private initializeRedoc(): void {
|
|
169
|
-
try {
|
|
170
|
-
const selectedRef = this.getSelectedReference();
|
|
171
|
-
if (selectedRef) {
|
|
172
|
-
this.updateUrlWithReference(selectedRef);
|
|
173
|
-
|
|
174
|
-
const specUrl = selectedRef.source;
|
|
175
|
-
const redocContainer = this.getRedocContainer();
|
|
176
|
-
if (specUrl && redocContainer) {
|
|
177
|
-
this.redocInitialized = true;
|
|
178
|
-
window.Redoc.init(
|
|
179
|
-
specUrl,
|
|
180
|
-
{
|
|
181
|
-
expandResponses: "200,400"
|
|
182
|
-
},
|
|
183
|
-
redocContainer,
|
|
184
|
-
() => {
|
|
185
|
-
this.insertCustomLayoutElements();
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
} else {
|
|
189
|
-
this.showError = true;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
} catch (error) {
|
|
193
|
-
this.showError = true;
|
|
194
|
-
console.error("Failed to load data:", error);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
private insertCustomLayoutElements(): void {
|
|
199
|
-
const redocContainer = this.getRedocContainer();
|
|
200
|
-
const apiContentDiv = redocContainer?.querySelector(".api-content");
|
|
201
|
-
if (apiContentDiv) {
|
|
202
|
-
(apiContentDiv as HTMLElement).setAttribute("lwc:dom", "manual");
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
const docPhaseInfo = this.getDocPhaseInfo();
|
|
206
|
-
if (docPhaseInfo) {
|
|
207
|
-
this.insertDocPhase(
|
|
208
|
-
apiContentDiv as HTMLElement,
|
|
209
|
-
docPhaseInfo
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
this.insertSprigSurvey(apiContentDiv as HTMLElement);
|
|
213
|
-
this.insertFooter(apiContentDiv as HTMLElement);
|
|
214
|
-
} catch (error) {
|
|
215
|
-
console.error(
|
|
216
|
-
"Error showing banner and footer elements",
|
|
217
|
-
error
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
this.layoutTimeoutId = window.setTimeout(
|
|
222
|
-
() => this.insertCustomLayoutElements(),
|
|
223
|
-
100
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private insertDocPhase(container: HTMLElement, docPhaseInfo: string): void {
|
|
229
|
-
const docPhaseElement = createElement("doc-phase", { is: DocPhase });
|
|
230
|
-
Object.assign(docPhaseElement, { docPhaseInfo });
|
|
231
|
-
|
|
232
|
-
const wrapper = document.createElement("div");
|
|
233
|
-
wrapper.className = "doc-phase-wrapper";
|
|
234
|
-
wrapper.appendChild(docPhaseElement);
|
|
235
|
-
|
|
236
|
-
container.insertBefore(wrapper, container.firstChild);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
private insertFooter(container: HTMLElement): void {
|
|
240
|
-
const footerElement = createElement("dx-footer", { is: DxFooter });
|
|
241
|
-
Object.assign(footerElement, { variant: "no-signup" });
|
|
242
|
-
container.appendChild(footerElement);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private insertSprigSurvey(container: HTMLElement): void {
|
|
246
|
-
const feedbackElement = createElement("doc-sprig-survey", {
|
|
247
|
-
is: SprigSurvey
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
const wrapper = document.createElement("div");
|
|
251
|
-
wrapper.className = "feedback-wrapper";
|
|
252
|
-
wrapper.appendChild(feedbackElement);
|
|
253
|
-
|
|
254
|
-
container.appendChild(wrapper);
|
|
255
|
-
}
|
|
256
|
-
}
|