I want to convert a UIWebView library to use WkWebview. The remaining piece is switching out JSContext because the valueForKeyPath
doesn't work anymore. So how do I rewrite something like the following to use WKScriptMessage as the other SO link suggests? (swift or ObjC answer is fine) How to get JSContext from WKWebView
JSContext *ctx = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
ctx[@"contentPasteCallback"] = ^(JSValue *msg) {
__weak typeof(weakSelf) StrongSelf = weakSelf;
StrongSelf.editorPaste = YES;
};
[ctx evaluateScript:@"document.getElementById('zss_editor_content').addEventListener('paste', contentPasteCallback, false);"];