Skip to content

Commit

Permalink
fix: automatially register languages highlighted by Shiki to Monaco E…
Browse files Browse the repository at this point in the history
…ditor (#1858)
  • Loading branch information
KermanX authored Sep 27, 2024
1 parent 030021b commit bb490ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/client/setup/monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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,
Expand Down

0 comments on commit bb490ff

Please sign in to comment.