@salesforcedevs/docs-components 0.3.11 → 0.3.14-banner-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lwc.config.json +12 -3
- package/package.json +17 -7
- package/src/modules/README.md +41 -0
- package/src/modules/doc/amfReference/amfReference.css +5 -0
- package/src/modules/doc/amfReference/amfReference.html +47 -0
- package/src/modules/doc/amfReference/amfReference.ts +1361 -0
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +133 -0
- package/src/modules/doc/amfReference/utils.ts +669 -0
- package/src/modules/doc/amfTopic/amfTopic.css +1 -0
- package/src/modules/doc/amfTopic/amfTopic.html +3 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +94 -0
- package/src/modules/doc/amfTopic/types.ts +54 -0
- package/src/modules/doc/amfTopic/utils.ts +130 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +64 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +60 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +187 -0
- package/src/modules/doc/content/content.css +58 -102
- package/src/modules/doc/content/content.ts +261 -174
- package/src/modules/doc/contentCallout/contentCallout.css +7 -24
- package/src/modules/doc/contentCallout/contentCallout.html +4 -2
- package/src/modules/doc/contentCallout/contentCallout.ts +8 -2
- package/src/modules/doc/contentLayout/contentLayout.css +98 -0
- package/src/modules/doc/contentLayout/contentLayout.html +51 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +322 -0
- package/src/modules/doc/header/header.css +103 -0
- package/src/modules/doc/header/header.html +160 -0
- package/src/modules/doc/header/header.ts +146 -0
- package/src/modules/doc/heading/heading.css +54 -0
- package/src/modules/doc/heading/heading.html +14 -0
- package/src/modules/doc/heading/heading.ts +65 -0
- package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
- package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
- package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
- package/src/modules/doc/headingContent/headingContent.css +53 -0
- package/src/modules/doc/headingContent/headingContent.html +13 -0
- package/src/modules/doc/headingContent/headingContent.ts +30 -0
- package/src/modules/doc/phase/phase.css +55 -0
- package/src/modules/doc/phase/phase.html +28 -0
- package/src/modules/doc/phase/phase.ts +57 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +12 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/toc/toc.html +3 -1
- package/src/modules/doc/toolbar/toolbar.ts +6 -6
- package/src/modules/doc/xmlContent/types.ts +114 -0
- package/src/modules/doc/xmlContent/utils.ts +161 -0
- package/src/modules/doc/xmlContent/xmlContent.css +32 -0
- package/src/modules/doc/xmlContent/xmlContent.html +40 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +677 -0
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +39 -0
- package/src/modules/docHelpers/status/status.css +22 -0
- package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +85 -0
- package/LICENSE +0 -12
- package/src/modules/doc/container/__benchmarks__/container.benchmark.js +0 -43
- package/src/modules/doc/container/__mocks__/mockAvailableLanguages.js +0 -8
- package/src/modules/doc/container/__mocks__/mockAvailableVersions.js +0 -122
- package/src/modules/doc/container/__mocks__/mockContentFetchResponse.json +0 -5
- package/src/modules/doc/container/__mocks__/mockDocContent.js +0 -29
- package/src/modules/doc/container/__mocks__/mockNavigationFetchResponse.json +0 -4061
- package/src/modules/doc/container/__mocks__/mockPageReference.js +0 -8
- package/src/modules/doc/container/__mocks__/mockPdfUrl.js +0 -1
- package/src/modules/doc/container/__mocks__/mockSelectedLanguage.js +0 -8
- package/src/modules/doc/container/__mocks__/mockSelectedVersion.js +0 -8
- package/src/modules/doc/container/__mocks__/mockToc.js +0 -146
- package/src/modules/doc/container/__tests__/container.test.ts +0 -117
- package/src/modules/doc/container/container.css +0 -37
- package/src/modules/doc/container/container.html +0 -28
- package/src/modules/doc/container/container.stories.ts +0 -44
- package/src/modules/doc/container/container.ts +0 -367
- package/src/modules/doc/content/__tests__/content.test.ts +0 -99
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -258
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/content/content.stories.ts +0 -82
- package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
- package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
- package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
- package/src/modules/doc/contentMedia/__tests__/contentMedia.test.ts +0 -97
- package/src/modules/doc/contentMedia/contentMedia.stories.ts +0 -113
- package/src/modules/doc/landing/__tests__/landing.test.ts +0 -60
- package/src/modules/doc/landing/__tests__/mockFetch.json +0 -370
- package/src/modules/doc/landing/landing.css +0 -63
- package/src/modules/doc/landing/landing.html +0 -122
- package/src/modules/doc/landing/landing.stories.ts +0 -21
- package/src/modules/doc/landing/landing.ts +0 -222
- package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/nav/__tests__/nav.test.ts +0 -58
- package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
- package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
|
@@ -1,40 +1,79 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-inner-html */
|
|
2
2
|
import { createElement, LightningElement, api, track } from "lwc";
|
|
3
|
-
import { DocContent, PageReference } from "
|
|
3
|
+
import { DocContent, PageReference } from "typings/custom";
|
|
4
4
|
import ContentCallout from "doc/contentCallout";
|
|
5
5
|
import CodeBlock from "dx/codeBlock";
|
|
6
6
|
import ContentMedia from "doc/contentMedia";
|
|
7
7
|
import Button from "dx/button";
|
|
8
|
+
import { highlightTerms } from "dxUtils/highlight";
|
|
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;
|
|
12
33
|
@api codeBlockType: string = "card";
|
|
34
|
+
@api showPaginationButtons: boolean = false;
|
|
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
|
}
|
|
21
|
-
|
|
45
|
+
|
|
22
46
|
@api
|
|
23
47
|
set codeBlockTheme(value) {
|
|
24
48
|
this._codeBlockTheme = value;
|
|
25
49
|
}
|
|
50
|
+
|
|
26
51
|
get codeBlockTheme() {
|
|
27
52
|
return this._codeBlockTheme;
|
|
28
53
|
}
|
|
29
54
|
|
|
30
55
|
@track docContent: DocContent = "";
|
|
56
|
+
_codeBlockTheme: string = "dark";
|
|
31
57
|
_docRendered: boolean = false;
|
|
32
58
|
originalCodeBlockThemeValue: String = "";
|
|
59
|
+
|
|
33
60
|
connectedCallback() {
|
|
34
61
|
this.template.addEventListener(
|
|
35
62
|
"themechange",
|
|
36
63
|
this.updateTheme.bind(this) // eslint-disableline no-use-before-define
|
|
37
64
|
);
|
|
65
|
+
|
|
66
|
+
window.addEventListener(
|
|
67
|
+
"highlightedtermchange",
|
|
68
|
+
this.updateHighlighted
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
disconnectedCallback(): void {
|
|
73
|
+
window.removeEventListener(
|
|
74
|
+
"highlightedtermchange",
|
|
75
|
+
this.updateHighlighted
|
|
76
|
+
);
|
|
38
77
|
}
|
|
39
78
|
|
|
40
79
|
updateTheme() {
|
|
@@ -46,193 +85,213 @@ export default class Content extends LightningElement {
|
|
|
46
85
|
});
|
|
47
86
|
}
|
|
48
87
|
|
|
88
|
+
renderPaginationButton(anchorEl: HTMLElement) {
|
|
89
|
+
const isNext = anchorEl.textContent.includes("Next →");
|
|
90
|
+
anchorEl.innerHTML = "";
|
|
91
|
+
const buttonEl = createElement("dx-button", { is: Button });
|
|
92
|
+
const params = isNext
|
|
93
|
+
? { iconSymbol: "chevronright" }
|
|
94
|
+
: {
|
|
95
|
+
iconPosition: "left",
|
|
96
|
+
iconSymbol: "chevronleft",
|
|
97
|
+
variant: "secondary"
|
|
98
|
+
};
|
|
99
|
+
Object.assign(buttonEl, params);
|
|
100
|
+
const textEl = document.createDocumentFragment();
|
|
101
|
+
textEl.textContent = isNext ? "Next" : "Previous";
|
|
102
|
+
buttonEl.appendChild(textEl);
|
|
103
|
+
anchorEl.appendChild(buttonEl);
|
|
104
|
+
}
|
|
105
|
+
|
|
49
106
|
// We don't use any tracked field here. The challenge is that
|
|
50
107
|
// for security reasons you can't pass pure HTML via a class
|
|
51
108
|
// field to the template. Hence we manipulate the DOM manually.
|
|
52
|
-
insertDocHtml() {
|
|
53
|
-
const divEl = this.
|
|
109
|
+
insertDocHtml(docContent?: string) {
|
|
110
|
+
const divEl = this.getCleanContainer();
|
|
54
111
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.docContent = this.docContent.trim();
|
|
58
|
-
// eslint-disable-next-line no-use-before-define
|
|
59
|
-
templateEl.innerHTML = this.docContent;
|
|
112
|
+
if (divEl) {
|
|
113
|
+
divEl.innerHTML = docContent || this.docContent;
|
|
60
114
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
language = className.split(":")[1];
|
|
115
|
+
// Query the code blocks and create a dx-code-block component that contains the code
|
|
116
|
+
const codeBlockEls = divEl.querySelectorAll(".codeSection");
|
|
117
|
+
codeBlockEls.forEach((codeBlockEl) => {
|
|
118
|
+
codeBlockEl.setAttribute("lwc:dom", "manual");
|
|
119
|
+
const classList = codeBlockEl.firstChild.classList;
|
|
120
|
+
let language = "";
|
|
121
|
+
for (const key in classList) {
|
|
122
|
+
if (typeof classList[key] === "string") {
|
|
123
|
+
const className = classList[key];
|
|
124
|
+
if (className.startsWith("brush:")) {
|
|
125
|
+
language = className.split(":")[1];
|
|
126
|
+
}
|
|
74
127
|
}
|
|
75
128
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const calloutEls = templateEl.content.querySelectorAll(".message");
|
|
92
|
-
calloutEls.forEach((calloutEl) => {
|
|
93
|
-
const calloutCompEl = createElement("doc-content-callout", {
|
|
94
|
-
is: ContentCallout
|
|
95
|
-
});
|
|
96
|
-
const detailEls = calloutEl.querySelectorAll(
|
|
97
|
-
"p, div.data, ol, ul, .codeSection, .mediaBd > span.ph"
|
|
98
|
-
);
|
|
99
|
-
detailEls.forEach((detailEl) => {
|
|
100
|
-
calloutCompEl.appendChild(detailEl);
|
|
101
|
-
});
|
|
102
|
-
const type = calloutEl.querySelector("h4").textContent;
|
|
103
|
-
const typeLower = type.toLowerCase();
|
|
104
|
-
Object.assign(calloutCompEl, {
|
|
105
|
-
title: type,
|
|
106
|
-
variant: typeLower
|
|
129
|
+
const blockCmp = createElement("dx-code-block", {
|
|
130
|
+
is: CodeBlock
|
|
131
|
+
});
|
|
132
|
+
Object.assign(blockCmp, {
|
|
133
|
+
codeBlock: codeBlockEl.innerHTML,
|
|
134
|
+
// ! Hot fix for incoming html tags from couchdb for xml blocks, fix me soon please
|
|
135
|
+
language: LANGUAGE_MAP[language] || language,
|
|
136
|
+
theme: this.codeBlockTheme,
|
|
137
|
+
title: "", // Default no title.
|
|
138
|
+
variant: this.codeBlockType,
|
|
139
|
+
isEncoded: true
|
|
140
|
+
});
|
|
141
|
+
// eslint-disable-next-line no-use-before-define
|
|
142
|
+
codeBlockEl.innerHTML = "";
|
|
143
|
+
codeBlockEl.appendChild(blockCmp);
|
|
107
144
|
});
|
|
108
|
-
// eslint-disable-next-line no-use-before-define
|
|
109
|
-
calloutEl.innerHTML = "";
|
|
110
|
-
calloutEl.appendChild(calloutCompEl);
|
|
111
|
-
});
|
|
112
145
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const buttonEl = createElement("dx-button", { is: Button });
|
|
119
|
-
Object.assign(buttonEl, {
|
|
120
|
-
iconSymbol: "chevronright"
|
|
121
|
-
});
|
|
122
|
-
const textEl = document.createDocumentFragment();
|
|
123
|
-
textEl.textContent = "Next";
|
|
124
|
-
buttonEl.appendChild(textEl);
|
|
125
|
-
anchorEl.appendChild(buttonEl);
|
|
126
|
-
}
|
|
127
|
-
if (anchorEl.textContent.includes("← Previous")) {
|
|
128
|
-
anchorEl.innerHTML = "";
|
|
129
|
-
const buttonEl = createElement("dx-button", { is: Button });
|
|
130
|
-
Object.assign(buttonEl, {
|
|
131
|
-
iconPosition: "left",
|
|
132
|
-
iconSymbol: "chevronleft",
|
|
133
|
-
variant: "secondary"
|
|
146
|
+
// Query the callouts and create a doc-content-callout component that contains the code
|
|
147
|
+
const calloutEls = divEl.querySelectorAll(".message");
|
|
148
|
+
calloutEls.forEach((calloutEl) => {
|
|
149
|
+
const calloutCompEl = createElement("doc-content-callout", {
|
|
150
|
+
is: ContentCallout
|
|
134
151
|
});
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
buttonEl.appendChild(textEl);
|
|
138
|
-
anchorEl.appendChild(buttonEl);
|
|
139
|
-
}
|
|
140
|
-
const href = anchorEl.href.split("/");
|
|
141
|
-
if (
|
|
142
|
-
(href[3] === this.pageReference.docId && this.isStorybook) ||
|
|
143
|
-
href[4] === this.pageReference.docId ||
|
|
144
|
-
href[6] === this.pageReference.docId
|
|
145
|
-
) {
|
|
146
|
-
let updatedURL;
|
|
147
|
-
switch (href.length) {
|
|
148
|
-
case 8:
|
|
149
|
-
updatedURL = href.splice(5).join("/");
|
|
150
|
-
break;
|
|
151
|
-
case 7:
|
|
152
|
-
updatedURL = href.splice(4).join("/");
|
|
153
|
-
break;
|
|
154
|
-
case 6:
|
|
155
|
-
updatedURL = href.splice(3).join("/");
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
updatedURL = href.splice(6).join("/");
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
anchorEl.addEventListener(
|
|
162
|
-
"click",
|
|
163
|
-
// eslint-disable-next-line no-use-before-define
|
|
164
|
-
this.handleNavClick.bind(this)
|
|
152
|
+
const detailEls = calloutEl.querySelectorAll(
|
|
153
|
+
"p, .p, div.data, ol, ul, p+.codeSection, p~.codeSection, div >.codeSection, .mediaBd > span.ph"
|
|
165
154
|
);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
155
|
+
detailEls.forEach((detailEl) => {
|
|
156
|
+
if (detailEl.innerHTML.trim() !== "") {
|
|
157
|
+
calloutCompEl.appendChild(detailEl);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
let flag = 1;
|
|
162
|
+
for (let i: number = 0; i < detailEls.length; i++) {
|
|
163
|
+
flag &= detailEls[i].innerHTML.trim() === "";
|
|
172
164
|
}
|
|
173
|
-
|
|
174
|
-
|
|
165
|
+
|
|
166
|
+
if (flag) {
|
|
167
|
+
const codeEls = calloutEl.querySelectorAll(".codeSection");
|
|
168
|
+
codeEls.forEach((codeEl) => {
|
|
169
|
+
calloutCompEl.appendChild(codeEl);
|
|
170
|
+
});
|
|
175
171
|
}
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
|
|
173
|
+
const type = calloutEl.querySelector("h4").textContent;
|
|
174
|
+
const typeLower = type.toLowerCase();
|
|
175
|
+
Object.assign(calloutCompEl, {
|
|
176
|
+
title: type,
|
|
177
|
+
variant: typeLower
|
|
178
|
+
});
|
|
179
|
+
// eslint-disable-next-line no-use-before-define
|
|
180
|
+
calloutEl.innerHTML = "";
|
|
181
|
+
calloutEl.appendChild(calloutCompEl);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Modify links to work with any domain, links that start with "#" are excluded
|
|
185
|
+
const anchorEls = divEl.querySelectorAll("a:not([href^='#'])");
|
|
186
|
+
|
|
187
|
+
anchorEls.forEach((anchorEl) => {
|
|
188
|
+
if (
|
|
189
|
+
anchorEl.textContent.includes("Next →") ||
|
|
190
|
+
anchorEl.textContent.includes("← Previous")
|
|
191
|
+
) {
|
|
192
|
+
if (this.showPaginationButtons) {
|
|
193
|
+
this.renderPaginationButton(anchorEl);
|
|
194
|
+
} else {
|
|
195
|
+
anchorEl.remove();
|
|
196
|
+
}
|
|
178
197
|
}
|
|
179
|
-
|
|
180
|
-
|
|
198
|
+
|
|
199
|
+
// ! This is a hack
|
|
200
|
+
// Normalize urls in case it doesn't come complete.
|
|
201
|
+
if (anchorEl.href.startsWith("atlas.")) {
|
|
202
|
+
anchorEl.href = "/docs/" + anchorEl.href;
|
|
181
203
|
}
|
|
182
|
-
anchorEl.setAttribute("href", updatedURL);
|
|
183
|
-
anchorEl.setAttribute("data-id", updatedURL);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
204
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
const href = anchorEl.href.split("/");
|
|
206
|
+
if (
|
|
207
|
+
(href[3] === this.pageReference.docId &&
|
|
208
|
+
this.isStorybook) ||
|
|
209
|
+
href[4] === this.pageReference.docId ||
|
|
210
|
+
href[6] === this.pageReference.docId
|
|
211
|
+
) {
|
|
212
|
+
let updatedURL;
|
|
213
|
+
switch (href.length) {
|
|
214
|
+
case 8:
|
|
215
|
+
updatedURL = href.splice(5).join("/");
|
|
216
|
+
break;
|
|
217
|
+
case 7:
|
|
218
|
+
updatedURL = href.splice(4).join("/");
|
|
219
|
+
break;
|
|
220
|
+
case 6:
|
|
221
|
+
updatedURL = href.splice(3).join("/");
|
|
222
|
+
break;
|
|
223
|
+
default:
|
|
224
|
+
updatedURL = href.splice(6).join("/");
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
anchorEl.addEventListener(
|
|
228
|
+
"click",
|
|
229
|
+
// eslint-disable-next-line no-use-before-define
|
|
230
|
+
this.handleNavClick.bind(this)
|
|
231
|
+
);
|
|
232
|
+
// anchor href event is not propagated here as we want SPA nature.
|
|
233
|
+
// But in prerender.io - as javascript is not executed, we want the anchor links are proper (absolute urls).
|
|
234
|
+
anchorEl.setAttribute("href", "/docs/" + updatedURL);
|
|
235
|
+
anchorEl.setAttribute("data-id", "docs/" + updatedURL);
|
|
236
|
+
return;
|
|
212
237
|
}
|
|
213
|
-
|
|
214
|
-
|
|
238
|
+
|
|
239
|
+
anchorEl.setAttribute("data-id", anchorEl.href);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Modify image src to work with any domain and replace images/iframes with doc-content-media
|
|
243
|
+
const imgEls = divEl.querySelectorAll("img, iframe");
|
|
244
|
+
|
|
245
|
+
imgEls.forEach((mediaEl) => {
|
|
246
|
+
const isImage = mediaEl.nodeName === "IMG";
|
|
247
|
+
let src = mediaEl.getAttribute("src");
|
|
248
|
+
if (!src) {
|
|
249
|
+
return;
|
|
215
250
|
}
|
|
216
|
-
|
|
217
|
-
mediaEl.
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
});
|
|
222
|
-
Object.assign(contentMediaEl, {
|
|
223
|
-
contentType: "iframe",
|
|
224
|
-
contentSrc: src,
|
|
225
|
-
mediaTitle: alt || title || label
|
|
226
|
-
});
|
|
227
|
-
mediaEl.parentNode!.insertBefore(contentMediaEl, mediaEl);
|
|
228
|
-
}
|
|
229
|
-
mediaEl.remove();
|
|
230
|
-
});
|
|
251
|
+
const alt = mediaEl.getAttribute("alt");
|
|
252
|
+
const title = mediaEl.getAttribute("title");
|
|
253
|
+
const label = mediaEl.getAttribute("label");
|
|
254
|
+
const width = mediaEl.getAttribute("width");
|
|
255
|
+
const height = mediaEl.getAttribute("height");
|
|
231
256
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
257
|
+
if (isImage) {
|
|
258
|
+
src = src.startsWith("/")
|
|
259
|
+
? `https://developer.salesforce.com${src}`
|
|
260
|
+
: src.replace(
|
|
261
|
+
window.location.origin,
|
|
262
|
+
"https://developer.salesforce.com"
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const img: HTMLImageElement = document.createElement("img");
|
|
266
|
+
img.src = src;
|
|
267
|
+
if (alt) {
|
|
268
|
+
img.alt = alt;
|
|
269
|
+
}
|
|
270
|
+
if (title) {
|
|
271
|
+
img.title = title;
|
|
272
|
+
}
|
|
273
|
+
if (height) {
|
|
274
|
+
img.height = parseFloat(height);
|
|
275
|
+
}
|
|
276
|
+
if (width) {
|
|
277
|
+
img.width = parseFloat(width);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
img.className = "content-image";
|
|
281
|
+
mediaEl.parentNode!.insertBefore(img, mediaEl);
|
|
282
|
+
} else {
|
|
283
|
+
const contentMediaEl = createElement("doc-content-media", {
|
|
284
|
+
is: ContentMedia
|
|
285
|
+
});
|
|
286
|
+
Object.assign(contentMediaEl, {
|
|
287
|
+
contentType: "iframe",
|
|
288
|
+
contentSrc: src,
|
|
289
|
+
mediaTitle: alt || title || label
|
|
290
|
+
});
|
|
291
|
+
mediaEl.parentNode!.insertBefore(contentMediaEl, mediaEl);
|
|
292
|
+
}
|
|
293
|
+
mediaEl.remove();
|
|
294
|
+
});
|
|
236
295
|
}
|
|
237
296
|
|
|
238
297
|
// Once the html has been corectly modified, naviage to the page reference on the page
|
|
@@ -241,13 +300,31 @@ export default class Content extends LightningElement {
|
|
|
241
300
|
}
|
|
242
301
|
}
|
|
243
302
|
|
|
303
|
+
private getCleanContainer(): HTMLElement | null {
|
|
304
|
+
const divEl = this.template.querySelector("div");
|
|
305
|
+
if (divEl?.hasChildNodes()) {
|
|
306
|
+
divEl.removeChild(divEl.firstChild!);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return divEl;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
isSamePage(reference: PageReference): boolean {
|
|
313
|
+
return (
|
|
314
|
+
this.pageReference.contentDocumentId ===
|
|
315
|
+
reference.contentDocumentId &&
|
|
316
|
+
this.pageReference.docId === reference.docId &&
|
|
317
|
+
this.pageReference.page === reference.page &&
|
|
318
|
+
this.pageReference.deliverable === reference.deliverable
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
244
322
|
handleNavClick(event: InputEvent) {
|
|
245
323
|
event.preventDefault();
|
|
246
324
|
// eslint-disable-next-line no-use-before-define
|
|
247
325
|
const target = event.currentTarget.dataset.id;
|
|
248
|
-
const [page, docId, deliverable, tempContentDocumentId] =
|
|
249
|
-
"/"
|
|
250
|
-
);
|
|
326
|
+
const [page, docId, deliverable, tempContentDocumentId] =
|
|
327
|
+
target.split("/");
|
|
251
328
|
const [contentDocumentId, hash] = tempContentDocumentId.split("#");
|
|
252
329
|
const newPageReference = {
|
|
253
330
|
page: page,
|
|
@@ -265,8 +342,18 @@ export default class Content extends LightningElement {
|
|
|
265
342
|
composed: true
|
|
266
343
|
})
|
|
267
344
|
);
|
|
345
|
+
|
|
346
|
+
if (this.isSamePage({ ...newPageReference, domain: "" })) {
|
|
347
|
+
this.navigateToHash(window.location.hash);
|
|
348
|
+
}
|
|
268
349
|
}
|
|
269
350
|
|
|
351
|
+
updateHighlighted = (event: any) =>
|
|
352
|
+
highlightTerms(
|
|
353
|
+
this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
354
|
+
event.detail
|
|
355
|
+
);
|
|
356
|
+
|
|
270
357
|
@api
|
|
271
358
|
public navigateToHash(hash: String) {
|
|
272
359
|
const splitHash = hash.split("#");
|
|
@@ -1,13 +1,9 @@
|
|
|
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
|
-
}
|
|
8
|
-
|
|
9
|
-
.dx-callout-icon {
|
|
10
|
-
padding-right: var(--dx-g-spacing-md);
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
.dx-callout-base {
|
|
@@ -25,19 +21,18 @@
|
|
|
25
21
|
border-color: var(--dx-g-green-vibrant-60);
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
.dx-callout-
|
|
29
|
-
background-color:
|
|
30
|
-
border-color: var(--dx-g-
|
|
24
|
+
.dx-callout-caution {
|
|
25
|
+
background-color: var(--dx-g-red-natural-95);
|
|
26
|
+
border-color: var(--dx-g-red-vibrant-50);
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
.dx-callout-
|
|
29
|
+
.dx-callout-warning {
|
|
34
30
|
background-color: var(--dx-g-red-natural-95);
|
|
35
31
|
border-color: var(--dx-g-red-vibrant-50);
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
.dx-callout-base_section {
|
|
39
35
|
width: 100%;
|
|
40
|
-
padding: var(--dx-g-spacing-md);
|
|
41
36
|
}
|
|
42
37
|
|
|
43
38
|
.dx-callout-base_section-large {
|
|
@@ -51,15 +46,3 @@
|
|
|
51
46
|
display: flex;
|
|
52
47
|
flex-direction: row;
|
|
53
48
|
}
|
|
54
|
-
|
|
55
|
-
.dx-callout-base_column > *:not(:last-child):not(dx-type-badge-group) {
|
|
56
|
-
margin-bottom: var(--dx-g-spacing-sm);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.dx-callout-base_column > dx-type-badge-group {
|
|
60
|
-
margin-bottom: var(--dx-g-spacing-sm);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.dx-callout-title {
|
|
64
|
-
font-weight: bold;
|
|
65
|
-
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class={className}>
|
|
3
|
-
<div class="dx-callout-icon">
|
|
3
|
+
<div class="doc-status-icon dx-callout-icon">
|
|
4
4
|
<dx-icon symbol={iconName} size="large" color={iconColor}></dx-icon>
|
|
5
5
|
</div>
|
|
6
6
|
<div class="dx-callout-content">
|
|
7
|
-
<p class="dx-callout-title dx-text-body-3">
|
|
7
|
+
<p class="doc-status-title dx-callout-title dx-text-body-3">
|
|
8
|
+
{title}
|
|
9
|
+
</p>
|
|
8
10
|
<span class="dx-callout-body dx-text-body-3">
|
|
9
11
|
<slot onslotchange={onSlotChange}></slot>
|
|
10
12
|
</span>
|
|
@@ -17,8 +17,8 @@ export default class ContentCallout extends LightningElement {
|
|
|
17
17
|
this.iconName = "success";
|
|
18
18
|
break;
|
|
19
19
|
case "warning":
|
|
20
|
-
this.cardVariant = "dx-callout-warning";
|
|
21
|
-
this.iconColor = "
|
|
20
|
+
this.cardVariant = "doc-status-container dx-callout-warning";
|
|
21
|
+
this.iconColor = "red-vibrant-50";
|
|
22
22
|
this.iconName = "warning";
|
|
23
23
|
break;
|
|
24
24
|
case "caution":
|
|
@@ -26,6 +26,11 @@ export default class ContentCallout extends LightningElement {
|
|
|
26
26
|
this.iconColor = "red-vibrant-50";
|
|
27
27
|
this.iconName = "alert";
|
|
28
28
|
break;
|
|
29
|
+
case "important":
|
|
30
|
+
this.cardVariant = "doc-status-container dx-callout-important";
|
|
31
|
+
this.iconColor = "gray-10";
|
|
32
|
+
this.iconName = "announcement";
|
|
33
|
+
break;
|
|
29
34
|
case "note":
|
|
30
35
|
default:
|
|
31
36
|
this.cardVariant = "dx-callout-note";
|
|
@@ -37,6 +42,7 @@ export default class ContentCallout extends LightningElement {
|
|
|
37
42
|
get className() {
|
|
38
43
|
return cx(
|
|
39
44
|
"dx-callout",
|
|
45
|
+
"doc-status-base",
|
|
40
46
|
"dx-callout-base_section",
|
|
41
47
|
"dx-callout-base_column",
|
|
42
48
|
this.cardVariant
|