Improve code blocks

This commit is contained in:
Ali
2023-11-04 00:35:26 +04:00
parent caa8a597e2
commit 94de15f0b6
4 changed files with 182 additions and 5 deletions

View File

@@ -215,9 +215,11 @@ public func stringWithAppliedEntities(_ text: String, entities: [MessageTextEnti
nsString = text as NSString
}
if let codeBlockTitleColor, let codeBlockAccentColor, let codeBlockBackgroundColor {
string.addAttribute(NSAttributedString.Key(rawValue: "Attribute__Blockquote"), value: TextNodeBlockQuoteData(kind: .code(language: language), title: language.flatMap {
NSAttributedString(string: $0.capitalized, font: boldFont.withSize(round(boldFont.pointSize * 0.8235294117647058)), textColor: codeBlockTitleColor)
}, color: codeBlockAccentColor, secondaryColor: nil, tertiaryColor: nil, backgroundColor: codeBlockBackgroundColor), range: range)
var title: NSAttributedString?
if let language, !language.isEmpty {
title = NSAttributedString(string: language.capitalized, font: boldFont.withSize(round(boldFont.pointSize * 0.8235294117647058)), textColor: codeBlockTitleColor)
}
string.addAttribute(NSAttributedString.Key(rawValue: "Attribute__Blockquote"), value: TextNodeBlockQuoteData(kind: .code(language: language), title: title, color: codeBlockAccentColor, secondaryColor: nil, tertiaryColor: nil, backgroundColor: codeBlockBackgroundColor), range: range)
}
case .BlockQuote:
addFontAttributes(range, .blockQuote)