@salesforcedevs/docs-components 0.17.1 → 0.17.12-search-alpha
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 +17 -3
- package/package.json +18 -7
- package/src/modules/README.md +41 -0
- package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
- package/src/modules/doc/amfReference/amfReference.css +25 -0
- package/src/modules/doc/amfReference/amfReference.html +55 -0
- package/src/modules/doc/amfReference/amfReference.ts +1467 -0
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +125 -0
- package/src/modules/doc/amfTopic/amfTopic.css +21 -0
- package/src/modules/doc/amfTopic/amfTopic.html +3 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
- package/src/modules/doc/amfTopic/types.ts +56 -0
- package/src/modules/doc/amfTopic/utils.ts +136 -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 +71 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
- package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +42 -0
- package/src/modules/doc/content/content.css +89 -70
- package/src/modules/doc/content/content.html +1 -0
- package/src/modules/doc/content/content.ts +188 -195
- package/src/modules/doc/contentCallout/contentCallout.css +18 -10
- package/src/modules/doc/contentCallout/contentCallout.html +13 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +14 -2
- package/src/modules/doc/contentLayout/contentLayout.css +1 -0
- package/src/modules/doc/contentLayout/contentLayout.html +46 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +524 -0
- package/src/modules/doc/doDont/doDont.css +47 -0
- package/src/modules/doc/doDont/doDont.html +27 -0
- package/src/modules/doc/doDont/doDont.ts +17 -0
- package/src/modules/doc/header/header.css +70 -37
- package/src/modules/doc/header/header.html +41 -138
- package/src/modules/doc/header/header.ts +56 -78
- package/src/modules/doc/heading/heading.css +33 -0
- package/src/modules/doc/heading/heading.html +14 -0
- package/src/modules/doc/heading/heading.ts +67 -0
- package/src/modules/doc/headingAnchor/headingAnchor.css +3 -3
- package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
- 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/lwcContentLayout/lwcContentLayout.css +1 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +45 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +256 -0
- package/src/modules/doc/overview/overview.css +40 -0
- package/src/modules/doc/overview/overview.html +34 -0
- package/src/modules/doc/overview/overview.ts +12 -0
- package/src/modules/doc/phase/phase.css +21 -6
- package/src/modules/doc/phase/phase.html +15 -3
- package/src/modules/doc/phase/phase.ts +48 -12
- package/src/modules/doc/specificationContent/specificationContent.css +36 -0
- package/src/modules/doc/specificationContent/specificationContent.html +167 -0
- package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/toc/toc.ts +1 -1
- package/src/modules/doc/versionPicker/versionPicker.css +64 -0
- package/src/modules/doc/versionPicker/versionPicker.html +38 -0
- package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
- package/src/modules/doc/xmlContent/types.ts +120 -0
- package/src/modules/doc/xmlContent/utils.ts +163 -0
- package/src/modules/doc/xmlContent/xmlContent.css +54 -0
- package/src/modules/doc/xmlContent/xmlContent.html +54 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +763 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
- package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
- package/src/modules/{helpers → docHelpers}/status/status.css +1 -1
- package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -0
- package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
- package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
- package/src/modules/docUtils/utils/utils.ts +32 -0
- package/LICENSE +0 -12
- package/src/modules/doc/content/__tests__/content.test.ts +0 -312
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -348
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/content/__tests__/mockSidebar.ts +0 -81
- package/src/modules/doc/content/content.stories.ts +0 -148
- 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/header/__tests__/coveoConfig.ts +0 -12
- package/src/modules/doc/header/__tests__/header.test.ts +0 -445
- package/src/modules/doc/header/__tests__/mockNavDevelopers.ts +0 -427
- package/src/modules/doc/header/__tests__/mockNavs.ts +0 -115
- package/src/modules/doc/header/__tests__/mockProps.ts +0 -152
- package/src/modules/doc/header/header.stories.ts +0 -190
- package/src/modules/doc/headingAnchor/__tests__/headingAnchor.test.ts +0 -111
- package/src/modules/doc/headingAnchor/headingAnchor.stories.ts +0 -33
- 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/phase/__tests__/mockProps.ts +0 -13
- package/src/modules/doc/phase/__tests__/phase.test.ts +0 -60
- package/src/modules/doc/phase/phase.stories.ts +0 -12
- 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,13 +1,13 @@
|
|
|
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";
|
|
5
4
|
import CodeBlock from "dx/codeBlock";
|
|
6
|
-
import ContentMedia from "doc/contentMedia";
|
|
7
5
|
import Button from "dx/button";
|
|
8
|
-
import { highlightTerms } from "
|
|
6
|
+
import { highlightTerms } from "dxUtils/highlight";
|
|
7
|
+
import ContentCallout from "doc/contentCallout";
|
|
8
|
+
import ContentMedia from "doc/contentMedia";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
11
|
"p",
|
|
12
12
|
".p",
|
|
13
13
|
".shortdesc",
|
|
@@ -21,7 +21,7 @@ const ALLOWED_ELEMENTS = [
|
|
|
21
21
|
"dl",
|
|
22
22
|
"th",
|
|
23
23
|
"td"
|
|
24
|
-
];
|
|
24
|
+
].join(",");
|
|
25
25
|
|
|
26
26
|
const LANGUAGE_MAP: { [key: string]: string } = {
|
|
27
27
|
js: "javascript"
|
|
@@ -43,26 +43,10 @@ export default class Content extends LightningElement {
|
|
|
43
43
|
return this.docContent;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
@api
|
|
47
|
-
set codeBlockTheme(value) {
|
|
48
|
-
this._codeBlockTheme = value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get codeBlockTheme() {
|
|
52
|
-
return this._codeBlockTheme;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
@track docContent: DocContent = "";
|
|
56
|
-
_codeBlockTheme: string = "dark";
|
|
57
47
|
_docRendered: boolean = false;
|
|
58
|
-
originalCodeBlockThemeValue: String = "";
|
|
59
48
|
|
|
60
49
|
connectedCallback() {
|
|
61
|
-
this.template.addEventListener(
|
|
62
|
-
"themechange",
|
|
63
|
-
this.updateTheme.bind(this) // eslint-disableline no-use-before-define
|
|
64
|
-
);
|
|
65
|
-
|
|
66
50
|
window.addEventListener(
|
|
67
51
|
"highlightedtermchange",
|
|
68
52
|
this.updateHighlighted
|
|
@@ -76,17 +60,8 @@ export default class Content extends LightningElement {
|
|
|
76
60
|
);
|
|
77
61
|
}
|
|
78
62
|
|
|
79
|
-
updateTheme() {
|
|
80
|
-
this._codeBlockTheme =
|
|
81
|
-
this._codeBlockTheme === "dark" ? "light" : "dark";
|
|
82
|
-
const codeBlockEls = this.template.querySelectorAll("dx-code-block");
|
|
83
|
-
codeBlockEls.forEach((codeBlockEl) => {
|
|
84
|
-
codeBlockEl.setAttribute("theme", this._codeBlockTheme);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
63
|
renderPaginationButton(anchorEl: HTMLElement) {
|
|
89
|
-
const isNext = anchorEl.textContent
|
|
64
|
+
const isNext = anchorEl.textContent!.includes("Next →");
|
|
90
65
|
anchorEl.innerHTML = "";
|
|
91
66
|
const buttonEl = createElement("dx-button", { is: Button });
|
|
92
67
|
const params = isNext
|
|
@@ -109,173 +84,194 @@ export default class Content extends LightningElement {
|
|
|
109
84
|
insertDocHtml(docContent?: string) {
|
|
110
85
|
const divEl = this.getCleanContainer();
|
|
111
86
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (className.startsWith("brush:")) {
|
|
128
|
-
language = className.split(":")[1];
|
|
87
|
+
if (divEl) {
|
|
88
|
+
divEl.innerHTML = docContent || this.docContent;
|
|
89
|
+
|
|
90
|
+
// Query the code blocks and create a dx-code-block component that contains the code
|
|
91
|
+
const codeBlockEls = divEl.querySelectorAll(".codeSection");
|
|
92
|
+
codeBlockEls.forEach((codeBlockEl) => {
|
|
93
|
+
codeBlockEl.setAttribute("lwc:dom", "manual");
|
|
94
|
+
const classList = codeBlockEl.firstElementChild?.classList;
|
|
95
|
+
let language = "";
|
|
96
|
+
if (classList) {
|
|
97
|
+
for (let i = 0; i < classList.length; i++) {
|
|
98
|
+
const className = classList[i];
|
|
99
|
+
if (className.startsWith("brush:")) {
|
|
100
|
+
language = className.split(":")[1];
|
|
101
|
+
}
|
|
129
102
|
}
|
|
130
103
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// Query the callouts and create a doc-content-callout component that contains the code
|
|
148
|
-
const calloutEls = templateEl.content.querySelectorAll(".message");
|
|
149
|
-
calloutEls.forEach((calloutEl) => {
|
|
150
|
-
const calloutCompEl = createElement("doc-content-callout", {
|
|
151
|
-
is: ContentCallout
|
|
152
|
-
});
|
|
153
|
-
const detailEls = calloutEl.querySelectorAll(
|
|
154
|
-
"p, div.data, ol, ul, .codeSection, .mediaBd > span.ph"
|
|
155
|
-
);
|
|
156
|
-
detailEls.forEach((detailEl) => {
|
|
157
|
-
calloutCompEl.appendChild(detailEl);
|
|
158
|
-
});
|
|
159
|
-
const type = calloutEl.querySelector("h4").textContent;
|
|
160
|
-
const typeLower = type.toLowerCase();
|
|
161
|
-
Object.assign(calloutCompEl, {
|
|
162
|
-
title: type,
|
|
163
|
-
variant: typeLower
|
|
104
|
+
const blockCmp = createElement("dx-code-block", {
|
|
105
|
+
is: CodeBlock
|
|
106
|
+
});
|
|
107
|
+
Object.assign(blockCmp, {
|
|
108
|
+
codeBlock: codeBlockEl.innerHTML,
|
|
109
|
+
// ! Hot fix for incoming html tags from couchdb for xml blocks, fix me soon please
|
|
110
|
+
language: LANGUAGE_MAP[language] || language,
|
|
111
|
+
header: "", // Default no title.
|
|
112
|
+
variant: this.codeBlockType,
|
|
113
|
+
isEncoded: true
|
|
114
|
+
});
|
|
115
|
+
// eslint-disable-next-line no-use-before-define
|
|
116
|
+
codeBlockEl.innerHTML = "";
|
|
117
|
+
codeBlockEl.appendChild(blockCmp);
|
|
164
118
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
anchorEl.textContent.includes("Next →") ||
|
|
176
|
-
anchorEl.textContent.includes("← Previous")
|
|
177
|
-
) {
|
|
178
|
-
if (this.showPaginationButtons) {
|
|
179
|
-
this.renderPaginationButton(anchorEl);
|
|
180
|
-
} else {
|
|
181
|
-
anchorEl.remove();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const href = anchorEl.href.split("/");
|
|
186
|
-
if (
|
|
187
|
-
(href[3] === this.pageReference.docId && this.isStorybook) ||
|
|
188
|
-
href[4] === this.pageReference.docId ||
|
|
189
|
-
href[6] === this.pageReference.docId
|
|
190
|
-
) {
|
|
191
|
-
let updatedURL;
|
|
192
|
-
switch (href.length) {
|
|
193
|
-
case 8:
|
|
194
|
-
updatedURL = href.splice(5).join("/");
|
|
195
|
-
break;
|
|
196
|
-
case 7:
|
|
197
|
-
updatedURL = href.splice(4).join("/");
|
|
198
|
-
break;
|
|
199
|
-
case 6:
|
|
200
|
-
updatedURL = href.splice(3).join("/");
|
|
201
|
-
break;
|
|
202
|
-
default:
|
|
203
|
-
updatedURL = href.splice(6).join("/");
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
anchorEl.addEventListener(
|
|
207
|
-
"click",
|
|
208
|
-
// eslint-disable-next-line no-use-before-define
|
|
209
|
-
this.handleNavClick.bind(this)
|
|
119
|
+
|
|
120
|
+
// Query the callouts and create a doc-content-callout component that contains the code
|
|
121
|
+
const calloutEls = divEl.querySelectorAll(".message");
|
|
122
|
+
calloutEls.forEach((calloutEl) => {
|
|
123
|
+
const calloutCompEl = createElement("doc-content-callout", {
|
|
124
|
+
is: ContentCallout
|
|
125
|
+
});
|
|
126
|
+
const detailEls = calloutEl.querySelectorAll(
|
|
127
|
+
"p, .p, div.data, ol, ul, p+.codeSection, p~.codeSection, div >.codeSection, .mediaBd > span.ph"
|
|
210
128
|
);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
// Modify image src to work with any domain and replace images/iframes with doc-content-media
|
|
222
|
-
const imgEls = templateEl.content.querySelectorAll("img, iframe");
|
|
223
|
-
|
|
224
|
-
imgEls.forEach((mediaEl) => {
|
|
225
|
-
const isImage = mediaEl.nodeName === "IMG";
|
|
226
|
-
let src = mediaEl.getAttribute("src");
|
|
227
|
-
if (!src) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
const alt = mediaEl.getAttribute("alt");
|
|
231
|
-
const title = mediaEl.getAttribute("title");
|
|
232
|
-
const label = mediaEl.getAttribute("label");
|
|
233
|
-
const width = mediaEl.getAttribute("width");
|
|
234
|
-
const height = mediaEl.getAttribute("height");
|
|
235
|
-
|
|
236
|
-
if (isImage) {
|
|
237
|
-
src = src.startsWith("/")
|
|
238
|
-
? `https://developer.salesforce.com${src}`
|
|
239
|
-
: src.replace(
|
|
240
|
-
window.location.origin,
|
|
241
|
-
"https://developer.salesforce.com"
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
const img: HTMLImageElement = document.createElement("img");
|
|
245
|
-
img.src = src;
|
|
246
|
-
if (alt) {
|
|
247
|
-
img.alt = alt;
|
|
129
|
+
detailEls.forEach((detailEl) => {
|
|
130
|
+
if (detailEl.innerHTML.trim() !== "") {
|
|
131
|
+
calloutCompEl.appendChild(detailEl);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Set a flag to 1 (true) if and only if all detailEls have no content.
|
|
136
|
+
let flag = 1;
|
|
137
|
+
for (let i: number = 0; i < detailEls.length; i++) {
|
|
138
|
+
flag &= (detailEls[i].innerHTML.trim() === "") as any; // Dark Magic TM
|
|
248
139
|
}
|
|
249
|
-
|
|
250
|
-
|
|
140
|
+
|
|
141
|
+
if (flag) {
|
|
142
|
+
const codeEls = calloutEl.querySelectorAll(".codeSection");
|
|
143
|
+
codeEls.forEach((codeEl) => {
|
|
144
|
+
calloutCompEl.appendChild(codeEl);
|
|
145
|
+
});
|
|
251
146
|
}
|
|
252
|
-
|
|
253
|
-
|
|
147
|
+
|
|
148
|
+
const type = calloutEl.querySelector("h4")!.textContent!;
|
|
149
|
+
const typeLower = type.toLowerCase();
|
|
150
|
+
Object.assign(calloutCompEl, {
|
|
151
|
+
header: type,
|
|
152
|
+
variant: typeLower
|
|
153
|
+
});
|
|
154
|
+
// eslint-disable-next-line no-use-before-define
|
|
155
|
+
calloutEl.innerHTML = "";
|
|
156
|
+
calloutEl.appendChild(calloutCompEl);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Modify links to work with any domain, links that start with "#" are excluded
|
|
160
|
+
const anchorEls = divEl.querySelectorAll("a:not([href^='#'])");
|
|
161
|
+
|
|
162
|
+
anchorEls.forEach((anchorEl: any) => {
|
|
163
|
+
if (
|
|
164
|
+
anchorEl.textContent!.includes("Next →") ||
|
|
165
|
+
anchorEl.textContent!.includes("← Previous")
|
|
166
|
+
) {
|
|
167
|
+
if (this.showPaginationButtons) {
|
|
168
|
+
this.renderPaginationButton(anchorEl);
|
|
169
|
+
} else {
|
|
170
|
+
anchorEl.remove();
|
|
171
|
+
}
|
|
254
172
|
}
|
|
255
|
-
|
|
256
|
-
|
|
173
|
+
|
|
174
|
+
// ! This is a hack
|
|
175
|
+
// Normalize urls in case it doesn't come complete.
|
|
176
|
+
if (anchorEl.href.startsWith("atlas.")) {
|
|
177
|
+
anchorEl.href = "/docs/" + anchorEl.href;
|
|
257
178
|
}
|
|
258
179
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
180
|
+
const href = anchorEl.href.split("/");
|
|
181
|
+
if (
|
|
182
|
+
(href[3] === this.pageReference.docId &&
|
|
183
|
+
this.isStorybook) ||
|
|
184
|
+
href[4] === this.pageReference.docId ||
|
|
185
|
+
href[6] === this.pageReference.docId
|
|
186
|
+
) {
|
|
187
|
+
let updatedURL;
|
|
188
|
+
switch (href.length) {
|
|
189
|
+
case 8:
|
|
190
|
+
updatedURL = href.splice(5).join("/");
|
|
191
|
+
break;
|
|
192
|
+
case 7:
|
|
193
|
+
updatedURL = href.splice(4).join("/");
|
|
194
|
+
break;
|
|
195
|
+
case 6:
|
|
196
|
+
updatedURL = href.splice(3).join("/");
|
|
197
|
+
break;
|
|
198
|
+
default:
|
|
199
|
+
updatedURL = href.splice(6).join("/");
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
anchorEl.addEventListener(
|
|
203
|
+
"click",
|
|
204
|
+
// eslint-disable-next-line no-use-before-define
|
|
205
|
+
this.handleNavClick.bind(this)
|
|
206
|
+
);
|
|
207
|
+
// anchor href event is not propagated here as we want SPA nature.
|
|
208
|
+
// But in prerender.io - as javascript is not executed, we want the anchor links are proper (absolute urls).
|
|
209
|
+
anchorEl.setAttribute("href", "/docs/" + updatedURL);
|
|
210
|
+
anchorEl.setAttribute("data-id", "docs/" + updatedURL);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
274
213
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
214
|
+
anchorEl.setAttribute("data-id", anchorEl.href);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Modify image src to work with any domain and replace images/iframes with doc-content-media
|
|
218
|
+
const imgEls = divEl.querySelectorAll("img, iframe");
|
|
219
|
+
|
|
220
|
+
imgEls.forEach((mediaEl) => {
|
|
221
|
+
const isImage = mediaEl.nodeName === "IMG";
|
|
222
|
+
let src = mediaEl.getAttribute("src");
|
|
223
|
+
if (!src) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const alt = mediaEl.getAttribute("alt");
|
|
227
|
+
const title = mediaEl.getAttribute("title");
|
|
228
|
+
const label = mediaEl.getAttribute("label");
|
|
229
|
+
const width = mediaEl.getAttribute("width");
|
|
230
|
+
const height = mediaEl.getAttribute("height");
|
|
231
|
+
const className = mediaEl.getAttribute("class");
|
|
232
|
+
|
|
233
|
+
if (isImage) {
|
|
234
|
+
src = src.startsWith("/")
|
|
235
|
+
? `https://developer.salesforce.com${src}`
|
|
236
|
+
: src.replace(
|
|
237
|
+
window.location.origin,
|
|
238
|
+
"https://developer.salesforce.com"
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const img: HTMLImageElement = document.createElement("img");
|
|
242
|
+
img.src = src;
|
|
243
|
+
img.alt = "";
|
|
244
|
+
if (alt) {
|
|
245
|
+
img.alt = alt;
|
|
246
|
+
}
|
|
247
|
+
if (title) {
|
|
248
|
+
img.title = title;
|
|
249
|
+
}
|
|
250
|
+
if (height) {
|
|
251
|
+
img.height = parseFloat(height);
|
|
252
|
+
}
|
|
253
|
+
if (width) {
|
|
254
|
+
img.width = parseFloat(width);
|
|
255
|
+
}
|
|
256
|
+
if (className) {
|
|
257
|
+
img.className = className;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
img.className = `content-image ${img.className}`;
|
|
261
|
+
mediaEl.parentNode!.insertBefore(img, mediaEl);
|
|
262
|
+
} else {
|
|
263
|
+
const contentMediaEl = createElement("doc-content-media", {
|
|
264
|
+
is: ContentMedia
|
|
265
|
+
});
|
|
266
|
+
Object.assign(contentMediaEl, {
|
|
267
|
+
contentType: "iframe",
|
|
268
|
+
contentSrc: src,
|
|
269
|
+
mediaTitle: alt || title || label
|
|
270
|
+
});
|
|
271
|
+
mediaEl.parentNode!.insertBefore(contentMediaEl, mediaEl);
|
|
272
|
+
}
|
|
273
|
+
mediaEl.remove();
|
|
274
|
+
});
|
|
279
275
|
}
|
|
280
276
|
|
|
281
277
|
// Once the html has been corectly modified, naviage to the page reference on the page
|
|
@@ -305,8 +301,7 @@ export default class Content extends LightningElement {
|
|
|
305
301
|
|
|
306
302
|
handleNavClick(event: InputEvent) {
|
|
307
303
|
event.preventDefault();
|
|
308
|
-
|
|
309
|
-
const target = event.currentTarget.dataset.id;
|
|
304
|
+
const target = (event.currentTarget! as any).dataset.id;
|
|
310
305
|
const [page, docId, deliverable, tempContentDocumentId] =
|
|
311
306
|
target.split("/");
|
|
312
307
|
const [contentDocumentId, hash] = tempContentDocumentId.split("#");
|
|
@@ -334,14 +329,12 @@ export default class Content extends LightningElement {
|
|
|
334
329
|
|
|
335
330
|
updateHighlighted = (event: any) =>
|
|
336
331
|
highlightTerms(
|
|
337
|
-
|
|
338
|
-
this.template.querySelectorAll(ALLOWED_ELEMENTS.join(","))
|
|
339
|
-
),
|
|
332
|
+
this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
340
333
|
event.detail
|
|
341
334
|
);
|
|
342
335
|
|
|
343
336
|
@api
|
|
344
|
-
public navigateToHash(hash: String) {
|
|
337
|
+
public navigateToHash = (hash: String) => {
|
|
345
338
|
const splitHash = hash.split("#");
|
|
346
339
|
if (splitHash.length === 2) {
|
|
347
340
|
hash = splitHash[1];
|
|
@@ -352,7 +345,7 @@ export default class Content extends LightningElement {
|
|
|
352
345
|
} else {
|
|
353
346
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
354
347
|
}
|
|
355
|
-
}
|
|
348
|
+
};
|
|
356
349
|
|
|
357
350
|
renderedCallback() {
|
|
358
351
|
if (this._docRendered) {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
@import "
|
|
2
|
-
@import "
|
|
3
|
-
@import "
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
@import "docHelpers/status";
|
|
4
4
|
|
|
5
5
|
.dx-callout {
|
|
6
6
|
border-radius: 4px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.dx-callout-base
|
|
9
|
+
.dx-callout-base,
|
|
10
|
+
.dx-callout-plain {
|
|
10
11
|
background-color: var(--dx-g-gray-95);
|
|
11
12
|
border-color: var(--dx-g-gray-50);
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
.dx-callout-plain {
|
|
16
|
+
border: none;
|
|
17
|
+
margin-bottom: var(--dx-g-text-2xl);
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
.dx-callout-note {
|
|
15
21
|
background-color: var(--dx-g-blue-vibrant-95);
|
|
16
22
|
border-color: var(--dx-g-blue-vibrant-50);
|
|
@@ -26,6 +32,11 @@
|
|
|
26
32
|
border-color: var(--dx-g-red-vibrant-50);
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
.dx-callout-warning {
|
|
36
|
+
background-color: var(--dx-g-red-natural-95);
|
|
37
|
+
border-color: var(--dx-g-red-vibrant-50);
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
.dx-callout-base_section {
|
|
30
41
|
width: 100%;
|
|
31
42
|
}
|
|
@@ -42,10 +53,7 @@
|
|
|
42
53
|
flex-direction: row;
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
.dx-callout-
|
|
46
|
-
|
|
56
|
+
.dx-callout-content {
|
|
57
|
+
flex: 1;
|
|
58
|
+
overflow: auto;
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
.dx-callout-base_column > dx-type-badge-group {
|
|
50
|
-
margin-bottom: var(--dx-g-spacing-sm);
|
|
51
|
-
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class={className}>
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
3
|
+
<template if:false={hideIcon}>
|
|
4
|
+
<div class="doc-status-icon dx-callout-icon">
|
|
5
|
+
<dx-icon
|
|
6
|
+
symbol={iconName}
|
|
7
|
+
size="large"
|
|
8
|
+
color={iconColor}
|
|
9
|
+
></dx-icon>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
6
13
|
<div class="dx-callout-content">
|
|
7
|
-
<p class="doc-status-title dx-callout-title dx-text-body-3">
|
|
14
|
+
<p class="doc-status-title dx-callout-title dx-text-body-3">
|
|
15
|
+
{header}
|
|
16
|
+
</p>
|
|
8
17
|
<span class="dx-callout-body dx-text-body-3">
|
|
9
18
|
<slot onslotchange={onSlotChange}></slot>
|
|
10
19
|
</span>
|
|
@@ -3,7 +3,7 @@ import cx from "classnames";
|
|
|
3
3
|
import { CalloutVariant, LightningSlotElement } from "typings/custom";
|
|
4
4
|
|
|
5
5
|
export default class ContentCallout extends LightningElement {
|
|
6
|
-
@api
|
|
6
|
+
@api header!: string;
|
|
7
7
|
@api variant!: CalloutVariant;
|
|
8
8
|
cardVariant?: string;
|
|
9
9
|
iconName?: string;
|
|
@@ -11,6 +11,9 @@ export default class ContentCallout extends LightningElement {
|
|
|
11
11
|
|
|
12
12
|
connectedCallback() {
|
|
13
13
|
switch (this.variant) {
|
|
14
|
+
case "plain":
|
|
15
|
+
this.cardVariant = "dx-callout-plain";
|
|
16
|
+
break;
|
|
14
17
|
case "tip":
|
|
15
18
|
this.cardVariant = "dx-callout-tip";
|
|
16
19
|
this.iconColor = "green-vibrant-60";
|
|
@@ -18,7 +21,7 @@ export default class ContentCallout extends LightningElement {
|
|
|
18
21
|
break;
|
|
19
22
|
case "warning":
|
|
20
23
|
this.cardVariant = "doc-status-container dx-callout-warning";
|
|
21
|
-
this.iconColor = "
|
|
24
|
+
this.iconColor = "red-vibrant-50";
|
|
22
25
|
this.iconName = "warning";
|
|
23
26
|
break;
|
|
24
27
|
case "caution":
|
|
@@ -26,6 +29,11 @@ export default class ContentCallout extends LightningElement {
|
|
|
26
29
|
this.iconColor = "red-vibrant-50";
|
|
27
30
|
this.iconName = "alert";
|
|
28
31
|
break;
|
|
32
|
+
case "important":
|
|
33
|
+
this.cardVariant = "doc-status-container dx-callout-important";
|
|
34
|
+
this.iconColor = "gray-10";
|
|
35
|
+
this.iconName = "announcement";
|
|
36
|
+
break;
|
|
29
37
|
case "note":
|
|
30
38
|
default:
|
|
31
39
|
this.cardVariant = "dx-callout-note";
|
|
@@ -44,6 +52,10 @@ export default class ContentCallout extends LightningElement {
|
|
|
44
52
|
);
|
|
45
53
|
}
|
|
46
54
|
|
|
55
|
+
get hideIcon() {
|
|
56
|
+
return this.variant === "plain";
|
|
57
|
+
}
|
|
58
|
+
|
|
47
59
|
private isSlotEmpty: boolean = true;
|
|
48
60
|
private onSlotChange(e: LightningSlotElement) {
|
|
49
61
|
// @ts-ignore
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "docHelpers/contentLayoutStyle";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="content">
|
|
3
|
+
<dx-sidebar-old
|
|
4
|
+
class="is-sticky left-nav-bar"
|
|
5
|
+
trees={sidebarContent}
|
|
6
|
+
value={sidebarValue}
|
|
7
|
+
header={sidebarHeader}
|
|
8
|
+
ontogglesidebar={onToggleSidebar}
|
|
9
|
+
languages={languages}
|
|
10
|
+
language={language}
|
|
11
|
+
bail-href={bailHref}
|
|
12
|
+
bail-label={bailLabel}
|
|
13
|
+
dev-center={devCenter}
|
|
14
|
+
brand={brand}
|
|
15
|
+
empty-state-message={emptyStateMessage}
|
|
16
|
+
>
|
|
17
|
+
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
18
|
+
</dx-sidebar-old>
|
|
19
|
+
<div class="content-body-doc-phase-container">
|
|
20
|
+
<slot name="doc-phase"></slot>
|
|
21
|
+
<slot name="version-banner"></slot>
|
|
22
|
+
<div class="content-body-container">
|
|
23
|
+
<div class="content-body">
|
|
24
|
+
<doc-breadcrumbs
|
|
25
|
+
lwc:if={showBreadcrumbs}
|
|
26
|
+
breadcrumbs={breadcrumbs}
|
|
27
|
+
></doc-breadcrumbs>
|
|
28
|
+
<slot onslotchange={onSlotChange}></slot>
|
|
29
|
+
<doc-sprig-survey
|
|
30
|
+
lwc:if={shouldDisplayFeedback}
|
|
31
|
+
></doc-sprig-survey>
|
|
32
|
+
</div>
|
|
33
|
+
<div lwc:if={showToc} class="right-nav-bar is-sticky">
|
|
34
|
+
<dx-toc
|
|
35
|
+
header={tocTitle}
|
|
36
|
+
options={tocOptions}
|
|
37
|
+
value={tocValue}
|
|
38
|
+
></dx-toc>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div lwc:if={showFooter} class="footer-container">
|
|
42
|
+
<dx-footer variant="no-signup"></dx-footer>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|