Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not create two editor with different theme #1713

Closed
WangYuLue opened this issue Dec 18, 2019 · 17 comments
Closed

Can not create two editor with different theme #1713

WangYuLue opened this issue Dec 18, 2019 · 17 comments
Labels
duplicate feature-request Request for new features or functionality themes
Milestone

Comments

@WangYuLue
Copy link

WangYuLue commented Dec 18, 2019

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

@WangYuLue WangYuLue changed the title Can not create tow editor with different theme Can not create two editor with different theme Dec 18, 2019
@alexdima alexdima added feature-request Request for new features or functionality themes labels Dec 20, 2019
@alexdima alexdima added this to the Backlog milestone Jan 6, 2020
@yunliang-ding
Copy link

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

@shmish111
Copy link

I can report the same thing, @yunliang-ding your solution didn't seem to work. In my case I am actually calling create at two different times:

exports.create_ = function (monaco, nodeId, languageId, themeName) {
  console.log(nodeId);
  console.log(languageId);
  console.log(themeName);
  const editor = monaco.editor.create(nodeId, {
    value: [
      'Close'
    ].join('\n'),
    language: languageId,
    theme: themeName,
  });
  return editor;
}

Note here that monaco references the same object coming from webpack entry point:

import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
global.monaco = monaco;

This is a real issue for me now 😢

@shmish111
Copy link

Also note that all other things that depend on languageId seem to work just fine (TokensProvider, DocumentFormattingEditProvider etc). For example, for one of the editors I provide a DocumentFormattingEditProvider but for the other I do not. If I press f1 on each editor then only 1 has access to "Format Document" as expected.

@shmish111
Copy link

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.

@bodinsamuel

This comment has been minimized.

@10229428

This comment has been minimized.

@shmish111
Copy link

I've been changing the theme every time I switch, not ideal though and it only works for me since I never have 2 editors on screen at the same time

@zuiidea

This comment has been minimized.

@SPERONIS

This comment has been minimized.

1 similar comment
@fomenyesu

This comment has been minimized.

@14glwu
Copy link

14glwu commented Jul 28, 2022

the same problem, how to solve?

@Oleksandr-Silin
Copy link

Is it planned to be fixed?

@joaohenrifranco
Copy link

Have you guys found any workarounds?

@keyon17
Copy link

keyon17 commented Mar 5, 2023

how to solve?

@praylee
Copy link

praylee commented Mar 30, 2023

I am also here to look for solutions. Didn't work for me at v0.36.1. Do we get a fix now?

@zerobytes
Copy link

This is related.
#338 (comment)

@hediet
Copy link
Member

hediet commented May 26, 2023

/duplicate #338

@hediet hediet closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate feature-request Request for new features or functionality themes
Projects
None yet
Development

No branches or pull requests