简体   繁体   English

摩纳哥编辑器主题无法动态更改

[英]monaco editor theme can not be changed dynamically

I want to update monaco editor theme on the fly, but I found it does not work:我想即时更新摩纳哥编辑器主题,但我发现它不起作用:

this.editorOptions = {
                ...this.editorOptions,
                readOnly: true, // this.readOnly,
                value: this.code,
                language: 'java',
                theme: 'vs'
            };
            this.currentEditor.updateOptions(this.editorOptions);

If I change the readOnly, it worked fine, but theme is NOT updated at all.如果我更改只读,它工作正常,但主题根本没有更新。

the create logic is like this:创建逻辑是这样的:

this.editorOptions = {
                ...this.editorOptions,
                readOnly: this.readOnly,
                value: this.code,
                language: this.updatedType.toLowerCase(),
                //theme: 'vs-dark'
                theme: t === 'light' ? 'dv-light-theme' : 'dv-dark-theme'
            };
            this.currentEditor = monaco.editor.create(this._editorContainer.nativeElement, this.editorOptions);

Please help and show how you can update the theme on the fly dynamically.请帮助并展示如何动态动态更新主题。

I just learned from https://blog.expo.dev/building-a-code-editor-with-monaco-f84b3a06deaf that to set the theme you call monaco.editor.setTheme('<theme-name>') .我刚刚从https://blog.expo.dev/building-a-code-editor-with-monaco-f84b3a06deaf了解到要设置您调用的主题monaco.editor.setTheme('<theme-name>') I was incorrectly calling setTheme on my editor instance.我在我的编辑器实例上错误地调用了setTheme

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM