Skip to content

Commit

Permalink
Merge pull request #1321 from nextcloud/enh/noid/shortcut-download
Browse files Browse the repository at this point in the history
allow to download files with a shortcut
  • Loading branch information
szaimen committed Aug 17, 2022
2 parents 36f6038 + a727a17 commit d2187d1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,13 @@ export default {
subscribe('files:sidebar:opened', this.handleAppSidebarOpen)
subscribe('files:sidebar:closed', this.handleAppSidebarClose)
window.addEventListener('keydown', this.keyboardDeleteFile)
window.addEventListener('keydown', this.keyboardDownloadFile)
},
beforeDestroy() {
window.removeEventListener('resize', this.onResize)
window.removeEventListener('keydown', this.keyboardDeleteFile)
window.removeEventListener('keydown', this.keyboardDownloadFile)
},
destroyed() {
Expand Down Expand Up @@ -680,6 +682,20 @@ export default {
}
},
keyboardDownloadFile(event) {
if (event.key === 's' && event.ctrlKey === true) {
event.preventDefault()
if (this.canDownload) {
const a = document.createElement('a')
a.href = this.currentFile.davPath
a.download = this.currentFile.basename
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
}
}
},
cleanup() {
// reset all properties
this.currentFile = {}
Expand Down

0 comments on commit d2187d1

Please sign in to comment.