Signed-off-by: Joas Schilling <coding@schilljs.com>tags/v25.0.0beta7
@@ -0,0 +1,32 @@ | |||
/** | |||
* @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com> | |||
* | |||
* @author Joas Schilling <coding@schilljs.com> | |||
* | |||
* @license AGPL-3.0-or-later | |||
* | |||
* This program is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
* | |||
*/ | |||
import { loadState } from '@nextcloud/initial-state' | |||
export default { | |||
/** | |||
* @return {boolean} Whether the user opted-out of shortcuts so that they should not be registered | |||
*/ | |||
disableKeyboardShortcuts() { | |||
return loadState('theming', 'shortcutsDisabled', false) | |||
}, | |||
} |
@@ -28,12 +28,14 @@ import * as AppConfig from './appconfig' | |||
import * as Comments from './comments' | |||
import * as WhatsNew from './whatsnew' | |||
import Accessibility from './accessibility' | |||
import Collaboration from './collaboration' | |||
import Loader from './loader' | |||
import Toast from './toast' | |||
/** @namespace OCP */ | |||
export default { | |||
Accessibility, | |||
AppConfig, | |||
Collaboration, | |||
Comments, |
@@ -81,6 +81,7 @@ export default { | |||
handler: this.closeMenu, | |||
middleware: this.clickOutsideMiddleware, | |||
}, | |||
shortcutsDisabled: OCP.Accessibility.disableKeyboardShortcuts(), | |||
} | |||
}, | |||
@@ -144,6 +145,10 @@ export default { | |||
}, | |||
onKeyDown(event) { | |||
if (this.shortcutsDisabled) { | |||
return | |||
} | |||
// If opened and escape pressed, close | |||
if (event.key === 'Escape' && this.opened) { | |||
event.preventDefault() |
@@ -334,6 +334,10 @@ export default { | |||
}, | |||
mounted() { | |||
if (OCP.Accessibility.disableKeyboardShortcuts()) { | |||
return | |||
} | |||
document.addEventListener('keydown', (event) => { | |||
// if not already opened, allows us to trigger default browser on second keydown | |||
if (event.ctrlKey && event.key === 'f' && !this.open) { |
@@ -427,10 +427,9 @@ | |||
*/ | |||
/** | |||
* @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net> | |||
* @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com> | |||
* | |||
* @author John Molakvoæ <skjnldsv@protonmail.com> | |||
* @author Julius Härtl <jus@bitgrid.net> | |||
* @author Joas Schilling <coding@schilljs.com> | |||
* | |||
* @license AGPL-3.0-or-later | |||
* |