Skip to content

Commit 190ae82

Browse files
committed
allow to download files with a shortcut
Signed-off-by: szaimen <szaimen@e.mail.de> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 2577cff commit 190ae82

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/views/Viewer.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,13 @@ export default {
350350
subscribe('files:sidebar:opened', this.handleAppSidebarOpen)
351351
subscribe('files:sidebar:closed', this.handleAppSidebarClose)
352352
window.addEventListener('keydown', this.keyboardDeleteFile)
353+
window.addEventListener('keydown', this.keyboardDownloadFile)
353354
},
354355
355356
beforeDestroy() {
356357
window.removeEventListener('resize', this.onResize)
357358
window.removeEventListener('keydown', this.keyboardDeleteFile)
359+
window.removeEventListener('keydown', this.keyboardDownloadFile)
358360
},
359361
360362
destroyed() {
@@ -680,6 +682,20 @@ export default {
680682
}
681683
},
682684
685+
keyboardDownloadFile(event) {
686+
if (event.key === 's' && event.ctrlKey === true) {
687+
event.preventDefault()
688+
if (this.canDownload) {
689+
const a = document.createElement('a')
690+
a.href = this.currentFile.davPath
691+
a.download = this.currentFile.basename
692+
document.body.appendChild(a)
693+
a.click()
694+
document.body.removeChild(a)
695+
}
696+
}
697+
},
698+
683699
cleanup() {
684700
// reset all properties
685701
this.currentFile = {}

0 commit comments

Comments
 (0)