How to get the value of Codemirror textarea
Try using getValue()
instead of getCode()
.
Pass in an optional argument into getValue(separator) to specify the string to be used to separate lines (the default is \n
).
This works fine for me.
editor.getValue()
Version: 5
According to the Documentation, you need now to do it like:
doc.getValue(?separator: string) → string
So in this example:
editor.getDoc().getValue("\n")
use your_editor_instance.getValue();
It will work fine because there is no function named with the name getCode()
in CodeMirror.
For setting value use your_editor_instance.setValue();