Bug 182536 - No information about copied image into clipboard
Summary: No information about copied image into clipboard
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari 11
Hardware: Mac macOS 10.13
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-06 09:44 PST by Jacek Bogdański
Modified: 2019-02-06 21:03 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jacek Bogdański 2018-02-06 09:44:14 PST
Safari is not supporting copying and pasting files from a clipboard.

Steps to reproduce the problem:
1. Visit https://codepen.io/jacekbogdanski/pen/aqmBze
2. Copy an image file into clipboard from file system explorer.
3. Paste copied file from explorer into contenteditable area using ctrl/cmd + v combination.
4. Check Images Count value.

What is the expected behavior?
Expected images count: 1. clipboardData should have information about image from clipboard.

What went wrong?
Image count: No items. clipboardData doesn't contain information about pasted file.
Comment 1 Alexey Proskuryakov 2018-02-06 10:53:36 PST
I'm getting different behavior in shipping Safari and in Safari Tech Preview.

Shipping Safari: image icon with a name appears when pasted, script says "Images count: No items".

STP: local file path (file:///Users/<...>) appears when pasted, script says "Images count: 1".
Comment 2 Wenson Hsieh 2018-02-06 12:13:11 PST
In STP and Safari 11.1, we now support DataTransfer.items, so you should be able to grab the image data as a File (you can alternately use DataTransfer.files as well).

(As for the local file path, that's legacy behavior that we should really consider removing...see the FIXME at the bottom of WebContentReaderCocoa.mm)
Comment 3 Alexey Proskuryakov 2018-02-06 12:24:35 PST
Is it really a legacy behavior if it's a change since shipping Safari?
Comment 4 Wenson Hsieh 2018-02-06 12:26:50 PST
(In reply to Alexey Proskuryakov from comment #3)
> Is it really a legacy behavior if it's a change since shipping Safari?

There was a bug previously where we pasted these as non-standard <attachment> elements, which we've fixed since.

Though, out of curiosity, I tried this out on a spade from December, and did not see any file path pasted, so I must be missing something here.

Investigating further...
Comment 5 Wenson Hsieh 2018-02-06 12:55:36 PST
(In reply to Wenson Hsieh from comment #4)
> (In reply to Alexey Proskuryakov from comment #3)
> > Is it really a legacy behavior if it's a change since shipping Safari?
> 
> There was a bug previously where we pasted these as non-standard
> <attachment> elements, which we've fixed since.
> 
> Though, out of curiosity, I tried this out on a spade from December, and did
> not see any file path pasted, so I must be missing something here.
> 
> Investigating further...

I'm going to close this as fixed (by a combination of implementing DataTransfer items and exposing images as items on the clipboard). I'll file a followup for the fact that we're pasting file paths.
Comment 6 Lucas Forschler 2019-02-06 09:19:13 PST
Mass move bugs into the DOM component.
Comment 7 Ryosuke Niwa 2019-02-06 21:03:46 PST
Clipboard is editing.