@wandelbots/wandelbots-js-react-components 1.51.0 → 1.51.1-pr.fix-shiki-singleton.170.af06691
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/dist/components/wandelscript-editor/WandelscriptEditor.d.ts.map +1 -1
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1538 -1523
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/wandelscript-editor/WandelscriptEditor.tsx +34 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v1.51.1-pr.fix-shiki-singleton.170.af06691",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,6 +24,37 @@ type WandelscriptEditorProps = {
|
|
|
24
24
|
|
|
25
25
|
const Editor = lazy(() => import("@monaco-editor/react"))
|
|
26
26
|
|
|
27
|
+
let preparedShiki: {
|
|
28
|
+
shiki: HighlighterGeneric<BundledLanguage, BundledTheme>
|
|
29
|
+
shikiToMonaco: (
|
|
30
|
+
shiki: HighlighterGeneric<BundledLanguage, BundledTheme>,
|
|
31
|
+
monaco: Monaco,
|
|
32
|
+
) => void
|
|
33
|
+
} | null = null
|
|
34
|
+
|
|
35
|
+
async function getShiki() {
|
|
36
|
+
if (!preparedShiki) {
|
|
37
|
+
const [{ createHighlighter }, { shikiToMonaco }] = await Promise.all([
|
|
38
|
+
import("shiki"),
|
|
39
|
+
import("@shikijs/monaco"),
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
const shiki = await createHighlighter({
|
|
43
|
+
// Our textmate grammar doesn't quite conform to the expected type
|
|
44
|
+
// here; I'm not sure what the missing properties mean exactly
|
|
45
|
+
langs: [wandelscriptTextmateGrammar as any],
|
|
46
|
+
themes: ["dark-plus", "light-plus"],
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
preparedShiki = {
|
|
50
|
+
shiki,
|
|
51
|
+
shikiToMonaco,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return preparedShiki
|
|
56
|
+
}
|
|
57
|
+
|
|
27
58
|
/** A Monaco (VSCode-style) embedded code editor with Wandelscript syntax highlighting */
|
|
28
59
|
export const WandelscriptEditor = externalizeComponent(
|
|
29
60
|
(props: WandelscriptEditorProps) => {
|
|
@@ -38,11 +69,6 @@ export const WandelscriptEditor = externalizeComponent(
|
|
|
38
69
|
theme.palette.mode === "dark" ? "dark-plus" : "light-plus"
|
|
39
70
|
|
|
40
71
|
async function setupEditor(monaco: Monaco) {
|
|
41
|
-
const [{ createHighlighter }, { shikiToMonaco }] = await Promise.all([
|
|
42
|
-
import("shiki"),
|
|
43
|
-
import("@shikijs/monaco"),
|
|
44
|
-
])
|
|
45
|
-
|
|
46
72
|
// Register and configure the Wandelscript language
|
|
47
73
|
monaco.languages.register({ id: "wandelscript" })
|
|
48
74
|
|
|
@@ -64,19 +90,11 @@ export const WandelscriptEditor = externalizeComponent(
|
|
|
64
90
|
],
|
|
65
91
|
})
|
|
66
92
|
|
|
93
|
+
const { shiki, shikiToMonaco } = await getShiki()
|
|
94
|
+
|
|
67
95
|
// Monaco doesn't support TextMate grammar config directly, so we
|
|
68
96
|
// use Shiki as an intermediary
|
|
69
|
-
|
|
70
|
-
if (!shikiHighlighterRef.current) {
|
|
71
|
-
shikiHighlighterRef.current = await createHighlighter({
|
|
72
|
-
// Our textmate grammar doesn't quite conform to the expected type
|
|
73
|
-
// here; I'm not sure what the missing properties mean exactly
|
|
74
|
-
langs: [wandelscriptTextmateGrammar as any],
|
|
75
|
-
themes: ["dark-plus", "light-plus"],
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
shikiToMonaco(shikiHighlighterRef.current, monaco)
|
|
97
|
+
shikiToMonaco(shiki, monaco)
|
|
80
98
|
|
|
81
99
|
// Override the generated shiki theme to use shiki syntax highlighting
|
|
82
100
|
// but vscode colors
|