diff --git a/static/script/editor.js b/static/script/editor.js index d2a9b09..92f7e7f 100644 --- a/static/script/editor.js +++ b/static/script/editor.js @@ -12,6 +12,8 @@ let proxy = URL.createObjectURL(new Blob([` require(["vs/editor/editor.main"], function () { let init_lang = 'python'; + /** @type {string[]} */ + const supported_langs = get_langs(); let editor = monaco.editor.create(document.getElementById('container'), { value: '# put code here', @@ -24,6 +26,8 @@ require(["vs/editor/editor.main"], function () { }); monaco.languages.getLanguages().forEach(x => { + if (supported_langs.indexOf(x.id) === -1) return + let el = document.createElement('option'); el.id = x.id; el.innerText = x.id; @@ -34,7 +38,8 @@ require(["vs/editor/editor.main"], function () { }) document.getElementById('lang').onchange = (e) => { - monaco.editor.setModelLanguage(editor.getModel(), e.target.value) + e = e.target; + monaco.editor.setModelLanguage(editor.getModel(), e.options[e.selectedIndex].id) } document.getElementById('run').onclick = (e) => { diff --git a/templates/base.html b/templates/base.html index 45f94f5..9521550 100644 --- a/templates/base.html +++ b/templates/base.html @@ -12,8 +12,10 @@

Sandy

+ {% block body %}{% endblock %} + {% block script %}{% endblock %}