     }
 
     func richTextViewWasPressed(_ recognizer: UIGestureRecognizer) {
-        guard recognizer.state == .recognized else {
-            return
+        guard let textView = self.textView,
+            recognizer.state == .recognized else {
+                return
         }
 
         let locationInTextView = recognizer.location(in: textView)

//
@objc class AttachmentGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {

    let textView: TextView
    fileprivate var currentSelectedAttachment: MediaAttachment?

    public init(textView: TextView) {

    }

    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {

        guard let textView = self.textView else {
            return false
        }

        let locationInTextView = gestureRecognizer.location(in: textView)
        guard textView.attachmentAtPoint(locationInTextView) != nil else {
