If you want to build an editor as much compatible with the web as possible, then CodeMirror is the way to go.