@salesforcedevs/docs-components 1.14.6-loader → 1.14.8-alpha100
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 +1 -1
- package/src/modules/doc/content/content.ts +3 -2
- package/src/modules/doc/specificationContent/specificationContent.css +5 -0
- package/src/modules/doc/specificationContent/specificationContent.html +1 -0
- package/src/modules/doc/xmlContent/utils.ts +10 -10
- package/src/modules/doc/xmlContent/xmlContent.ts +1 -1
- package/src/modules/docUtils/htmlEntities.ts +25 -0
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/htmlEntities";
|
|
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");
|
|
@@ -38,9 +38,11 @@ export class FetchContent {
|
|
|
38
38
|
pdf_url,
|
|
39
39
|
deliverable
|
|
40
40
|
} = await this.fetchResource<ApiDocData>(
|
|
41
|
-
|
|
41
|
+
`/cx-router/dsc/toc?projectId=sfdocs-asl_dev_guide&projectVersion=254-7-dev&locale=en-us`
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
+
console.log(docId);
|
|
45
|
+
|
|
44
46
|
const { normalizedToc, tocMap } = this.normalizeToc(toc);
|
|
45
47
|
return {
|
|
46
48
|
availableLanguages:
|
|
@@ -70,26 +72,24 @@ export class FetchContent {
|
|
|
70
72
|
deliverable: string,
|
|
71
73
|
contentId: string,
|
|
72
74
|
options: ContentApiOptions
|
|
73
|
-
): Promise<
|
|
74
|
-
return this.fetchResource<
|
|
75
|
-
|
|
75
|
+
): Promise<String> {
|
|
76
|
+
return this.fetchResource<String>(
|
|
77
|
+
`/cx-router/dsc/topic?projectId=sfdocs-asl_dev_guide&projectVersion=254-7-dev&locale=en-us&topic=${contentId}`
|
|
76
78
|
);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
private async fetchResource<T>(url: string): Promise<T> {
|
|
80
82
|
const response = await fetch(url);
|
|
81
|
-
if (!response.ok) {
|
|
83
|
+
/*if (!response.ok) {
|
|
82
84
|
throw new Error(response.statusText);
|
|
83
|
-
}
|
|
85
|
+
}*/
|
|
84
86
|
|
|
85
87
|
const json = await response.json();
|
|
86
88
|
|
|
87
|
-
return json;
|
|
89
|
+
return json.response;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
private normalizeToc(
|
|
91
|
-
apiToc: Array<ApiNavItem>
|
|
92
|
-
): {
|
|
92
|
+
private normalizeToc(apiToc: Array<ApiNavItem>): {
|
|
93
93
|
tocMap: { [key: string]: TreeNode };
|
|
94
94
|
normalizedToc: Array<TreeNode>;
|
|
95
95
|
} {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes HTML entities in a string by first decoding any double-encoded entities
|
|
3
|
+
* and then properly encoding special characters
|
|
4
|
+
* @param str The string to normalize
|
|
5
|
+
* @returns The normalized string with properly encoded HTML entities
|
|
6
|
+
*/
|
|
7
|
+
export const normalizeHtmlEntities = (str: string): string => {
|
|
8
|
+
if (typeof str !== 'string') {
|
|
9
|
+
return str;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// First decode any double-encoded entities
|
|
13
|
+
const tempDiv = document.createElement('div');
|
|
14
|
+
tempDiv.innerHTML = str;
|
|
15
|
+
const decoded = tempDiv.textContent || tempDiv.innerText;
|
|
16
|
+
|
|
17
|
+
// Then properly encode special characters
|
|
18
|
+
return decoded
|
|
19
|
+
.replace(/&/g, '&')
|
|
20
|
+
.replace(/</g, '<')
|
|
21
|
+
.replace(/>/g, '>')
|
|
22
|
+
.replace(/"/g, '"')
|
|
23
|
+
.replace(/'/g, ''')
|
|
24
|
+
.replace(/\u00A0/g, ' '); // Handle non-breaking space
|
|
25
|
+
};
|