mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 08:31:31 +00:00
Replace roll-your-own basic WebIDE with Ace Editor
This commit is contained in:
parent
642ca7f54c
commit
cb625bf116
@ -11,6 +11,7 @@ downloaded from the following locations:
|
||||
* [Popper.js](https://github.com/FezVrasta/popper.js#installation)
|
||||
* [Highlight.js](https://highlightjs.org/download/)
|
||||
* [Showdown](https://github.com/showdownjs/showdown/releases)
|
||||
* [ace](https://github.com/ajaxorg/ace-builds/releases)
|
||||
|
||||
## Building and running with Docker
|
||||
|
||||
|
@ -1,6 +1,11 @@
|
||||
let ws = new WebSocket('ws://' + document.location.host + '/ws');
|
||||
|
||||
let converter = new showdown.Converter();
|
||||
// TODO: don't hardcode anchor id
|
||||
let editor = ace.edit('anchor_webide');
|
||||
editor.setTheme('ace/theme/monokai');
|
||||
editor.getSession().setMode('ace/mode/python');
|
||||
editor.$blockScrolling = Infinity;
|
||||
|
||||
$('#container').on('click', '.anchor', ( function (event) {
|
||||
let anchorName = $(this).attr('id').replace('_event', '');
|
||||
@ -42,8 +47,7 @@ ws.onmessage = function (messageEvent) {
|
||||
console.log(message);
|
||||
let $anchor = $('#' + message['anchor']);
|
||||
if (message['anchor'] === 'anchor_webide') {
|
||||
let code = hljs.highlightAuto(message['data']);
|
||||
$anchor.html(code.value);
|
||||
editor.setValue(message['data'], -1);
|
||||
}
|
||||
else {
|
||||
let formatted_message = converter.makeHtml(message['data']);
|
||||
|
@ -42,6 +42,7 @@
|
||||
<script src="{{ static_url('vendor/js/bootstrap.min.js') }}" defer></script>
|
||||
<script src="{{ static_url('vendor/js/highlight.min.js') }} defer"></script>
|
||||
<script src="{{ static_url('vendor/js/showdown.min.js') }} defer"></script>
|
||||
<script src="{{ static_url('vendor/js/ace/ace.js') }} defer"></script>
|
||||
<script src="{{ static_url('ws_listener.js') }}" defer></script>
|
||||
</body>
|
||||
</html>
|
@ -1,9 +1,6 @@
|
||||
<h1>Source code</h1>
|
||||
<pre>
|
||||
<code id="{{ anchor_id }}">
|
||||
|
||||
</code>
|
||||
</pre>
|
||||
<div id="{{ anchor_id }}" class="mt-3 mb-3">
|
||||
</div>
|
||||
<button type="button" class="btn btn-outline-primary anchor" id="{{ anchor_id }}_event">
|
||||
Next
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user