fix: reset button now resets to original content like reset all function
Fixed reset button behavior to match reset all functionality: ## 🔄 Reset Button Enhancement - **Before**: Only cleared staged changes, kept current modified content - **After**: Resets section to original content like "Reset All" function does ## 🎯 Consistent Behavior - **Reset Button**: Now calls `sectionManager.resetSection()` for complete reset - **Reset All**: Already used `resetSection()` for each section - **Result**: Both reset functions now have identical behavior ## 🚀 Implementation Details - **Section Reset**: Calls `resetSection()` to restore original markdown content - **DOM Update**: Immediately updates display with `updateSectionContent()` - **Staging State**: Updates staging state to reflect original content values - **Preview Update**: Resets image preview and alt text input to original values - **Change Indicator**: Clears "unsaved changes" warning ## 📝 Reset Button Workflow (New) 1. **Reset Section**: Restore section to original content and state 2. **Update Display**: Show original content immediately in document 3. **Parse Original**: Extract original image source and alt text 4. **Update Staging**: Set staging state to reflect original values 5. **Clear Changes**: Remove any staged modifications 6. **Update UI**: Reset preview and form inputs to original values ## ✅ User Experience - **Consistent**: Reset button behavior now matches user expectations - **Complete**: Resets everything back to original (not just current changes) - **Immediate**: Users see original content restored right away - **Reliable**: Works the same way as "Reset All" function Added comprehensive test suite with 4 tests covering complete reset functionality. Reset button now provides true "revert to original" behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2098,7 +2098,28 @@ class DOMRenderer {
|
||||
});
|
||||
|
||||
const resetBtn = this.createButton('↺ Reset', 'ui-edit-reset', (e) => {
|
||||
// Reset both section and staging state
|
||||
// Reset section to original content (like reset all does)
|
||||
this.sectionManager.resetSection(sectionId);
|
||||
|
||||
// Get the reset section to update staging state with original content
|
||||
const resetSection = this.sectionManager.sections.get(sectionId);
|
||||
if (resetSection) {
|
||||
// Update DOM immediately to show reset content
|
||||
this.updateSectionContent(sectionId, resetSection.currentMarkdown);
|
||||
|
||||
// Parse original image info from reset content
|
||||
const originalImageMatch = resetSection.currentMarkdown.match(/!\[(.*?)\]\((.*?)\)/);
|
||||
if (originalImageMatch) {
|
||||
const [, originalAltText, originalImageSrc] = originalImageMatch;
|
||||
|
||||
// Update staging state to reflect original content
|
||||
stagingState.originalMarkdown = resetSection.currentMarkdown;
|
||||
stagingState.currentAltText = originalAltText;
|
||||
stagingState.currentImageSrc = originalImageSrc;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear any staged changes
|
||||
stagingState.stagedImageSrc = null;
|
||||
stagingState.stagedAltText = null;
|
||||
stagingState.hasChanges = false;
|
||||
|
||||
Reference in New Issue
Block a user