// TODO: works only once on a page // requires JQuery // TODO: update hidden value every time a change occurs sS hAceEditor(S text, O... _) { //_ = html_massageAutofocusParam(_); optPar S name = "text"; S id = "ace_" + name; ret div(htmlEncode2(text), params_stylePlus("display: none", paramsPlus(_, +id))) + hscriptsrc("https://botcompany.de/ace-builds/src-noconflict/ace.js") + hscriptsrc("https://botcompany.de/ace-builds/src-noconflict/ext-language_tools.js") + hhiddenWithIDAndName(name) + hscript(replaceDollarVars([[ { ace.require("ace/ext/language_tools"); var editor = ace.edit($id); editor.setTheme("ace/theme/ambience"); editor.getSession().setTabSize(2); editor.getSession().setUseSoftTabs(true); editor.getSession().setUseWrapMode(true); document.getElementById($id).style.fontSize='15px'; editor.setOptions({ enableBasicAutocompletion: true }); var div = $("#" + $id); div.show(); //editor.focus(); var form = div.closest('form'); if (form) { console.log("Adding submit listener to form"); form.on('submit', function() { var textField = document.getElementById($name); console.log("textField: " + textField); textField.value = editor.getValue(); }); } } ]], id := jsQuote(id), name := jsQuote(name)); }