Browse Source

Add an OCP method to check the shortcut state and use it for global search and menu control

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v25.0.0beta7
Joas Schilling 1 year ago
parent
commit
5267ea2624
No account linked to committer's email address

+ 32
- 0
core/src/OCP/accessibility.js View File

@@ -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)
},
}

+ 2
- 0
core/src/OCP/index.js View File

@@ -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,

+ 5
- 0
core/src/components/HeaderMenu.vue View File

@@ -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()

+ 4
- 0
core/src/views/UnifiedSearch.vue View File

@@ -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) {

+ 2
- 2
dist/core-main.js
File diff suppressed because it is too large
View File


+ 2
- 3
dist/core-main.js.LICENSE.txt View File

@@ -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
*

+ 1
- 1
dist/core-main.js.map
File diff suppressed because it is too large
View File


+ 2
- 2
dist/core-unified-search.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/core-unified-search.js.map
File diff suppressed because it is too large
View File


Loading…
Cancel
Save