@salesforcedevs/dx-components 1.3.83 → 1.3.85

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 (60) hide show
  1. package/lwc.config.json +3 -6
  2. package/package.json +2 -3
  3. package/src/modules/dx/breadcrumbs/breadcrumbs.ts +10 -8
  4. package/src/modules/dx/cardCallout/cardCallout.css +2 -2
  5. package/src/modules/dx/cardCallout/cardCallout.html +1 -1
  6. package/src/modules/dx/cardContent/cardContent.html +1 -4
  7. package/src/modules/dx/cardDocs/cardDocs.css +3 -3
  8. package/src/modules/dx/cardDocs/cardDocs.html +1 -4
  9. package/src/modules/dx/cardEvent/cardEvent.css +1 -6
  10. package/src/modules/dx/cardEvent/cardEvent.html +2 -2
  11. package/src/modules/dx/cardNews/cardNews.css +5 -5
  12. package/src/modules/dx/cardNews/cardNews.html +1 -1
  13. package/src/modules/dx/cardTitle/cardTitle.css +2 -2
  14. package/src/modules/dx/cardTitle/cardTitle.html +1 -1
  15. package/src/modules/dx/codeBlock/codeBlock.css +7 -23
  16. package/src/modules/dx/codeBlock/codeBlock.html +20 -1
  17. package/src/modules/dx/codeBlock/codeBlock.ts +110 -70
  18. package/src/modules/dx/dropdown/dropdown.ts +3 -2
  19. package/src/modules/dx/emptyState/emptyState.html +1 -1
  20. package/src/modules/dx/feature/feature.html +2 -2
  21. package/src/modules/dx/featuredContentHeader/featuredContentHeader.css +3 -3
  22. package/src/modules/dx/featuredContentHeader/featuredContentHeader.html +4 -4
  23. package/src/modules/dx/featuresList/featuresList.css +2 -2
  24. package/src/modules/dx/featuresList/featuresList.html +2 -2
  25. package/src/modules/dx/filterMenu/filterMenu.html +2 -7
  26. package/src/modules/dx/filterMenu/filterMenu.ts +3 -4
  27. package/src/modules/dx/footer/footer.html +1 -1
  28. package/src/modules/dx/footer/links.ts +4 -2
  29. package/src/modules/dx/grid/grid.ts +1 -3
  30. package/src/modules/dx/groupText/groupText.css +3 -7
  31. package/src/modules/dx/groupText/groupText.html +2 -2
  32. package/src/modules/dx/groupText/groupText.ts +2 -11
  33. package/src/modules/dx/header/header.html +1 -1
  34. package/src/modules/dx/logo/logo.html +1 -1
  35. package/src/modules/dx/mainContentHeader/mainContentHeader.html +2 -2
  36. package/src/modules/dx/podcastHost/podcastHost.html +1 -1
  37. package/src/modules/dx/popover/popover.ts +3 -3
  38. package/src/modules/dx/searchResults/searchResults.ts +3 -1
  39. package/src/modules/dx/section/section.css +1 -1
  40. package/src/modules/dx/section/section.html +1 -1
  41. package/src/modules/dx/section/section.ts +1 -1
  42. package/src/modules/dx/select/select.ts +3 -2
  43. package/src/modules/dx/sidebar/sidebar.html +2 -2
  44. package/src/modules/dx/sidebar/sidebar.ts +5 -7
  45. package/src/modules/dx/sidebarOld/sidebarOld.html +1 -1
  46. package/src/modules/dx/sidebarSearch/sidebarSearch.ts +5 -2
  47. package/src/modules/dx/tabPanelList/tabPanelList.ts +2 -2
  48. package/src/modules/dx/toc/toc.css +1 -1
  49. package/src/modules/dx/toc/toc.ts +1 -1
  50. package/src/modules/dxBaseElements/matchMediaElement/matchMediaElement.ts +4 -2
  51. package/src/modules/dxHelpers/card/card.css +2 -6
  52. package/src/modules/dxHelpers/code/code.css +296 -0
  53. package/src/modules/dxHelpers/text/text.css +39 -41
  54. package/src/modules/dxUtils/prismjs/prismjs.html +3 -0
  55. package/src/modules/dxUtils/prismjs/prismjs.ts +167 -287
  56. package/src/assets/shiki/languages/amp.tmLanguage.json +0 -205
  57. package/src/assets/shiki/themes/codey-highnoon.json +0 -650
  58. package/src/assets/shiki/themes/codey-midnight.json +0 -622
  59. package/src/modules/dxUtils/shiki/languages.ts +0 -18
  60. package/src/modules/dxUtils/shiki/shiki.ts +0 -75
package/lwc.config.json CHANGED
@@ -1,11 +1,7 @@
1
1
  {
2
2
  "modules": [
3
- {
4
- "dir": "src/modules"
5
- },
6
- {
7
- "npm": "@salesforcedevs/dw-components"
8
- }
3
+ { "dir": "src/modules" },
4
+ { "npm": "@salesforcedevs/dw-components" }
9
5
  ],
10
6
  "expose": [
11
7
  "dx/audio",
@@ -94,6 +90,7 @@
94
90
  "dxHelpers/animations",
95
91
  "dxHelpers/button",
96
92
  "dxHelpers/card",
93
+ "dxHelpers/code",
97
94
  "dxHelpers/commonHeader",
98
95
  "dxHelpers/reset",
99
96
  "dxHelpers/scrollbar",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.3.83",
3
+ "version": "1.3.85",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -24,7 +24,6 @@
24
24
  "lodash.kebabcase": "^4.1.1",
25
25
  "microtip": "0.2.2",
26
26
  "salesforce-oauth2": "^0.2.0",
27
- "shiki": "^0.11.1",
28
27
  "throttle-debounce": "^5.0.0",
29
28
  "uuid": "^9.0.0"
30
29
  },
@@ -41,5 +40,5 @@
41
40
  "eventsourcemock": "^2.0.0",
42
41
  "luxon": "^3.1.0"
43
42
  },
44
- "gitHead": "97b96b6a71af7312811bd937293c9da3102ad443"
43
+ "gitHead": "6b738627c2fefd4e639f1def42cdc4d4a44c7171"
45
44
  }
@@ -85,14 +85,16 @@ export default class Breadcrumbs extends LightningElement {
85
85
  breadcrumbs: Breadcrumb[]
86
86
  ): NormalizedBreadcrumb[] {
87
87
  const { length } = breadcrumbs;
88
- return breadcrumbs.map((breadcrumb, i): NormalizedBreadcrumb => {
89
- const last = i === length - 1;
90
- return {
91
- ...breadcrumb,
92
- asLink: this.hideCurrentLocation || !last,
93
- last
94
- };
95
- });
88
+ return breadcrumbs.map(
89
+ (breadcrumb, i): NormalizedBreadcrumb => {
90
+ const last = i === length - 1;
91
+ return {
92
+ ...breadcrumb,
93
+ asLink: this.hideCurrentLocation || !last,
94
+ last
95
+ };
96
+ }
97
+ );
96
98
  }
97
99
 
98
100
  private get breadcrumbDropdownOptions() {
@@ -16,7 +16,7 @@
16
16
 
17
17
  /* title */
18
18
 
19
- .dx-text-heading-3 {
19
+ .dx-text-display-4 {
20
20
  color: inherit;
21
21
  margin-bottom: var(--dx-g-spacing-3xl);
22
22
  overflow-wrap: hyphenate-word;
@@ -51,7 +51,7 @@ dx-icon::part(svg) {
51
51
  }
52
52
 
53
53
  @media screen and (max-width: 1024px) {
54
- .dx-text-heading-3 {
54
+ .dx-text-display-4 {
55
55
  margin-bottom: var(--dx-g-spacing-xl);
56
56
  }
57
57
  }
@@ -6,7 +6,7 @@
6
6
  style={style}
7
7
  onclick={sendGtm}
8
8
  >
9
- <h3 class="dx-text-heading-3">{title}</h3>
9
+ <h3 class="dx-text-display-4">{title}</h3>
10
10
  <span class="dx-text-button-light">
11
11
  {label}
12
12
  <dx-icon symbol="forward"></dx-icon>
@@ -21,10 +21,7 @@
21
21
  />
22
22
  </a>
23
23
  <div
24
- class="
25
- dx-card-base_section-vertical dx-card-base_column
26
- card_section-text
27
- "
24
+ class="dx-card-base_section-vertical dx-card-base_column card_section-text"
28
25
  >
29
26
  <span if:true={label} part="label" class="label dx-text-label-3">
30
27
  {label}
@@ -24,11 +24,11 @@
24
24
  flex-grow: 1;
25
25
  }
26
26
 
27
- .dx-text-heading-6 dx-button {
27
+ .dx-text-display-8 dx-button {
28
28
  margin-left: var(--dx-g-spacing-xs);
29
29
  }
30
30
 
31
- .dx-text-heading-4 {
31
+ .dx-text-display-6 {
32
32
  position: relative;
33
33
  -webkit-line-clamp: var(--dx-c-heading-max-lines);
34
34
  -webkit-box-orient: vertical;
@@ -36,7 +36,7 @@
36
36
  overflow: hidden;
37
37
  }
38
38
 
39
- .dx-text-heading-4 dx-icon {
39
+ .dx-text-display-6 dx-icon {
40
40
  display: inline-block;
41
41
  transform: translateY(-3px);
42
42
  }
@@ -7,10 +7,7 @@
7
7
  class="image dx-card-base_image"
8
8
  />
9
9
  <div
10
- class="
11
- dx-card-base_section-vertical dx-card-base_column
12
- card_section-text
13
- "
10
+ class="dx-card-base_section-vertical dx-card-base_column card_section-text"
14
11
  >
15
12
  <span class="dx-text-label-3">{label}</span>
16
13
  <dx-card-title
@@ -105,12 +105,7 @@ dx-formatted-date-time {
105
105
  display: none;
106
106
  }
107
107
 
108
- .dx-text-heading-5 {
109
- font-size: 18px;
110
- line-height: 24px;
111
- }
112
-
113
- .dx-text-heading-4 {
108
+ .dx-text-display-6 {
114
109
  font-size: 24px;
115
110
  line-height: 28px;
116
111
  }
@@ -20,12 +20,12 @@
20
20
  if:true={featured}
21
21
  >
22
22
  <dx-formatted-date-time
23
- class="dx-text-heading-5 month"
23
+ class="dx-text-display-8 month"
24
24
  value={startDatetime}
25
25
  month="short"
26
26
  ></dx-formatted-date-time>
27
27
  <dx-formatted-date-time
28
- class="dx-text-heading-1 day"
28
+ class="dx-text-display-1b day"
29
29
  value={startDatetime}
30
30
  day="2-digit"
31
31
  ></dx-formatted-date-time>
@@ -24,7 +24,7 @@
24
24
  z-index: 1;
25
25
  }
26
26
 
27
- .dx-text-heading-3 {
27
+ .dx-text-display-4 {
28
28
  margin: 4px 0 4px 0;
29
29
  color: inherit;
30
30
  }
@@ -44,7 +44,7 @@ img {
44
44
  margin: 0;
45
45
  }
46
46
 
47
- .dx-card-size-large .dx-text-heading-3 {
47
+ .dx-card-size-large .dx-text-display-4 {
48
48
  font-size: 30px;
49
49
  letter-spacing: 0.3px;
50
50
  line-height: 40px;
@@ -81,7 +81,7 @@ img {
81
81
  box-shadow: var(--dx-g-box-shadow-sm);
82
82
  }
83
83
 
84
- .dx-text-heading-3 {
84
+ .dx-text-display-4 {
85
85
  letter-spacing: 0.1px;
86
86
  }
87
87
 
@@ -114,7 +114,7 @@ img {
114
114
  max-width: 50%;
115
115
  }
116
116
 
117
- .dx-card-size-normal .dx-text-heading-3 {
117
+ .dx-card-size-normal .dx-text-display-4 {
118
118
  font-size: var(--dx-g-text-xl);
119
119
  line-height: 28px;
120
120
  }
@@ -128,7 +128,7 @@ img {
128
128
  margin: 14px 0 -2px 0;
129
129
  }
130
130
 
131
- .dx-card-size-large .dx-text-heading-3 {
131
+ .dx-card-size-large .dx-text-display-4 {
132
132
  font-size: var(--dx-g-text-2xl);
133
133
  line-height: 40px;
134
134
  letter-spacing: 0.6px;
@@ -8,7 +8,7 @@
8
8
  part="container"
9
9
  >
10
10
  <div class={textContainerClassName}>
11
- <h3 class="dx-text-heading-3">{title}</h3>
11
+ <h3 class="dx-text-display-4">{title}</h3>
12
12
  <p>{body}</p>
13
13
  <div class="cta">
14
14
  <dx-button if:true={hasLargeButton} size="large">
@@ -9,7 +9,7 @@
9
9
  --dx-c-card-title-icon-size: 22px;
10
10
  }
11
11
 
12
- h3.dx-text-heading-4 {
12
+ h3.dx-text-display-6 {
13
13
  color: var(--dx-c-card-title-color);
14
14
  transition: var(--dx-g-transition-hue-1x);
15
15
  font-size: var(--dx-c-card-title-font-size);
@@ -32,7 +32,7 @@ dx-icon {
32
32
  }
33
33
 
34
34
  @media screen and (max-width: 1024px) {
35
- .dx-text-heading-4 {
35
+ .dx-text-display-6 {
36
36
  font-size: 20px;
37
37
  line-height: 24px;
38
38
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <h3 class="dx-text-heading-4">
2
+ <h3 class="dx-text-display-6">
3
3
  <a if:true={href} href={href} target={target}>
4
4
  {titleToWrap}
5
5
  <template if:true={needsSpace}>&#32;</template>
@@ -1,3 +1,4 @@
1
+ @import "dxHelpers/code";
1
2
  @import "dxHelpers/text";
2
3
  @import "./darkTheme.css";
3
4
  @import "./lightTheme.css";
@@ -101,7 +102,7 @@ div.code-block-content {
101
102
  background: var(--dx-g-gray-95);
102
103
  }
103
104
 
104
- code[class*="shiki"] {
105
+ code[class*="language-"] {
105
106
  margin-left: -11px;
106
107
  }
107
108
 
@@ -109,36 +110,19 @@ code[class*="shiki"] {
109
110
  margin-right: var(--dx-g-spacing-xs);
110
111
  }
111
112
 
112
- .italic {
113
- font-style: italic;
114
- }
115
-
116
- pre[class*="shiki"] {
117
- font-size: 14px;
113
+ pre[class*="language-"] {
118
114
  border-radius: 0 0 0.3em 0.3em;
119
115
  padding-bottom: var(--dx-g-spacing-smd);
120
116
  background-color: unset;
121
117
  padding-top: var(--dx-g-spacing-sm);
122
118
  }
123
119
 
120
+ pre[class*="language-"].line-numbers {
121
+ padding-left: 56px;
122
+ }
123
+
124
124
  @media screen and (max-width: 640px) {
125
125
  .dx-code-block-heading {
126
126
  display: none;
127
127
  }
128
128
  }
129
-
130
- /* Adding line numbers via CSS counters */
131
- code {
132
- counter-reset: step;
133
- counter-increment: step 0;
134
- }
135
-
136
- code .line::before {
137
- content: counter(step);
138
- counter-increment: step;
139
- width: 1rem;
140
- margin-right: 1.5rem;
141
- display: inline-block;
142
- text-align: right;
143
- color: rgba(115, 138, 148, 0.4);
144
- }
@@ -3,10 +3,29 @@
3
3
  <div class={codeblocksClassname}>
4
4
  <div class="toolbar">
5
5
  <div class="toolbar-item">
6
- <div class="dx-text-heading-7 dx-code-block-heading">
6
+ <div class="dx-text-display-8 dx-code-block-heading">
7
7
  { title }
8
8
  </div>
9
9
  </div>
10
+ <template if:true={showLanguageDropdown}>
11
+ <div class="toolbar-item">
12
+ <dx-dropdown
13
+ small="true"
14
+ options={allLanguages}
15
+ value={selectedLanguageId}
16
+ onchange={onLanguageChange}
17
+ >
18
+ <dx-button
19
+ icon-symbol="chevrondown"
20
+ class="btn language-btn"
21
+ variant="custom"
22
+ >
23
+ { selectedLanguageLabel }
24
+ </dx-button>
25
+ </dx-dropdown>
26
+ </div>
27
+ <div class="divider"></div>
28
+ </template>
10
29
  <template if:true={showCodeSourceBtn}>
11
30
  <div class="toolbar-item">
12
31
  <dx-tooltip
@@ -1,7 +1,7 @@
1
1
  import { LightningElement, api, wire, track } from "lwc";
2
- import { CodeBlockTheme } from "typings/custom";
2
+ import { CodeBlockTheme, CodeBlockLanguage } from "typings/custom";
3
3
  import cx from "classnames";
4
- import { Shiki } from "dxUtils/shiki";
4
+ import Prism from "dxUtils/prismjs";
5
5
  import {
6
6
  getLocalStorageData,
7
7
  setLocalStorageData
@@ -24,6 +24,39 @@ export default class CodeBlock extends LightningElement {
24
24
  // if it is true, it renders code as is coming instead of wrapping it into html/xml comments tags.
25
25
  @api isEncoded = false;
26
26
 
27
+ private markupLangs = ["visualforce", "html", "xml"];
28
+ private _codeBlockRendered: boolean = false;
29
+ private componentLoaded: boolean = false;
30
+ private showLanguageDropdown: boolean = false;
31
+ private copyBtnText: string = "Click to copy";
32
+ private selectedLanguageLabel: string = "";
33
+ private selectedLanguageId: string = "";
34
+ private selectedLanguage: CodeBlockLanguage = { label: "Language", id: "" };
35
+ private allLanguages: CodeBlockLanguage[] = [
36
+ { label: "Language", id: "" },
37
+ { label: "Apex", id: "apex" },
38
+ { label: "Java", id: "java" },
39
+ { label: "Javascript", id: "javascript" },
40
+ { label: "CSS", id: "css" },
41
+ { label: "Visualforce", id: "visualforce" },
42
+ { label: "Html", id: "html" },
43
+ { label: "xml", id: "xml" },
44
+ { label: "TypeScript", id: "typescript" },
45
+ { label: "PHP", id: "php" },
46
+ { label: "JSON", id: "json" },
47
+ { label: "Swift", id: "swift" },
48
+ { label: "Kotlin", id: "kotlin" },
49
+ { label: "Python", id: "python" },
50
+ { label: "Bash", id: "bash" },
51
+ { label: "Shell", id: "shell" },
52
+ { label: "Shell", id: "sh" },
53
+ { label: "SQL", id: "sql" },
54
+ { label: "YAML", id: "yaml" },
55
+ { label: "Markdown", id: "markdown" },
56
+ { label: "Markdown", id: "md" },
57
+ { label: "JSX", id: "jsx" }
58
+ ];
59
+
27
60
  connectedCallback() {
28
61
  if (!this.theme) {
29
62
  this.theme = this.defaultTheme;
@@ -33,11 +66,11 @@ export default class CodeBlock extends LightningElement {
33
66
  _codeBlock: string = "";
34
67
  @api
35
68
  set codeBlock(value: string) {
69
+ this._codeBlockRendered = false;
36
70
  let match;
37
- this._codeBlock = (
38
- (match = preTagRegexp.exec(value.trim())) === null
39
- ? value.trim()
40
- : match[1]
71
+ this._codeBlock = ((match = preTagRegexp.exec(value.trim())) === null
72
+ ? value.trim()
73
+ : match[1]
41
74
  ).trim();
42
75
  }
43
76
 
@@ -45,16 +78,12 @@ export default class CodeBlock extends LightningElement {
45
78
  return this._codeBlock;
46
79
  }
47
80
 
48
- private copyBtnText = "Click to copy";
49
81
  @track private theme: CodeBlockTheme | null = null;
50
82
 
51
83
  @wire(getLocalStorageData, { key: "dx-codeblock-theme" })
52
84
  updateThemeForCodeblock(value: any) {
53
85
  if (themes.includes(value)) {
54
86
  this.theme = value;
55
- // As styles computation is static the code needs to be reformatted after a theme change
56
- Shiki.setTheme(this.theme!);
57
- this.formatCodeBlock();
58
87
  } else {
59
88
  setLocalStorageData(
60
89
  LOCAL_STORAGE_KEY,
@@ -75,7 +104,7 @@ export default class CodeBlock extends LightningElement {
75
104
  return cx(`dx-theme-${this.theme}`);
76
105
  }
77
106
 
78
- async formatCodeBlock() {
107
+ formatCodeBlock() {
79
108
  const divEl = this.template.querySelector("div.code-block-content");
80
109
  const templateEl = document.createElement("template");
81
110
 
@@ -88,13 +117,17 @@ export default class CodeBlock extends LightningElement {
88
117
  "vvvvv$1vvvvv"
89
118
  );
90
119
 
91
- if (!this.isEncoded && Shiki.isMarkupLanguage(this.language)) {
92
- cleanCodeBlock = `${cleanCodeBlock.replace(
120
+ if (
121
+ !this.isEncoded &&
122
+ this.markupLangs.includes(this.selectedLanguage.id || "")
123
+ ) {
124
+ // Temporarily replace HTML comment characters, which Prism would also strip
125
+ cleanCodeBlock = `<!--${cleanCodeBlock.replace(
93
126
  /<!--(.*?)-->/gs,
94
127
  "@@$1##"
95
- )}`;
128
+ )}-->`;
96
129
  } else {
97
- // If this is a non-encoded markup language, encode angle brackets
130
+ // If this is a non-encoded markup language, encode angle brackets that Prism would strip
98
131
  cleanCodeBlock = this.isEncoded
99
132
  ? cleanCodeBlock
100
133
  : cleanCodeBlock.replace(/</g, "&lt").replace(/>/g, "&gt");
@@ -103,62 +136,42 @@ export default class CodeBlock extends LightningElement {
103
136
  // eslint-disable-next-line
104
137
  templateEl.innerHTML = `<pre class='codeblock'>${cleanCodeBlock}</pre>`;
105
138
 
106
- const codeBlockEls = Array.from(
107
- templateEl.content.querySelectorAll("pre")
108
- );
109
-
110
- // temporary hack to avoid prismjs tokens from showing up in markup languages
111
- const isDocs = window.location.href.includes("/docs/");
112
-
113
- const promisesForHighlighted = codeBlockEls.map((codeBlockEl) =>
139
+ const codeBlockEls = templateEl.content.querySelectorAll("pre");
140
+ codeBlockEls.forEach((codeBlockEl) => {
114
141
  // eslint-disable-next-line
115
- Shiki.codeToHtml(
116
- Shiki.isMarkupLanguage(this.language) && !isDocs
117
- ? codeBlockEl.innerHTML
118
- : codeBlockEl.textContent,
119
- {
120
- lang: this.language
121
- }
122
- )
123
- .then((highlightedCode) => {
124
- codeBlockEl.classList.add("line-numbers");
125
- // for custom markup content, it is a workaround to be refactored later.
126
- const codeEl = document.createElement("code");
127
- // eslint-disable-next-line
128
- this.language !== "text"
129
- ? // eslint-disable-next-line
130
- (codeEl.innerHTML = highlightedCode)
131
- : (codeEl.textContent = highlightedCode.trim());
132
- // eslint-disable-next-line
133
- codeBlockEl.innerHTML = "";
134
- codeBlockEl.appendChild(codeEl);
135
-
136
- // Italicize anything marked as a "variable" by the docs team
137
- // eslint-disable-next-line
138
- codeBlockEl.innerHTML = codeBlockEl.innerHTML.replace(
139
- /vvvvv(.+?)vvvvv/g,
140
- "<span class='token italic'>$1</span>"
141
- );
142
- })
143
- .catch((error) => {
144
- console.error(error);
145
- // Italicize anything marked as a "variable" by the docs team
146
- // eslint-disable-next-line
147
- codeBlockEl.innerHTML = codeBlockEl.innerHTML.replace(
148
- /vvvvv(.+?)vvvvv/g,
149
- "<span class='token italic'>$1</span>"
150
- );
151
- })
152
- );
153
-
154
- await Promise.all(promisesForHighlighted);
142
+ const codeHTML = codeBlockEl.innerHTML;
143
+ codeBlockEl.classList.add("line-numbers");
144
+ const codeEl = document.createElement("code");
145
+ codeEl.classList.add(
146
+ `language-${
147
+ this.markupLangs.includes(this.selectedLanguage.id || "")
148
+ ? "markup"
149
+ : this.selectedLanguage.id
150
+ }`
151
+ );
152
+ // for custom markup content, it is a workaround to be refactored later.
153
+ // eslint-disable-next-line
154
+ this.language !== "text"
155
+ ? // eslint-disable-next-line
156
+ (codeEl.innerHTML = codeHTML)
157
+ : (codeEl.textContent = this._codeBlock.trim());
158
+ // eslint-disable-next-line
159
+ codeBlockEl.innerHTML = "";
160
+ codeBlockEl.appendChild(codeEl);
161
+ Prism.highlightAllUnder(codeBlockEl);
162
+ // Italicize anything marked as a "variable" by the docs team
163
+ // eslint-disable-next-line
164
+ codeBlockEl.innerHTML = codeBlockEl.innerHTML.replace(
165
+ /vvvvv(.+?)vvvvv/g,
166
+ "<span class='token italic'>$1</span>"
167
+ );
168
+ });
155
169
 
156
170
  if (divEl) {
157
171
  // eslint-disable-next-line
158
172
  divEl.innerHTML = "";
159
173
  divEl.append(templateEl.content);
160
-
161
- if (Shiki.isMarkupLanguage(this.language)) {
174
+ if (this.markupLangs.includes(this.selectedLanguage.id || "")) {
162
175
  const res = this.template.querySelector(`code.language-markup`);
163
176
  if (res) {
164
177
  // Restore any temporarily replaced HTML comment characters
@@ -172,6 +185,25 @@ export default class CodeBlock extends LightningElement {
172
185
  }
173
186
  }
174
187
 
188
+ onLanguageChange(newLang: any) {
189
+ this.selectedLanguage =
190
+ this.allLanguages.find(
191
+ (lang: CodeBlockLanguage) => lang.id === newLang.detail
192
+ ) || this.allLanguages[0];
193
+ this.selectedLanguageLabel = this.selectedLanguage.label;
194
+ this.selectedLanguageId = this.selectedLanguage.id;
195
+ this.formatCodeBlock();
196
+
197
+ gtmTrack(newLang, "custEv_ctaLinkClick", {
198
+ event: "custEv_ctaLinkClick",
199
+ click_text: newLang.detail,
200
+ element_title: "dx-dropdown",
201
+ click_url: this.selectedLanguageId,
202
+ element_type: "link",
203
+ content_category: "code block"
204
+ });
205
+ }
206
+
175
207
  /**
176
208
  * Note: There is a known issue in storybook@6.1.13 where some apis are not available if you access Storybook through IP address.
177
209
  * https://github.com/storybookjs/storybook/issues/13529
@@ -185,8 +217,9 @@ export default class CodeBlock extends LightningElement {
185
217
  });
186
218
 
187
219
  try {
188
- const snippetContainer: HTMLElement | null =
189
- this.template.querySelector(".code-block-content");
220
+ const snippetContainer: HTMLElement | null = this.template.querySelector(
221
+ ".code-block-content"
222
+ );
190
223
  if (snippetContainer && snippetContainer.textContent) {
191
224
  await navigator.clipboard.writeText(
192
225
  snippetContainer.textContent
@@ -203,9 +236,6 @@ export default class CodeBlock extends LightningElement {
203
236
 
204
237
  updateTheme(event: any) {
205
238
  this.theme = this.theme === DARK ? LIGHT : DARK;
206
- // As styles computation is static the code needs to be reformatted after a theme change
207
- Shiki.setTheme(this.theme);
208
- this.formatCodeBlock();
209
239
  setLocalStorageData(LOCAL_STORAGE_KEY, this.theme);
210
240
 
211
241
  gtmTrack(event.target, "custEv_iconClick", {
@@ -217,6 +247,16 @@ export default class CodeBlock extends LightningElement {
217
247
  }
218
248
 
219
249
  renderedCallback() {
250
+ if (this._codeBlockRendered) {
251
+ return;
252
+ }
253
+ this.selectedLanguage =
254
+ this.allLanguages.find(
255
+ (l: CodeBlockLanguage) => l.id === this.language
256
+ ) || this.allLanguages[0];
257
+ this.selectedLanguageLabel = this.selectedLanguage.label;
258
+ this.selectedLanguageId = this.selectedLanguage.id;
220
259
  this.formatCodeBlock();
260
+ this._codeBlockRendered = true;
221
261
  }
222
262
  }
@@ -172,8 +172,9 @@ export default class Dropdown extends LightningElement {
172
172
  ? this.findOptionElementIndex(this.value)
173
173
  : 0;
174
174
 
175
- const optionToFocus: any =
176
- this.optionsElements[defaultIndex < 0 ? 0 : defaultIndex];
175
+ const optionToFocus: any = this.optionsElements[
176
+ defaultIndex < 0 ? 0 : defaultIndex
177
+ ];
177
178
  if (optionToFocus) {
178
179
  optionToFocus.focus();
179
180
  this._focusedValue = optionToFocus.option.id;
@@ -2,7 +2,7 @@
2
2
  <div class={containerClassName} part="container">
3
3
  <img src={imageAssetPath} alt="Mountains" />
4
4
  <div class="text">
5
- <h3 class="title dx-text-heading-3">{title}</h3>
5
+ <h3 class="title dx-text-display-4">{title}</h3>
6
6
  <p class="subtitle dx-text-body-2" if:true={subtitle}>{subtitle}</p>
7
7
  </div>
8
8
  </div>
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <section class={sectionClass}>
3
3
  <div class="description">
4
- <h2 if:true={hasLabel} class="dx-text-heading-7 label">{label}</h2>
5
- <h3 class="dx-text-heading-3">{title}</h3>
4
+ <h2 if:true={hasLabel} class="dx-text-display-8 label">{label}</h2>
5
+ <h3 class="dx-text-display-4">{title}</h3>
6
6
  <div class="body dx-text-body-2">
7
7
  <slot></slot>
8
8
  </div>