Skip to content

Commit

Permalink
fix: open non-image attachment
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Mar 29, 2023
1 parent 46225f3 commit 7e1e84a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/components/Editor/MediaHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default {
const src = dirname + '/'
+ encodeURIComponent(name).replace(/[!'()*]/g, (c) => {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
}) + '?fileId=' + fileId
// simply get rid of brackets to make sure link text is valid
// as it does not need to be unique and matching the real file name
const alt = name.replaceAll(/[[\]]/g, '')
Expand Down
36 changes: 21 additions & 15 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@
<transition name="fade">
<template v-if="!failed">
<div v-if="isMediaAttachment"
class="media"
@click="handleImageClick(src)">
class="media">
<div class="media__wrapper">
<img v-show="loaded"
:src="imageUrl"
class="image__main"
@load="onLoaded">
<div class="metadata">
<span class="name">{{ alt }}</span>
<span class="size">{{ attachmentMetadata.size }}</span>
</div>
<a :href="internalLinkOrImage"
target="_blank">
<img v-show="loaded"
:src="imageUrl"
class="image__main"
@load="onLoaded">
<div class="metadata">
<span class="name">{{ alt }}</span>
<span class="size">{{ attachmentMetadata.size }}</span>
</div>
</a>
</div>
<div v-if="showDeleteIcon"
class="buttons">
Expand Down Expand Up @@ -225,16 +227,13 @@ export default {
return this.loaded && this.imageLoaded
},
imageFileId() {
return getQueryVariable(this.src, 'fileId')
},
isSupportedImage() {
return typeof this.mime === 'undefined'
|| IMAGE_MIMES.indexOf(this.mime) !== -1
},
internalLinkOrImage() {
if (this.imageFileId) {
return generateUrl('/f/' + this.imageFileId)
if (this.fileId) {
return generateUrl('/f/' + this.fileId)
}
return this.src
},
Expand All @@ -258,6 +257,9 @@ export default {
})
},
},
fileId() {
return getQueryVariable(this.src, 'fileId')
},
t() {
return (a, s) => window.t(a, s)
},
Expand Down Expand Up @@ -464,6 +466,10 @@ export default {
border-radius: var(--border-radius-large);
padding: 8px;
a {
display: contents;
}
img {
width: 44px;
height: 44px;
Expand Down

0 comments on commit 7e1e84a

Please sign in to comment.