Add ctrl-S save shortcut
parent
a8a7aeecd6
commit
3bbb32b25a
|
@ -802,10 +802,8 @@ document.addEventListener("editor", (event) => {
|
||||||
Array.from(addFrontMatterItemButtons).forEach(button => {
|
Array.from(addFrontMatterItemButtons).forEach(button => {
|
||||||
button.addEventListener('click', addFrontMatterItem);
|
button.addEventListener('click', addFrontMatterItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('form').addEventListener('submit', (event) => {
|
let saveContent = function() {
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
let data = form2js(document.querySelector('form'));
|
let data = form2js(document.querySelector('form'));
|
||||||
let html = button.changeToLoading();
|
let html = button.changeToLoading();
|
||||||
let request = new XMLHttpRequest();
|
let request = new XMLHttpRequest();
|
||||||
|
@ -818,7 +816,23 @@ document.addEventListener("editor", (event) => {
|
||||||
button.changeToDone((request.status != 200), html);
|
button.changeToDone((request.status != 200), html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.querySelector('form').addEventListener('submit', (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
saveContent();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('keydown', (event) => {
|
||||||
|
if (event.ctrlKey || event.metaKey) {
|
||||||
|
switch (String.fromCharCode(event.which).toLowerCase()) {
|
||||||
|
case 's':
|
||||||
|
event.preventDefault();
|
||||||
|
saveContent();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue