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
I have two Monaco Editors in a React project. The first one has a custom theme and accepts text, and the second one accepts the vs-light theme as I understand from my library and prints html in it. Separately, they work correctly, but when the user clicks a button on the page and the second Monaco Editor appears, it breaks the first one and one loses syntax highlighting. But the worst thing is that it stops making text in different tags and makes all the text in one tag, as if it lost their definition. My React components with Monaco Editor are written in classes
I'm talking about this:
Monarch Tokenizer: Основной механизм, который разбивает текст на токены и определяет, какие части текста должны быть выделены, и как они будут отрисованы. Эти токены отображаются с помощью классов , где каждая часть текста, соответствующая определенному типу токена (ключевое слово, строка, комментарий и т.д.), оборачивается в с нужными стилями.
span: Для каждого токена Monaco генерирует элементы span, которым присваиваются определённые классы, связанные с типом токена. Эти классы могут включать mtk1, mtk2, и т.д., для различных типов синтаксиса.
I read a couple of threads on forums that many people have encountered this, but I didn't find a solution, the problem is old, maybe there is a solution now?
monaco.editor.setTheme(theme);
which changes the theme of the second Editor when it appears, they write that it is global. Most likely, that is why it breaks the first Editor. On stackoverflow and git I saw branches where they write that two Editor(s) on one page should have the same style. I tried to put a condition before it, for example, by setting an id or pseudo-class to the element and applying the method only to it through this, it did not help I also tried to wrap the library theme in a custom wrapper that inherits it, because I thought that it would not interrupt, but since setTheme(theme) is most likely global within one page, this did not help
If you comment out the theme of the second Editor, then the first one does not break when it appears, but then the second one does not have syntax highlighting and span tags, it starts everything in one tag.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have two Monaco Editors in a React project. The first one has a custom theme and accepts text, and the second one accepts the vs-light theme as I understand from my library and prints html in it. Separately, they work correctly, but when the user clicks a button on the page and the second Monaco Editor appears, it breaks the first one and one loses syntax highlighting. But the worst thing is that it stops making text in different tags and makes all the text in one tag, as if it lost their definition. My React components with Monaco Editor are written in classes
I'm talking about this:
I read a couple of threads on forums that many people have encountered this, but I didn't find a solution, the problem is old, maybe there is a solution now?
monaco.editor.setTheme(theme);
which changes the theme of the second Editor when it appears, they write that it is global. Most likely, that is why it breaks the first Editor. On stackoverflow and git I saw branches where they write that two Editor(s) on one page should have the same style. I tried to put a condition before it, for example, by setting an id or pseudo-class to the element and applying the method only to it through this, it did not help I also tried to wrap the library theme in a custom wrapper that inherits it, because I thought that it would not interrupt, but since setTheme(theme) is most likely global within one page, this did not help
If you comment out the theme of the second Editor, then the first one does not break when it appears, but then the second one does not have syntax highlighting and span tags, it starts everything in one tag.
Beta Was this translation helpful? Give feedback.
All reactions