If you already use javascript, I think embed a code editor will be better than create a new one, I’ve tried to make an example with ax-webview in Axure 9:
【Preview】
http://minicg.com/demo/axure/monaco-code-editor
【RP File】
monaco-code-editor.rp (58.5 KB)
【Monaco Editor】
https://microsoft.github.io/monaco-editor/playground.html