Video Messages Improvements

(cherry picked from commit e614343888)
This commit is contained in:
Ilya Laktyushin
2021-07-31 00:27:42 +03:00
committed by Ali
parent 51b1f7a836
commit 40b7feac42
6 changed files with 193 additions and 12 deletions

View File

@@ -720,21 +720,23 @@ public func convertMarkdownToAttributes(_ text: NSAttributedString) -> NSAttribu
let entity = string.substring(with: match.range(at: 7))
let substring = string.substring(with: match.range(at: 6)) + text + string.substring(with: match.range(at: 9))
let textInputAttribute: NSAttributedString.Key?
switch entity {
case "`":
result.append(NSAttributedString(string: substring, attributes: [ChatTextInputAttributes.monospace: true as NSNumber]))
offsetRanges.append((NSMakeRange(matchIndex + match.range(at: 6).length, text.count), match.range(at: 6).length * 2))
textInputAttribute = ChatTextInputAttributes.monospace
case "**":
result.append(NSAttributedString(string: substring, attributes: [ChatTextInputAttributes.bold: true as NSNumber]))
offsetRanges.append((NSMakeRange(matchIndex + match.range(at: 6).length, text.count), match.range(at: 6).length * 2))
textInputAttribute = ChatTextInputAttributes.bold
case "__":
result.append(NSAttributedString(string: substring, attributes: [ChatTextInputAttributes.italic: true as NSNumber]))
offsetRanges.append((NSMakeRange(matchIndex + match.range(at: 6).length, text.count), match.range(at: 6).length * 2))
textInputAttribute = ChatTextInputAttributes.italic
case "~~":
result.append(NSAttributedString(string: substring, attributes: [ChatTextInputAttributes.strikethrough: true as NSNumber]))
offsetRanges.append((NSMakeRange(matchIndex + match.range(at: 6).length, text.count), match.range(at: 6).length * 2))
textInputAttribute = ChatTextInputAttributes.strikethrough
default:
break
textInputAttribute = nil
}
if let textInputAttribute = textInputAttribute {
result.append(NSAttributedString(string: substring, attributes: [textInputAttribute: true as NSNumber]))
offsetRanges.append((NSMakeRange(matchIndex + match.range(at: 6).length, text.count), match.range(at: 6).length * 2))
}
stringOffset -= match.range(at: 7).length * 2