Merge pull request #995 from ramiresviana/key-shortcuts

pull/1005/head
Oleg Lobanov 2020-06-22 13:48:56 +02:00 committed by GitHub
commit 5023e77296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 2 deletions

View File

@ -190,7 +190,7 @@ export default {
document.removeEventListener('drop', this.drop) document.removeEventListener('drop', this.drop)
}, },
methods: { methods: {
...mapMutations([ 'updateUser' ]), ...mapMutations([ 'updateUser', 'addSelected' ]),
base64: function (name) { base64: function (name) {
return window.btoa(unescape(encodeURIComponent(name))) return window.btoa(unescape(encodeURIComponent(name)))
}, },
@ -213,6 +213,19 @@ export default {
case 'v': case 'v':
this.paste(event) this.paste(event)
break break
case 'a':
event.preventDefault()
for (let file of this.items.files) {
if (this.$store.state.selected.indexOf(file.index) === -1) {
this.addSelected(file.index)
}
}
for (let dir of this.items.dirs) {
if (this.$store.state.selected.indexOf(dir.index) === -1) {
this.addSelected(dir.index)
}
}
break
} }
}, },
preventDefault (event) { preventDefault (event) {

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<component :is="currentComponent"></component> <component ref="currentComponent" :is="currentComponent"></component>
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div> <div v-show="showOverlay" @click="resetPrompts" class="overlay"></div>
</div> </div>
</template> </template>
@ -46,6 +46,33 @@ export default {
} }
} }
}, },
created () {
window.addEventListener('keydown', (event) => {
if (this.show == null)
return
let prompt = this.$refs.currentComponent;
// Enter
if (event.keyCode == 13) {
switch (this.show) {
case 'delete':
prompt.submit()
break;
case 'copy':
prompt.copy(event)
break;
case 'move':
prompt.move(event)
break;
case 'replace':
prompt.showConfirm(event)
break;
}
}
})
},
computed: { computed: {
...mapState(['show', 'plugins']), ...mapState(['show', 'plugins']),
currentComponent: function () { currentComponent: function () {