Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: open non-image attachment #3924

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
luka-nextcloud marked this conversation as resolved.
Show resolved Hide resolved
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