From fe29d25ddb1cf3fb12b01f7292a8bc516e36c6ce Mon Sep 17 00:00:00 2001 From: nmemmert <67961292+nmemmert@users.noreply.github.com> Date: Thu, 30 Jul 2026 11:37:58 -0400 Subject: [PATCH] Restore iframe embed with full-width, auto-height CSS - Removed narrow max-width/margin from generated HTML page - iframe now spans full card width (100%) - onload JS auto-sizes iframe height to content so nothing is cut off - Falls back to 500px if cross-origin restriction ever applies Co-Authored-By: Claude Sonnet 4.6 --- public/admin.js | 4 ++-- server.js | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/public/admin.js b/public/admin.js index dab6668..031d315 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.htmlBody - ? `
📄 ${result.originalName}
${result.htmlBody}

⬇️ Download ${result.originalName}

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

⬇️ Download ${result.originalName}

` : `📄 ${result.originalName}`; if (type === 'assignment') { const cur = $('#ie-body-assignment').value; diff --git a/server.js b/server.js index 1918334..592c716 100644 --- a/server.js +++ b/server.js @@ -1548,16 +1548,23 @@ 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 for inline rendering - let htmlBody = null; + // Convert to HTML for the iframe viewer + let htmlUrl = null; try { - const { value } = await mammoth.convertToHtml({ buffer }); - htmlBody = value || null; + 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}`; } catch (_) { // preview failed — download link still works } - return res.json({ url: `/api/attachments/${filename}`, htmlBody, originalName }); + return res.json({ url: `/api/attachments/${filename}`, htmlUrl, originalName }); }); app.get('/health', (req, res) => res.json({ ok: true }));