Fix import content not appearing in editor fields
Lesson body is a contenteditable div — must use innerHTML, not .value. Assignment body is a plain textarea — strip HTML tags before setting .value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
19f922c4ba
commit
6b72031672
1 file changed
+7
-7
+7
-7
@@ -619,14 +619,14 @@ $('#import-go-btn').addEventListener('click', async () => {
|
|||||||
const result = await api('/api/admin/import-docx', { method: 'POST', body: { base64 } });
|
const result = await api('/api/admin/import-docx', { method: 'POST', body: { base64 } });
|
||||||
if (!$('#ie-title').value && result.title) $('#ie-title').value = result.title;
|
if (!$('#ie-title').value && result.title) $('#ie-title').value = result.title;
|
||||||
if (result.body) {
|
if (result.body) {
|
||||||
const bodyField = type === 'assignment' ? '#ie-body-assignment' : '#ie-body-lesson';
|
if (type === 'assignment') {
|
||||||
const bodyEl = $(bodyField);
|
const tmp = document.createElement('div');
|
||||||
if (bodyEl) {
|
tmp.innerHTML = result.body;
|
||||||
bodyEl.value = result.body;
|
$('#ie-body-assignment').value = tmp.textContent || tmp.innerText || '';
|
||||||
$('#import-status').textContent = '✅ Text extracted. Review and edit before saving.';
|
} else if (type === 'lesson') {
|
||||||
} else {
|
$('#ie-body-lesson').innerHTML = result.body;
|
||||||
$('#import-status').textContent = '✅ Title set. Paste content from your doc manually for quiz questions.';
|
|
||||||
}
|
}
|
||||||
|
$('#import-status').textContent = '✅ Text extracted. Review and edit before saving.';
|
||||||
} else {
|
} else {
|
||||||
$('#import-status').textContent = '⚠️ File imported but no content was found.';
|
$('#import-status').textContent = '⚠️ File imported but no content was found.';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user