Skip to content

Commit

Permalink
Update AttributedStringBuilderComponent identifiers, fix layout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jan 12, 2024
1 parent e51e2ac commit 2d66e76
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions ElementX/Sources/Other/Extensions/AttributedString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Foundation

struct AttributedStringBuilderComponent: Hashable, Identifiable {
let id: Int
let id: String
let attributedString: AttributedString
let isBlockquote: Bool
}
Expand Down

0 comments on commit 2d66e76

Please sign in to comment.