@salesforcedevs/dx-components 1.3.82 → 1.3.84
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 +3 -6
- package/package.json +2 -3
- package/src/modules/dx/audio/audio.ts +50 -0
- package/src/modules/dx/breadcrumbs/breadcrumbs.ts +10 -8
- package/src/modules/dx/cardContent/cardContent.html +1 -4
- package/src/modules/dx/cardDocs/cardDocs.html +1 -4
- package/src/modules/dx/codeBlock/codeBlock.css +7 -23
- package/src/modules/dx/codeBlock/codeBlock.html +19 -0
- package/src/modules/dx/codeBlock/codeBlock.ts +110 -70
- package/src/modules/dx/dropdown/dropdown.ts +3 -2
- package/src/modules/dx/filterMenu/filterMenu.html +2 -7
- package/src/modules/dx/filterMenu/filterMenu.ts +3 -4
- package/src/modules/dx/footer/links.ts +4 -2
- package/src/modules/dx/grid/grid.ts +1 -3
- package/src/modules/dx/popover/popover.ts +3 -3
- package/src/modules/dx/searchResults/searchResults.ts +3 -1
- package/src/modules/dx/select/select.ts +3 -2
- package/src/modules/dx/sidebar/sidebar.ts +5 -7
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +5 -2
- package/src/modules/dx/tabPanelList/tabPanelList.ts +2 -2
- package/src/modules/dxBaseElements/matchMediaElement/matchMediaElement.ts +4 -2
- package/src/modules/dxHelpers/code/code.css +296 -0
- package/src/modules/dxUtils/prismjs/prismjs.html +3 -0
- package/src/modules/dxUtils/prismjs/prismjs.ts +167 -287
- package/src/assets/shiki/languages/amp.tmLanguage.json +0 -205
- package/src/assets/shiki/themes/codey-highnoon.json +0 -650
- package/src/assets/shiki/themes/codey-midnight.json +0 -622
- package/src/modules/dxUtils/shiki/languages.ts +0 -18
- package/src/modules/dxUtils/shiki/shiki.ts +0 -75
|
@@ -1,75 +0,0 @@
|
|
|
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 === "plain" ||
|
|
29
|
-
lang === ""
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async codeToHtml(code: string, options?: any) {
|
|
34
|
-
const langs = DEFAULT_LANGUAGES.map(
|
|
35
|
-
(bundle: any) => ({
|
|
36
|
-
id: bundle.id,
|
|
37
|
-
scopeName: bundle.scopeName,
|
|
38
|
-
aliases: bundle.aliases,
|
|
39
|
-
grammar: bundle
|
|
40
|
-
}),
|
|
41
|
-
{}
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const highlighter = await getHighlighter({
|
|
45
|
-
themes: THEMES,
|
|
46
|
-
langs
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (!highlighter.getLoadedLanguages().includes(options.lang)) {
|
|
50
|
-
if (this.isMarkupLanguage(options.lang)) {
|
|
51
|
-
options.lang = "html";
|
|
52
|
-
}
|
|
53
|
-
let langBundle = BUNDLED_LANGUAGES.find((bundle) => {
|
|
54
|
-
return bundle.id === options.lang;
|
|
55
|
-
});
|
|
56
|
-
if (!langBundle && CUSTOM_LANGUAGES.length > 0) {
|
|
57
|
-
langBundle = CUSTOM_LANGUAGES.find((bundle) => {
|
|
58
|
-
return bundle.id === options.lang;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
await highlighter.loadLanguage(langBundle);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
// If we _really_ have no code in the whole project let's just return the text.
|
|
65
|
-
return code;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
options.theme = this.theme;
|
|
69
|
-
return highlighter.codeToHtml(code, options);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const Shiki = new ShikiWrapper();
|
|
74
|
-
|
|
75
|
-
export { Shiki };
|