@salesforcedevs/dx-components 1.3.66 → 1.3.70

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.3.66",
3
+ "version": "1.3.70",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -40,5 +40,5 @@
40
40
  "eventsourcemock": "^2.0.0",
41
41
  "luxon": "^3.1.0"
42
42
  },
43
- "gitHead": "f20982f83f9a0eeaf9b4dcbcd48396af8c341736"
43
+ "gitHead": "2a96eac5a76bea4ca124d6a3b0119e8312365f60"
44
44
  }
@@ -108,23 +108,35 @@ export default class CodeBlock extends LightningElement {
108
108
  formatCodeBlock() {
109
109
  const divEl = this.template.querySelector("div.code-block-content");
110
110
  const templateEl = document.createElement("template");
111
+
112
+ // Replace any <var> markup with a temporary nonsense sentinel (but one that is very
113
+ // unlikely to affect Prism's tokenization) so that Prism will not strip them but does
114
+ // still tokenize correctly. We want to italicize the "variables" ourselves after Prism
115
+ // does its own thing (W-11975205).
116
+ let cleanCodeBlock = this.codeBlock.replace(
117
+ /<var.*?>(.+?)<\/var>/g,
118
+ "vvvvv$1vvvvv"
119
+ );
120
+
111
121
  if (
112
122
  !this.isEncoded &&
113
123
  this.markupLangs.includes(this.selectedLanguage.id || "")
114
124
  ) {
115
- // eslint-disable-next-line
116
- templateEl.innerHTML = `<pre class='codeblock'><!--${this.codeBlock.replace(
125
+ // Temporarily replace HTML comment characters, which Prism would also strip
126
+ cleanCodeBlock = `<!--${cleanCodeBlock.replace(
117
127
  /<!--(.*?)-->/gs,
118
128
  "@@$1##"
119
- )}--></pre>`;
129
+ )}-->`;
120
130
  } else {
121
- // eslint-disable-next-line
122
- const innerHtml = this.isEncoded
123
- ? this.codeBlock
124
- : this.codeBlock.replace(/</g, "&lt").replace(/>/g, "&gt");
125
-
126
- templateEl.innerHTML = `<pre class='codeblock'>${innerHtml}</pre>`;
131
+ // If this is a non-encoded markup language, encode angle brackets that Prism would strip
132
+ cleanCodeBlock = this.isEncoded
133
+ ? cleanCodeBlock
134
+ : cleanCodeBlock.replace(/</g, "&lt").replace(/>/g, "&gt");
127
135
  }
136
+
137
+ // eslint-disable-next-line
138
+ templateEl.innerHTML = `<pre class='codeblock'>${cleanCodeBlock}</pre>`;
139
+
128
140
  const codeBlockEls = templateEl.content.querySelectorAll("pre");
129
141
  codeBlockEls.forEach((codeBlockEl) => {
130
142
  // eslint-disable-next-line
@@ -141,12 +153,19 @@ export default class CodeBlock extends LightningElement {
141
153
  // for custom markup content, it is a workaround to be refactored later.
142
154
  // eslint-disable-next-line
143
155
  this.language !== "text"
144
- ? (codeEl.innerHTML = codeHTML)
156
+ ? // eslint-disable-next-line
157
+ (codeEl.innerHTML = codeHTML)
145
158
  : (codeEl.textContent = this._codeBlock.trim());
146
159
  // eslint-disable-next-line
147
160
  codeBlockEl.innerHTML = "";
148
161
  codeBlockEl.appendChild(codeEl);
149
162
  Prism.highlightAllUnder(codeBlockEl);
163
+ // Italicize anything marked as a "variable" by the docs team
164
+ // eslint-disable-next-line
165
+ codeBlockEl.innerHTML = codeBlockEl.innerHTML.replace(
166
+ /vvvvv(.+?)vvvvv/g,
167
+ "<span class='token italic'>$1</span>"
168
+ );
150
169
  });
151
170
 
152
171
  if (divEl) {
@@ -156,6 +175,7 @@ export default class CodeBlock extends LightningElement {
156
175
  if (this.markupLangs.includes(this.selectedLanguage.id || "")) {
157
176
  const res = this.template.querySelector(`code.language-markup`);
158
177
  if (res) {
178
+ // Restore any temporarily replaced HTML comment characters
159
179
  // eslint-disable-next-line
160
180
  res.innerHTML = res.innerHTML.replace(
161
181
  /@@(.*?)##/gs,