mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Update AttributedStringBuilderComponent identifiers, fix layout issues
This commit is contained in:
committed by
Stefan Ceriu
parent
e51e2ac2af
commit
2d66e76b51
@@ -18,12 +18,7 @@ import Foundation
|
|||||||
|
|
||||||
extension AttributedString {
|
extension AttributedString {
|
||||||
var formattedComponents: [AttributedStringBuilderComponent] {
|
var formattedComponents: [AttributedStringBuilderComponent] {
|
||||||
var components = [AttributedStringBuilderComponent]()
|
runs[\.blockquote].map { value, range in
|
||||||
|
|
||||||
for (index, run) in runs[\.blockquote].enumerated() {
|
|
||||||
let value = run.0
|
|
||||||
let range = run.1
|
|
||||||
|
|
||||||
var attributedString = AttributedString(self[range])
|
var attributedString = AttributedString(self[range])
|
||||||
|
|
||||||
// Remove trailing new lines if any
|
// Remove trailing new lines if any
|
||||||
@@ -34,10 +29,8 @@ extension AttributedString {
|
|||||||
|
|
||||||
let isBlockquote = value != nil
|
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.
|
/// Replaces the specified placeholder with a string that links to the specified URL.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct AttributedStringBuilderComponent: Hashable, Identifiable {
|
struct AttributedStringBuilderComponent: Hashable, Identifiable {
|
||||||
let id: Int
|
let id: String
|
||||||
let attributedString: AttributedString
|
let attributedString: AttributedString
|
||||||
let isBlockquote: Bool
|
let isBlockquote: Bool
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user