objective c - WebKit WebView paste: fails for dynamic UTIs -
when copying url chrome on osx , pasting editable webkit webview, nothing gets pasted.
i verified there items on nspasteboard , nspasteboarditem has following types:
"dyn.ah62d4rv4gu8zs3pcnzme2641rf4guzdmsv0gn64uqm10c6xenv61a3k", "dyn.ah62d4rv4gu8yc6durvwwaznwmuuha2pxsvw0e55bsmwca7d3sbwu", "public.utf8-plain-text", "dyn.ah62d4rv4gu8yg55wqzkgc65yqzvg82pwqvdg22p0r73fk8puqyuda8b1gy5xerwdgk2a", "dyn.ah62d4rv4gu8yg55wqzkgc65yqzvg82pwqvdg22p0r73fk8puqyuda8b1gy5xerwdg3cu"
i understand these auto-generated , map weburlswithtitlespboardtype.
on performing same operation safari webview, works since contains
"public.utf8-plain-text"
is there known workaround handling these utis better?
webkit webviews don't seem support paste operations dynamic utis. worked around recreating pasteboard items without utis when paste: intercepted in webview:docommandbyselector:
- (void)cleanuppasteboard:(nspasteboard *)pasteboard { nsmutablearray *newitems = [[nsmutablearray alloc] init]; (nspasteboarditem *item in pasteboard.pasteboarditems) { nspasteboarditem *newitem = [[nspasteboarditem alloc] init]; (nsstring *type in item.types) { if (![type hasprefix:@"dyn"]) { [newitem setdata:[item datafortype:type] fortype:type]; } } [newitems addobject:newitem]; } [pasteboard clearcontents]; [pasteboard writeobjects:newitems]; }
Comments
Post a Comment