mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix Ace editor saving keybinds and ex-commands
* Remove our manual keydown handler and use an Ace builtin function * Define Vim's :write aka :w ex-command
This commit is contained in:
parent
392cf3d4e7
commit
a67f069709
@ -278,6 +278,17 @@
|
||||
let editor = ace.edit('editor');
|
||||
editor.setTheme('ace/theme/dracula');
|
||||
editor.session.setUseSoftTabs(true);
|
||||
editor.commands.addCommand({
|
||||
name: 'saveFile',
|
||||
bindKey: {
|
||||
win: 'Ctrl-S',
|
||||
mac: 'Command-S',
|
||||
sender: 'editor|cli'
|
||||
},
|
||||
exec: function(env, args, request) {
|
||||
save()
|
||||
}
|
||||
});
|
||||
|
||||
// mouseup = css resize end
|
||||
document.addEventListener("mouseup", function (e) {
|
||||
@ -534,15 +545,6 @@
|
||||
|
||||
});
|
||||
|
||||
$('#editor').bind('keydown', function (event) {
|
||||
file_loaded = true;
|
||||
if (event.ctrlKey && event.key === 's') {
|
||||
event.preventDefault();
|
||||
save();
|
||||
}
|
||||
//console.log(event.keyCode);
|
||||
});
|
||||
|
||||
|
||||
setFileName();
|
||||
$('#editorParent').toggle(false) // show
|
||||
@ -1108,7 +1110,13 @@
|
||||
function setKeyboard(target) {
|
||||
var handlerName = target.getAttribute('data-handler-name');
|
||||
if (handlerName == 'null') handlerName = null;
|
||||
editor.setKeyboardHandler(handlerName);
|
||||
editor.setKeyboardHandler(handlerName, () => {
|
||||
if (handlerName == 'ace/keyboard/vim') {
|
||||
require("ace/keyboard/vim").Vim.defineEx('write', 'w', function() {
|
||||
save();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var nodes = target.parentNode.querySelectorAll("[data-handler-name]");
|
||||
nodes.forEach(node => {
|
||||
|
Loading…
Reference in New Issue
Block a user