From bb490ffcd8b18924aafd8bf2a76a8b8d83a4ddea Mon Sep 17 00:00:00 2001 From: _Kerman Date: Fri, 27 Sep 2024 15:14:01 +0800 Subject: [PATCH] fix: automatially register languages highlighted by Shiki to Monaco Editor (#1858) --- packages/client/setup/monaco.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/client/setup/monaco.ts b/packages/client/setup/monaco.ts index 05f480521f..4119e57389 100644 --- a/packages/client/setup/monaco.ts +++ b/packages/client/setup/monaco.ts @@ -92,7 +92,7 @@ const setup = createSingletonPromise(async () => { monaco.languages.register({ id: 'typescript' }) monaco.languages.register({ id: 'javascript' }) - const { shiki, themes, shikiToMonaco } = await import('#slidev/shiki') + const { shiki, langs, themes, shikiToMonaco } = await import('#slidev/shiki') const highlighter = await shiki const editorOptions: MonacoSetupReturn['editorOptions'] & object = {} @@ -113,6 +113,10 @@ const setup = createSingletonPromise(async () => { : themes.light || 'vitesse-light') }) } + // Register all languages, otherwise Monaco will not highlight them + for (const lang of langs) { + monaco.languages.register({ id: lang }) + } return { monaco,