diff --git a/src/components/DumpCreateModal.tsx b/src/components/DumpCreateModal.tsx index 3f104ec..4a628ef 100644 --- a/src/components/DumpCreateModal.tsx +++ b/src/components/DumpCreateModal.tsx @@ -186,6 +186,12 @@ export function DumpCreateModal( // Paste handler useEffect(() => { const handler = (e: ClipboardEvent) => { + // Fields own their paste: the comment editor uploads pasted images as + // inline attachments, and the URL input has its own file handler below. + // Without this guard, pasting an image into the description would flip + // the whole modal over to a file dump. + const tag = (e.target as HTMLElement).tagName; + if (tag === "INPUT" || tag === "TEXTAREA") return; const pastedFile = e.clipboardData?.files[0]; if (pastedFile) { setMode("file"); @@ -194,8 +200,6 @@ export function DumpCreateModal( clearErrors("root"); return; } - const tag = (e.target as HTMLElement).tagName; - if (tag === "INPUT" || tag === "TEXTAREA") return; const text = e.clipboardData?.getData("text") ?? ""; try { const u = new URL(normalizeUrl(text)); diff --git a/src/components/Markdown.tsx b/src/components/Markdown.tsx index 3395a59..7bb83a0 100644 --- a/src/components/Markdown.tsx +++ b/src/components/Markdown.tsx @@ -16,10 +16,10 @@ function preprocessMentions(text: string): string { return text.replace(/(?["components"] = { +type Components = React.ComponentProps["components"]; + +// Static components objects — defined once at module scope to avoid recreation on every render +const MARKDOWN_COMPONENTS: Components = { a: ({ href, children: linkChildren }) => { if (href?.startsWith("/users/")) { return {linkChildren}; @@ -32,6 +32,14 @@ const MARKDOWN_COMPONENTS: React.ComponentProps< }, }; +// Inline renderings are line-clamped teasers inside cards, where an embedded +// image blows the layout apart. Drop images there — the full description is +// one click away on the detail page. +const INLINE_MARKDOWN_COMPONENTS: Components = { + ...MARKDOWN_COMPONENTS, + img: () => null, +}; + export function Markdown( { children, className, inline = false }: MarkdownProps, ) { @@ -45,7 +53,9 @@ export function Markdown( > {processed}