mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 18:30:13 +01:00
Make sure keyboard shortcuts are enabled and no text is selected on shortcut triggers
This commit is contained in:
parent
295c9c8617
commit
fb008569ab
1 changed files with 16 additions and 0 deletions
|
|
@ -14,6 +14,22 @@ window.addEventListener('keydown', (e) => {
|
||||||
Mousetrap.trigger(String.fromCharCode(e.which).toLowerCase());
|
Mousetrap.trigger(String.fromCharCode(e.which).toLowerCase());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Store the original stopCallback in a global
|
||||||
|
const originalStopCallback = Mousetrap.stopCallback;
|
||||||
|
|
||||||
|
// Overwrite the stopCallback to allow for more keyboard shortcut customizations
|
||||||
|
Mousetrap.stopCallback = (e, element) => {
|
||||||
|
// Are shortcuts enabled for the user?
|
||||||
|
if (!ReactiveCache.getCurrentUser().isKeyboardShortcuts())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Make sure there are no selected characters
|
||||||
|
if (window.getSelection().type === "Range")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return originalStopCallback(e, element);
|
||||||
|
}
|
||||||
|
|
||||||
function getHoveredCardId() {
|
function getHoveredCardId() {
|
||||||
const card = $('.js-minicard:hover').get(0);
|
const card = $('.js-minicard:hover').get(0);
|
||||||
if (!card) return null;
|
if (!card) return null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue