@salesforcedevs/dx-components 1.3.72 → 1.3.73-alpha.0
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/lwc.config.json +6 -3
- package/package.json +3 -3
- package/src/assets/shiki/languages/amp.tmLanguage.json +205 -0
- package/src/assets/shiki/themes/codey-highnoon.json +650 -0
- package/src/assets/shiki/themes/codey-midnight.json +622 -0
- package/src/modules/dx/breadcrumbs/breadcrumbs.ts +8 -10
- package/src/modules/dx/cardContent/cardContent.html +4 -1
- package/src/modules/dx/cardDocs/cardDocs.html +4 -1
- package/src/modules/dx/codeBlock/codeBlock.css +23 -7
- package/src/modules/dx/codeBlock/codeBlock.html +0 -19
- package/src/modules/dx/codeBlock/codeBlock.ts +58 -119
- package/src/modules/dx/dropdown/dropdown.ts +2 -3
- package/src/modules/dx/filterMenu/filterMenu.html +7 -2
- package/src/modules/dx/filterMenu/filterMenu.ts +4 -3
- package/src/modules/dx/footer/links.ts +2 -4
- package/src/modules/dx/grid/grid.ts +3 -1
- package/src/modules/dx/header/header.html +4 -1
- package/src/modules/dx/popover/popover.ts +3 -3
- package/src/modules/dx/searchResults/searchResults.ts +1 -3
- package/src/modules/dx/select/select.ts +2 -3
- package/src/modules/dx/sidebar/sidebar.ts +7 -5
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +2 -5
- package/src/modules/dx/tabPanelList/tabPanelList.ts +2 -2
- package/src/modules/dxBaseElements/headerBase/headerBase.ts +2 -0
- package/src/modules/dxBaseElements/matchMediaElement/matchMediaElement.ts +2 -4
- package/src/modules/dxUtils/prismjs/prismjs.ts +287 -167
- package/src/modules/dxUtils/shiki/languages.ts +18 -0
- package/src/modules/dxUtils/shiki/shiki.ts +74 -0
- package/LICENSE +0 -12
- package/src/modules/dxHelpers/code/code.css +0 -296
- package/src/modules/dxUtils/prismjs/prismjs.html +0 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Definition of languages that should directly be bundled with this module.
|
|
2
|
+
//
|
|
3
|
+
// File data is read and replaced when bundled.
|
|
4
|
+
//
|
|
5
|
+
// https://github.com/shikijs/shiki/blob/main/docs/languages.md#supporting-your-own-languages-with-shiki
|
|
6
|
+
// I ack that this is _super_ hacky for Rollup. 🤷🏼♂️
|
|
7
|
+
export const DEFAULT_LANGUAGES: any = process.env.SHIKI_LANGUAGES || [];
|
|
8
|
+
|
|
9
|
+
// export const DEFAULT_LANGUAGES = process.env.SHIKI_LANGUAGES;
|
|
10
|
+
// Definition of languages that are not part of the Shiki project (yet).
|
|
11
|
+
export const CUSTOM_LANGUAGES = [
|
|
12
|
+
{
|
|
13
|
+
id: "amp",
|
|
14
|
+
scopeName: "source.amp",
|
|
15
|
+
path: "languages/amp.tmLanguage.json",
|
|
16
|
+
embeddedLangs: ["r"]
|
|
17
|
+
}
|
|
18
|
+
];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { BUNDLED_LANGUAGES, getHighlighter, setCDN, setWasm } from "shiki";
|
|
2
|
+
import { CUSTOM_LANGUAGES, DEFAULT_LANGUAGES } from "./languages";
|
|
3
|
+
|
|
4
|
+
// Sets the path where to load assets from.
|
|
5
|
+
const SHIKI_ASSETS_PATH: string =
|
|
6
|
+
process.env.SHIKI_ASSETS_PATH || "/assets/shiki/";
|
|
7
|
+
setCDN(SHIKI_ASSETS_PATH);
|
|
8
|
+
setWasm("dist/onig.wasm"); // Loads the WASM file, eventually better to put into an observable to ensure single-time load
|
|
9
|
+
|
|
10
|
+
// Custom themes that are used for syntax highlighting
|
|
11
|
+
// https://github.com/forcedotcom/codey-midnight
|
|
12
|
+
// https://github.com/forcedotcom/codey-highnoon
|
|
13
|
+
const THEMES = ["codey-highnoon", "codey-midnight"];
|
|
14
|
+
|
|
15
|
+
class ShikiWrapper {
|
|
16
|
+
private theme = THEMES[0];
|
|
17
|
+
|
|
18
|
+
setTheme(theme: string) {
|
|
19
|
+
this.theme = theme === "light" ? "codey-highnoon" : "codey-midnight";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
isMarkupLanguage(lang: string) {
|
|
23
|
+
return (
|
|
24
|
+
lang === "html" ||
|
|
25
|
+
lang === "visualforce" ||
|
|
26
|
+
lang === "xml" ||
|
|
27
|
+
lang === "text" ||
|
|
28
|
+
lang === ""
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async codeToHtml(code: string, options?: any) {
|
|
33
|
+
const langs = DEFAULT_LANGUAGES.map(
|
|
34
|
+
(bundle: any) => ({
|
|
35
|
+
id: bundle.id,
|
|
36
|
+
scopeName: bundle.scopeName,
|
|
37
|
+
aliases: bundle.aliases,
|
|
38
|
+
grammar: bundle
|
|
39
|
+
}),
|
|
40
|
+
{}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const highlighter = await getHighlighter({
|
|
44
|
+
themes: THEMES,
|
|
45
|
+
langs
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!highlighter.getLoadedLanguages().includes(options.lang)) {
|
|
49
|
+
if (this.isMarkupLanguage(options.lang)) {
|
|
50
|
+
options.lang = "html";
|
|
51
|
+
}
|
|
52
|
+
let langBundle = BUNDLED_LANGUAGES.find((bundle) => {
|
|
53
|
+
return bundle.id === options.lang;
|
|
54
|
+
});
|
|
55
|
+
if (!langBundle && CUSTOM_LANGUAGES.length > 0) {
|
|
56
|
+
langBundle = CUSTOM_LANGUAGES.find((bundle) => {
|
|
57
|
+
return bundle.id === options.lang;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
await highlighter.loadLanguage(langBundle);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
// If we _really_ have no code in the whole project let's just return the text.
|
|
64
|
+
return code;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
options.theme = this.theme;
|
|
68
|
+
return highlighter.codeToHtml(code, options);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const Shiki = new ShikiWrapper();
|
|
73
|
+
|
|
74
|
+
export { Shiki };
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
/* Custom prism.js stylesheet */
|
|
2
|
-
/* stylelint-disable selector-pseudo-element-no-unknown */
|
|
3
|
-
.dx-variant-block dx-button {
|
|
4
|
-
--dx-c-button-primary-color: var(--dx-g-gray-50);
|
|
5
|
-
--dx-c-button-primary-color-hover: var(--dx-g-gray-50);
|
|
6
|
-
--dx-c-button-secondary-color-hover: var(--dx-g-gray-95);
|
|
7
|
-
--dx-c-button-inline-color-hover: var(--dx-g-gray-50);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.dx-theme-dark.dx-variant-card dx-button {
|
|
11
|
-
--dx-c-button-primary-color: var(--dx-g-hot-orange-vibrant-95);
|
|
12
|
-
--dx-c-button-primary-color-hover: var(--dx-g-hot-orange-vibrant-95);
|
|
13
|
-
--dx-c-button-secondary-color-hover: var(--dx-g-blue-vibrant-10);
|
|
14
|
-
--dx-c-button-inline-color-hover: var(--dx-g-hot-orange-vibrant-95);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.dx-theme-light.dx-variant-card dx-button {
|
|
18
|
-
--dx-c-button-primary-color: var(--dx-g-blue-vibrant-20);
|
|
19
|
-
--dx-c-button-primary-color-hover: var(--dx-g-blue-vibrant-20);
|
|
20
|
-
--dx-c-button-secondary-color-hover: var(--dx-g-hot-orange-vibrant-95);
|
|
21
|
-
--dx-c-button-inline-color-hover: var(--dx-g-hot-orange-vibrant-95);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
pre[class*="language-"],
|
|
25
|
-
code[class*="language-"] {
|
|
26
|
-
font-size: 14px;
|
|
27
|
-
text-shadow: none;
|
|
28
|
-
font-family: var(--dx-g-font-mono);
|
|
29
|
-
direction: ltr;
|
|
30
|
-
text-align: left;
|
|
31
|
-
white-space: pre;
|
|
32
|
-
word-spacing: normal;
|
|
33
|
-
word-break: normal;
|
|
34
|
-
line-height: 20px;
|
|
35
|
-
-moz-tab-size: 4;
|
|
36
|
-
-o-tab-size: 4;
|
|
37
|
-
tab-size: 4;
|
|
38
|
-
-webkit-hyphens: none;
|
|
39
|
-
-moz-hyphens: none;
|
|
40
|
-
-ms-hyphens: none;
|
|
41
|
-
hyphens: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
pre[class*="language-"]::selection,
|
|
45
|
-
code[class*="language-"]::selection,
|
|
46
|
-
pre[class*="language-"]::mozselection,
|
|
47
|
-
code[class*="language-"]::mozselection {
|
|
48
|
-
text-shadow: none;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.dx-theme-dark code[class*="language-"] {
|
|
52
|
-
color: rgb(255, 255, 255);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.dx-theme-light code[class*="language-"] {
|
|
56
|
-
color: var(--dx-g-gray-10);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.dx-theme-dark code[class*="language-"]::mozselection {
|
|
60
|
-
background: rgb(255, 255, 255);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.dx-theme-light code[class*="language-"]::mozselection {
|
|
64
|
-
background: var(--dx-g-gray-95);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.dx-variant-card pre[class*="language-"] {
|
|
68
|
-
padding: 1em;
|
|
69
|
-
border-radius: 0 0 0.3em 0.3em;
|
|
70
|
-
overflow: auto;
|
|
71
|
-
word-wrap: normal;
|
|
72
|
-
white-space: pre;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.dx-variant-card :not(pre) > code[class*="language-"] {
|
|
76
|
-
padding: 0.1em 0.3em;
|
|
77
|
-
border-radius: 0.3em;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.dx-variant-block pre[class*="language-"] {
|
|
81
|
-
padding: 1em;
|
|
82
|
-
border-radius: 0.3em;
|
|
83
|
-
overflow: auto;
|
|
84
|
-
word-wrap: normal;
|
|
85
|
-
white-space: pre;
|
|
86
|
-
width: 94%;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.dx-variant-block :not(pre) > code[class*="language-"] {
|
|
90
|
-
padding: 0.1em 0.3em;
|
|
91
|
-
border-radius: 0.3em;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.dx-theme-dark pre[class*="language-"] {
|
|
95
|
-
color: rgb(255, 255, 255);
|
|
96
|
-
background: var(--dx-g-blue-vibrant-10);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.dx-theme-dark :not(pre) > code[class*="language-"] {
|
|
100
|
-
color: rgb(255, 255, 255);
|
|
101
|
-
background: var(--dx-g-blue-vibrant-10);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.dx-theme-light pre[class*="language-"] {
|
|
105
|
-
color: var(--dx-g-gray-10);
|
|
106
|
-
background: var(--dx-g-gray-95);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.dx-theme-light :not(pre) > code[class*="language-"] {
|
|
110
|
-
color: var(--dx-g-gray-10);
|
|
111
|
-
background: var(--dx-g-gray-95);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/*********************************************************
|
|
115
|
-
* Tokens
|
|
116
|
-
*/
|
|
117
|
-
.namespace {
|
|
118
|
-
opacity: 0.7;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.token.important,
|
|
122
|
-
.token.bold {
|
|
123
|
-
font-weight: bold;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.token.italic {
|
|
127
|
-
font-style: italic;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.token.entity {
|
|
131
|
-
cursor: help;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/*********************************************************
|
|
135
|
-
* Line highlighting
|
|
136
|
-
*/
|
|
137
|
-
pre[data-line] {
|
|
138
|
-
position: relative;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
pre[class*="language-"] > code[class*="language-"] {
|
|
142
|
-
position: relative;
|
|
143
|
-
display: block;
|
|
144
|
-
z-index: 1;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.line-highlight {
|
|
148
|
-
position: absolute;
|
|
149
|
-
left: 0;
|
|
150
|
-
right: 0;
|
|
151
|
-
padding: inherit 0;
|
|
152
|
-
margin-top: 1em;
|
|
153
|
-
background: #1e2d50;
|
|
154
|
-
box-shadow: inset 5px 0 0 #0176d3;
|
|
155
|
-
z-index: 0;
|
|
156
|
-
pointer-events: none;
|
|
157
|
-
line-height: inherit;
|
|
158
|
-
white-space: pre;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.line-numbers .line-highlight::before,
|
|
162
|
-
.line-numbers .line-highlight::after {
|
|
163
|
-
content: none;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.line-numbers-rows > span::before {
|
|
167
|
-
content: counter(linenumber);
|
|
168
|
-
color: var(--dx-g-gray-50);
|
|
169
|
-
display: block;
|
|
170
|
-
padding-right: 0.4em;
|
|
171
|
-
text-align: right;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
pre[id].linkable-line-numbers span.line-numbers-rows {
|
|
175
|
-
pointer-events: all;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
pre[id].linkable-line-numbers span.line-numbers-rows > span::before {
|
|
179
|
-
cursor: pointer;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
pre[id].linkable-line-numbers span.line-numbers-rows > span:hover::before {
|
|
183
|
-
background-color: rgba(128, 128, 128, 0.2);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
pre[class*="language-"].line-numbers {
|
|
187
|
-
position: relative;
|
|
188
|
-
padding-left: 3.8em;
|
|
189
|
-
counter-reset: linenumber;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
pre[class*="language-"].line-numbers > code {
|
|
193
|
-
position: relative;
|
|
194
|
-
white-space: inherit;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.line-numbers .line-numbers-rows {
|
|
198
|
-
position: absolute;
|
|
199
|
-
pointer-events: none;
|
|
200
|
-
top: 0;
|
|
201
|
-
font-size: 100%;
|
|
202
|
-
left: -3.8em;
|
|
203
|
-
width: 3em; /* works for line-numbers below 1000 lines */
|
|
204
|
-
letter-spacing: -1px;
|
|
205
|
-
-webkit-user-select: none;
|
|
206
|
-
-moz-user-select: none;
|
|
207
|
-
-ms-user-select: none;
|
|
208
|
-
user-select: none;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.line-numbers-rows > span {
|
|
212
|
-
display: block;
|
|
213
|
-
counter-increment: linenumber;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.dx-variant-block.code-toolbar {
|
|
217
|
-
display: flex;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/* for card variant */
|
|
221
|
-
div.code-toolbar.dx-variant-card {
|
|
222
|
-
display: flex;
|
|
223
|
-
flex-direction: column-reverse;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
div.code-toolbar:hover > .toolbar {
|
|
227
|
-
opacity: 1;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
div.code-toolbar:focus-within > .toolbar {
|
|
231
|
-
opacity: 1;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
div.code-toolbar.dx-variant-card > .toolbar {
|
|
235
|
-
border-radius: 0.3em 0.3em 0 0;
|
|
236
|
-
opacity: 1; /* card for base set to 0 */
|
|
237
|
-
display: flex;
|
|
238
|
-
align-items: center;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
div.code-toolbar.dx-variant-block > .toolbar {
|
|
242
|
-
transition: opacity 0.3s ease-in-out;
|
|
243
|
-
opacity: 0; /* card for base set to 0 */
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
div.code-toolbar.dx-theme-dark.dx-variant-card > .toolbar {
|
|
247
|
-
background-color: var(--dx-g-blue-natural-20);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
div.code-toolbar.dx-theme-light.dx-variant-card > .toolbar {
|
|
251
|
-
background-color: var(--dx-g-gray-90);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.dx-variant-block .toolbar-item {
|
|
255
|
-
padding-left: 4px;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.dx-variant-card .toolbar-item:first-child {
|
|
259
|
-
flex-basis: 95%;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.dx-variant-card .dx-code-block-heading {
|
|
263
|
-
transform: translateY(3px);
|
|
264
|
-
padding-left: 20px;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.dx-variant-card.dx-theme-dark .dx-code-block-heading {
|
|
268
|
-
color: white !important;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.dx-variant-card.dx-theme-light .dx-code-block-heading {
|
|
272
|
-
color: var(--dx-g-blue-vibrant-20);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/* Separate line b/c rules are thrown out if selector is invalid.
|
|
276
|
-
IE11 and old Edge versions don't support :focus-within. */
|
|
277
|
-
|
|
278
|
-
div.code-toolbar > .toolbar .toolbar-item {
|
|
279
|
-
display: inline-block;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
div.code-toolbar > .toolbar a {
|
|
283
|
-
cursor: pointer;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
div.code-toolbar > .toolbar a,
|
|
287
|
-
div.code-toolbar > .toolbar button,
|
|
288
|
-
div.code-toolbar > .toolbar a:hover,
|
|
289
|
-
div.code-toolbar > .toolbar a:focus,
|
|
290
|
-
div.code-toolbar > .toolbar button:hover,
|
|
291
|
-
div.code-toolbar > .toolbar button:focus,
|
|
292
|
-
div.code-toolbar > .toolbar span:hover,
|
|
293
|
-
div.code-toolbar > .toolbar span:focus {
|
|
294
|
-
color: inherit;
|
|
295
|
-
text-decoration: none;
|
|
296
|
-
}
|