forked from shadowfacts/Tusker
visionOS: Don't use deprecated UITextViewDelegate method
This commit is contained in:
parent
f122383d0b
commit
dc654812b1
@ -236,6 +236,20 @@ class ContentTextView: LinkTextView, BaseEmojiLabel {
|
||||
}
|
||||
|
||||
extension ContentTextView: UITextViewDelegate {
|
||||
#if os(visionOS)
|
||||
func textView(_ textView: UITextView, primaryActionFor textItem: UITextItem, defaultAction: UIAction) -> UIAction? {
|
||||
guard case .link(let url) = textItem.content else {
|
||||
return defaultAction
|
||||
}
|
||||
if url.scheme == dataDetectorsScheme {
|
||||
return defaultAction
|
||||
} else {
|
||||
return UIAction { _ in
|
||||
self.handleLinkTapped(url: url, text: (self.text as NSString).substring(with: textItem.range))
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
|
||||
// the builtin data detectors use the x-apple-data-detectors scheme, and we allow the text view to handle those itself
|
||||
if URL.scheme == dataDetectorsScheme {
|
||||
@ -249,6 +263,7 @@ extension ContentTextView: UITextViewDelegate {
|
||||
return false
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extension ContentTextView: MenuActionProvider {
|
||||
|
Loading…
x
Reference in New Issue
Block a user