feat: enable Android Share Sheet for graphics & files; handle direct PDF/image clipping

This commit is contained in:
chrisf committed 2026-10-29 17:13:57 -06:00
1 parent 338d388c2e
commit 3ed7fb8036
3 files changed
+217 -11

No files matched your search

+8
View File
@@ -321,11 +321,18 @@ export async function POST(req: NextRequest) {
appendedMediaHtml += `<p><audio controls src="/api/attachments/${att.id}"></audio></p>\n`;
} else if (mimeType.startsWith('video/')) {
appendedMediaHtml += `<p><video controls src="/api/attachments/${att.id}" style="max-width: 100%; border-radius: 8px;"></video></p>\n`;
} else if (mimeType === 'application/pdf' || filename.toLowerCase().endsWith('.pdf')) {
appendedMediaHtml += `<p><a href="/api/attachments/${att.id}" target="_blank" rel="noopener noreferrer">📄 View PDF: ${filename}</a></p>\n`;
} else {
appendedMediaHtml += `<p><a href="/api/attachments/${att.id}" target="_blank" rel="noopener noreferrer">📎 ${filename}</a></p>\n`;
}
}
const firstImgAtt = await prisma.attachment.findFirst({
where: { noteId: note.id, mimeType: { startsWith: 'image/' } },
select: { id: true },
});
if (appendedMediaHtml) {
const combinedHtml = `${finalHtml ? `${finalHtml}\n` : ''}${appendedMediaHtml}`;
await prisma.note.update({
@@ -334,6 +341,7 @@ export async function POST(req: NextRequest) {
contentHtml: combinedHtml,
contentText: stripHtmlToText(combinedHtml),
excerpt: makeExcerpt(stripHtmlToText(combinedHtml)),
...(firstImgAtt ? { thumbnailUrl: `/api/attachments/${firstImgAtt.id}` } : {}),
},
});
}