diff --git a/ElementX/Sources/Other/Extensions/AttributedString.swift b/ElementX/Sources/Other/Extensions/AttributedString.swift index 668f5484d5..efd51b9e2e 100644 --- a/ElementX/Sources/Other/Extensions/AttributedString.swift +++ b/ElementX/Sources/Other/Extensions/AttributedString.swift @@ -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. diff --git a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderProtocol.swift b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderProtocol.swift index 21124dd136..0b03f7fce4 100644 --- a/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderProtocol.swift +++ b/ElementX/Sources/Other/HTMLParsing/AttributedStringBuilderProtocol.swift @@ -17,7 +17,7 @@ import Foundation struct AttributedStringBuilderComponent: Hashable, Identifiable { - let id: Int + let id: String let attributedString: AttributedString let isBlockquote: Bool }