Why don't you just copy the class CodeEditor from the example and use it as it is.