Add basic slash commands support to UserSuggestion module

This commit is contained in:
aringenbach
2023-04-19 10:45:40 +02:00
parent 65c0c1b4b8
commit cacf97233a
12 changed files with 226 additions and 60 deletions
@@ -58,6 +58,22 @@ extension RoomViewController {
}
}
@objc func setCommand(_ command: String) {
if let wysiwygInputToolbar, wysiwygInputToolbar.textFormattingEnabled {
wysiwygInputToolbar.command(command)
wysiwygInputToolbar.becomeFirstResponder()
} else {
guard let attributedText = inputToolbarView.attributedTextMessage else { return }
let newAttributedString = NSMutableAttributedString(attributedString: attributedText)
newAttributedString.append(NSAttributedString(string: "\(command) ",
attributes: [.font: inputToolbarView.defaultFont]))
inputToolbarView.attributedTextMessage = newAttributedString
inputToolbarView.becomeFirstResponder()
}
}
/// Send the formatted text message and its raw counterpart to the room
///