File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -187,7 +187,8 @@ describe('Card', function () {
187187 cy . get ( '.file-picker__main [data-filename="welcome.txt"]' , { timeout : 30000 } ) . should ( 'be.visible' )
188188 . click ( )
189189 cy . get ( '.dialog__actions button.button-vue--vue-primary' ) . click ( )
190- cy . get ( '.attachment-list .basename' ) . contains ( 'welcome.txt' )
190+ cy . get ( '.attachment-list .filename' ) . contains ( 'welcome' )
191+ cy . get ( '.attachment-list .filename .extension' ) . contains ( 'txt' )
191192 } )
192193
193194 it ( 'Shows the modal with the editor' , ( ) => {
Original file line number Diff line number Diff line change 2424 <div class =" details" >
2525 <a >
2626 <div class =" filename" >
27- <span class =" basename" >{{ attachment.name }}</span >
27+ <span >{{ attachmentBasename(attachment) }}</span >
28+ <span class =" extension" >.{{ attachmentExtension(attachment) }}</span >
2829 </div >
2930 <progress :value =" attachment.progress" max =" 100" />
3031 </a >
4142 <div class =" details" >
4243 <a :href =" internalLink(attachment)" @click.prevent =" showViewer(attachment)" >
4344 <div class =" filename" >
44- <span class =" basename" >{{ attachment.data }}</span >
45+ <span >{{ attachmentBasename(attachment) }}</span >
46+ <span class =" extension" >.{{ attachmentExtension(attachment) }}</span >
4547 </div >
4648 <div v-if =" attachment.deletedAt === 0" >
4749 <span class =" filesize" >{{ formattedFileSize(attachment.extendedData.filesize) }}</span >
@@ -183,6 +185,14 @@ export default {
183185 return t (' deck' , ' Drop your files to upload' )
184186 }
185187 },
188+ attachmentBasename () {
189+ return (attachment ) => attachment? .extendedData ? .info .filename
190+ ?? (attachment? .name ?? attachment .data ).replace (/ \. [^ /. ] + $ / , ' ' )
191+ },
192+ attachmentExtension () {
193+ return (attachment ) => attachment? .extendedData ? .info ? .extension
194+ ?? (attachment? .name ?? attachment .data ).split (' .' ).pop ()
195+ },
186196 },
187197 watch: {
188198 cardId: {
Original file line number Diff line number Diff line change @@ -239,15 +239,18 @@ export default {
239239 },
240240 addAttachment (attachment ) {
241241 const asImage = (attachment .type === ' file' && attachment .extendedData .hasPreview ) || attachment .extendedData .mimetype .includes (' image' )
242+ // We need to strip those as text does not support rtl yet, so we cannot insert them separately
243+ const stripRTLO = (text ) => text .replaceAll (' \u202e ' , ' ' )
244+ const fileName = stripRTLO (attachment .extendedData .info .filename ) + ' .' + stripRTLO (attachment .extendedData .info .extension )
242245 if (this .editor ) {
243246 this .editor .insertAtCursor (
244247 asImage
245248 ? ` <a href="${ this .attachmentPreview (attachment)} "><img src="${ this .attachmentPreview (attachment)} " alt="${ attachment .data } " /></a>`
246- : ` <a href="${ this .attachmentPreview (attachment)} ">${ attachment . data } </a>` ,
249+ : ` <a href="${ this .attachmentPreview (attachment)} ">${ fileName } </a>` ,
247250 )
248251 return
249252 } else {
250- const attachmentString = (asImage ? ' !' : ' ' ) + ' [📎 ' + attachment . data + ' ](' + this .attachmentPreview (attachment) + ' )'
253+ const attachmentString = (asImage ? ' !' : ' ' ) + ' [📎 ' + fileName + ' ](' + this .attachmentPreview (attachment) + ' )'
251254 const descString = this .$refs .markdownEditor .easymde .value ()
252255 const newContent = descString + ' \n ' + attachmentString
253256 this .$refs .markdownEditor .easymde .value (newContent)
You can’t perform that action at this time.
0 commit comments