From 2384fc9f7d2752a76b0c8df5230c80b99f41a04a Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Thu, 30 Jul 2026 10:31:50 -0400 Subject: [PATCH] Render document content inline instead of in iframe Replace the

⬇️ Download ${result.originalName}

` + const embed = result.htmlBody + ? `
📄 ${result.originalName}
${result.htmlBody}

⬇️ Download ${result.originalName}

` : `📄 ${result.originalName}`; if (type === 'assignment') { const cur = $('#ie-body-assignment').value; diff --git a/server.js b/server.js index 21ea7e6..1918334 100644 --- a/server.js +++ b/server.js @@ -1548,22 +1548,16 @@ app.post('/api/admin/upload-attachment', requirePin, async (req, res) => { return res.status(500).json({ error: `Could not save file: ${err.message}` }); } - // Convert to HTML so it can be shown in an iframe - let htmlUrl = null; + // Convert to HTML for inline rendering + let htmlBody = null; try { - const { value: bodyHtml } = await mammoth.convertToHtml({ buffer }); - const htmlFilename = `${uuid}.html`; - const page = ` - -${bodyHtml}`; - await writeFile(join(ATTACHMENTS_DIR, htmlFilename), page); - htmlUrl = `/api/attachments/${htmlFilename}`; + const { value } = await mammoth.convertToHtml({ buffer }); + htmlBody = value || null; } catch (_) { - // HTML preview generation failed — download link still works + // preview failed — download link still works } - return res.json({ url: `/api/attachments/${filename}`, htmlUrl, originalName }); + return res.json({ url: `/api/attachments/${filename}`, htmlBody, originalName }); }); app.get('/health', (req, res) => res.json({ ok: true }));