basecamp / trix

A rich text editor for everyday writing
https://trix-editor.org/
MIT License
18.97k stars 1.11k forks source link

Upload to Active Storage when paste images with CTRL + V #1171

Open gabriel-fsa opened 1 month ago

gabriel-fsa commented 1 month ago

Hello, I use Trix to create a chat on my website and I am having the following problem.

Users are copying images (Github, discord) and placing them using CTRL + V, however, the URL of these sites remains expired and over time the image is lost, giving the user the false impression that the image was sent.

I would like to know if there is any functionality that already does this upload when ctrl + v is pressed or if there is an event that I could listen to to download and send to Active Storage to persist in my backend.

When dragging and dropping the image on my machine it works, but I would like to upload images pasted using CTRL + V.

Below is a GIF exemplifying the image pasted with the Discord URL:

pasting_on_trix

Here's a GIF of the functionality I'd like to have on Github: paste_github

lmansur commented 1 month ago

You should be able to listen to the trix-attachment-add event and get the image URL with event.attachment.getAttribute("url")