Horizontally scrollable code blocks (#5001)

* Remove attributed string backed codeblock background color

* Add code block support to attributed string componentization

* Render code blocks within their own custom horizontal scroll view within the timeline

* Update preview test snapshots

* Introduce a attributed string component type instead of a 2 different booleans.
This commit is contained in:
Stefan Ceriu
2026-01-26 12:39:55 +02:00
committed by GitHub
parent bb801d0be1
commit cf79cb9b01
9 changed files with 75 additions and 36 deletions
@@ -204,7 +204,6 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
content.setFontPreservingSymbolicTraits(UIFont.monospacedSystemFont(ofSize: fontPointSize, weight: .regular))
content.addAttribute(.CodeBlock, value: true, range: NSRange(location: 0, length: content.length))
content.addAttribute(.backgroundColor, value: UIColor.compound._bgCodeBlock as Any, range: NSRange(location: 0, length: content.length))
// Don't allow identifiers or links in code blocks
content.removeAttribute(.MatrixRoomID, range: NSRange(location: 0, length: content.length))
@@ -9,9 +9,15 @@
import Foundation
struct AttributedStringBuilderComponent: Hashable, Identifiable {
enum ComponentType {
case plainText
case blockquote
case codeBlock
}
let id: String
let attributedString: AttributedString
let isBlockquote: Bool
let type: ComponentType
}
protocol AttributedStringBuilderProtocol {