-
Notifications
You must be signed in to change notification settings - Fork 178
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
Upload from clipboard #414
Conversation
I'm not really familiar with the clipboard browser API. Could we maybe add a button next to "confirm" that pulls an image from the clipboard? To make it look neat on mobile, It could just have this icon (https://fontawesome.com/v5.15/icons/paste) and a tooltip could explain what it does. |
I don't think this is possible. You aren't allowed to 'pull' data from the clipboard, you can only 'accept' data when the user pastes the content themself. The action has to be initiated by the user. There is a new clipboard.read API, but I haven't tested it and it also looks like it isn't really supported. |
Hmm, OK.
(a) and (b) function similar to how adding tags to posts work, it would also allow us to 'get away' with shrinking the confirm button because most people won't be using it as much anymore
|
Images copy-pasted from Chrome will not work because there are two items, one of which gets resolved to
There is, with |
DataTransferItem.getAsFile() can return null, e.g. when pasting an image copied from chrome. Filter the array to get rid of these.
1eb3b83
to
6599023
Compare
Seems to work well enough in some basic tests. |
A few small issues.
1. You can only paste an image in the text input
This could be fixed by changing
this._urlInputNode.addEventListener("paste", ...)
towindow.onpaste = ...;
, but it feels a bit dirty to touch the window. We can't usewindow.addEventListener
because I don't think we have an 'unmounted' event where we can callremoveEventListener
. Though the same is true when usingwindow.onpaste
, but at least then it wouldn't add duplicate listeners when mounting the upload view multiple times (happens when navigating from upload -> another page -> upload again).2. The "Change post content" upload field text is unchanged
Because it wouldn't fit. Any suggestions?
How it is now:
How it would be with the change:
3. No feedback when the clipboard can't be accessed
This doesn't work when the user has some privacy settings enabled (though at that point it also wouldn't work on imgur etc). I wouldn't know which specific setting. It doesn't work on my personal Chrome/Firefox setup, but it works in a 'clean' Edge (Chromium).