Add ctrl+s instant update
This commit is contained in:
parent
f7688429a8
commit
626dfc523c
|
@ -2,14 +2,14 @@
|
||||||
// before updating in response to a change.
|
// before updating in response to a change.
|
||||||
var nonce = 0;
|
var nonce = 0;
|
||||||
|
|
||||||
function ifNoFurtherChanges(callback) {
|
function ifNoFurtherChanges(callback, timeout=2000) {
|
||||||
var nonce_local = Math.random();
|
var nonce_local = Math.random();
|
||||||
nonce = nonce_local;
|
nonce = nonce_local;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (nonce == nonce_local) {
|
if (nonce == nonce_local) {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}, 2500);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize editor
|
// Initialize editor
|
||||||
|
@ -72,7 +72,10 @@ window.addEventListener("keydown", function(event) {
|
||||||
if (String.fromCharCode(event.which).toLowerCase() == 's')
|
if (String.fromCharCode(event.which).toLowerCase() == 's')
|
||||||
{
|
{
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
onContentChange();
|
ifNoFurtherChanges(() => {
|
||||||
|
var article = getArticleObj();
|
||||||
|
update(article);
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in New Issue