Is this a possibility? Say I wanted to include the contents of the editor as part of a form and submit the entered text? Codemirror supports this by allowing you to bind the editor to a textarea. Binding it like this is not really necessary in my specific situation but an easy call to grab the contents of the editor as text would be helpful. Is this possible?
Yes, Try this in the playground
var editor = monaco.editor.create(document.getElementById("container"), {
value: "function hello() {\n\talert('Hello world!');\n}",
language: "javascript"
});
console.log(editor.getValue())
Awesome thanks for the quick response. I had assumed there was a simple solution to this but was for some reason unable to find it.
So, it's not OK to put the editor inside a <form> and expect to get the full content to be send to the server. The value should be retrieved with editor.getValue() just before submit the form.
Most helpful comment
Yes, Try this in the playground