-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#181] Add paste ability for files to textarea
closes #181 Signed-off-by: Knut Ahlers <[email protected]>
- Loading branch information
Showing
5 changed files
with
178 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div class="list-group mb-3"> | ||
<a | ||
v-for="file in files" | ||
:key="file.id" | ||
class="cursor-pointer list-group-item list-group-item-action font-monospace d-flex align-items-center" | ||
:href="file.url" | ||
:download="file.name" | ||
@click="handleClick(file)" | ||
> | ||
<i :class="fasFileType(file.type)" /> | ||
<span>{{ file.name }}</span> | ||
<span class="ms-auto">{{ bytesToHuman(file.size) }}</span> | ||
<template v-if="trackDownload"> | ||
<i | ||
v-if="!hasDownloaded[file.id]" | ||
class="fas fa-fw fa-download ms-2 text-warning" | ||
/> | ||
<i | ||
v-else | ||
class="fas fa-fw fa-circle-check ms-2 text-success" | ||
/> | ||
</template> | ||
<template v-if="canDelete"> | ||
<i | ||
class="fas fa-fw fa-trash ms-2 text-danger" | ||
/> | ||
</template> | ||
</a> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { bytesToHuman } from '../helpers' | ||
export default { | ||
data() { | ||
return { | ||
hasDownloaded: {}, | ||
} | ||
}, | ||
methods: { | ||
bytesToHuman, | ||
fasFileType(type) { | ||
return [ | ||
'fas', | ||
'fa-fw', | ||
'me-2', | ||
...[ | ||
{ icon: ['fa-file-pdf'], match: /application\/pdf/ }, | ||
{ icon: ['fa-file-audio'], match: /^audio\// }, | ||
{ icon: ['fa-file-image'], match: /^image\// }, | ||
{ icon: ['fa-file-lines'], match: /^text\// }, | ||
{ icon: ['fa-file-video'], match: /^video\// }, | ||
{ icon: ['fa-file-zipper'], match: /^application\/(gzip|x-tar|zip)$/ }, | ||
{ icon: ['fa-file-circle-question'], match: /.*/ }, | ||
].filter(el => el.match.test(type))[0].icon, | ||
].join(' ') | ||
}, | ||
handleClick(file) { | ||
this.$set(this.hasDownloaded, file.id, true) | ||
this.$emit('fileClicked', file.id) | ||
}, | ||
}, | ||
name: 'AppFileDisplay', | ||
props: { | ||
canDelete: { | ||
default: false, | ||
required: false, | ||
type: Boolean, | ||
}, | ||
files: { | ||
required: true, | ||
type: Array, | ||
}, | ||
trackDownload: { | ||
default: true, | ||
required: false, | ||
type: Boolean, | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,8 @@ $web-font-path: ''; | |
textarea { | ||
font-family: monospace !important; | ||
} | ||
|
||
.cursor-pointer { | ||
cursor: pointer; | ||
} | ||
} |