mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 20:22:18 +00:00
Added (Ctrl+s) draft force save
This commit is contained in:
parent
f602b088ac
commit
5b9362ab0b
@ -379,6 +379,15 @@ module.exports = function (ngApp, events) {
|
||||
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
|
||||
* content from the system via an AJAX request.
|
||||
|
@ -185,6 +185,10 @@ module.exports = function (ngApp, events) {
|
||||
scope.mceChange(content);
|
||||
});
|
||||
|
||||
editor.on('keydown', (event) => {
|
||||
scope.$emit('editor-keydown', event);
|
||||
});
|
||||
|
||||
editor.on('init', (e) => {
|
||||
scope.mceModel = editor.getContent();
|
||||
});
|
||||
@ -305,8 +309,9 @@ module.exports = function (ngApp, events) {
|
||||
lastScroll = now;
|
||||
});
|
||||
|
||||
// Insert image shortcut
|
||||
// Editor key-presses
|
||||
input.keydown(event => {
|
||||
// Insert image shortcut
|
||||
if (event.which === 73 && event.ctrlKey && event.shiftKey) {
|
||||
event.preventDefault();
|
||||
var caretPos = input[0].selectionStart;
|
||||
@ -316,7 +321,10 @@ module.exports = function (ngApp, events) {
|
||||
input.focus();
|
||||
input[0].selectionStart = caretPos + ("![](".length);
|
||||
input[0].selectionEnd = caretPos + ('![](http://'.length);
|
||||
return;
|
||||
}
|
||||
// Pass key presses to controller via event
|
||||
scope.$emit('editor-keydown', event);
|
||||
});
|
||||
|
||||
// Insert image from image manager
|
||||
|
Loading…
Reference in New Issue
Block a user