@salesforcedevs/docs-components 0.0.4 → 0.0.5-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 +25 -2
- 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 +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 +821 -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 +382 -6
- package/src/modules/doc/content/content.html +3 -2
- package/src/modules/doc/content/content.ts +287 -110
- package/src/modules/doc/contentCallout/contentCallout.css +25 -26
- package/src/modules/doc/contentCallout/contentCallout.html +13 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +22 -11
- package/src/modules/doc/contentLayout/contentLayout.css +13 -0
- package/src/modules/doc/contentLayout/contentLayout.html +73 -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 +4 -2
- package/src/modules/doc/nav/nav.html +8 -13
- package/src/modules/doc/nav/nav.ts +1 -1
- 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.html +11 -6
- package/src/modules/doc/toc/toc.ts +2 -6
- package/src/modules/doc/toolbar/toolbar.html +8 -1
- package/src/modules/doc/toolbar/toolbar.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 +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.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 -82
- package/src/modules/doc/container/container.css +0 -33
- package/src/modules/doc/container/container.html +0 -23
- package/src/modules/doc/container/container.stories.ts +0 -18
- package/src/modules/doc/container/container.ts +0 -360
- package/src/modules/doc/content/__tests__/content.test.ts +0 -30
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -29
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- 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/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 -66
- package/src/modules/doc/prismcss/prismcss.css +0 -184
- package/src/modules/doc/prismjs/prismjs.html +0 -3
- package/src/modules/doc/prismjs/prismjs.ts +0 -1842
- package/src/modules/doc/search/__tests__/search.test.ts +0 -20
- package/src/modules/doc/search/search.html +0 -1
- package/src/modules/doc/search/search.ts +0 -3
- 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,20 +1,44 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-inner-html */
|
|
2
|
-
import { LightningElement, api, track } from "lwc";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
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
|
+
};
|
|
8
29
|
|
|
9
30
|
export default class Content extends LightningElement {
|
|
10
31
|
@api isStorybook: boolean = false;
|
|
11
32
|
@api pageReference!: PageReference;
|
|
33
|
+
@api codeBlockType: string = "card";
|
|
34
|
+
@api showPaginationButtons: boolean = false;
|
|
12
35
|
|
|
13
36
|
@api
|
|
14
37
|
set docsData(value) {
|
|
15
38
|
this._docRendered = false;
|
|
16
|
-
this.docContent = value;
|
|
39
|
+
this.docContent = (value && value.trim()) || "";
|
|
17
40
|
}
|
|
41
|
+
|
|
18
42
|
get docsData() {
|
|
19
43
|
return this.docContent;
|
|
20
44
|
}
|
|
@@ -22,122 +46,266 @@ export default class Content extends LightningElement {
|
|
|
22
46
|
@track docContent: DocContent = "";
|
|
23
47
|
_docRendered: boolean = false;
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
window.addEventListener(
|
|
51
|
+
"highlightedtermchange",
|
|
52
|
+
this.updateHighlighted
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
disconnectedCallback(): void {
|
|
57
|
+
window.removeEventListener(
|
|
58
|
+
"highlightedtermchange",
|
|
59
|
+
this.updateHighlighted
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
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();
|
|
28
86
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Modify anchors to work with any domain
|
|
47
|
-
const anchorEls = templateEl.content.querySelectorAll("a");
|
|
48
|
-
anchorEls.forEach((anchorEl) => {
|
|
49
|
-
let href = anchorEl.href.split("/");
|
|
50
|
-
if (
|
|
51
|
-
(href[3] === this.pageReference.docId && this.isStorybook) ||
|
|
52
|
-
href[4] === this.pageReference.docId ||
|
|
53
|
-
href[6] === this.pageReference.docId
|
|
54
|
-
) {
|
|
55
|
-
let updatedURL;
|
|
56
|
-
switch (href.length) {
|
|
57
|
-
case 8:
|
|
58
|
-
updatedURL = href.splice(5).join("/");
|
|
59
|
-
break;
|
|
60
|
-
case 7:
|
|
61
|
-
updatedURL = href.splice(4).join("/");
|
|
62
|
-
break;
|
|
63
|
-
case 6:
|
|
64
|
-
updatedURL = href.splice(3).join("/");
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
updatedURL = href.splice(6).join("/");
|
|
68
|
-
break;
|
|
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
|
+
}
|
|
102
|
+
}
|
|
69
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
|
+
});
|
|
70
119
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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"
|
|
75
128
|
);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
|
82
139
|
}
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
140
|
+
|
|
141
|
+
if (flag) {
|
|
142
|
+
const codeEls = calloutEl.querySelectorAll(".codeSection");
|
|
143
|
+
codeEls.forEach((codeEl) => {
|
|
144
|
+
calloutCompEl.appendChild(codeEl);
|
|
145
|
+
});
|
|
86
146
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
}
|
|
90
172
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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;
|
|
94
178
|
}
|
|
95
|
-
console.log(updatedURL);
|
|
96
|
-
anchorEl.setAttribute("href", updatedURL);
|
|
97
|
-
anchorEl.setAttribute("data-id", updatedURL);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Modify image src to work with any domain
|
|
102
|
-
const imgEls = templateEl.content.querySelectorAll("img");
|
|
103
|
-
imgEls.forEach((imgEl) => {
|
|
104
|
-
let src = imgEl.src;
|
|
105
|
-
let updatedURL = src.replace(
|
|
106
|
-
this.pageReference.domain,
|
|
107
|
-
"https://developer.salesforce.com"
|
|
108
|
-
);
|
|
109
|
-
imgEl.setAttribute("src", updatedURL);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// We don't use any tracked field here. The challenge is that
|
|
113
|
-
// for security reasons you can't pass pure HTML via a class
|
|
114
|
-
// field to the template. Hence we manipulate the DOM manually.
|
|
115
|
-
if (divEl) {
|
|
116
|
-
divEl.innerHTML = "";
|
|
117
|
-
divEl.append(templateEl.content);
|
|
118
|
-
}
|
|
119
179
|
|
|
120
|
-
|
|
121
|
-
|
|
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
|
+
}
|
|
122
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
|
|
123
278
|
if (this.pageReference.hash) {
|
|
124
279
|
this.navigateToHash(this.pageReference.hash);
|
|
125
280
|
}
|
|
126
281
|
}
|
|
127
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
|
+
}
|
|
291
|
+
|
|
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
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
128
302
|
handleNavClick(event: InputEvent) {
|
|
129
303
|
event.preventDefault();
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
tempContentDocumentId,
|
|
136
|
-
contentDocumentId,
|
|
137
|
-
hash;
|
|
138
|
-
[page, docId, deliverable, tempContentDocumentId] = target.split("/");
|
|
139
|
-
[contentDocumentId, hash] = tempContentDocumentId.split("#");
|
|
140
|
-
let newPageReference = {
|
|
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 = {
|
|
141
309
|
page: page,
|
|
142
310
|
docId: docId,
|
|
143
311
|
deliverable: deliverable,
|
|
@@ -153,11 +321,21 @@ export default class Content extends LightningElement {
|
|
|
153
321
|
composed: true
|
|
154
322
|
})
|
|
155
323
|
);
|
|
324
|
+
|
|
325
|
+
if (this.isSamePage({ ...newPageReference, domain: "" })) {
|
|
326
|
+
this.navigateToHash(window.location.hash);
|
|
327
|
+
}
|
|
156
328
|
}
|
|
157
329
|
|
|
330
|
+
updateHighlighted = (event: any) =>
|
|
331
|
+
highlightTerms(
|
|
332
|
+
this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
333
|
+
event.detail
|
|
334
|
+
);
|
|
335
|
+
|
|
158
336
|
@api
|
|
159
|
-
public navigateToHash(hash: String) {
|
|
160
|
-
|
|
337
|
+
public navigateToHash = (hash: String) => {
|
|
338
|
+
const splitHash = hash.split("#");
|
|
161
339
|
if (splitHash.length === 2) {
|
|
162
340
|
hash = splitHash[1];
|
|
163
341
|
}
|
|
@@ -167,13 +345,12 @@ export default class Content extends LightningElement {
|
|
|
167
345
|
} else {
|
|
168
346
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
169
347
|
}
|
|
170
|
-
}
|
|
348
|
+
};
|
|
171
349
|
|
|
172
350
|
renderedCallback() {
|
|
173
351
|
if (this._docRendered) {
|
|
174
352
|
return;
|
|
175
353
|
}
|
|
176
|
-
|
|
177
354
|
this.insertDocHtml();
|
|
178
355
|
this._docRendered = true;
|
|
179
356
|
}
|
|
@@ -1,60 +1,59 @@
|
|
|
1
|
-
@import "
|
|
2
|
-
@import "
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
@import "docHelpers/status";
|
|
3
4
|
|
|
4
5
|
.dx-callout {
|
|
5
6
|
border-radius: 4px;
|
|
6
|
-
border-left: 4px solid;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.dx-callout-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.dx-callout-base {
|
|
9
|
+
.dx-callout-base,
|
|
10
|
+
.dx-callout-plain {
|
|
14
11
|
background-color: var(--dx-g-gray-95);
|
|
15
12
|
border-color: var(--dx-g-gray-50);
|
|
16
13
|
}
|
|
17
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
|
+
|
|
18
25
|
.dx-callout-tip {
|
|
19
26
|
background-color: var(--dx-g-green-natural-95);
|
|
20
27
|
border-color: var(--dx-g-green-vibrant-60);
|
|
21
28
|
}
|
|
22
29
|
|
|
23
|
-
.dx-callout-
|
|
24
|
-
background-color:
|
|
25
|
-
border-color: var(--dx-g-
|
|
30
|
+
.dx-callout-caution {
|
|
31
|
+
background-color: var(--dx-g-red-natural-95);
|
|
32
|
+
border-color: var(--dx-g-red-vibrant-50);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
.dx-callout-
|
|
35
|
+
.dx-callout-warning {
|
|
29
36
|
background-color: var(--dx-g-red-natural-95);
|
|
30
37
|
border-color: var(--dx-g-red-vibrant-50);
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
.dx-callout-
|
|
40
|
+
.dx-callout-base_section {
|
|
34
41
|
width: 100%;
|
|
35
|
-
padding: var(--dx-g-spacing-md);
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
.dx-callout-
|
|
44
|
+
.dx-callout-base_section-large {
|
|
39
45
|
width: 100%;
|
|
40
46
|
padding: var(--dx-g-spacing-xl);
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
/* callout column */
|
|
44
50
|
|
|
45
|
-
.dx-callout-
|
|
51
|
+
.dx-callout-base_column {
|
|
46
52
|
display: flex;
|
|
47
53
|
flex-direction: row;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
.dx-callout-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.dx-callout-base__column > dx-type-badge-group {
|
|
55
|
-
margin-bottom: var(--dx-g-spacing-sm);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.dx-callout-title {
|
|
59
|
-
font-weight: bold;
|
|
56
|
+
.dx-callout-content {
|
|
57
|
+
flex: 1;
|
|
58
|
+
overflow: auto;
|
|
60
59
|
}
|
|
@@ -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="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>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import { CalloutVariant, LightningSlotElement } from "typings/custom
|
|
3
|
+
import { CalloutVariant, LightningSlotElement } from "typings/custom";
|
|
4
4
|
|
|
5
5
|
export default class ContentCallout extends LightningElement {
|
|
6
|
-
@api
|
|
7
|
-
@api title!: string;
|
|
6
|
+
@api header!: string;
|
|
8
7
|
@api variant!: CalloutVariant;
|
|
9
8
|
cardVariant?: string;
|
|
10
9
|
iconName?: string;
|
|
@@ -12,14 +11,17 @@ export default class ContentCallout extends LightningElement {
|
|
|
12
11
|
|
|
13
12
|
connectedCallback() {
|
|
14
13
|
switch (this.variant) {
|
|
14
|
+
case "plain":
|
|
15
|
+
this.cardVariant = "dx-callout-plain";
|
|
16
|
+
break;
|
|
15
17
|
case "tip":
|
|
16
18
|
this.cardVariant = "dx-callout-tip";
|
|
17
19
|
this.iconColor = "green-vibrant-60";
|
|
18
20
|
this.iconName = "success";
|
|
19
21
|
break;
|
|
20
22
|
case "warning":
|
|
21
|
-
this.cardVariant = "dx-callout-warning";
|
|
22
|
-
this.iconColor = "
|
|
23
|
+
this.cardVariant = "doc-status-container dx-callout-warning";
|
|
24
|
+
this.iconColor = "red-vibrant-50";
|
|
23
25
|
this.iconName = "warning";
|
|
24
26
|
break;
|
|
25
27
|
case "caution":
|
|
@@ -27,10 +29,15 @@ export default class ContentCallout extends LightningElement {
|
|
|
27
29
|
this.iconColor = "red-vibrant-50";
|
|
28
30
|
this.iconName = "alert";
|
|
29
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;
|
|
30
37
|
case "note":
|
|
31
38
|
default:
|
|
32
|
-
this.cardVariant = "dx-callout-
|
|
33
|
-
this.iconColor = "
|
|
39
|
+
this.cardVariant = "dx-callout-note";
|
|
40
|
+
this.iconColor = "blue-vibrant-50";
|
|
34
41
|
this.iconName = "info";
|
|
35
42
|
}
|
|
36
43
|
}
|
|
@@ -38,13 +45,17 @@ export default class ContentCallout extends LightningElement {
|
|
|
38
45
|
get className() {
|
|
39
46
|
return cx(
|
|
40
47
|
"dx-callout",
|
|
41
|
-
"
|
|
42
|
-
"dx-callout-
|
|
43
|
-
|
|
44
|
-
this.
|
|
48
|
+
"doc-status-base",
|
|
49
|
+
"dx-callout-base_section",
|
|
50
|
+
"dx-callout-base_column",
|
|
51
|
+
this.cardVariant
|
|
45
52
|
);
|
|
46
53
|
}
|
|
47
54
|
|
|
55
|
+
get hideIcon() {
|
|
56
|
+
return this.variant === "plain";
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
private isSlotEmpty: boolean = true;
|
|
49
60
|
private onSlotChange(e: LightningSlotElement) {
|
|
50
61
|
// @ts-ignore
|