Dismiss the keyboard and minimise the composer when pasting an image, a video or a file

This commit is contained in:
Nicolas Mauri
2023-11-17 11:02:32 +01:00
parent 19c209129d
commit 48ef23f439

View File

@@ -140,6 +140,20 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
wysiwygViewModel.maxCompressedHeight
}
override func paste(_ sender: Any?) {
let pasteboard = MXKPasteboardManager.shared.pasteboard
let types = pasteboard.types.map { UTI(rawValue: $0) }
// Minimise the composer and dismiss the keyboard if it's an image, a video or a file
if types.contains(where: { $0.conforms(to: .image) || $0.conforms(to: .movie) || $0.conforms(to: .video) || $0.conforms(to: .application) }) {
wysiwygViewModel.maximised = false
DispatchQueue.main.async {
self.viewModel.dismissKeyboard()
}
}
super.paste(sender)
}
// MARK: - Setup
override class func instantiate() -> MXKRoomInputToolbarView! {