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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 3 10:51:33 PDT 2018


            Bug ID: 184271
           Summary: Can not create custom pasteboard types in
           Product: WebKit
           Version: Safari 11
          Hardware: iPhone / iPad
                OS: iOS 11
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: ccorcos at gmail.com

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.

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.


<div id="input" contenteditable>Hello world</div>



const input = document.getElementById("input")

window.addEventListener("copy", event => {
  const data = JSON.stringify({data: input.textContent})
  console.log("copy", data)
  event.clipboardData.setData("app/custom-key", data)

window.addEventListener("paste", event => {
  const data = event.clipboardData.getData("app/custom-key")
  console.log("pasteData", data)
  if (!data) {
    console.log("no data")
  const result = JSON.parse(data)
  input.innerHTML = result.data


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/20180403/4571f3a5/attachment-0002.html>

More information about the webkit-unassigned mailing list