Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to download files with a shortcut #1321

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
szaimen authored and skjnldsv committed Aug 17, 2022
commit a727a17291c3b3130e549bedf22eacf7eabb9079
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