Embed .docx as HTML iframe with download fallback

On upload, mammoth converts the doc to a styled HTML page saved alongside
the .docx. The item body gets an <iframe> pointing to the HTML so students
see the document inline. A download link below gives access to the original.
Falls back to a plain download link if HTML conversion fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-07-30 08:58:02 -04:00
1 parent 5de4cfa6cf
commit eff8cf5e60
2 files changed
+25 -6

No files matched your search

+6 -4
View File
@@ -620,13 +620,15 @@ $('#import-go-btn').addEventListener('click', async () => {
method: 'POST',
body: { base64, originalName: file.name },
});
const link = `<a href="${result.url}" target="_blank">📄 ${result.originalName}</a>`;
const embed = result.htmlUrl
? `<iframe src="${result.htmlUrl}" style="width:100%;height:600px;border:1px solid #ccc;border-radius:4px;"></iframe>\n<p><a href="${result.url}" download="${result.originalName}">⬇️ Download ${result.originalName}</a></p>`
: `<a href="${result.url}" target="_blank">📄 ${result.originalName}</a>`;
if (type === 'assignment') {
$('#ie-body-assignment').value = link;
$('#ie-body-assignment').value = embed;
} else {
$('#ie-body-lesson').innerHTML = link;
$('#ie-body-lesson').innerHTML = embed;
}
$('#import-status').textContent = '✅ File uploaded. Link inserted into body.';
$('#import-status').textContent = '✅ File uploaded. Document embedded in body.';
} catch (err) {
$('#import-status').textContent = `❌ ${err.message}`;
} finally {