Render pills in RTE (#1874)

* for now this can only work locally

* works

* added a test

* updated RTE

* revert package

* pr suggestion

* reverting package versions

* better naming
This commit is contained in:
Mauro
2023-10-11 16:40:52 +02:00
committed by GitHub
parent ff4d59bac7
commit c358150449
13 changed files with 136 additions and 36 deletions
@@ -220,15 +220,15 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
}
}
private func addAllUsersMention(_ attributedString: NSMutableAttributedString) {
func addAllUsersMention(_ attributedString: NSMutableAttributedString) {
MatrixEntityRegex.allUsersRegex.matches(in: attributedString.string, options: []).forEach { match in
if attributedString.attribute(.link, at: 0, longestEffectiveRange: nil, in: match.range) == nil {
if attributedString.attribute(.link, at: 0, longestEffectiveRange: nil, in: match.range) as? URL == nil {
attributedString.addAttribute(.MatrixAllUsersMention, value: true, range: match.range)
}
}
}
private func detectPermalinks(_ attributedString: NSMutableAttributedString) {
func detectPermalinks(_ attributedString: NSMutableAttributedString) {
attributedString.enumerateAttribute(.link, in: .init(location: 0, length: attributedString.length), options: []) { value, range, _ in
if value != nil {
if let url = value as? URL {