Update AttributedStringBuilderComponent identifiers, fix layout issues

This commit is contained in:
Stefan Ceriu
2024-01-12 08:51:31 +02:00
committed by Stefan Ceriu
parent e51e2ac2af
commit 2d66e76b51
2 changed files with 3 additions and 10 deletions
@@ -18,12 +18,7 @@ import Foundation
extension AttributedString {
var formattedComponents: [AttributedStringBuilderComponent] {
var components = [AttributedStringBuilderComponent]()
for (index, run) in runs[\.blockquote].enumerated() {
let value = run.0
let range = run.1
runs[\.blockquote].map { value, range in
var attributedString = AttributedString(self[range])
// Remove trailing new lines if any
@@ -34,10 +29,8 @@ extension AttributedString {
let isBlockquote = value != nil
components.append(AttributedStringBuilderComponent(id: index, attributedString: attributedString, isBlockquote: isBlockquote))
return AttributedStringBuilderComponent(id: String(attributedString.characters), attributedString: attributedString, isBlockquote: isBlockquote)
}
return components
}
/// Replaces the specified placeholder with a string that links to the specified URL.
@@ -17,7 +17,7 @@
import Foundation
struct AttributedStringBuilderComponent: Hashable, Identifiable {
let id: Int
let id: String
let attributedString: AttributedString
let isBlockquote: Bool
}