From d5fd80d116ff489341b7e29812b3134d93a1bf28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 30 Aug 2024 13:17:42 +0200 Subject: [PATCH] fix: Properly show attachment extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/card/AttachmentList.vue | 14 ++++++++++++-- src/components/card/Description.vue | 7 +++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/card/AttachmentList.vue b/src/components/card/AttachmentList.vue index 19f1dc567..d7fa35f72 100644 --- a/src/components/card/AttachmentList.vue +++ b/src/components/card/AttachmentList.vue @@ -24,7 +24,8 @@
- {{ attachment.name }} + {{ attachmentBasename(attachment) }} + .{{ attachmentExtension(attachment) }}
@@ -41,7 +42,8 @@
- {{ attachment.data }} + {{ attachmentBasename(attachment) }} + .{{ attachmentExtension(attachment) }}
{{ formattedFileSize(attachment.extendedData.filesize) }} @@ -183,6 +185,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: { diff --git a/src/components/card/Description.vue b/src/components/card/Description.vue index b905bde34..5969bcf25 100644 --- a/src/components/card/Description.vue +++ b/src/components/card/Description.vue @@ -239,15 +239,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 ? `${attachment.data}` - : `${attachment.data}`, + : `${fileName}`, ) 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)