To my understanding monaco-editor and VSCode are using two different formats to define themes.
- Example: Default Monaco themes
- Example: Default VSC theme
It seems that an earlier version of VSC primarily used the tmTheme
definition format which allowed themes to be converted using this tool (also see a GitHub issue from 2017). However, since VSC is now using a new format to define its themes, I'm wondering whether there is a (simple) way to use existing VSC themes in the Monaco editor.
Thanks a lot for your help! :)
P.S. This GitHub issue comment from 2019 seems to indicate that there is indeed no easy way to do this but hopefully things have changed since then.
The tmTheme format is still supported in theme extensions and converted on import (from what I remember). The primary definition of a theme in an extension, however, is using the approach like shown in dark_plus.json.
It's pretty easy to convert the json format to the structure that's expected by monaco-editor:
These interfaces describe the format of the json file. Older theme definitions use the
settings
member to define theme colors. In such a case simply set thetokenColors
member to thesettings
member and proceed.Once the theme has been loaded you can use this static method to load it into monaco-editor:
CodeEditor
is my TS class that wraps the monaco-editor. The functioncolorToHex
is defined as: