mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-20 15:09:38 +00:00
Added (Ctrl+s) draft force save
This commit is contained in:
parent
f602b088ac
commit
5b9362ab0b
2 changed files with 18 additions and 1 deletions
resources/assets/js
|
@ -379,6 +379,15 @@ module.exports = function (ngApp, events) {
|
||||||
saveDraft();
|
saveDraft();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Listen to shortcuts coming via events
|
||||||
|
$scope.$on('editor-keydown', (event, data) => {
|
||||||
|
// Save shortcut (ctrl+s)
|
||||||
|
if (data.keyCode == 83 && (navigator.platform.match("Mac") ? data.metaKey : data.ctrlKey)) {
|
||||||
|
data.preventDefault();
|
||||||
|
saveDraft();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discard the current draft and grab the current page
|
* Discard the current draft and grab the current page
|
||||||
* content from the system via an AJAX request.
|
* content from the system via an AJAX request.
|
||||||
|
|
|
@ -185,6 +185,10 @@ module.exports = function (ngApp, events) {
|
||||||
scope.mceChange(content);
|
scope.mceChange(content);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.on('keydown', (event) => {
|
||||||
|
scope.$emit('editor-keydown', event);
|
||||||
|
});
|
||||||
|
|
||||||
editor.on('init', (e) => {
|
editor.on('init', (e) => {
|
||||||
scope.mceModel = editor.getContent();
|
scope.mceModel = editor.getContent();
|
||||||
});
|
});
|
||||||
|
@ -305,8 +309,9 @@ module.exports = function (ngApp, events) {
|
||||||
lastScroll = now;
|
lastScroll = now;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Insert image shortcut
|
// Editor key-presses
|
||||||
input.keydown(event => {
|
input.keydown(event => {
|
||||||
|
// Insert image shortcut
|
||||||
if (event.which === 73 && event.ctrlKey && event.shiftKey) {
|
if (event.which === 73 && event.ctrlKey && event.shiftKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var caretPos = input[0].selectionStart;
|
var caretPos = input[0].selectionStart;
|
||||||
|
@ -316,7 +321,10 @@ module.exports = function (ngApp, events) {
|
||||||
input.focus();
|
input.focus();
|
||||||
input[0].selectionStart = caretPos + (";
|
input[0].selectionStart = caretPos + (";
|
||||||
input[0].selectionEnd = caretPos + (';
|
input[0].selectionEnd = caretPos + (';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// Pass key presses to controller via event
|
||||||
|
scope.$emit('editor-keydown', event);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Insert image from image manager
|
// Insert image from image manager
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue