From 096faae844a1149c992f6cf43922d43d79ab031f Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Wed, 2 Mar 2022 09:26:30 +0100 Subject: [PATCH] Remove some shortcuts due to conflicts, read #252 --- dev/Common/Utils.js | 10 ---------- dev/External/SquireUI.js | 4 ++-- dev/Knoin/AbstractViews.js | 2 -- dev/View/Popup/Compose.js | 16 +++++----------- dev/View/User/MailBox/MessageView.js | 6 +++--- dev/View/User/SystemDropDown.js | 2 +- dev/shortcuts.js | 12 ++++-------- .../Views/User/PopupsKeyboardShortcutsHelp.html | 6 +++--- 8 files changed, 18 insertions(+), 40 deletions(-) diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index b9062dae8..519580692 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -29,16 +29,6 @@ export const domItem && item && undefined !== item.disabled && domItem.classList.toggle('disabled', domItem.disabled = item.disabled), - inFocus = () => { - try { - return doc.activeElement && doc.activeElement.matches( - 'input,textarea,[contenteditable]' - ); - } catch (e) { - return false; - } - }, - // unescape(encodeURIComponent()) makes the UTF-16 DOMString to an UTF-8 string b64EncodeJSON = data => btoa(unescape(encodeURIComponent(JSON.stringify(data)))), /* // Without deprecated 'unescape': diff --git a/dev/External/SquireUI.js b/dev/External/SquireUI.js index 8736f84d0..dbc687e8c 100644 --- a/dev/External/SquireUI.js +++ b/dev/External/SquireUI.js @@ -354,8 +354,8 @@ class SquireUI changes.redo.input.disabled = !state.canRedo; }); - squire.addEventListener('focus', () => shortcuts.off()); - squire.addEventListener('blur', () => shortcuts.on()); +// squire.addEventListener('focus', () => shortcuts.off()); +// squire.addEventListener('blur', () => shortcuts.on()); container.append(toolbar, wysiwyg, plain); diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index f5a37c9e6..ba3afa71b 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -1,6 +1,5 @@ import ko from 'ko'; -import { inFocus } from 'Common/Utils'; import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko'; import { Scope } from 'Common/Enums'; import { keyScope, SettingsGet, leftPanelDisabled } from 'Common/Globals'; @@ -68,7 +67,6 @@ export class AbstractViewPopup extends AbstractView } return true; }); - shortcuts.add('backspace', '', name, inFocus()); } // Happens when user hits Escape or Close key diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 5dde3ebec..2a04dcaed 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -11,7 +11,7 @@ import { SetSystemFoldersNotification } from 'Common/EnumsUser'; -import { inFocus, pInt, isArray, arrayLength, forEachObjectEntry } from 'Common/Utils'; +import { pInt, isArray, arrayLength, forEachObjectEntry } from 'Common/Utils'; import { initFullscreen } from 'Common/UtilsUser'; import { encodeHtml, HtmlEditor, htmlToPlain } from 'Common/Html'; import { koArrayWithDestroy } from 'External/ko'; @@ -1197,14 +1197,6 @@ export class ComposePopupView extends AbstractViewPopup { } } - popupMenu(event) { - if (event.ctrlKey || event.metaKey || 'ContextMenu' == event.key - || (this.oEditor && !this.oEditor.hasFocus() && !inFocus())) { - this.identitiesDropdownTrigger(true); - return false; - } - } - onBuild(dom) { // initUploader const oJua = new Jua({ @@ -1326,8 +1318,10 @@ export class ComposePopupView extends AbstractViewPopup { shortcuts.add('q', 'meta', ScopeCompose, ()=>false); shortcuts.add('w', 'meta', ScopeCompose, ()=>false); - shortcuts.add('contextmenu', '', ScopeCompose, e => this.popupMenu(e)); - shortcuts.add('m', 'meta', ScopeCompose, e => this.popupMenu(e)); + shortcuts.add('m', 'meta', ScopeCompose, () => { + this.identitiesDropdownTrigger(true); + return false; + }); shortcuts.add('arrowdown', 'meta', ScopeCompose, () => { this.skipCommand(); diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index e8a5d7f79..0184abc72 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -24,7 +24,7 @@ import { fireEvent } from 'Common/Globals'; -import { arrayLength, inFocus } from 'Common/Utils'; +import { arrayLength } from 'Common/Utils'; import { download, mailToHelper, showMessageComposer, initFullscreen } from 'Common/UtilsUser'; import { SMAudio } from 'Common/Audio'; @@ -333,12 +333,12 @@ export class MailMessageView extends AbstractViewRight { } }); - keyScopeReal.subscribe(value => this.messageDomFocused(Scope.MessageView === value && !inFocus())); + keyScopeReal.subscribe(value => this.messageDomFocused(Scope.MessageView === value)); // initShortcuts // exit fullscreen, back - shortcuts.add('escape,backspace', '', Scope.MessageView, () => { + shortcuts.add('escape', '', Scope.MessageView, () => { if (!this.viewModelDom.hidden && currentMessage()) { const preview = SettingsUserStore.usePreviewPane(); if (this.fullScreenMode()) { diff --git a/dev/View/User/SystemDropDown.js b/dev/View/User/SystemDropDown.js index 36c948d1b..c52c0c3df 100644 --- a/dev/View/User/SystemDropDown.js +++ b/dev/View/User/SystemDropDown.js @@ -125,7 +125,7 @@ export class SystemDropDownUserView extends AbstractViewRight { } onBuild() { - shortcuts.add('m,contextmenu', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => { + shortcuts.add('m', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => { if (!this.viewModelDom.hidden) { MessageUserStore.fullScreen(false); this.accountMenuDropdownTrigger(true); diff --git a/dev/shortcuts.js b/dev/shortcuts.js index a325860b9..794cfd2bf 100644 --- a/dev/shortcuts.js +++ b/dev/shortcuts.js @@ -63,14 +63,10 @@ const keydown = event => { let key = (event.key || '').toLowerCase().replace(' ','space'), - target = event.target; - // ignore keydown in any element that supports keyboard input unless it's the Escape key - if ('escape' === key || !target.closest || !target.closest('input,select,textarea,[contenteditable]')) { - let modifiers = ['alt','ctrl','meta','shift'].filter(v => event[v+'Key']).join('+'); - scope[key] && scope[key][modifiers] && scope[key][modifiers].forEach(cmd => exec(event, cmd)); - !event.defaultPrevented && _scope !== 'all' && _scopes.all[key] && _scopes.all[key][modifiers] - && _scopes.all[key][modifiers].forEach(cmd => exec(event, cmd)); - } + modifiers = ['alt','ctrl','meta','shift'].filter(v => event[v+'Key']).join('+'); + scope[key] && scope[key][modifiers] && scope[key][modifiers].forEach(cmd => exec(event, cmd)); + !event.defaultPrevented && _scope !== 'all' && _scopes.all[key] && _scopes.all[key][modifiers] + && _scopes.all[key][modifiers].forEach(cmd => exec(event, cmd)); }; win.shortcuts = shortcuts; diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsKeyboardShortcutsHelp.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsKeyboardShortcutsHelp.html index 496ab1a79..1cf96f7ae 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsKeyboardShortcutsHelp.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsKeyboardShortcutsHelp.html @@ -14,9 +14,9 @@ tabindex="0" data-i18n="SHORTCUTS_HELP/TAB_MAILBOX">
- +
- + @@ -84,7 +84,7 @@
M, Menu
M
R, Reply
A, Shift + Reply
F, Fwd
- +
W, C, New
Menu, + M
+ M
+ S, Save
Send, + Enter
Esc, Close