monaco-editor: Can not create two editor with different theme

monaco-editor version: 0.14.2 & 0.18.1 Browser: chrome 69 OS: macOS Mojave 10.14 Playground code that reproduces the issue:

monaco.editor.create(document.getElementById("container"), {
	value: "function hello() {\n\talert('Hello world!');\n}",
        theme: 'vs-light',
	language: "javascript"
});


monaco.editor.create(document.getElementById("container1"), {
	value: "function hello() {\n\talert('Hello Monaco!');\n}",
        theme: 'vs-dark',
	language: "javascript"
});
<div id="container" style="height:30%;"></div>
<hr>
<div id="container1" style="height:30%;"></div>

屏幕快照 2019-12-18 下午7 45 58

I set dark theme and light theme, but all show dark theme

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 17 (1 by maintainers)

Most upvoted comments

You can try… const ed1 = monaco.editor const ed2 = monaco.editor // Other monaco ed1.create(…) ed2.create(…)

the same problem, how to solve?

Ah, I discovered that setTheme exists but it is a global thing: https://microsoft.github.io/monaco-editor/api/modules/monaco.editor.html#settheme

so this issue then is a feature request to move setTheme to https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandalonecodeeditor.html or some other way of achieving the same thing.