fix: resolve reset all function and image changing functionality issues

Fixed reset all function:
- Fix section-reset event handler to call updateSectionContent instead of non-existent updateTextareaContent
- Ensure proper DOM updates when sections are reset

Fixed image changing functionality:
- Improve image replacement flow with proper DOM updates
- Add safety checks for section retrieval after content updates
- Ensure updateSectionContent is called for immediate DOM reflection

Added comprehensive test suite to verify image functionality works correctly.
All functionality now working as expected.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-02 16:36:17 +01:00
parent d65df8c2a4
commit 91291d727e
2 changed files with 152 additions and 2 deletions

View File

@@ -1352,7 +1352,8 @@ class DOMRenderer {
this.updateSectionContent(data.sectionId, data.content);
});
this.sectionManager.on('section-reset', (data) => {
this.updateTextareaContent(data.content, data.sectionId);
this.hideEditor(data.sectionId);
this.updateSectionContent(data.sectionId, data.content);
});
}
@@ -1977,7 +1978,14 @@ class DOMRenderer {
);
this.sectionManager.updateContent(sectionId, newMarkdown);
this.hideEditor(sectionId);
setTimeout(() => this.showImageEditor(sectionId, this.sectionManager.sections.get(sectionId)), 100);
this.updateSectionContent(sectionId, newMarkdown);
// Wait for DOM update before showing image editor
setTimeout(() => {
const updatedSection = this.sectionManager.sections.get(sectionId);
if (updatedSection) {
this.showImageEditor(sectionId, updatedSection);
}
}, 100);
}
};
reader.readAsDataURL(file);