new implementation based on the usage of NSTextAttachment to allocate space for the timestamp

This commit is contained in:
Mauro Romito
2026-05-11 16:59:40 +02:00
committed by Mauro
parent deac31e48d
commit 686753721e
3 changed files with 115 additions and 26 deletions
@@ -101,6 +101,25 @@ extension String {
}
}
extension String {
/// Whether the first character with a strong BiDi direction is right-to-left.
/// Mirrors the Unicode BiDi "first strong" rule used by TextKit to resolve
/// paragraph direction when `baseWritingDirection` is `.natural`.
var firstStrongCharacterIsRTL: Bool {
for scalar in unicodeScalars {
let value = scalar.value
// Strong RTL: Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic,
// Arabic Extended, and their presentation forms.
let isStrongRTL = (0x0590...0x08FF).contains(value) ||
(0xFB1D...0xFDFF).contains(value) ||
(0xFE70...0xFEFF).contains(value)
if isStrongRTL { return true }
if scalar.properties.isAlphabetic { return false }
}
return false
}
}
extension String {
/// To be used if the string is actually a URL
var asSanitizedLink: String {