You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// default monaco-editor imports
import * as monaco from 'monaco-editor';
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
// utilities to override Monaco services
import { initialize } from 'vscode/services'
import getConfigurationServiceOverride, { updateUserConfiguration } from '@codingame/monaco-vscode-configuration-service-override'
window.MonacoEnvironment = {
getWorker: (_moduleId, _label) => new editorWorker()
}
// overriding Monaco service with VSCode
await initialize({
...getConfigurationServiceOverride(),
});
// json config like in vscode settings.json
updateUserConfiguration(`{
"editor.fontSize": 30,
"editor.lineHeight": 30,
"editor.fontFamily": "monospace",
"editor.fontWeight": "bold",
"editor.letterSpacing": 0,
}`)
// creating an editor with VSCode configuration
monaco.editor.create(document.getElementById('editor')!, {
value: "Editor with VSCode config and large bold fonts",
});
Yes, this way I can configure some font operations. What if I want to configure my own defined theme
The original method of using Monaco was relatively simple, eg
If you are not using the theme and textmate service overrides, using monaco.editor.defineTheme is perfectly fine
updateUserConfiguration allows to update the user configuration, it has nothing to do with the color theme
if you are using the textmate and theme service overrides, themes are registered by VSCode extensions. You need one to register your custom theme. Either by using an existing extension vsix file, or programmatically:
import{ExtensionHostKind,registerExtension}from'vscode/extensions'const{ registerFileUrl }=registerExtension({name: 'myTheme',publisher: 'me',version: '1.0.0',engines: {vscode: '*'},contributes: {themes: [{id: "My Theme Id",label: "My Theme Name",uiTheme: "vs-dark",path: "./themes/mytheme.json",}]})// The theme content can be registered using its content via a base64 urlsregisterFileUrl('./themes/mytheme.json','data:text/javascript;base64,'+window.btoa(JSON.stringify(themeJsonContent)))// Or reference a json file from the diskregisterFileUrl('./themes/mytheme.json',newURL('./the/file/on/the/disk.json',import.meta.url))
I am using Vite+Vue3
The latest monaco-vscode-api package used
I read #465 ,but I'm confused.
Yes, this way I can configure some font operations. What if I want to configure my own defined theme
The original method of using Monaco was relatively simple, eg
Of course, I made some attempts but it didn't work. e.g
I admit that my programming ability is weak, and I hope you can provide beginners with a rich set of operation and learning documents.
I read #517 Benefiting greatly
But it's been several days now and there hasn't been any progress.
Thanks
The text was updated successfully, but these errors were encountered: