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

Conversation

luka-nextcloud
Copy link
Contributor

@luka-nextcloud luka-nextcloud commented Mar 10, 2023

📝 Summary

🖼️ Screenshots

🚧 TODO

  • ...

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

@luka-nextcloud luka-nextcloud self-assigned this Mar 10, 2023
@cypress
Copy link

cypress bot commented Mar 10, 2023

@mejo-
Copy link
Member

mejo- commented Mar 10, 2023

Thanks for looking into this @luka-nextcloud. From the screenshot I wonder why you changed the layout of non-image attachments? I think we should preserve the way they were rendered before, no?

@mejo-
Copy link
Member

mejo- commented Mar 10, 2023

@luka-nextcloud I would have envisioned a simple <a href="/f/<fileId>">[...]</a> around the non-image attachment node here:

<div v-if="isMediaAttachment"
class="media"
@click="handleImageClick(src)">
<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>
</div>

Additionally, the registered @click handler in this block would need to be removed. That would allow Text/Collectives to treat the non-media attachment node as simple link with their registered linkHandlers. What do you think about that approach?

@luka-nextcloud luka-nextcloud force-pushed the bug/open-non-image-attachment branch from 79ac9d4 to d07bfd1 Compare March 10, 2023 18:49
@luka-nextcloud
Copy link
Contributor Author

Thanks for looking into this @luka-nextcloud. From the screenshot I wonder why you changed the layout of non-image attachments? I think we should preserve the way they were rendered before, no?

Actually, I didn't change the layout, this layout for non-image was already there at the beginning. It wasn't shown before because of some missing data (mime type of file was missing before). I just fixed it.

@luka-nextcloud
Copy link
Contributor Author

@luka-nextcloud I would have envisioned a simple <a href="/f/<fileId>">[...]</a> around the non-image attachment node here:

<div v-if="isMediaAttachment"
class="media"
@click="handleImageClick(src)">
<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>
</div>

Additionally, the registered @click handler in this block would need to be removed. That would allow Text/Collectives to treat the non-media attachment node as simple link with their registered linkHandlers. What do you think about that approach?

I think it's already done here. Please check: https://github.com/nextcloud/text/blob/main/src/nodes/ImageView.vue#L108

@mejo-
Copy link
Member

mejo- commented Mar 14, 2023

@luka-nextcloud I think there's a missunderstanding here.

To my understanding, the following block is used for attachments that have a set, but unsupported mimetype:

<div v-else class="image-view__cant_display">
<transition name="fade">
<div v-show="loaded">
<a :href="internalLinkOrImage" target="_blank">
<span v-if="!isSupportedImage">{{ alt }}</span>
</a>
</div>
</transition>
<transition v-if="isSupportedImage" name="fade">
<div v-show="loaded" class="image__caption">
<input ref="altInput"
type="text"
:value="alt"
:disabled="!editable"
@blur="updateAlt"
@keyup.enter="updateAlt">
</div>
</transition>
</div>

I would like to continue using the following block for media attachments (non-image attachments) instead (where it's rendered properly as attachment node), just making this node a link to the files URL of the attachment:

<div v-if="isMediaAttachment"
class="media"
@click="handleImageClick(src)">
<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>
</div>
<div v-if="showDeleteIcon"
class="buttons">
<NcButton :aria-label="t('text', 'Delete this attachment')"
:title="t('text', 'Delete this attachment')"
@click="deleteNode">
<template #icon>
<DeleteIcon />
</template>
</NcButton>
</div>
</div>

@luka-nextcloud luka-nextcloud force-pushed the bug/open-non-image-attachment branch from d07bfd1 to f9fab12 Compare March 14, 2023 19:24
@luka-nextcloud
Copy link
Contributor Author

@mejo- Could you please check again?

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks better already but still I think most of your changes are not necessary 😉

Also, could you squash all commits in the PR into one?

src/nodes/ImageView.vue Show resolved Hide resolved
src/nodes/ImageView.vue Outdated Show resolved Hide resolved
src/nodes/ImageView.vue Outdated Show resolved Hide resolved
src/nodes/ImageView.vue Outdated Show resolved Hide resolved
Signed-off-by: Luka Trovic <luka@nextcloud.com>
@luka-nextcloud luka-nextcloud force-pushed the bug/open-non-image-attachment branch from 0d1ccb5 to 7e1e84a Compare March 29, 2023 10:04
@luka-nextcloud luka-nextcloud requested a review from mejo- March 29, 2023 10:05
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @luka-nextcloud. I think that the PR has to wait until #3974 got resolved.

As said, the option to inject fileId as query param to the markdown in insertAttachment() of MediaHandler.vue brings several problems and should be avoided in my eyes:

  • It doesn't work for attachments that were uploaded prior to this PR.
  • It will break whenever the text document gets copied - fileIds of the attachments will change in that case.
  • It will not work for attachments that got inserted manually (arguably neglectable though)

@luka-nextcloud
Copy link
Contributor Author

luka-nextcloud commented Apr 6, 2023

@mejo-

It doesn't work for attachments that were uploaded prior to this

For attachments already saved before, there is no way to detect it's fileId. The saved content before will look like this.
image

It will break whenever the text document gets copied - fileIds of the attachments will change in that case.

Not sure what it means...

It will not work for attachments that got inserted manually (arguably neglectable though)

Do you mean using "Upload from computer"?
image

@mejo-
Copy link
Member

mejo- commented Apr 11, 2023

Hey @luka-nextcloud,

For attachments already saved before, there is no way to detect it's fileId. The saved content before will look like this.

Exactly, and that's why I suggested to update the logic of AttachmentResolver as described in #3974 😉

It will break whenever the text document gets copied - fileIds of the attachments will change in that case.

Not sure what it means...

I mean the following: create a Text document and add an attachment. Then you will have the attachment fileId hardcoded in its markdown. Afterwards, copy the document in the Nextcloud Files app ("Move or copy" in three-dot-menu, then "Copy"). The resulting copy will have the attachment copied over as well, but the fileId in markdown will be wrong.

@ralfrupf1976
Copy link

I just uploaded a PDF in Kollektive - still PDFs are not shown correctly. Any Updates on this?

Screenshot

@mejo-
Copy link
Member

mejo- commented Nov 13, 2023

I just uploaded a PDF in Kollektive - still PDFs are not shown correctly. Any Updates on this?

@ralfrupf1976 we're working on a proper fix for this. It can take a bit though because it requires bigger internal code changes.

@blizzz blizzz modified the milestones: Nextcloud 28, Nextcloud 29 Nov 23, 2023
@juliusknorr
Copy link
Member

@mejo- I guess this will be covered by #5042 then so let's close this one for now I'd say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opening non-image attachments is broken
5 participants