configui/templates/components/editor.tmpl

35 lines
1008 B
Cheetah

{{define "components/editor"}}
{{template "components/toolbar" .}}
<!-- <container class="container is-max-desktop"> -->
<div id="editor">{{.File.Content}}</div>
<!-- </container> -->
<script>
function setEditor(){
var beautify = ace.require("ace/ext/beautify");
window.beautify = beautify
var editor = ace.edit("editor");
window.editor = editor
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/{{.Editor.Lang}}");
editor.session.setUseWrapMode(false);
editor.session.setNewLineMode('{{.Editor.Platform}}')
editor.setReadOnly({{.File.RO}});
editor.session.on('change', function(delta) {
// delta.start, delta.end, delta.lines, delta.action
window.ContentChanged = true
});
editor.commands.addCommand({
name: 'SaveContent',
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
exec: function(editor) {
//...
FileSave()
},
readOnly: false // false if this command should not apply in readOnly mode
});
}
</script>
{{end}}