@salesforcedevs/docs-components 0.0.7 → 0.0.9-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.
Files changed (141) hide show
  1. package/lwc.config.json +25 -2
  2. package/package.json +17 -6
  3. package/src/modules/README.md +41 -0
  4. package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
  5. package/src/modules/doc/amfReference/amfReference.css +25 -0
  6. package/src/modules/doc/amfReference/amfReference.html +60 -0
  7. package/src/modules/doc/amfReference/amfReference.ts +1494 -0
  8. package/src/modules/doc/amfReference/constants.ts +76 -0
  9. package/src/modules/doc/amfReference/types.ts +125 -0
  10. package/src/modules/doc/amfTopic/amfTopic.css +21 -0
  11. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  12. package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
  13. package/src/modules/doc/amfTopic/types.ts +56 -0
  14. package/src/modules/doc/amfTopic/utils.ts +136 -0
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
  16. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
  17. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +71 -0
  18. package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
  19. package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
  20. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
  21. package/src/modules/doc/chat/README.md +179 -0
  22. package/src/modules/doc/chat/chat.css +821 -0
  23. package/src/modules/doc/chat/chat.html +241 -0
  24. package/src/modules/doc/chat/chat.ts +586 -0
  25. package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
  26. package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
  27. package/src/modules/doc/componentPlayground/componentPlayground.ts +29 -0
  28. package/src/modules/doc/content/content.css +249 -87
  29. package/src/modules/doc/content/content.html +3 -2
  30. package/src/modules/doc/content/content.ts +272 -152
  31. package/src/modules/doc/contentCallout/contentCallout.css +25 -26
  32. package/src/modules/doc/contentCallout/contentCallout.html +13 -4
  33. package/src/modules/doc/contentCallout/contentCallout.ts +21 -10
  34. package/src/modules/doc/contentLayout/contentLayout.css +1 -0
  35. package/src/modules/doc/contentLayout/contentLayout.html +68 -0
  36. package/src/modules/doc/contentLayout/contentLayout.ts +531 -0
  37. package/src/modules/doc/contentMedia/contentMedia.css +49 -0
  38. package/src/modules/doc/contentMedia/contentMedia.html +23 -0
  39. package/src/modules/doc/contentMedia/contentMedia.ts +34 -0
  40. package/src/modules/doc/doDont/doDont.css +47 -0
  41. package/src/modules/doc/doDont/doDont.html +27 -0
  42. package/src/modules/doc/doDont/doDont.ts +17 -0
  43. package/src/modules/doc/editFile/editFile.css +511 -0
  44. package/src/modules/doc/editFile/editFile.html +163 -0
  45. package/src/modules/doc/editFile/editFile.ts +238 -0
  46. package/src/modules/doc/header/header.css +132 -0
  47. package/src/modules/doc/header/header.html +55 -0
  48. package/src/modules/doc/header/header.ts +120 -0
  49. package/src/modules/doc/heading/heading.css +33 -0
  50. package/src/modules/doc/heading/heading.html +14 -0
  51. package/src/modules/doc/heading/heading.ts +67 -0
  52. package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
  53. package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
  54. package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
  55. package/src/modules/doc/headingContent/headingContent.css +53 -0
  56. package/src/modules/doc/headingContent/headingContent.html +13 -0
  57. package/src/modules/doc/headingContent/headingContent.ts +30 -0
  58. package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
  59. package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
  60. package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +168 -0
  61. package/src/modules/doc/nav/nav.css +4 -2
  62. package/src/modules/doc/nav/nav.ts +1 -1
  63. package/src/modules/doc/overview/overview.css +40 -0
  64. package/src/modules/doc/overview/overview.html +34 -0
  65. package/src/modules/doc/overview/overview.ts +12 -0
  66. package/src/modules/doc/phase/phase.css +70 -0
  67. package/src/modules/doc/phase/phase.html +38 -0
  68. package/src/modules/doc/phase/phase.ts +93 -0
  69. package/src/modules/doc/specificationContent/specificationContent.css +36 -0
  70. package/src/modules/doc/specificationContent/specificationContent.html +171 -0
  71. package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
  72. package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
  73. package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
  74. package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
  75. package/src/modules/doc/toc/toc.html +11 -6
  76. package/src/modules/doc/toc/toc.ts +1 -1
  77. package/src/modules/doc/toolbar/toolbar.html +8 -1
  78. package/src/modules/doc/versionPicker/versionPicker.css +64 -0
  79. package/src/modules/doc/versionPicker/versionPicker.html +38 -0
  80. package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
  81. package/src/modules/doc/xmlContent/types.ts +120 -0
  82. package/src/modules/doc/xmlContent/utils.ts +163 -0
  83. package/src/modules/doc/xmlContent/xmlContent.css +54 -0
  84. package/src/modules/doc/xmlContent/xmlContent.html +52 -0
  85. package/src/modules/doc/xmlContent/xmlContent.ts +792 -0
  86. package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
  87. package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
  88. package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
  89. package/src/modules/docHelpers/status/status.css +22 -0
  90. package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -0
  91. package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
  92. package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
  93. package/src/modules/docUtils/utils/utils.ts +32 -0
  94. package/src/modules/doc/container/__benchmarks__/container.benchmark.js +0 -43
  95. package/src/modules/doc/container/__mocks__/mockAvailableLanguages.js +0 -8
  96. package/src/modules/doc/container/__mocks__/mockAvailableVersions.js +0 -122
  97. package/src/modules/doc/container/__mocks__/mockContentFetchResponse.json +0 -5
  98. package/src/modules/doc/container/__mocks__/mockDocContent.js +0 -29
  99. package/src/modules/doc/container/__mocks__/mockNavigationFetchResponse.json +0 -4061
  100. package/src/modules/doc/container/__mocks__/mockPageReference.js +0 -8
  101. package/src/modules/doc/container/__mocks__/mockPdfUrl.js +0 -1
  102. package/src/modules/doc/container/__mocks__/mockSelectedLanguage.js +0 -8
  103. package/src/modules/doc/container/__mocks__/mockSelectedVersion.js +0 -8
  104. package/src/modules/doc/container/__mocks__/mockToc.js +0 -146
  105. package/src/modules/doc/container/__tests__/container.test.ts +0 -82
  106. package/src/modules/doc/container/container.css +0 -34
  107. package/src/modules/doc/container/container.html +0 -23
  108. package/src/modules/doc/container/container.stories.ts +0 -18
  109. package/src/modules/doc/container/container.ts +0 -356
  110. package/src/modules/doc/content/__tests__/content.test.ts +0 -30
  111. package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -29
  112. package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
  113. package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
  114. package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
  115. package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
  116. package/src/modules/doc/landing/__tests__/landing.test.ts +0 -32
  117. package/src/modules/doc/landing/__tests__/mockFetch.json +0 -370
  118. package/src/modules/doc/landing/landing.css +0 -66
  119. package/src/modules/doc/landing/landing.html +0 -109
  120. package/src/modules/doc/landing/landing.stories.ts +0 -10
  121. package/src/modules/doc/landing/landing.ts +0 -225
  122. package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
  123. package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
  124. package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
  125. package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
  126. package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
  127. package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
  128. package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
  129. package/src/modules/doc/nav/__tests__/nav.test.ts +0 -62
  130. package/src/modules/doc/search/__tests__/search.test.ts +0 -20
  131. package/src/modules/doc/search/search.html +0 -1
  132. package/src/modules/doc/search/search.ts +0 -3
  133. package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
  134. package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
  135. package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
  136. package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
  137. package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
  138. package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
  139. package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
  140. package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
  141. package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
@@ -1,184 +1,277 @@
1
1
  /* eslint-disable @lwc/lwc/no-inner-html */
2
- import { LightningElement, api, track } from "lwc";
3
- import { DocContent, PageReference } from "../../../../../../../typings/custom";
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
+ };
4
29
 
5
30
  export default class Content extends LightningElement {
6
31
  @api isStorybook: boolean = false;
7
32
  @api pageReference!: PageReference;
8
33
  @api codeBlockType: string = "card";
34
+ @api showPaginationButtons: boolean = false;
35
+
9
36
  @api
10
37
  set docsData(value) {
11
38
  this._docRendered = false;
12
- this.docContent = value;
39
+ this.docContent = (value && value.trim()) || "";
13
40
  }
41
+
14
42
  get docsData() {
15
43
  return this.docContent;
16
44
  }
17
- _codeBlockTheme: string = "dark";
18
- @api
19
- set codeBlockTheme(value) {
20
- this._codeBlockTheme = value;
21
- }
22
- get codeBlockTheme() {
23
- return this._codeBlockTheme;
24
- }
25
45
 
26
46
  @track docContent: DocContent = "";
27
47
  _docRendered: boolean = false;
28
- originalCodeBlockThemeValue: String = "";
48
+
29
49
  connectedCallback() {
30
- this.template.addEventListener(
31
- "themechange",
32
- this.updateTheme.bind(this) // eslint-disableline no-use-before-define
50
+ window.addEventListener(
51
+ "highlightedtermchange",
52
+ this.updateHighlighted
33
53
  );
34
54
  }
35
55
 
36
- updateTheme() {
37
- this._codeBlockTheme =
38
- this._codeBlockTheme === "dark" ? "light" : "dark";
39
- const codeBlockEls = this.template.querySelectorAll("dx-code-block");
40
- codeBlockEls.forEach((codeBlockEl) => {
41
- codeBlockEl.setAttribute("theme", this._codeBlockTheme);
42
- });
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);
43
79
  }
44
80
 
45
81
  // We don't use any tracked field here. The challenge is that
46
82
  // for security reasons you can't pass pure HTML via a class
47
83
  // field to the template. Hence we manipulate the DOM manually.
48
- insertDocHtml() {
49
- const divEl = this.template.querySelector("div");
84
+ insertDocHtml(docContent?: string) {
85
+ const divEl = this.getCleanContainer();
50
86
 
51
- // Some simple data mutation to make Prism work on-the-fly with the existing datasource
52
- const templateEl = document.createElement("template");
53
- this.docContent = this.docContent.trim();
54
- // eslint-disable-next-line no-use-before-define
55
- templateEl.innerHTML = this.docContent;
87
+ if (divEl) {
88
+ divEl.innerHTML = docContent || this.docContent;
56
89
 
57
- // Query the code blocks and create a dx-code-block component that contains the code
58
- const codeBlockEls = templateEl.content.querySelectorAll(
59
- ".codeSection"
60
- );
61
- codeBlockEls.forEach((codeBlockEl) => {
62
- const blockEl = document.createElement("dx-code-block");
63
- const classList = codeBlockEl.firstChild.classList;
64
- let language = "";
65
- for (const key in classList) {
66
- if (typeof classList[key] === "string") {
67
- const className = classList[key];
68
- if (className.startsWith("brush:")) {
69
- 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
+ }
70
102
  }
71
103
  }
72
- }
73
- blockEl.setAttribute("title", "Code Block Title");
74
- blockEl.setAttribute("theme", this.codeBlockTheme);
75
- blockEl.setAttribute("variant", this.codeBlockType);
76
- blockEl.setAttribute("language", language);
77
- // eslint-disable-next-line no-use-before-define
78
- blockEl.setAttribute("code-block", codeBlockEl.innerHTML);
79
- // eslint-disable-next-line no-use-before-define
80
- codeBlockEl.innerHTML = "";
81
- codeBlockEl.appendChild(blockEl);
82
- });
83
-
84
- // Query the callouts and create a doc-content-callout component that contains the code
85
- const calloutEls = templateEl.content.querySelectorAll(".message");
86
- calloutEls.forEach((calloutEl) => {
87
- const calloutCompEl = document.createElement("doc-content-callout");
88
- const detailEls = calloutEl.querySelectorAll("p");
89
- detailEls.forEach((detailEl) => {
90
- calloutCompEl.appendChild(detailEl);
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);
91
118
  });
92
- const type = calloutEl.querySelector("h4").textContent;
93
- const typeLower = type.toLowerCase();
94
- calloutCompEl.setAttribute("title", type);
95
- calloutCompEl.setAttribute("variant", typeLower);
96
- calloutEl.innerHTML = "";
97
- calloutEl.appendChild(calloutCompEl);
98
- });
99
-
100
- // Modify links to work with any domain
101
- const anchorEls = templateEl.content.querySelectorAll("a");
102
- anchorEls.forEach((anchorEl) => {
103
- if (anchorEl.textContent.includes("Next →")) {
104
- anchorEl.textContent = "";
105
- const buttonEl = document.createElement("dx-button");
106
- buttonEl.setAttribute("icon-symbol", "chevronright");
107
- buttonEl.textContent = "Next";
108
- anchorEl.appendChild(buttonEl);
109
- }
110
- if (anchorEl.textContent.includes("← Previous")) {
111
- anchorEl.textContent = "";
112
- const buttonEl = document.createElement("dx-button");
113
- buttonEl.setAttribute("icon-symbol", "chevronleft");
114
- buttonEl.setAttribute("icon-position", "left");
115
- buttonEl.setAttribute("variant", "secondary");
116
- buttonEl.textContent = "Previous";
117
- anchorEl.appendChild(buttonEl);
118
- }
119
- const href = anchorEl.href.split("/");
120
- if (
121
- (href[3] === this.pageReference.docId && this.isStorybook) ||
122
- href[4] === this.pageReference.docId ||
123
- href[6] === this.pageReference.docId
124
- ) {
125
- let updatedURL;
126
- switch (href.length) {
127
- case 8:
128
- updatedURL = href.splice(5).join("/");
129
- break;
130
- case 7:
131
- updatedURL = href.splice(4).join("/");
132
- break;
133
- case 6:
134
- updatedURL = href.splice(3).join("/");
135
- break;
136
- default:
137
- updatedURL = href.splice(6).join("/");
138
- break;
139
- }
140
- anchorEl.addEventListener(
141
- "click",
142
- // eslint-disable-next-line no-use-before-define
143
- this.handleNavClick.bind(this)
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"
144
128
  );
145
- anchorEl.setAttribute("href", "docs/" + updatedURL);
146
- anchorEl.setAttribute("data-id", "docs/" + updatedURL);
147
- } else if (href[2] === "developer.salesforce.com") {
148
- let updatedURL = this.pageReference.domain;
149
- if (href[3]) {
150
- updatedURL = updatedURL + `/${href[3]}`;
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
151
139
  }
152
- if (href[4]) {
153
- updatedURL = updatedURL + `/${href[4]}`;
140
+
141
+ if (flag) {
142
+ const codeEls = calloutEl.querySelectorAll(".codeSection");
143
+ codeEls.forEach((codeEl) => {
144
+ calloutCompEl.appendChild(codeEl);
145
+ });
146
+ }
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
+ }
154
172
  }
155
- if (href[5]) {
156
- updatedURL = updatedURL + `/${href[5]}`;
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;
157
178
  }
158
- if (href[6]) {
159
- updatedURL = updatedURL + `/${href[6]}`;
179
+
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;
160
212
  }
161
- anchorEl.setAttribute("href", updatedURL);
162
- anchorEl.setAttribute("data-id", updatedURL);
163
- }
164
- });
165
-
166
- // Modify image src to work with any domain
167
- const imgEls = templateEl.content.querySelectorAll("img");
168
- imgEls.forEach((imgEl) => {
169
- const src = imgEl.src;
170
- const origin = window.location.origin;
171
- const updatedURL = src.replace(
172
- origin,
173
- "https://developer.salesforce.com"
174
- );
175
- imgEl.setAttribute("src", updatedURL);
176
- });
177
213
 
178
- if (divEl) {
179
- // eslint-disable-next-line no-use-before-define
180
- divEl.innerHTML = "";
181
- divEl.append(templateEl.content);
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
+ });
182
275
  }
183
276
 
184
277
  // Once the html has been corectly modified, naviage to the page reference on the page
@@ -187,13 +280,30 @@ export default class Content extends LightningElement {
187
280
  }
188
281
  }
189
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
+
190
302
  handleNavClick(event: InputEvent) {
191
303
  event.preventDefault();
192
- // eslint-disable-next-line no-use-before-define
193
- const target = event.currentTarget.dataset.id;
194
- const [page, docId, deliverable, tempContentDocumentId] = target.split(
195
- "/"
196
- );
304
+ const target = (event.currentTarget! as any).dataset.id;
305
+ const [page, docId, deliverable, tempContentDocumentId] =
306
+ target.split("/");
197
307
  const [contentDocumentId, hash] = tempContentDocumentId.split("#");
198
308
  const newPageReference = {
199
309
  page: page,
@@ -211,10 +321,20 @@ export default class Content extends LightningElement {
211
321
  composed: true
212
322
  })
213
323
  );
324
+
325
+ if (this.isSamePage({ ...newPageReference, domain: "" })) {
326
+ this.navigateToHash(window.location.hash);
327
+ }
214
328
  }
215
329
 
330
+ updateHighlighted = (event: any) =>
331
+ highlightTerms(
332
+ this.template.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
333
+ event.detail
334
+ );
335
+
216
336
  @api
217
- public navigateToHash(hash: String) {
337
+ public navigateToHash = (hash: String) => {
218
338
  const splitHash = hash.split("#");
219
339
  if (splitHash.length === 2) {
220
340
  hash = splitHash[1];
@@ -225,7 +345,7 @@ export default class Content extends LightningElement {
225
345
  } else {
226
346
  window.scrollTo({ top: 0, behavior: "smooth" });
227
347
  }
228
- }
348
+ };
229
349
 
230
350
  renderedCallback() {
231
351
  if (this._docRendered) {
@@ -1,60 +1,59 @@
1
- @import "helpers/reset";
2
- @import "helpers/text";
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-icon {
10
- padding-right: var(--dx-g-spacing-md);
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-warning {
24
- background-color: rgb(254, 243, 217);
25
- border-color: var(--dx-g-yellow-vibrant-80);
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-caution {
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-base__section {
40
+ .dx-callout-base_section {
34
41
  width: 100%;
35
- padding: var(--dx-g-spacing-md);
36
42
  }
37
43
 
38
- .dx-callout-base__section-large {
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-base__column {
51
+ .dx-callout-base_column {
46
52
  display: flex;
47
53
  flex-direction: row;
48
54
  }
49
55
 
50
- .dx-callout-base__column > *:not(:last-child):not(dx-type-badge-group) {
51
- margin-bottom: var(--dx-g-spacing-sm);
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
- <div class="dx-callout-icon">
4
- <dx-icon symbol={iconName} size="large" color={iconColor}></dx-icon>
5
- </div>
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">{title}</p>
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 overrideWidth?: boolean = false;
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 = "yellow-vibrant-80";
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-base";
33
- this.iconColor = "gray-50";
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
- "dx-callout-base__section",
42
- "dx-callout-base__column",
43
- this.cardVariant,
44
- this.overrideWidth && "dx-callout-base--override-width"
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";