The public API method -[WKUIDelegate webView:contextMenuConfigurationForElement:completionHandler] is only called for links, not for images. The SPI version (-[WKUIDelegate _webView:contextMenuConfigurationForElement:completionHandler]) does get called for images. This means that WKWebView embedders cannot easily customize the context menu shown for images. The logic for this is in -[WKContentViewInteraction continueContextMenuInteraction:], which does: if (_positionInformation.isLink && [uiDelegate respondsToSelector:@selector(webView:contextMenuConfigurationForElement:completionHandler:)]) { ..... } else if ([uiDelegate respondsToSelector:@selector(_webView:contextMenuConfigurationForElement:completionHandler:)]) { ..... } Could we change the first condition to also include |_positionInformation.isImage|?
<rdar://problem/68000830>
This API was designed to be a replacement for the API it deprecated without substantial changes. We are considering improving the context menu API, and this input is noted.