Fix previewing HTTP(S) URLs
This commit is contained in:
parent
a0a12f3865
commit
d4af73a18e
|
@ -11,6 +11,7 @@ import WebKit
|
|||
import GeminiProtocol
|
||||
import GeminiFormat
|
||||
import GeminiRenderer
|
||||
import SafariServices
|
||||
|
||||
class BrowserWebViewController: UIViewController {
|
||||
|
||||
|
@ -252,12 +253,16 @@ extension BrowserWebViewController: WKNavigationDelegate {
|
|||
extension BrowserWebViewController: WKUIDelegate {
|
||||
func webView(_ webView: WKWebView, contextMenuConfigurationForElement elementInfo: WKContextMenuElementInfo, completionHandler: @escaping (UIContextMenuConfiguration?) -> Void) {
|
||||
guard let url = elementInfo.linkURL,
|
||||
url.scheme == "gemini" else {
|
||||
url.scheme == "gemini" || url.scheme == "http" || url.scheme == "https" else {
|
||||
completionHandler(nil)
|
||||
return
|
||||
}
|
||||
let config = UIContextMenuConfiguration(identifier: nil) {
|
||||
return BrowserWebViewController(navigator: self.navigator, url: url)
|
||||
if url.scheme == "gemini" {
|
||||
return BrowserWebViewController(navigator: self.navigator, url: url)
|
||||
} else {
|
||||
return SFSafariViewController(url: url)
|
||||
}
|
||||
} actionProvider: { (_) in
|
||||
return nil
|
||||
}
|
||||
|
@ -266,8 +271,13 @@ extension BrowserWebViewController: WKUIDelegate {
|
|||
|
||||
func webView(_ webView: WKWebView, contextMenuForElement elementInfo: WKContextMenuElementInfo, willCommitWithAnimator animator: UIContextMenuInteractionCommitAnimating) {
|
||||
animator.preferredCommitStyle = .pop
|
||||
let url = elementInfo.linkURL!
|
||||
animator.addCompletion {
|
||||
self.navigator.changeURL(elementInfo.linkURL!)
|
||||
if url.scheme == "http" || url.scheme == "https" {
|
||||
self.present(animator.previewViewController!, animated: true)
|
||||
} else {
|
||||
self.navigator.changeURL(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue