tmpl/ui/user/panel/webrootedit.tmpl
<div class="tabview" id="{{.ID}}" pkg="{{.PKG}}">
<div class="row">
<div class="col-sm-9 clear-btn" style="min-height:32px;">
<button class="btn btn-warning" onclick="SaveFileWeb('{{.ID}}', '{{.SavesTo}}','{{.PKG}}')"><i class="fa fa-save"></i></button>
<button type="button" class="btn btn-primary" onclick="editors['{{.ID}}c'].wrap = editors['{{.ID}}c'].wrap ? false : true;editors['{{.ID}}'].getSession().setUseWrapMode( editors['{{.ID}}c'].wrap );" data-toggle="button" aria-pressed="true" autocomplete="off">
Wrap text
</button>
</div>
</div>
<div id="editor{{.ID}}" class="defed">{{printf "%s" .File}}</div>
<script type="text/javascript">
editors["{{.ID}}"] = ace.edit("editor{{.ID}}");
editors[{{.ID}} + "c"] = {wrap:false};
editors["{{.ID}}"].getSession().setMode("ace/mode/" + {{.Type}})
//editors["{{.ID}}"].setTheme("ace/theme/clouds_midnight");
editors["{{.ID}}"].setOptions({enableBasicAutocompletion: true, enableSnippets: true, enableLiveAutocompletion: true});
editors["{{.ID}}"].commands.addCommand({
name: 'myCommand',
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
exec: function(editor) {
//...
SaveFileWeb('{{.ID}}', '{{.SavesTo}}','{{.PKG}}');
},
readOnly: true // false if this command should not apply in readOnly mode
});
editors["{{.ID}}"].commands.addCommand({
name: 'oterm',
bindKey: {win: 'Ctrl-I', mac: 'Ctrl-I'},
exec: function(editor) {
//...
toggleTerm()
},
readOnly: true // false if this command should not apply in readOnly mode
});
editors["{{.ID}}"].commands.addCommand({
name: 'collapse',
bindKey: {win: 'Ctrl-M', mac: 'Ctrl-M'},
exec: function(editor) {
//...
CollapseGloj()
},
readOnly: true // false if this command should not apply in readOnly mode
});
editors["{{.ID}}"].container.addEventListener("contextmenu", function(e) {
var edt = editors["{{.ID}}"]
var cursor = edt.selection.getCursor()
var txt = edt.session.getTextRange(edt.getSelectionRange());
$('body').contextMenu("destroy");
e.preventDefault();
$.contextMenu({
selector: 'body',
trigger: 'none',
animation: {duration: 0, show: 'fadeIn', hide: 'fadeOut'},
callback: function(key, options) {
handleClickStruk(key, txt, {{.ID}}, {{.PKG}})
},
items: getItems(txt)
});
$('body').contextMenu();
return false;
}, false);
editors["{{.ID}}"].on('change', function() {
sendMessage({
path : '{{.PKG}} - {{.SavesTo}}',
editor : editors["{{.ID}}"].getValue()
});
});
editorPaths['{{.PKG}} - {{.SavesTo}}'] = editors["{{.ID}}"];
addTab('{{.PKG}} - {{.SavesTo}}'.replace("\\", "/"), {{.ID}} );
</script>
</div>