@salesforcedevs/docs-components 0.0.5 → 0.0.6-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 +17 -6
- 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 -8
- package/src/modules/doc/content/content.html +3 -2
- package/src/modules/doc/content/content.ts +270 -128
- 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 +21 -10
- package/src/modules/doc/contentLayout/contentLayout.css +1 -0
- package/src/modules/doc/contentLayout/contentLayout.html +68 -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 +511 -0
- package/src/modules/doc/editFile/editFile.html +164 -0
- package/src/modules/doc/editFile/editFile.ts +214 -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/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 +1 -1
- package/src/modules/doc/toolbar/toolbar.html +8 -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 -34
- 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/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,162 +1,277 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-inner-html */
|
|
2
|
-
import { LightningElement, api, track } from "lwc";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
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
|
+
};
|
|
7
29
|
|
|
8
30
|
export default class Content extends LightningElement {
|
|
9
31
|
@api isStorybook: boolean = false;
|
|
10
32
|
@api pageReference!: PageReference;
|
|
11
33
|
@api codeBlockType: string = "card";
|
|
34
|
+
@api showPaginationButtons: boolean = false;
|
|
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
|
-
_codeBlockTheme: string = "dark";
|
|
21
|
-
@api
|
|
22
|
-
set codeBlockTheme(value) {
|
|
23
|
-
this._codeBlockTheme = value;
|
|
24
|
-
}
|
|
25
|
-
get codeBlockTheme() {
|
|
26
|
-
return this._codeBlockTheme;
|
|
27
|
-
}
|
|
28
45
|
|
|
29
46
|
@track docContent: DocContent = "";
|
|
30
47
|
_docRendered: boolean = false;
|
|
31
|
-
|
|
48
|
+
|
|
32
49
|
connectedCallback() {
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
this.
|
|
50
|
+
window.addEventListener(
|
|
51
|
+
"highlightedtermchange",
|
|
52
|
+
this.updateHighlighted
|
|
36
53
|
);
|
|
37
54
|
}
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.updateTheme.bind(this) // eslint-disableline no-use-before-define
|
|
56
|
+
disconnectedCallback(): void {
|
|
57
|
+
window.removeEventListener(
|
|
58
|
+
"highlightedtermchange",
|
|
59
|
+
this.updateHighlighted
|
|
44
60
|
);
|
|
45
61
|
}
|
|
46
62
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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);
|
|
54
79
|
}
|
|
55
80
|
|
|
56
81
|
// We don't use any tracked field here. The challenge is that
|
|
57
82
|
// for security reasons you can't pass pure HTML via a class
|
|
58
83
|
// field to the template. Hence we manipulate the DOM manually.
|
|
59
|
-
insertDocHtml() {
|
|
60
|
-
const divEl = this.
|
|
84
|
+
insertDocHtml(docContent?: string) {
|
|
85
|
+
const divEl = this.getCleanContainer();
|
|
61
86
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.docContent = this.docContent.trim();
|
|
65
|
-
// eslint-disable-next-line no-use-before-define
|
|
66
|
-
templateEl.innerHTML = this.docContent;
|
|
87
|
+
if (divEl) {
|
|
88
|
+
divEl.innerHTML = docContent || this.docContent;
|
|
67
89
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
language = className.split(":")[1];
|
|
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
|
+
}
|
|
81
102
|
}
|
|
82
103
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
updatedURL = href.splice(5).join("/");
|
|
108
|
-
break;
|
|
109
|
-
case 7:
|
|
110
|
-
updatedURL = href.splice(4).join("/");
|
|
111
|
-
break;
|
|
112
|
-
case 6:
|
|
113
|
-
updatedURL = href.splice(3).join("/");
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
updatedURL = href.splice(6).join("/");
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
anchorEl.addEventListener(
|
|
120
|
-
"click",
|
|
121
|
-
// eslint-disable-next-line no-use-before-define
|
|
122
|
-
this.handleNavClick.bind(this)
|
|
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"
|
|
123
128
|
);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
130
139
|
}
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
|
|
141
|
+
if (flag) {
|
|
142
|
+
const codeEls = calloutEl.querySelectorAll(".codeSection");
|
|
143
|
+
codeEls.forEach((codeEl) => {
|
|
144
|
+
calloutCompEl.appendChild(codeEl);
|
|
145
|
+
});
|
|
133
146
|
}
|
|
134
|
-
|
|
135
|
-
|
|
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
|
+
}
|
|
136
172
|
}
|
|
137
|
-
|
|
138
|
-
|
|
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;
|
|
139
178
|
}
|
|
140
|
-
anchorEl.setAttribute("href", updatedURL);
|
|
141
|
-
anchorEl.setAttribute("data-id", updatedURL);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// Modify image src to work with any domain
|
|
146
|
-
const imgEls = templateEl.content.querySelectorAll("img");
|
|
147
|
-
imgEls.forEach((imgEl) => {
|
|
148
|
-
const src = imgEl.src;
|
|
149
|
-
const updatedURL = src.replace(
|
|
150
|
-
this.pageReference.domain,
|
|
151
|
-
"https://developer.salesforce.com"
|
|
152
|
-
);
|
|
153
|
-
imgEl.setAttribute("src", updatedURL);
|
|
154
|
-
});
|
|
155
179
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
});
|
|
160
275
|
}
|
|
161
276
|
|
|
162
277
|
// Once the html has been corectly modified, naviage to the page reference on the page
|
|
@@ -165,13 +280,30 @@ export default class Content extends LightningElement {
|
|
|
165
280
|
}
|
|
166
281
|
}
|
|
167
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
|
+
|
|
168
302
|
handleNavClick(event: InputEvent) {
|
|
169
303
|
event.preventDefault();
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
"/"
|
|
174
|
-
);
|
|
304
|
+
const target = (event.currentTarget! as any).dataset.id;
|
|
305
|
+
const [page, docId, deliverable, tempContentDocumentId] =
|
|
306
|
+
target.split("/");
|
|
175
307
|
const [contentDocumentId, hash] = tempContentDocumentId.split("#");
|
|
176
308
|
const newPageReference = {
|
|
177
309
|
page: page,
|
|
@@ -189,10 +321,20 @@ export default class Content extends LightningElement {
|
|
|
189
321
|
composed: true
|
|
190
322
|
})
|
|
191
323
|
);
|
|
324
|
+
|
|
325
|
+
if (this.isSamePage({ ...newPageReference, domain: "" })) {
|
|
326
|
+
this.navigateToHash(window.location.hash);
|
|
327
|
+
}
|
|
192
328
|
}
|
|
193
329
|
|
|
330
|
+
updateHighlighted = (event: any) =>
|
|
331
|
+
highlightTerms(
|
|
332
|
+
this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
333
|
+
event.detail
|
|
334
|
+
);
|
|
335
|
+
|
|
194
336
|
@api
|
|
195
|
-
public navigateToHash(hash: String) {
|
|
337
|
+
public navigateToHash = (hash: String) => {
|
|
196
338
|
const splitHash = hash.split("#");
|
|
197
339
|
if (splitHash.length === 2) {
|
|
198
340
|
hash = splitHash[1];
|
|
@@ -203,7 +345,7 @@ export default class Content extends LightningElement {
|
|
|
203
345
|
} else {
|
|
204
346
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
205
347
|
}
|
|
206
|
-
}
|
|
348
|
+
};
|
|
207
349
|
|
|
208
350
|
renderedCallback() {
|
|
209
351
|
if (this._docRendered) {
|
|
@@ -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>
|
|
@@ -3,8 +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
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "docHelpers/contentLayoutStyle";
|