Render iOS message markdown
This commit is contained in:
@@ -526,7 +526,7 @@ public struct MessageRow: View {
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Text(message.text)
|
||||
Text(renderedText)
|
||||
.textSelection(.enabled)
|
||||
if !message.reactions.isEmpty {
|
||||
Text(message.reactions.map(\.emoji).joined(separator: " "))
|
||||
@@ -552,6 +552,17 @@ public struct MessageRow: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var renderedText: AttributedString {
|
||||
(
|
||||
try? AttributedString(
|
||||
markdown: message.text,
|
||||
options: AttributedString.MarkdownParsingOptions(
|
||||
interpretedSyntax: .inlineOnlyPreservingWhitespace
|
||||
)
|
||||
)
|
||||
) ?? AttributedString(message.text)
|
||||
}
|
||||
}
|
||||
|
||||
public struct ComposeBar: View {
|
||||
|
||||
Reference in New Issue
Block a user