Bug 196702 - insertFromPaste InputEvent missing text/uri-list in dataTransfer for pasted links
Summary: insertFromPaste InputEvent missing text/uri-list in dataTransfer for pasted l...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari 12
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-04-08 12:18 PDT by Javan Makhmali
Modified: 2019-04-10 18:32 PDT (History)
3 users (show)

See Also:


Attachments
Link paste inspection (40.87 KB, image/png)
2019-04-08 12:18 PDT, Javan Makhmali
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Javan Makhmali 2019-04-08 12:18:38 PDT
Created attachment 366966 [details]
Link paste inspection

To reproduce:
1. Open a page containing the following HTML: <a href="https://bugs.webkit.org/">WebKit Bugzilla</a>
2. Right-click the link and choose "Copy Link"
3. Paste into a contenteditable element
4. Inspect the "paste" event's clipboardData: 
   { 
     "text/plain": "https://bugs.webkit.org/", 
     "text/uri-list": "https://bugs.webkit.org/" 
   }
5. Compare that to the "beforeinput" or "input" event's dataTransfer: 
   { 
     "text/html": "<a href="https://bugs.webkit.org/">WebKit Bugzilla</a>", 
     "text/plain": "WebKit Bugzilla" 
   }


Example paste: https://input-inspector.now.sh/profiles/u8CdyvoSRZtimXxzBSS0
Comment 1 Wenson Hsieh 2019-04-08 12:23:08 PDT
(In reply to Javan Makhmali from comment #0)
> Created attachment 366966 [details]
> Link paste inspection
> 
> To reproduce:
> 1. Open a page containing the following HTML: <a
> href="https://bugs.webkit.org/">WebKit Bugzilla</a>
> 2. Right-click the link and choose "Copy Link"
> 3. Paste into a contenteditable element
> 4. Inspect the "paste" event's clipboardData: 
>    { 
>      "text/plain": "https://bugs.webkit.org/", 
>      "text/uri-list": "https://bugs.webkit.org/" 
>    }
> 5. Compare that to the "beforeinput" or "input" event's dataTransfer: 
>    { 
>      "text/html": "<a href="https://bugs.webkit.org/">WebKit Bugzilla</a>", 
>      "text/plain": "WebKit Bugzilla" 
>    }
> 
> 
> Example paste: https://input-inspector.now.sh/profiles/u8CdyvoSRZtimXxzBSS0

Hi Javan!

According to the spec here: https://www.w3.org/TR/input-events-2, the prepopulated DataTransfer object accessible via input events should contain 1 entry for "text/html" and 1 entry for "text/plain". It *seems* reasonable to add one for text/uri-list as well though, in circumstances such as these (pasting or dropping a link).
Comment 2 Javan Makhmali 2019-04-08 14:14:31 PDT
Hey Wenson!

For some context, I recently updated our rich text editor (https://trix-editor.org/) to handle Level 2 Input Events instead of a whole suite of keyboard events. I had hoped to avoid handling the paste event entirely, but ran into a couple cases where beforeinput.insertFromPaste's dataTransfer lacked necessary detail (see also https://bugs.webkit.org/show_bug.cgi?id=194921). I ended up handling both events, relying on the paste event for a handful of known cases where beforeinput won't work, which feels unfortunate. To quote the spec:

> The goal of these events is to allow authors to understand and/or override default edit behavior both before and after editing occurs.
Comment 3 Radar WebKit Bug Importer 2019-04-10 18:32:41 PDT
<rdar://problem/49798852>