From a7fc464dc55252d70cb9242850e9b4a5b771ce52 Mon Sep 17 00:00:00 2001 From: Alaqmar Gandhi Date: Wed, 16 Sep 2026 00:33:08 -0400 Subject: [PATCH 1/7] Fix incoming mail links and add richer compose formatting + attachment previews - Links in message bodies were completely inert (iframe sandbox blocked even opening a new tab); now sandboxed but allow-popups. - Fix the gap between a reply and the quoted message it's replying to. - Compose editor: fuller toolbar (strikethrough, lists, quote, clear formatting), active-state highlighting, Shift+Enter for a soft line break. - Attachments (images, PDF, audio, video, text/JSON/CSV) preview inline instead of forcing a download. --- app/admin/mail/attachment-preview.tsx | 242 +++++++++++++++++++++++ app/admin/mail/editor.tsx | 154 ++++++++++++--- app/admin/mail/html.ts | 1 + app/admin/mail/message-view.tsx | 83 +++++--- app/api/mail/messages/[id]/body/route.ts | 3 + 5 files changed, 425 insertions(+), 58 deletions(-) create mode 100644 app/admin/mail/attachment-preview.tsx diff --git a/app/admin/mail/attachment-preview.tsx b/app/admin/mail/attachment-preview.tsx new file mode 100644 index 00000000..eea0be05 --- /dev/null +++ b/app/admin/mail/attachment-preview.tsx @@ -0,0 +1,242 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { ChevronLeft, ChevronRight, Download, X } from "lucide-react"; +import type { BodyPart } from "@/lib/mail/jmap-mail"; +import { withAs } from "./inbox-picker"; + +export type PreviewKind = "image" | "pdf" | "text" | "audio" | "video"; + +const TEXT_PREVIEW = /^text\/(plain|csv|markdown)$|^application\/json$/i; +const TEXT_PREVIEW_MAX_BYTES = 512 * 1024; + +/** What kind of inline preview a MIME type supports, or null to fall back + * to a plain download. Nothing here needs the blob route to change: Content- + * Disposition doesn't stop /