I can't find a getter method in the API docs for monaco editor, is there an example for how to get code that a user has entered in the editor?
Asked
Active
Viewed 844 times
1 Answers
2
You can retrieve the code that an user has entered by calling the following method:
// Store your editor in a variable
var codeEditor = monaco.editor.create(...);
// Then, whenever you want to retrieve the code, use this.
var codeFromUser = codeEditor.getValue();
You can find similar answers here: Get the value of Monaco Editor

Pablo Alexis Domínguez Grau
- 629
- 7
- 18
-
1thank you, I was going crazy trying to figure it out. – Dion Coder May 01 '20 at 18:14
-
No problem @DionCoder, I'm glad to help. Also, as I see that you're into Monaco, you may also want to checkout other libraries like [Highlight](https://highlightjs.org) and [Prism](https://prismjs.com), it may come in handy too! – Pablo Alexis Domínguez Grau May 01 '20 at 19:27