File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 4141 <div class =" details" >
4242 <a >
4343 <div class =" filename" >
44- <span class =" basename" >{{ attachment.name }}</span >
44+ <span >{{ attachmentBasename(attachment) }}</span >
45+ <span class =" extension" >.{{ attachmentExtension(attachment) }}</span >
4546 </div >
4647 <progress :value =" attachment.progress" max =" 100" />
4748 </a >
5859 <div class =" details" >
5960 <a :href =" internalLink(attachment)" @click.prevent =" showViewer(attachment)" >
6061 <div class =" filename" >
61- <span class =" basename" >{{ attachment.data }}</span >
62+ <span >{{ attachmentBasename(attachment) }}</span >
63+ <span class =" extension" >.{{ attachmentExtension(attachment) }}</span >
6264 </div >
6365 <div v-if =" attachment.deletedAt === 0" >
6466 <span class =" filesize" >{{ formattedFileSize(attachment.extendedData.filesize) }}</span >
@@ -200,6 +202,14 @@ export default {
200202 return t (' deck' , ' Drop your files to upload' )
201203 }
202204 },
205+ attachmentBasename () {
206+ return (attachment ) => attachment? .extendedData ? .info .filename
207+ ?? (attachment? .name ?? attachment .data ).replace (/ \. [^ /. ] + $ / , ' ' )
208+ },
209+ attachmentExtension () {
210+ return (attachment ) => attachment? .extendedData ? .info ? .extension
211+ ?? (attachment? .name ?? attachment .data ).split (' .' ).pop ()
212+ },
203213 },
204214 watch: {
205215 cardId: {
Original file line number Diff line number Diff line change @@ -243,15 +243,18 @@ export default {
243243 },
244244 addAttachment (attachment ) {
245245 const asImage = (attachment .type === ' file' && attachment .extendedData .hasPreview ) || attachment .extendedData .mimetype .includes (' image' )
246+ // We need to strip those as text does not support rtl yet, so we cannot insert them separately
247+ const stripRTLO = (text ) => text .replaceAll (' \u202e ' , ' ' )
248+ const fileName = stripRTLO (attachment .extendedData .info .filename ) + ' .' + stripRTLO (attachment .extendedData .info .extension )
246249 if (this .editor ) {
247250 this .editor .insertAtCursor (
248251 asImage
249252 ? ` <a href="${ this .attachmentPreview (attachment)} "><img src="${ this .attachmentPreview (attachment)} " alt="${ attachment .data } " /></a>`
250- : ` <a href="${ this .attachmentPreview (attachment)} ">${ attachment . data } </a>`
253+ : ` <a href="${ this .attachmentPreview (attachment)} ">${ fileName } </a>` ,
251254 )
252255 return
253256 } else {
254- const attachmentString = (asImage ? ' !' : ' ' ) + ' [📎 ' + attachment . data + ' ](' + this .attachmentPreview (attachment) + ' )'
257+ const attachmentString = (asImage ? ' !' : ' ' ) + ' [📎 ' + fileName + ' ](' + this .attachmentPreview (attachment) + ' )'
255258 const descString = this .$refs .markdownEditor .easymde .value ()
256259 const newContent = descString + ' \n ' + attachmentString
257260 this .$refs .markdownEditor .easymde .value (newContent)
You can’t perform that action at this time.
0 commit comments