зеркало из https://github.com/nextcloud/deck.git
Merge pull request #6675 from nextcloud/backport/6671/stable28
[stable28] fix: Properly show attachment extension
This commit is contained in:
Коммит
312393e22d
|
@ -41,7 +41,8 @@
|
|||
<div class="details">
|
||||
<a>
|
||||
<div class="filename">
|
||||
<span class="basename">{{ attachment.name }}</span>
|
||||
<span>{{ attachmentBasename(attachment) }}</span>
|
||||
<span class="extension">.{{ attachmentExtension(attachment) }}</span>
|
||||
</div>
|
||||
<progress :value="attachment.progress" max="100" />
|
||||
</a>
|
||||
|
@ -58,7 +59,8 @@
|
|||
<div class="details">
|
||||
<a :href="internalLink(attachment)" @click.prevent="showViewer(attachment)">
|
||||
<div class="filename">
|
||||
<span class="basename">{{ attachment.data }}</span>
|
||||
<span>{{ attachmentBasename(attachment) }}</span>
|
||||
<span class="extension">.{{ attachmentExtension(attachment) }}</span>
|
||||
</div>
|
||||
<div v-if="attachment.deletedAt === 0">
|
||||
<span class="filesize">{{ formattedFileSize(attachment.extendedData.filesize) }}</span>
|
||||
|
@ -200,6 +202,14 @@ export default {
|
|||
return t('deck', 'Drop your files to upload')
|
||||
}
|
||||
},
|
||||
attachmentBasename() {
|
||||
return (attachment) => attachment?.extendedData?.info.filename
|
||||
?? (attachment?.name ?? attachment.data).replace(/\.[^/.]+$/, '')
|
||||
},
|
||||
attachmentExtension() {
|
||||
return (attachment) => attachment?.extendedData?.info?.extension
|
||||
?? (attachment?.name ?? attachment.data).split('.').pop()
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
cardId: {
|
||||
|
|
|
@ -256,15 +256,18 @@ export default {
|
|||
},
|
||||
addAttachment(attachment) {
|
||||
const asImage = (attachment.type === 'file' && attachment.extendedData.hasPreview) || attachment.extendedData.mimetype.includes('image')
|
||||
// We need to strip those as text does not support rtl yet, so we cannot insert them separately
|
||||
const stripRTLO = (text) => text.replaceAll('\u202e', '')
|
||||
const fileName = stripRTLO(attachment.extendedData.info.filename) + '.' + stripRTLO(attachment.extendedData.info.extension)
|
||||
if (this.editor) {
|
||||
this.editor.insertAtCursor(
|
||||
asImage
|
||||
? `<a href="${this.attachmentPreview(attachment)}"><img src="${this.attachmentPreview(attachment)}" alt="${attachment.data}" /></a>`
|
||||
: `<a href="${this.attachmentPreview(attachment)}">${attachment.data}</a>`,
|
||||
: `<a href="${this.attachmentPreview(attachment)}">${fileName}</a>`,
|
||||
)
|
||||
return
|
||||
} else {
|
||||
const attachmentString = (asImage ? '!' : '') + '[📎 ' + attachment.data + '](' + this.attachmentPreview(attachment) + ')'
|
||||
const attachmentString = (asImage ? '!' : '') + '[📎 ' + fileName + '](' + this.attachmentPreview(attachment) + ')'
|
||||
const descString = this.$refs.markdownEditor.easymde.value()
|
||||
const newContent = descString + '\n' + attachmentString
|
||||
this.$refs.markdownEditor.easymde.value(newContent)
|
||||
|
|
Загрузка…
Ссылка в новой задаче