mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add support for <details> and <summary> tags (#6077)
This commit is contained in:
@@ -17,10 +17,11 @@ nonisolated extension AttributedString {
|
||||
var formattedComponents: [AttributedStringBuilderComponent] {
|
||||
var components = [AttributedStringBuilderComponent]()
|
||||
|
||||
for run in runs[\.blockquote, \.codeBlock] {
|
||||
for run in runs[\.blockquote, \.codeBlock, \.details] {
|
||||
let isBlockquote = run.0 != nil
|
||||
let isCodeBlock = run.1 != nil
|
||||
var attributedString = AttributedString(self[run.2])
|
||||
let details = run.2
|
||||
var attributedString = AttributedString(self[run.3])
|
||||
|
||||
// Remove trailing new lines if any
|
||||
if attributedString.characters.last?.isNewline ?? false,
|
||||
@@ -28,12 +29,14 @@ nonisolated extension AttributedString {
|
||||
attributedString.removeSubrange(range)
|
||||
}
|
||||
|
||||
let componentType: AttributedStringBuilderComponent.ComponentType = switch (isBlockquote, isCodeBlock) {
|
||||
case (true, _):
|
||||
let componentType: AttributedStringBuilderComponent.ComponentType = switch (details, isBlockquote, isCodeBlock) {
|
||||
case (.some(let summary), _, _):
|
||||
.details(summary: summary)
|
||||
case (_, true, _):
|
||||
.blockquote
|
||||
case (false, true):
|
||||
case (_, false, true):
|
||||
.codeBlock
|
||||
case (false, false):
|
||||
case (_, false, false):
|
||||
.plainText
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user