 
     fileprivate(set) lazy var tapGestureRecognizer: UIGestureRecognizer = {
         let recognizer = UITapGestureRecognizer(target: self, action: #selector(richTextViewWasPressed))
-        recognizer.cancelsTouchesInView = false
+        recognizer.cancelsTouchesInView = true
+        recognizer.delaysTouchesBegan = true
+        recognizer.delaysTouchesEnded = true
         recognizer.delegate = self
         return recognizer
     }()

        textView.formattingDelegate = self
        textView.mediaDelegate = self
        textView.addGestureRecognizer(self.tapGestureRecognizer)

        return textView
    }()

        return true
    }

    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        let locationInTextView = gestureRecognizer.location(in: richTextView)
        // check if we have an attachment in the position we tapped
        guard richTextView.attachmentAtPoint(locationInTextView) != nil else {
            // if we have a current selected attachment marked lets unmark it
            if let selectedAttachment = currentSelectedAttachment {
                selectedAttachment.clearAllOverlays()
                richTextView.refreshLayoutFor(attachment: selectedAttachment)
                currentSelectedAttachment = nil
            }
            return false
        }
        return true
    }

    func richTextViewWasPressed(_ recognizer: UIGestureRecognizer) {
        let locationInTextView = recognizer.location(in: richTextView)
        // check if we have an attachment in the position we tapped
        guard let attachment = richTextView.attachmentAtPoint(locationInTextView) else {
            // if we have an attachment marked lets unmark it
            if let selectedAttachment = currentSelectedAttachment {
                selectedAttachment.clearAllOverlays()
                richTextView.refreshLayoutFor(attachment: selectedAttachment)
                currentSelectedAttachment = nil
