iOS 26 added an AttributedString version of TextEditor. It can display links but I have no idea how to detect when a user taps them. This is possible when using a Text element and the openURL environment modifier, but this doesn't seem to work with TextEditor?
e.g.
struct ContentView: View {
var text: AttributedString {
var attributedString = AttributedString("Link")
attributedString.link = URL(string: "https://www.apple.com")
return attributedString
}
var body: some View {
TextEditor(text: .constant(text))
.environment(\.openURL, OpenURLAction { url in
// This is not called.
print(url)
return .handled
})
}
}
Any ideas?