Show empty string when no markdown (#1732)

This commit is contained in:
Ryan Nystrom
2018-04-14 23:12:44 -04:00
committed by GitHub
parent 8c4e734d9c
commit bf263b7e05

View File

@@ -319,6 +319,20 @@ private extension Element {
}
}
private func emptyDescription(options: CMarkOptions) -> ListDiffable {
let builder = StyledTextBuilder.markdownBase()
.add(
text: NSLocalizedString("No description provided.", comment: ""),
traits: .traitItalic,
attributes: [.foregroundColor: Styles.Colors.Gray.medium.color]
)
return StyledTextRenderer(
string: builder.build(),
contentSizeCategory: options.contentSizeCategory,
inset: IssueCommentTextCell.inset
).warm(width: options.width)
}
func MarkdownModels(
_ markdown: String,
owner: String,
@@ -342,6 +356,11 @@ func MarkdownModels(
viewerCanUpdate: viewerCanUpdate,
contentSizeCategory: contentSizeCategory
)
return node.flatElements.compactMap { $0.model(options) }
let models = node.flatElements.compactMap { $0.model(options) }
if models.count == 0 {
return [emptyDescription(options: options)]
} else {
return models
}
}