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

Insert images from local device (or link) #1900

Merged
merged 63 commits into from
Jan 3, 2022

Conversation

julien-nc
Copy link
Member

@julien-nc julien-nc commented Oct 18, 2021

Fixes #58

Here is a basic implementation of 2 new options to insert images:

  • Upload from local device
  • Download from http link

In both cases, the image is then stored in the /Text directory which is created if it does not exist.
An alternative mentioned in #58 (comment) would be to store uploaded images in a directory next to the markdown file.

Todo

  • Menu action for local file insertion
  • Handling file upload
  • Display uploaded image
  • Handle and display upload errors
  • Menu action for image link insertion
  • Handling link download/store
  • Display image from link
  • Handle and display link insertion errors
  • Change menu item naming
  • Change attachment folder name
  • Use the attachment folder when inserting images from Files
  • Handle .md file copy/move/delete with File events
  • Cleanup attachment folder when images are removed from markdown content

Gifcording 😁

link

src/components/MenuBar.vue Outdated Show resolved Hide resolved
src/components/MenuBar.vue Show resolved Hide resolved
src/components/MenuBar.vue Outdated Show resolved Hide resolved
lib/Controller/ImageController.php Show resolved Hide resolved
@julien-nc
Copy link
Member Author

This now includes "attachment folder" changes. It's been rebased on master (so it must be used in NC 24).

The TODO list in this PR's description has been updated.

@julien-nc julien-nc requested a review from mejo- November 22, 2021 12:14
return null;
}
if ($imageFile instanceof File) {
// return $imageFile;
Copy link
Member

Choose a reason for hiding this comment

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

  • To be discussed if we still need the original file for gif support for example

Copy link
Member Author

Choose a reason for hiding this comment

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

This has been changed and will work if we want to support GIFs. If the mime type is not supported by the preview generator, the original file is returned now. This also fixes the svg display because there is no related preview provider by default.

@julien-nc
Copy link
Member Author

/compile amend

@mejo-
Copy link
Member

mejo- commented Jan 3, 2022

We can now merge or wait until a pairing session about Cypress and some more tests. As you wish.

I don't mind to merge now and add cypress tests later (if we don't forget about it 😬). But the failing psalm tests should be tackled first, no?

@julien-nc julien-nc force-pushed the enh/58/insert-local-images branch 2 times, most recently from 69b91e2 to 4879432 Compare January 3, 2022 10:23
@julien-nc
Copy link
Member Author

/compile amend

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
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.

Super nice work 👌

@juliushaertl juliushaertl merged commit f33e0e5 into master Jan 3, 2022
@juliushaertl juliushaertl deleted the enh/58/insert-local-images branch January 3, 2022 10:58
This was referenced Jan 3, 2022
@juliushaertl
Copy link
Member

Filed #2049 for the cypress tests

@tobiasKaminsky
Copy link
Member

Is this also ready for clients via our DirectEditingMobileInterface?

@julien-nc
Copy link
Member Author

@tobiasKaminsky All related endpoints are public and use the session edition token and optionally the public share token to authenticate.
So it is supposed to be ok but in reality it partially works. I've tried it on our Android app:

  • Inserting an image from a link ✔️
  • Uploading a local image ❌ The <input type=file> does not work when rendered in the Android app.
  • Serving the images ❌ 2 mistakes:
    • The share token presence detection is broken in
    • The ImageController does not get the user ID from the session

I'll make a PR to fix the 2 image serving issues.
I don't know about the local image upload issue. Do you think we should just hide this feature on mobile apps? Or is there a way to get a system file selector when clicking on such file input?

julien-nc pushed a commit that referenced this pull request Jan 7, 2022
…hareToken, use the edition session to get the user ID

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
julien-nc pushed a commit that referenced this pull request Jan 9, 2022
…hareToken, use the edition session to get the user ID

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
@tobiasKaminsky
Copy link
Member

I don't know about the local image upload issue. Do you think we should just hide this feature on mobile apps? Or is there a way to get a system file selector when clicking on such file input?

This is possible, as we do it with Collabora.

In this regard, we have this nextcloud/server#16132, but want to wait for your side (move RichDocuments to directEditing)

julien-nc pushed a commit that referenced this pull request Jan 10, 2022
…hareToken, use the edition session to get the user ID

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
@juliushaertl juliushaertl mentioned this pull request Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to insert images from local device (or link)
4 participants