[Webkit-unassigned] [Bug 184271] Can not create custom pasteboard types in clipboardData.setData

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 6 23:00:16 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=184271

--- Comment #3 from Wenson Hsieh <wenson_hsieh at apple.com> ---
Thanks for the report, Chet! Responses inline.

(In reply to Chet Corcos from comment #0)
> It appears that in iOS, only a limited set of pasteboard types are allowed.
> See the supportedWebContentPasteboardTypes method inside
> https://opensource.apple.com/source/WebCore/WebCore-7604.1.38.0.7/platform/
> ios/PasteboardIOS.mm.auto.html

So this is the special list of types that WebKit provides out-of-the-box support for pasting or dropping in editable web content. Custom pasteboard data types (setData(), getData() with types that are not "text/plain", "text/uri-list" and "text/html") take a totally different codepath than this one (search for "customPasteboardData")

Could you try copying the "3 Custom Copy Types" text on https://whsieh.github.io/examples/custom-pasteboard-data and pasting in the gray dashed area below?

> 
> Whereas on desktop, you can create whatever pasteboard types that you want.
> 
> This is very important in rich text applications that rely on copy-paste of
> structured content that needs to be treated differently when pasting inside
> the application vs outside the application.
> 
> I've created a simple demonstration of this in a CodePen which you can open
> in iOS Safari and I've copied the source code below:
> https://codepen.io/ccorcos/pen/KooVZB?editors=1010
> 
> When you create a selection in the contenteditable input and select copy, we
> save some structured information in a custom pasteboard type, and when we
> paste, we parse it back out. This works fine in desktop Safari, but does not
> work on iOS.
> 
> ```html
> 
> <div id="input" contenteditable>Hello world</div>
> 
> ```
> 
> 
> ```js
> 
> const input = document.getElementById("input")
> 
> window.addEventListener("copy", event => {
>   event.preventDefault()
>   const data = JSON.stringify({data: input.textContent})
>   console.log("copy", data)
>   event.clipboardData.setData("app/custom-key", data)
> })
> 
> window.addEventListener("paste", event => {
>   event.preventDefault()
>   console.log(event)
>   const data = event.clipboardData.getData("app/custom-key")
>   console.log("pasteData", data)
>   if (!data) {
>     console.log("no data")
>     return
>   }
>   const result = JSON.parse(data)
>   input.innerHTML = result.data
> })
> 
> ```

Hm...I just tried this on a recent version of iOS, and cannot paste. I think we may have a bug where the callout action bar doesn't give the user the option to paste if there are only custom types on the pasteboard. If you are testing on iOS 11.3, could you try setting "text/plain" to something as well, and let me know if the problem still reproduces?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180407/3cc43e59/attachment-0002.html>


More information about the webkit-unassigned mailing list