Merge pull request #783 from kiwix/775-pdf-in-nautilus-made-zim-are-not-open-via-simple-click

Add support for target=blank links
This commit is contained in:
Kelson 2024-05-31 16:00:29 +02:00 committed by GitHub
commit f373d96349
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -393,6 +393,24 @@ final class BrowserViewModel: NSObject, ObservableObject,
_ = createNewTab(url: newUrl)
return nil
}
#else
func webView(
_ webView: WKWebView,
createWebViewWith configuration: WKWebViewConfiguration,
for navigationAction: WKNavigationAction,
windowFeatures: WKWindowFeatures
) -> WKWebView? {
guard let newURL = navigationAction.request.url else { return nil }
if let frame = navigationAction.targetFrame, frame.isMainFrame {
return nil
}
guard newURL.isExternal == false else {
externalURL = newURL
return nil
}
webView.load(navigationAction.request)
return nil
}
#endif
#if os(iOS)