2019-07-09 22:44:51 +02:00
|
|
|
;;; lang/org/autoload/contrib-dragndrop.el -*- lexical-binding: t; -*-
|
|
|
|
;;;###if (featurep! +dragndrop)
|
|
|
|
|
|
|
|
;;;###autoload
|
2019-10-20 18:45:15 -04:00
|
|
|
(defun +org-dragndrop-download-dnd-fn (uri action)
|
2019-10-25 20:00:06 -04:00
|
|
|
"Handle file links and base64 data uris."
|
2019-07-09 22:44:51 +02:00
|
|
|
(if (eq major-mode 'org-mode)
|
2020-01-02 16:22:52 -05:00
|
|
|
(+org/attach-file-and-insert-link uri)
|
2019-07-09 22:44:51 +02:00
|
|
|
(let ((dnd-protocol-alist
|
2020-02-17 04:58:57 -05:00
|
|
|
(rassq-delete-all '+org-dragndrop-download-dnd-fn
|
2019-07-09 22:44:51 +02:00
|
|
|
(copy-alist dnd-protocol-alist))))
|
|
|
|
(dnd-handle-one-url nil action uri))))
|
2020-04-15 23:47:14 -04:00
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +org-dragndrop-image-fn (protocol link _description)
|
|
|
|
"Return the image associated with the current attachment."
|
|
|
|
(let ((file (expand-file-name link org-attach-id-dir)))
|
|
|
|
(when (and (file-exists-p file) (image-type-from-file-name file))
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents file)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(buffer-substring-no-properties (point) (point-max))))))
|