From fde08e6793128c4877123a6f2f19ee4d0637145f Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Fri, 25 Apr 2025 13:13:53 -0700 Subject: [PATCH] Attachments: support image-only --- .../attachment-drafts/useAttachmentDrafts.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/common/attachment-drafts/useAttachmentDrafts.tsx b/src/common/attachment-drafts/useAttachmentDrafts.tsx index f9b649b6c..76cab4858 100644 --- a/src/common/attachment-drafts/useAttachmentDrafts.tsx +++ b/src/common/attachment-drafts/useAttachmentDrafts.tsx @@ -194,6 +194,13 @@ export function useAttachmentDrafts(attachmentsStoreApi: AttachmentDraftsStoreAp // attach as Text/Html (further conversion, e.g. to markdown is done later) if (attachText && (textHtml || textPlain)) { + + // only-images: skip this data transfer text attachment + if (filterOnlyImages) { + notifyOnlyImages(textPlain || textHtml); + return false; + } + void _createAttachmentDraft({ media: 'text', method, textPlain, textHtml, }, { hintAddImages }); @@ -206,7 +213,7 @@ export function useAttachmentDrafts(attachmentsStoreApi: AttachmentDraftsStoreAp // did not attach anything from this data transfer return false; - }, [_createAttachmentDraft, attachAppendFile, attachAppendUrl, enableLoadURLsOnPaste, hintAddImages]); + }, [_createAttachmentDraft, attachAppendFile, attachAppendUrl, enableLoadURLsOnPaste, filterOnlyImages, hintAddImages]); /** * Append clipboard items to the attachments. @@ -275,6 +282,13 @@ export function useAttachmentDrafts(attachmentsStoreApi: AttachmentDraftsStoreAp // attach as Text if (textHtml || textPlain) { + + // only-images: skip this clipboard text attachment + if (filterOnlyImages) { + notifyOnlyImages(textPlain || textHtml); + return false; + } + void _createAttachmentDraft({ media: 'text', method: 'clipboard-read', textPlain, textHtml, }, { hintAddImages });