You can access the code using the code property:
code
Create valdocument.getElementById("editor").code