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
how to change the display languge #375
Comments
If you're referring to the language the syntax highlight uses, then I think editor.updateOptions({
language: "cpp" // or whatever language you need here, javascript, or go or whatever
}); should do the trick. |
i have solved the issue: |
it doesn't work when i use
with |
You should change a language on a model: |
Are you sure In my code Note that it is not the problem of the directive, because it works well to change Could anyone help? |
@SoftTimur I believe It's confusing because |
I have tried I have been at this for hours. (Using Angular 5), So I am creating the editor with simple html, Can anyone be of assistance? |
Welp... hackin my way through....
this seems to work for me |
@SGissubel The https://microsoft.github.io/monaco-editor/api/modules/monaco.editor.html#getmodel You can't just call |
@rcjsuen As mentioned though.... |
@SGissubel Yes, I realize that that function was not working for you. And I was explaining to you why the code you wrote won't work because you need to provide the https://microsoft.github.io/monaco-editor/api/modules/monaco.editor.html#getmodel
You shouldn't call |
@rcjsuen Absolutely... the documents are a maze of mine-fields and dead ends. As I said, I combed those documents thoroughly for most of the day. URI is still a bit ambiguous to me, how it's recieved, what it is... So for now, the getModels()[0] works for me and does the job. |
Here is some code that you can try in the Monaco Editor Playground. If you click on the button you can toggle between JavaScript syntax highlighting and HTML syntax highlighting. Good luck with your project! JavaScript: const value = `function test() {
}
<button onclick="change()">Click</button>
<div id="container" style="height:90%;"></div>`;
const model = monaco.editor.createModel(value, "javascript");
monaco.editor.create(document.getElementById("container"), {
model: model
});
var js = true;
function change() {
js = !js;
var language = js ? "javascript" : "html";
monaco.editor.setModelLanguage(monaco.editor.getModel(model.uri), language);
} HTML: <button onclick="change()">toggle language</button>
<div id="container" style="height:90%;"></div> |
Where you are put this code? I'm trying put it to monacoConfig.onMonacoLoad but it doesn't work :(
|
Anyone knows how to change the language according to code file extension or first line like "#!/usr/bin/env python"? |
i need to change the display language, don`t know how to do?
The text was updated successfully, but these errors were encountered: