mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fixed the link color and improved link dection in code blocks (#2466)
This commit is contained in:
@@ -151,8 +151,20 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
if let value = value as? UIColor,
|
||||
value == temporaryCodeBlockMarkingColor {
|
||||
attributedString.addAttribute(.backgroundColor, value: UIColor(.compound._bgCodeBlock) as Any, range: range)
|
||||
// Codeblocks should not have links and all users mentions
|
||||
attributedString.removeAttribute(.link, range: range)
|
||||
// Codebloks should not have explicit links
|
||||
attributedString.enumerateAttribute(.link, in: range, options: []) { value, range, _ in
|
||||
if let link = value as? URL {
|
||||
var text = attributedString.attributedSubstring(from: range).string
|
||||
if !text.contains("://") {
|
||||
// we sanitize links by always them use https://
|
||||
text.insert(contentsOf: "https://", at: text.startIndex)
|
||||
}
|
||||
if text == link.absoluteString {
|
||||
attributedString.removeAttribute(.link, range: range)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Codeblocks should not have all users mentions
|
||||
attributedString.removeAttribute(.MatrixAllUsersMention, range: range)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user