@salesforcedevs/docs-components 1.14.8-alpha1 → 1.14.8-alpha101
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/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import Button from "dx/button";
|
|
|
6
6
|
import { highlightTerms } from "dxUtils/highlight";
|
|
7
7
|
import ContentCallout from "doc/contentCallout";
|
|
8
8
|
import ContentMedia from "doc/contentMedia";
|
|
9
|
+
import { normalizeHtmlEntities } from "docUtils/utils";
|
|
9
10
|
|
|
10
11
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
12
|
"p",
|
|
@@ -36,7 +37,7 @@ export default class Content extends LightningElement {
|
|
|
36
37
|
@api
|
|
37
38
|
set docsData(value) {
|
|
38
39
|
this._docRendered = false;
|
|
39
|
-
this.docContent = (value && value.trim()) || "";
|
|
40
|
+
this.docContent = (value && normalizeHtmlEntities(value.trim())) || "";
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
get docsData() {
|
|
@@ -110,7 +111,7 @@ export default class Content extends LightningElement {
|
|
|
110
111
|
const divEl = this.getCleanContainer();
|
|
111
112
|
|
|
112
113
|
if (divEl) {
|
|
113
|
-
divEl.innerHTML = docContent || this.docContent;
|
|
114
|
+
divEl.innerHTML = normalizeHtmlEntities(docContent || this.docContent);
|
|
114
115
|
|
|
115
116
|
// Query the code blocks and create a dx-code-block component that contains the code
|
|
116
117
|
const codeBlockEls = divEl.querySelectorAll(".codeSection");
|
|
@@ -72,22 +72,21 @@ export class FetchContent {
|
|
|
72
72
|
deliverable: string,
|
|
73
73
|
contentId: string,
|
|
74
74
|
options: ContentApiOptions
|
|
75
|
-
): Promise<
|
|
76
|
-
|
|
77
|
-
return this.fetchResource<ContentData>(
|
|
75
|
+
): Promise<String> {
|
|
76
|
+
return this.fetchResource<String>(
|
|
78
77
|
`/cx-router/dsc/topic?projectId=sfdocs-asl_dev_guide&projectVersion=254-7-dev&locale=en-us&topic=${contentId}`
|
|
79
78
|
);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
private async fetchResource<T>(url: string): Promise<T> {
|
|
83
82
|
const response = await fetch(url);
|
|
84
|
-
if (!response.ok) {
|
|
83
|
+
/*if (!response.ok) {
|
|
85
84
|
throw new Error(response.statusText);
|
|
86
|
-
}
|
|
85
|
+
}*/
|
|
87
86
|
|
|
88
87
|
const json = await response.json();
|
|
89
88
|
|
|
90
|
-
return json;
|
|
89
|
+
return json.response;
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
private normalizeToc(apiToc: Array<ApiNavItem>): {
|
|
@@ -30,3 +30,23 @@ export function logCoveoPageView(
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
export function normalizeHtmlEntities(str: string): string {
|
|
35
|
+
if (typeof str !== 'string') {
|
|
36
|
+
return str;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// First decode any double-encoded entities
|
|
40
|
+
const tempDiv = document.createElement('div');
|
|
41
|
+
tempDiv.innerHTML = str;
|
|
42
|
+
const decoded = tempDiv.textContent || tempDiv.innerText;
|
|
43
|
+
|
|
44
|
+
// Then properly encode special characters
|
|
45
|
+
return decoded
|
|
46
|
+
.replace(/&/g, '&')
|
|
47
|
+
.replace(/</g, '<')
|
|
48
|
+
.replace(/>/g, '>')
|
|
49
|
+
.replace(/"/g, '"')
|
|
50
|
+
.replace(/'/g, ''')
|
|
51
|
+
.replace(/\u00A0/g, ' '); // Handle non-breaking space
|
|
52
|
+
}
|