monaco editor theme can not be changed dynamically

Viewed 217

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.

0 Answers
Related