@salesforcedevs/docs-components 0.3.12 → 0.3.14-banner-alpha1
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 +12 -3
- package/package.json +17 -7
- package/src/modules/README.md +41 -0
- package/src/modules/doc/amfReference/amfReference.css +5 -0
- package/src/modules/doc/amfReference/amfReference.html +47 -0
- package/src/modules/doc/amfReference/amfReference.ts +1361 -0
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +133 -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 +130 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +64 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +60 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +187 -0
- package/src/modules/doc/content/content.css +58 -103
- package/src/modules/doc/content/content.ts +261 -174
- package/src/modules/doc/contentCallout/contentCallout.css +7 -24
- package/src/modules/doc/contentCallout/contentCallout.html +4 -2
- package/src/modules/doc/contentCallout/contentCallout.ts +8 -2
- package/src/modules/doc/contentLayout/contentLayout.css +98 -0
- package/src/modules/doc/contentLayout/contentLayout.html +51 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +322 -0
- package/src/modules/doc/header/header.css +103 -0
- package/src/modules/doc/header/header.html +160 -0
- package/src/modules/doc/header/header.ts +146 -0
- package/src/modules/doc/heading/heading.css +54 -0
- package/src/modules/doc/heading/heading.html +14 -0
- package/src/modules/doc/heading/heading.ts +65 -0
- package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
- package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
- package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
- package/src/modules/doc/headingContent/headingContent.css +53 -0
- package/src/modules/doc/headingContent/headingContent.html +13 -0
- package/src/modules/doc/headingContent/headingContent.ts +30 -0
- package/src/modules/doc/phase/phase.css +55 -0
- package/src/modules/doc/phase/phase.html +28 -0
- package/src/modules/doc/phase/phase.ts +57 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +12 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/toc/toc.html +3 -1
- package/src/modules/doc/toolbar/toolbar.ts +6 -6
- package/src/modules/doc/xmlContent/types.ts +114 -0
- package/src/modules/doc/xmlContent/utils.ts +161 -0
- package/src/modules/doc/xmlContent/xmlContent.css +32 -0
- package/src/modules/doc/xmlContent/xmlContent.html +40 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +677 -0
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +39 -0
- package/src/modules/docHelpers/status/status.css +22 -0
- package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +85 -0
- package/LICENSE +0 -12
- package/src/modules/doc/container/__benchmarks__/container.benchmark.js +0 -43
- package/src/modules/doc/container/__mocks__/mockAvailableLanguages.js +0 -8
- package/src/modules/doc/container/__mocks__/mockAvailableVersions.js +0 -122
- package/src/modules/doc/container/__mocks__/mockContentFetchResponse.json +0 -5
- package/src/modules/doc/container/__mocks__/mockDocContent.js +0 -29
- package/src/modules/doc/container/__mocks__/mockNavigationFetchResponse.json +0 -4061
- package/src/modules/doc/container/__mocks__/mockPageReference.js +0 -8
- package/src/modules/doc/container/__mocks__/mockPdfUrl.js +0 -1
- package/src/modules/doc/container/__mocks__/mockSelectedLanguage.js +0 -8
- package/src/modules/doc/container/__mocks__/mockSelectedVersion.js +0 -8
- package/src/modules/doc/container/__mocks__/mockToc.js +0 -146
- package/src/modules/doc/container/__tests__/container.test.ts +0 -117
- package/src/modules/doc/container/container.css +0 -37
- package/src/modules/doc/container/container.html +0 -28
- package/src/modules/doc/container/container.stories.ts +0 -44
- package/src/modules/doc/container/container.ts +0 -367
- package/src/modules/doc/content/__tests__/content.test.ts +0 -99
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -258
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/content/content.stories.ts +0 -82
- package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
- package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
- package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
- package/src/modules/doc/contentMedia/__tests__/contentMedia.test.ts +0 -97
- package/src/modules/doc/contentMedia/contentMedia.stories.ts +0 -113
- package/src/modules/doc/landing/__tests__/landing.test.ts +0 -60
- package/src/modules/doc/landing/__tests__/mockFetch.json +0 -370
- package/src/modules/doc/landing/landing.css +0 -63
- package/src/modules/doc/landing/landing.html +0 -122
- package/src/modules/doc/landing/landing.stories.ts +0 -21
- package/src/modules/doc/landing/landing.ts +0 -222
- package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/nav/__tests__/nav.test.ts +0 -58
- package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
- package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { LightningElement, api } from "lwc";
|
|
2
|
-
import {
|
|
3
|
-
AvailableLanguages,
|
|
4
|
-
AvailableVersions,
|
|
5
|
-
ContentLoaded,
|
|
6
|
-
DocContent,
|
|
7
|
-
NavigationLoaded,
|
|
8
|
-
NormalizedToc,
|
|
9
|
-
PageReference,
|
|
10
|
-
SelectedVersion,
|
|
11
|
-
SelectedLanguage,
|
|
12
|
-
SelectedNavigationItem,
|
|
13
|
-
DocToc,
|
|
14
|
-
PdfUrl
|
|
15
|
-
} from "typings/custom";
|
|
16
|
-
|
|
17
|
-
const DEFAULT_URL = "https://developer.salesforce.com/";
|
|
18
|
-
|
|
19
|
-
export default class Container extends LightningElement {
|
|
20
|
-
@api domainApi: string = DEFAULT_URL;
|
|
21
|
-
// TODO: We have to evaluate if we can find a better way to do component testing in Storybook.
|
|
22
|
-
@api
|
|
23
|
-
set storybookDomain(value: string) {
|
|
24
|
-
this.pageReference.domain = value;
|
|
25
|
-
this._isStorybook = true;
|
|
26
|
-
}
|
|
27
|
-
get storybookDomain() {
|
|
28
|
-
return this.pageReference.domain;
|
|
29
|
-
}
|
|
30
|
-
@api
|
|
31
|
-
set storybookPage(value: string) {
|
|
32
|
-
this.pageReference.page = value;
|
|
33
|
-
}
|
|
34
|
-
get storybookPage() {
|
|
35
|
-
return this.pageReference.page;
|
|
36
|
-
}
|
|
37
|
-
@api
|
|
38
|
-
set storybookDocId(value: string) {
|
|
39
|
-
this.pageReference.docId = value;
|
|
40
|
-
}
|
|
41
|
-
get storybookDocId() {
|
|
42
|
-
return this.pageReference.docId;
|
|
43
|
-
}
|
|
44
|
-
@api
|
|
45
|
-
set storybookDeliverable(value: string) {
|
|
46
|
-
this.pageReference.deliverable = value;
|
|
47
|
-
}
|
|
48
|
-
get storybookDeliverable() {
|
|
49
|
-
return this.pageReference.deliverable;
|
|
50
|
-
}
|
|
51
|
-
@api
|
|
52
|
-
set storybookContentDocumentId(value: string) {
|
|
53
|
-
this.pageReference.contentDocumentId = value;
|
|
54
|
-
}
|
|
55
|
-
get storybookContentDocumentId() {
|
|
56
|
-
return this.pageReference.contentDocumentId;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Navigation
|
|
60
|
-
toc: DocToc = [
|
|
61
|
-
{
|
|
62
|
-
children: [],
|
|
63
|
-
text: "",
|
|
64
|
-
a_attr: {
|
|
65
|
-
href: ""
|
|
66
|
-
},
|
|
67
|
-
id: ""
|
|
68
|
-
}
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
// Toolbar
|
|
72
|
-
availableLanguages: AvailableLanguages = [
|
|
73
|
-
{
|
|
74
|
-
label: "",
|
|
75
|
-
code: "",
|
|
76
|
-
locale: "",
|
|
77
|
-
url: ""
|
|
78
|
-
}
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
availableVersions: AvailableVersions = [
|
|
82
|
-
{
|
|
83
|
-
version_test: "",
|
|
84
|
-
release_version: "",
|
|
85
|
-
doc_version: "",
|
|
86
|
-
version_url: ""
|
|
87
|
-
}
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
pdfUrl: PdfUrl = "";
|
|
91
|
-
|
|
92
|
-
selectedLanguage: SelectedLanguage = [
|
|
93
|
-
{
|
|
94
|
-
label: "",
|
|
95
|
-
code: "",
|
|
96
|
-
locale: "",
|
|
97
|
-
url: ""
|
|
98
|
-
}
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
selectedVersion: SelectedVersion = [
|
|
102
|
-
{
|
|
103
|
-
version_test: "",
|
|
104
|
-
release_version: "",
|
|
105
|
-
doc_version: "",
|
|
106
|
-
version_url: ""
|
|
107
|
-
}
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
// Content
|
|
111
|
-
docContent: DocContent = "";
|
|
112
|
-
|
|
113
|
-
// TODO: Impliment dx-tree component
|
|
114
|
-
selectedNavigationItem: SelectedNavigationItem = "";
|
|
115
|
-
|
|
116
|
-
normalizedToc: NormalizedToc = [
|
|
117
|
-
{
|
|
118
|
-
name: "",
|
|
119
|
-
label: "",
|
|
120
|
-
items: []
|
|
121
|
-
}
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
// Storybook Properties
|
|
125
|
-
selectedContentDocumentId: string | undefined;
|
|
126
|
-
selectedContentId: string | undefined;
|
|
127
|
-
selectedVersionUrl: string | undefined;
|
|
128
|
-
_isStorybook = false;
|
|
129
|
-
|
|
130
|
-
// State
|
|
131
|
-
navigationLoaded: NavigationLoaded = false;
|
|
132
|
-
|
|
133
|
-
contentLoaded: ContentLoaded = false;
|
|
134
|
-
|
|
135
|
-
pageReference: PageReference = {
|
|
136
|
-
domain: "",
|
|
137
|
-
page: "",
|
|
138
|
-
docId: "",
|
|
139
|
-
deliverable: "",
|
|
140
|
-
contentDocumentId: "",
|
|
141
|
-
hash: ""
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
showLandingPage: boolean = false;
|
|
145
|
-
|
|
146
|
-
apiMainUrl: string = "";
|
|
147
|
-
apiDetailUrl: string = "";
|
|
148
|
-
|
|
149
|
-
constructor() {
|
|
150
|
-
super();
|
|
151
|
-
this.template.addEventListener(
|
|
152
|
-
"navclick",
|
|
153
|
-
this.handleNavEvent.bind(this) // eslint-disableline no-use-before-define
|
|
154
|
-
);
|
|
155
|
-
this.template.addEventListener(
|
|
156
|
-
"versionselected",
|
|
157
|
-
this.handleToolbarEvent.bind(this) // eslint-disable-line no-use-before-define
|
|
158
|
-
);
|
|
159
|
-
this.template.addEventListener(
|
|
160
|
-
"languageselected",
|
|
161
|
-
this.handleToolbarEvent.bind(this) // eslint-disable-line no-use-before-define
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
connectedCallback() {
|
|
166
|
-
const normalizedDomainApi = this.domainApi.endsWith("/")
|
|
167
|
-
? this.domainApi
|
|
168
|
-
: this.domainApi + "/";
|
|
169
|
-
this.apiMainUrl = `${normalizedDomainApi}docs/get_document/`;
|
|
170
|
-
this.apiDetailUrl = `${normalizedDomainApi}docs/get_document_content`;
|
|
171
|
-
if (!this._isStorybook) {
|
|
172
|
-
this.getPageContext();
|
|
173
|
-
}
|
|
174
|
-
this.fetchDocData("navigation");
|
|
175
|
-
window.onpopstate = () => {
|
|
176
|
-
this.getPageContext();
|
|
177
|
-
this.fetchDocData("content");
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
getPageContext() {
|
|
182
|
-
[
|
|
183
|
-
this.pageReference.domain,
|
|
184
|
-
this.pageReference.page,
|
|
185
|
-
this.pageReference.docId,
|
|
186
|
-
this.pageReference.deliverable,
|
|
187
|
-
this.pageReference.contentDocumentId
|
|
188
|
-
] = window.location.pathname.split("/");
|
|
189
|
-
this.pageReference.hash = window.location.hash;
|
|
190
|
-
this.pageReference.domain = `${window.location.protocol}//${window.location.host}`;
|
|
191
|
-
this.updateSelectedItem();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
handleNavEvent(event: CustomEvent) {
|
|
195
|
-
if (event.detail.pageReference) {
|
|
196
|
-
const newPageReference = event.detail.pageReference;
|
|
197
|
-
const docIdPartials = window.location.pathname.split("/");
|
|
198
|
-
if (
|
|
199
|
-
this.pageReference.contentDocumentId ===
|
|
200
|
-
newPageReference.contentDocumentId &&
|
|
201
|
-
newPageReference.hash
|
|
202
|
-
) {
|
|
203
|
-
this.updatePageReference(newPageReference);
|
|
204
|
-
this.rewriteUrl(docIdPartials, newPageReference);
|
|
205
|
-
} else {
|
|
206
|
-
this.updatePageReference(newPageReference);
|
|
207
|
-
this.rewriteUrl(docIdPartials, newPageReference);
|
|
208
|
-
this.fetchDocData("content");
|
|
209
|
-
}
|
|
210
|
-
if (newPageReference.hash) {
|
|
211
|
-
this.navigateToHash(newPageReference.hash);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
navigateToHash(hash: String) {
|
|
217
|
-
// eslint-disable-next-line no-use-before-define
|
|
218
|
-
this.template.querySelector("doc-content").navigateToHash(hash);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
rewriteUrl(docIdPartials: string[], newPageReference: PageReference) {
|
|
222
|
-
if (!this._isStorybook) {
|
|
223
|
-
docIdPartials[4] = newPageReference.contentDocumentId;
|
|
224
|
-
let urlRewrite = docIdPartials.join("/");
|
|
225
|
-
if (this.pageReference.hash) {
|
|
226
|
-
urlRewrite = `${urlRewrite}#${newPageReference.hash}`;
|
|
227
|
-
}
|
|
228
|
-
window.history.pushState("Docs", "Docs", urlRewrite);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
updatePageReference(newPageReference: PageReference) {
|
|
233
|
-
if (
|
|
234
|
-
newPageReference.page &&
|
|
235
|
-
this.pageReference.page !== newPageReference.page
|
|
236
|
-
) {
|
|
237
|
-
this.pageReference.page = newPageReference.page;
|
|
238
|
-
}
|
|
239
|
-
if (
|
|
240
|
-
newPageReference.docId &&
|
|
241
|
-
this.pageReference.docId !== newPageReference.docId
|
|
242
|
-
) {
|
|
243
|
-
this.pageReference.docId = newPageReference.docId;
|
|
244
|
-
}
|
|
245
|
-
if (
|
|
246
|
-
newPageReference.deliverable &&
|
|
247
|
-
this.pageReference.deliverable !== newPageReference.deliverable
|
|
248
|
-
) {
|
|
249
|
-
this.pageReference.deliverable = newPageReference.deliverable;
|
|
250
|
-
}
|
|
251
|
-
if (
|
|
252
|
-
newPageReference.contentDocumentId &&
|
|
253
|
-
this.pageReference.contentDocumentId !==
|
|
254
|
-
newPageReference.contentDocumentId
|
|
255
|
-
) {
|
|
256
|
-
if (
|
|
257
|
-
newPageReference.contentDocumentId.endsWith(".htm") ||
|
|
258
|
-
newPageReference.contentDocumentId.includes("#")
|
|
259
|
-
) {
|
|
260
|
-
this.pageReference.contentDocumentId =
|
|
261
|
-
newPageReference.contentDocumentId;
|
|
262
|
-
} else {
|
|
263
|
-
this.pageReference.contentDocumentId =
|
|
264
|
-
newPageReference.contentDocumentId + ".htm";
|
|
265
|
-
}
|
|
266
|
-
this.updateSelectedItem();
|
|
267
|
-
}
|
|
268
|
-
if (
|
|
269
|
-
newPageReference.hash &&
|
|
270
|
-
this.pageReference.hash !== newPageReference.hash
|
|
271
|
-
) {
|
|
272
|
-
this.pageReference.hash = newPageReference.hash;
|
|
273
|
-
} else {
|
|
274
|
-
this.pageReference.hash = "";
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
updateSelectedItem() {
|
|
279
|
-
if (this.pageReference.contentDocumentId) {
|
|
280
|
-
let item = "";
|
|
281
|
-
if (this.pageReference.contentDocumentId.includes(".htm")) {
|
|
282
|
-
item = this.pageReference.contentDocumentId.replace(".htm", "");
|
|
283
|
-
}
|
|
284
|
-
if (this.pageReference.hash) {
|
|
285
|
-
item = `${item}-${this.pageReference.hash.replace("#", "")}`;
|
|
286
|
-
}
|
|
287
|
-
this.selectedNavigationItem = item;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
handleToolbarEvent(event: CustomEvent) {
|
|
292
|
-
if (event.detail.type === "language") {
|
|
293
|
-
this.selectedLanguage = this.availableLanguages.filter(
|
|
294
|
-
(language) => language.locale === event.detail.value
|
|
295
|
-
);
|
|
296
|
-
} else if (event.detail.type === "version") {
|
|
297
|
-
this.selectedVersion = this.availableVersions.filter(
|
|
298
|
-
(version) => version.doc_version === event.detail.value
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
const newPageReference = { ...this.pageReference };
|
|
302
|
-
newPageReference.docId = `atlas.${this.selectedLanguage[0].locale}.${this.selectedVersion[0].doc_version}.${this.pageReference.deliverable}.meta`;
|
|
303
|
-
const docIdPartials = window.location.pathname.split("/");
|
|
304
|
-
this.updatePageReference(newPageReference);
|
|
305
|
-
docIdPartials[2] = newPageReference.docId;
|
|
306
|
-
const urlRewrite = docIdPartials.join("/");
|
|
307
|
-
window.history.pushState("Docs", "Docs", urlRewrite);
|
|
308
|
-
this.fetchDocData("navigation");
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
fetchDocData(docType: String) {
|
|
312
|
-
const docRestUrl = this.generateCalloutURL(docType);
|
|
313
|
-
fetch(docRestUrl)
|
|
314
|
-
.then((result) => {
|
|
315
|
-
return result.json();
|
|
316
|
-
})
|
|
317
|
-
.then((json) => {
|
|
318
|
-
const docData = json;
|
|
319
|
-
if (docType === "navigation") {
|
|
320
|
-
this.toc = this.normalizeToc(docData.toc);
|
|
321
|
-
this.availableLanguages = docData.available_languages;
|
|
322
|
-
this.availableVersions = docData.available_versions;
|
|
323
|
-
this.selectedLanguage = [docData.language];
|
|
324
|
-
this.selectedVersion = [docData.version];
|
|
325
|
-
this.pdfUrl = docData.pdf_url;
|
|
326
|
-
this.navigationLoaded = true;
|
|
327
|
-
if (this.pageReference.contentDocumentId === undefined) {
|
|
328
|
-
this.pageReference.contentDocumentId =
|
|
329
|
-
docData.content_document_id + ".htm";
|
|
330
|
-
}
|
|
331
|
-
this.fetchDocData("content");
|
|
332
|
-
} else if (docType === "content") {
|
|
333
|
-
this.docContent = docData.content;
|
|
334
|
-
this.contentLoaded = true;
|
|
335
|
-
if (!this.pageReference.hash) {
|
|
336
|
-
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
})
|
|
340
|
-
.catch(() => {
|
|
341
|
-
this.showLandingPage = true;
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Generate the callout URL for the fetch based on the docType
|
|
346
|
-
generateCalloutURL(docType: String) {
|
|
347
|
-
if (docType === "navigation") {
|
|
348
|
-
return this.apiMainUrl + this.pageReference.docId;
|
|
349
|
-
} else if (docType === "content") {
|
|
350
|
-
return `${this.apiDetailUrl}/${this.pageReference.deliverable}/${this.pageReference.contentDocumentId}/${this.selectedLanguage[0].locale}/${this.selectedVersion[0].doc_version}`;
|
|
351
|
-
}
|
|
352
|
-
return "";
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Render page only with navigation and content are both loaded
|
|
356
|
-
get loaded() {
|
|
357
|
-
return this.navigationLoaded && this.contentLoaded;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
normalizeToc(toc: DocToc) {
|
|
361
|
-
let normalizedToc = JSON.stringify(toc).replace(/"text"/g, '"label"');
|
|
362
|
-
normalizedToc = normalizedToc.replace(/"id"/g, '"name"');
|
|
363
|
-
const jsonToc = JSON.parse(normalizedToc);
|
|
364
|
-
jsonToc.isExpanded = true;
|
|
365
|
-
return jsonToc;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { createRenderComponent } from "utils/tests";
|
|
2
|
-
import Content from "../content";
|
|
3
|
-
import * as mockContent from "./mockDocContent";
|
|
4
|
-
import mockPageReference from "./mockPageReference";
|
|
5
|
-
|
|
6
|
-
const TAG = "doc-content";
|
|
7
|
-
const render = createRenderComponent(TAG, Content);
|
|
8
|
-
|
|
9
|
-
describe("doc-content", () => {
|
|
10
|
-
it("renders the content", () => {
|
|
11
|
-
const component = render({
|
|
12
|
-
docsData: mockContent.content,
|
|
13
|
-
pageReference: mockPageReference,
|
|
14
|
-
_isStorybook: false
|
|
15
|
-
});
|
|
16
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
17
|
-
'[data-name="content"]'
|
|
18
|
-
);
|
|
19
|
-
expect(contentEl).not.toBeNull();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("swaps out images", () => {
|
|
23
|
-
const component = render({
|
|
24
|
-
docsData: mockContent.withImages,
|
|
25
|
-
pageReference: mockPageReference,
|
|
26
|
-
_isStorybook: false
|
|
27
|
-
});
|
|
28
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
29
|
-
'[data-name="content"]'
|
|
30
|
-
);
|
|
31
|
-
expect(contentEl).not.toBeNull();
|
|
32
|
-
const images = component.shadowRoot.querySelectorAll("img");
|
|
33
|
-
expect(images.length).toEqual(3);
|
|
34
|
-
const contentMediaEls = component.shadowRoot.querySelectorAll(
|
|
35
|
-
"doc-content-media"
|
|
36
|
-
);
|
|
37
|
-
expect(contentMediaEls.length).toEqual(0);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("swaps out iframes", () => {
|
|
41
|
-
const component = render({
|
|
42
|
-
docsData: mockContent.withVideos,
|
|
43
|
-
pageReference: mockPageReference,
|
|
44
|
-
_isStorybook: false
|
|
45
|
-
});
|
|
46
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
47
|
-
'[data-name="content"]'
|
|
48
|
-
);
|
|
49
|
-
expect(contentEl).not.toBeNull();
|
|
50
|
-
const images = component.shadowRoot.querySelectorAll("iframe");
|
|
51
|
-
expect(images.length).toEqual(0);
|
|
52
|
-
const contentMediaEls = component.shadowRoot.querySelectorAll(
|
|
53
|
-
"doc-content-media"
|
|
54
|
-
);
|
|
55
|
-
expect(contentMediaEls.length).toEqual(2);
|
|
56
|
-
contentMediaEls.forEach((contentMedia) => {
|
|
57
|
-
expect(contentMedia.contentType).toEqual("iframe");
|
|
58
|
-
expect(contentMedia.mediaTitle).not.toBeUndefined();
|
|
59
|
-
expect(contentMedia.contentSrc).toMatch(
|
|
60
|
-
"https://play.vidyard.com/"
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("swaps out notes", () => {
|
|
66
|
-
const component = render({
|
|
67
|
-
docsData: mockContent.withNotes,
|
|
68
|
-
pageReference: mockPageReference,
|
|
69
|
-
_isStorybook: false
|
|
70
|
-
});
|
|
71
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
72
|
-
'[data-name="content"]'
|
|
73
|
-
);
|
|
74
|
-
expect(contentEl).not.toBeNull();
|
|
75
|
-
const notes = component.shadowRoot.querySelectorAll(".message");
|
|
76
|
-
expect(notes).toHaveLength(4);
|
|
77
|
-
notes.forEach((note) => {
|
|
78
|
-
const noteHeader = note.querySelector("doc-content-callout");
|
|
79
|
-
expect(noteHeader).not.toBeNull();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("includes tables, lists, and code blocks in notes", () => {
|
|
84
|
-
const component = render({
|
|
85
|
-
docsData: mockContent.withNotes,
|
|
86
|
-
pageReference: mockPageReference,
|
|
87
|
-
_isStorybook: false
|
|
88
|
-
});
|
|
89
|
-
const contentEl = component.shadowRoot.querySelector(
|
|
90
|
-
'[data-name="content"]'
|
|
91
|
-
);
|
|
92
|
-
expect(contentEl).not.toBeNull();
|
|
93
|
-
const notes = component.shadowRoot.querySelectorAll(".message");
|
|
94
|
-
expect(notes[0].querySelector("table")).not.toBeNull();
|
|
95
|
-
expect(notes[1].querySelector("ul")).not.toBeNull();
|
|
96
|
-
expect(notes[2].querySelector("ol")).not.toBeNull();
|
|
97
|
-
expect(notes[3].querySelector("dx-code-block")).not.toBeNull();
|
|
98
|
-
});
|
|
99
|
-
});
|