I want to enable the end user to customize the syntax highlighting of the Monaco editor. I know there's defineTheme but I want individual functions for each part of the Monaco colors like the code I have below.
SetBackground = function(background) {
monaco.editor.defineTheme('Custom', {
base: 'vs-dark',
inherit: false,
rules: [],
colors: {
'editor.background': `#${background}`,
}
});
}
This code works for setting the background but when I use my other function for setting the foreground the background reverts to that of vs-dark. Is there any way to write functions like these that add on to an existing theme and update it using user input?
You should keep your theme as a whole in memory and modify it with your function calls. At the end of all the modifier functions set your theme in monaco-editor.