            detailsViewController.linkURL = url
         }
         
-        detailsViewController.onUpdate = { (alignment, size, url, linkURL, alt) in
-            self.richTextView.edit(attachment) { updated in
+        detailsViewController.onUpdate = { [weak self] (alignment, size, url, linkURL, alt) in
+            self?.richTextView.edit(attachment) { updated in
                 if let alt = alt {
                     updated.extraAttributes["alt"] = alt
                 }

            ])

        NSLayoutConstraint.activate([
            richTextView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            richTextView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
            richTextView.topAnchor.constraint(equalTo: layoutGuide.topAnchor, constant: 0),
            richTextView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0)
            ])

        NSLayoutConstraint.activate([
            htmlTextView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            htmlTextView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
            htmlTextView.topAnchor.constraint(equalTo: richTextView.topAnchor),
            htmlTextView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
            ])
    }


            }
            // Update associated link
            if let updatedURL = linkURL {
                self?.richTextView.setLink(updatedURL, inRange: attachmentRange)
            } else if oldURL != nil && linkURL == nil {
                self?.richTextView.removeLink(inRange: attachmentRange)
            }
        }

