@salesforcedevs/docs-components 0.0.2 → 0.0.3-edit
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 +27 -2
- package/package.json +19 -8
- 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 +60 -0
- package/src/modules/doc/amfReference/amfReference.ts +1494 -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/chat/README.md +179 -0
- package/src/modules/doc/chat/chat.css +818 -0
- package/src/modules/doc/chat/chat.html +241 -0
- package/src/modules/doc/chat/chat.ts +586 -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 +29 -0
- package/src/modules/doc/content/content.css +388 -4
- package/src/modules/doc/content/content.html +3 -2
- package/src/modules/doc/content/content.ts +319 -45
- package/src/modules/doc/contentCallout/contentCallout.css +59 -0
- package/src/modules/doc/contentCallout/contentCallout.html +22 -0
- package/src/modules/doc/contentCallout/contentCallout.ts +65 -0
- package/src/modules/doc/contentLayout/contentLayout.css +1 -0
- package/src/modules/doc/contentLayout/contentLayout.html +72 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +531 -0
- package/src/modules/doc/contentMedia/contentMedia.css +49 -0
- package/src/modules/doc/contentMedia/contentMedia.html +23 -0
- package/src/modules/doc/contentMedia/contentMedia.ts +34 -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/editFile/editFile.css +505 -0
- package/src/modules/doc/editFile/editFile.html +164 -0
- package/src/modules/doc/editFile/editFile.ts +213 -0
- package/src/modules/doc/header/header.css +132 -0
- package/src/modules/doc/header/header.html +55 -0
- package/src/modules/doc/header/header.ts +120 -0
- 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 +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/lwcContentLayout/lwcContentLayout.css +1 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +168 -0
- package/src/modules/doc/nav/nav.css +8 -2
- package/src/modules/doc/nav/nav.html +10 -7
- package/src/modules/doc/nav/nav.ts +33 -29
- 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 +70 -0
- package/src/modules/doc/phase/phase.html +38 -0
- package/src/modules/doc/phase/phase.ts +93 -0
- package/src/modules/doc/specificationContent/specificationContent.css +36 -0
- package/src/modules/doc/specificationContent/specificationContent.html +171 -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.css +14 -0
- package/src/modules/doc/toc/toc.html +99 -22
- package/src/modules/doc/toc/toc.ts +11 -6
- package/src/modules/doc/toolbar/toolbar.css +8 -0
- package/src/modules/doc/toolbar/toolbar.html +32 -15
- package/src/modules/doc/toolbar/toolbar.ts +69 -30
- 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 +52 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +792 -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/docHelpers/status/status.css +22 -0
- 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/src/modules/doc/container/__benchmarks__/container.benchmarkrenamed.js +0 -18
- package/src/modules/doc/container/container.css +0 -8
- package/src/modules/doc/container/container.html +0 -11
- package/src/modules/doc/container/container.stories.ts +0 -15
- package/src/modules/doc/container/container.ts +0 -164
- package/src/modules/doc/content/prismjs.css +0 -184
- package/src/modules/doc/content/prismjs.html +0 -3
- package/src/modules/doc/content/prismjs.ts +0 -853
- package/src/modules/doc/prismcss/prismcss.css +0 -184
- package/src/modules/doc/search/search.html +0 -1
- package/src/modules/doc/search/search.ts +0 -6
|
@@ -1,83 +1,357 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-inner-html */
|
|
2
|
-
import { LightningElement, api, track } from "lwc";
|
|
3
|
-
import
|
|
2
|
+
import { createElement, LightningElement, api, track } from "lwc";
|
|
3
|
+
import { DocContent, PageReference } from "typings/custom";
|
|
4
|
+
import CodeBlock from "dx/codeBlock";
|
|
5
|
+
import Button from "dx/button";
|
|
6
|
+
import { highlightTerms } from "dxUtils/highlight";
|
|
7
|
+
import ContentCallout from "doc/contentCallout";
|
|
8
|
+
import ContentMedia from "doc/contentMedia";
|
|
9
|
+
|
|
10
|
+
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
|
+
"p",
|
|
12
|
+
".p",
|
|
13
|
+
".shortdesc",
|
|
14
|
+
"h1",
|
|
15
|
+
"h2",
|
|
16
|
+
"h3",
|
|
17
|
+
"h4",
|
|
18
|
+
"h5",
|
|
19
|
+
"h6",
|
|
20
|
+
"li",
|
|
21
|
+
"dl",
|
|
22
|
+
"th",
|
|
23
|
+
"td"
|
|
24
|
+
].join(",");
|
|
25
|
+
|
|
26
|
+
const LANGUAGE_MAP: { [key: string]: string } = {
|
|
27
|
+
js: "javascript"
|
|
28
|
+
};
|
|
4
29
|
|
|
5
|
-
/**
|
|
6
|
-
* @element doc-content
|
|
7
|
-
*/
|
|
8
30
|
export default class Content extends LightningElement {
|
|
9
|
-
|
|
10
|
-
@
|
|
31
|
+
@api isStorybook: boolean = false;
|
|
32
|
+
@api pageReference!: PageReference;
|
|
33
|
+
@api codeBlockType: string = "card";
|
|
34
|
+
@api showPaginationButtons: boolean = false;
|
|
11
35
|
|
|
12
36
|
@api
|
|
13
37
|
set docsData(value) {
|
|
14
38
|
this._docRendered = false;
|
|
15
|
-
this.docContent = value;
|
|
39
|
+
this.docContent = (value && value.trim()) || "";
|
|
16
40
|
}
|
|
41
|
+
|
|
17
42
|
get docsData() {
|
|
18
43
|
return this.docContent;
|
|
19
44
|
}
|
|
20
45
|
|
|
21
|
-
|
|
22
|
-
|
|
46
|
+
@track docContent: DocContent = "";
|
|
47
|
+
_docRendered: boolean = false;
|
|
23
48
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for (const preEl of preEls) {
|
|
32
|
-
const codeHTML = preEl.innerHTML;
|
|
33
|
-
const codeEl = document.createElement("code");
|
|
34
|
-
codeEl.classList.add("language-js");
|
|
35
|
-
codeEl.innerHTML = codeHTML;
|
|
36
|
-
preEl.innerHTML = "";
|
|
37
|
-
// preEl.classList.add("line-numbers"); // TODO: Re-add once we have line-numbers plugin added
|
|
38
|
-
preEl.appendChild(codeEl);
|
|
39
|
-
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
window.addEventListener(
|
|
51
|
+
"highlightedtermchange",
|
|
52
|
+
this.updateHighlighted
|
|
53
|
+
);
|
|
54
|
+
}
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
disconnectedCallback(): void {
|
|
57
|
+
window.removeEventListener(
|
|
58
|
+
"highlightedtermchange",
|
|
59
|
+
this.updateHighlighted
|
|
60
|
+
);
|
|
61
|
+
}
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
63
|
+
renderPaginationButton(anchorEl: HTMLElement) {
|
|
64
|
+
const isNext = anchorEl.textContent!.includes("Next →");
|
|
65
|
+
anchorEl.innerHTML = "";
|
|
66
|
+
const buttonEl = createElement("dx-button", { is: Button });
|
|
67
|
+
const params = isNext
|
|
68
|
+
? { iconSymbol: "chevronright" }
|
|
69
|
+
: {
|
|
70
|
+
iconPosition: "left",
|
|
71
|
+
iconSymbol: "chevronleft",
|
|
72
|
+
variant: "secondary"
|
|
73
|
+
};
|
|
74
|
+
Object.assign(buttonEl, params);
|
|
75
|
+
const textEl = document.createDocumentFragment();
|
|
76
|
+
textEl.textContent = isNext ? "Next" : "Previous";
|
|
77
|
+
buttonEl.appendChild(textEl);
|
|
78
|
+
anchorEl.appendChild(buttonEl);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// We don't use any tracked field here. The challenge is that
|
|
82
|
+
// for security reasons you can't pass pure HTML via a class
|
|
83
|
+
// field to the template. Hence we manipulate the DOM manually.
|
|
84
|
+
insertDocHtml(docContent?: string) {
|
|
85
|
+
const divEl = this.getCleanContainer();
|
|
50
86
|
|
|
51
|
-
// We don't use any tracked field here. The challenge is that
|
|
52
|
-
// for security reasons you can't pass pure HTML via a class
|
|
53
|
-
// field to the template. Hence we manipulate the DOM manually.
|
|
54
87
|
if (divEl) {
|
|
55
|
-
divEl.innerHTML =
|
|
56
|
-
|
|
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
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
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);
|
|
118
|
+
});
|
|
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"
|
|
128
|
+
);
|
|
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
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (flag) {
|
|
142
|
+
const codeEls = calloutEl.querySelectorAll(".codeSection");
|
|
143
|
+
codeEls.forEach((codeEl) => {
|
|
144
|
+
calloutCompEl.appendChild(codeEl);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
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
|
+
}
|
|
172
|
+
}
|
|
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;
|
|
178
|
+
}
|
|
179
|
+
|
|
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
|
+
}
|
|
213
|
+
|
|
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
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Once the html has been corectly modified, naviage to the page reference on the page
|
|
278
|
+
if (this.pageReference.hash) {
|
|
279
|
+
this.navigateToHash(this.pageReference.hash);
|
|
57
280
|
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private getCleanContainer(): HTMLElement | null {
|
|
284
|
+
const divEl = this.template.querySelector("div");
|
|
285
|
+
if (divEl?.hasChildNodes()) {
|
|
286
|
+
divEl.removeChild(divEl.firstChild!);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return divEl;
|
|
290
|
+
}
|
|
58
291
|
|
|
59
|
-
|
|
292
|
+
isSamePage(reference: PageReference): boolean {
|
|
293
|
+
return (
|
|
294
|
+
this.pageReference.contentDocumentId ===
|
|
295
|
+
reference.contentDocumentId &&
|
|
296
|
+
this.pageReference.docId === reference.docId &&
|
|
297
|
+
this.pageReference.page === reference.page &&
|
|
298
|
+
this.pageReference.deliverable === reference.deliverable
|
|
299
|
+
);
|
|
60
300
|
}
|
|
61
301
|
|
|
62
302
|
handleNavClick(event: InputEvent) {
|
|
63
303
|
event.preventDefault();
|
|
304
|
+
const target = (event.currentTarget! as any).dataset.id;
|
|
305
|
+
const [page, docId, deliverable, tempContentDocumentId] =
|
|
306
|
+
target.split("/");
|
|
307
|
+
const [contentDocumentId, hash] = tempContentDocumentId.split("#");
|
|
308
|
+
const newPageReference = {
|
|
309
|
+
page: page,
|
|
310
|
+
docId: docId,
|
|
311
|
+
deliverable: deliverable,
|
|
312
|
+
contentDocumentId: contentDocumentId,
|
|
313
|
+
hash: hash
|
|
314
|
+
};
|
|
64
315
|
this.dispatchEvent(
|
|
65
316
|
new CustomEvent("navclick", {
|
|
66
317
|
detail: {
|
|
67
|
-
|
|
68
|
-
type: "content"
|
|
318
|
+
pageReference: newPageReference
|
|
69
319
|
},
|
|
70
320
|
bubbles: true,
|
|
71
321
|
composed: true
|
|
72
322
|
})
|
|
73
323
|
);
|
|
324
|
+
|
|
325
|
+
if (this.isSamePage({ ...newPageReference, domain: "" })) {
|
|
326
|
+
this.navigateToHash(window.location.hash);
|
|
327
|
+
}
|
|
74
328
|
}
|
|
75
329
|
|
|
76
|
-
|
|
77
|
-
|
|
330
|
+
updateHighlighted = (event: any) =>
|
|
331
|
+
highlightTerms(
|
|
332
|
+
this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
333
|
+
event.detail
|
|
334
|
+
);
|
|
78
335
|
|
|
79
|
-
|
|
336
|
+
@api
|
|
337
|
+
public navigateToHash = (hash: String) => {
|
|
338
|
+
const splitHash = hash.split("#");
|
|
339
|
+
if (splitHash.length === 2) {
|
|
340
|
+
hash = splitHash[1];
|
|
341
|
+
}
|
|
342
|
+
const anchorEl = this.template.querySelector(`[id='${hash}']`);
|
|
343
|
+
if (anchorEl) {
|
|
344
|
+
anchorEl.scrollIntoView();
|
|
345
|
+
} else {
|
|
346
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
347
|
+
}
|
|
348
|
+
};
|
|
80
349
|
|
|
350
|
+
renderedCallback() {
|
|
351
|
+
if (this._docRendered) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
this.insertDocHtml();
|
|
81
355
|
this._docRendered = true;
|
|
82
356
|
}
|
|
83
357
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
@import "docHelpers/status";
|
|
4
|
+
|
|
5
|
+
.dx-callout {
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.dx-callout-base,
|
|
10
|
+
.dx-callout-plain {
|
|
11
|
+
background-color: var(--dx-g-gray-95);
|
|
12
|
+
border-color: var(--dx-g-gray-50);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dx-callout-plain {
|
|
16
|
+
border: none;
|
|
17
|
+
margin-bottom: var(--dx-g-text-2xl);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.dx-callout-note {
|
|
21
|
+
background-color: var(--dx-g-blue-vibrant-95);
|
|
22
|
+
border-color: var(--dx-g-blue-vibrant-50);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.dx-callout-tip {
|
|
26
|
+
background-color: var(--dx-g-green-natural-95);
|
|
27
|
+
border-color: var(--dx-g-green-vibrant-60);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.dx-callout-caution {
|
|
31
|
+
background-color: var(--dx-g-red-natural-95);
|
|
32
|
+
border-color: var(--dx-g-red-vibrant-50);
|
|
33
|
+
}
|
|
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
|
+
|
|
40
|
+
.dx-callout-base_section {
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.dx-callout-base_section-large {
|
|
45
|
+
width: 100%;
|
|
46
|
+
padding: var(--dx-g-spacing-xl);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* callout column */
|
|
50
|
+
|
|
51
|
+
.dx-callout-base_column {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: row;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dx-callout-content {
|
|
57
|
+
flex: 1;
|
|
58
|
+
overflow: auto;
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class={className}>
|
|
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
|
+
|
|
13
|
+
<div class="dx-callout-content">
|
|
14
|
+
<p class="doc-status-title dx-callout-title dx-text-body-3">
|
|
15
|
+
{header}
|
|
16
|
+
</p>
|
|
17
|
+
<span class="dx-callout-body dx-text-body-3">
|
|
18
|
+
<slot onslotchange={onSlotChange}></slot>
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import { CalloutVariant, LightningSlotElement } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
export default class ContentCallout extends LightningElement {
|
|
6
|
+
@api header!: string;
|
|
7
|
+
@api variant!: CalloutVariant;
|
|
8
|
+
cardVariant?: string;
|
|
9
|
+
iconName?: string;
|
|
10
|
+
iconColor?: string;
|
|
11
|
+
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
switch (this.variant) {
|
|
14
|
+
case "plain":
|
|
15
|
+
this.cardVariant = "dx-callout-plain";
|
|
16
|
+
break;
|
|
17
|
+
case "tip":
|
|
18
|
+
this.cardVariant = "dx-callout-tip";
|
|
19
|
+
this.iconColor = "green-vibrant-60";
|
|
20
|
+
this.iconName = "success";
|
|
21
|
+
break;
|
|
22
|
+
case "warning":
|
|
23
|
+
this.cardVariant = "doc-status-container dx-callout-warning";
|
|
24
|
+
this.iconColor = "red-vibrant-50";
|
|
25
|
+
this.iconName = "warning";
|
|
26
|
+
break;
|
|
27
|
+
case "caution":
|
|
28
|
+
this.cardVariant = "dx-callout-caution";
|
|
29
|
+
this.iconColor = "red-vibrant-50";
|
|
30
|
+
this.iconName = "alert";
|
|
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;
|
|
37
|
+
case "note":
|
|
38
|
+
default:
|
|
39
|
+
this.cardVariant = "dx-callout-note";
|
|
40
|
+
this.iconColor = "blue-vibrant-50";
|
|
41
|
+
this.iconName = "info";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get className() {
|
|
46
|
+
return cx(
|
|
47
|
+
"dx-callout",
|
|
48
|
+
"doc-status-base",
|
|
49
|
+
"dx-callout-base_section",
|
|
50
|
+
"dx-callout-base_column",
|
|
51
|
+
this.cardVariant
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get hideIcon() {
|
|
56
|
+
return this.variant === "plain";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private isSlotEmpty: boolean = true;
|
|
60
|
+
private onSlotChange(e: LightningSlotElement) {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
const slot = e.target;
|
|
63
|
+
this.isSlotEmpty = slot.assignedElements().length === 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "docHelpers/contentLayoutStyle";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="content">
|
|
3
|
+
<template lwc:if={useOldSidebar}>
|
|
4
|
+
<dx-sidebar-old
|
|
5
|
+
class="is-sticky left-nav-bar"
|
|
6
|
+
trees={sidebarContent}
|
|
7
|
+
value={sidebarValue}
|
|
8
|
+
header={sidebarHeader}
|
|
9
|
+
ontogglesidebar={onToggleSidebar}
|
|
10
|
+
languages={languages}
|
|
11
|
+
language={language}
|
|
12
|
+
bail-href={bailHref}
|
|
13
|
+
bail-label={bailLabel}
|
|
14
|
+
dev-center={devCenter}
|
|
15
|
+
brand={brand}
|
|
16
|
+
>
|
|
17
|
+
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
18
|
+
</dx-sidebar-old>
|
|
19
|
+
</template>
|
|
20
|
+
<template lwc:else>
|
|
21
|
+
<dx-sidebar
|
|
22
|
+
class="is-sticky left-nav-bar"
|
|
23
|
+
trees={sidebarContent}
|
|
24
|
+
value={sidebarValue}
|
|
25
|
+
header={sidebarHeader}
|
|
26
|
+
coveo-organization-id={coveoOrganizationId}
|
|
27
|
+
coveo-public-access-token={coveoPublicAccessToken}
|
|
28
|
+
coveo-search-hub={coveoSearchHub}
|
|
29
|
+
coveo-advanced-query-config={coveoAdvancedQueryConfig}
|
|
30
|
+
ontogglesidebar={onToggleSidebar}
|
|
31
|
+
languages={languages}
|
|
32
|
+
language={language}
|
|
33
|
+
bail-href={bailHref}
|
|
34
|
+
bail-label={bailLabel}
|
|
35
|
+
dev-center={devCenter}
|
|
36
|
+
brand={brand}
|
|
37
|
+
>
|
|
38
|
+
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
39
|
+
</dx-sidebar>
|
|
40
|
+
</template>
|
|
41
|
+
<div class="content-body-doc-phase-container">
|
|
42
|
+
<slot name="doc-phase"></slot>
|
|
43
|
+
<slot name="version-banner"></slot>
|
|
44
|
+
<div class="content-body-container">
|
|
45
|
+
<div class="content-body">
|
|
46
|
+
<doc-breadcrumbs
|
|
47
|
+
lwc:if={showBreadcrumbs}
|
|
48
|
+
breadcrumbs={breadcrumbs}
|
|
49
|
+
></doc-breadcrumbs>
|
|
50
|
+
<slot onslotchange={onSlotChange}></slot>
|
|
51
|
+
<doc-sprig-survey
|
|
52
|
+
lwc:if={shouldDisplayFeedback}
|
|
53
|
+
></doc-sprig-survey>
|
|
54
|
+
<doc-edit-file
|
|
55
|
+
file-name="example.txt"
|
|
56
|
+
title="Edit File"
|
|
57
|
+
></doc-edit-file>
|
|
58
|
+
</div>
|
|
59
|
+
<div lwc:if={showToc} class="right-nav-bar is-sticky">
|
|
60
|
+
<dx-toc
|
|
61
|
+
header={tocTitle}
|
|
62
|
+
options={tocOptions}
|
|
63
|
+
value={tocValue}
|
|
64
|
+
></dx-toc>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<div lwc:if={showFooter} class="footer-container">
|
|
68
|
+
<dx-footer variant="no-signup"></dx-footer>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|