diff --git a/public/admin.js b/public/admin.js
index 9b106ac..dab6668 100644
--- a/public/admin.js
+++ b/public/admin.js
@@ -620,8 +620,8 @@ $('#import-go-btn').addEventListener('click', async () => {
method: 'POST',
body: { base64, originalName: file.name },
});
- const embed = result.htmlUrl
- ? `📄 ${result.originalName}
⬇️ 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 }));