Bible App 1.4.34 — full source
First commit on the local Gitea server, made after moving the tree off the Windows machine. Build outputs, node_modules and the AI models stay out (see .gitignore); everything the installer build needs is tracked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
# Undo/Redo System Fixes
|
||||
|
||||
## Issues Fixed
|
||||
|
||||
### 1. Tab Restoration Not Loading Text
|
||||
**Problem**: When undoing a closed tab, the tab would be restored but the text content wouldn't load, requiring the user to manually click the "Fire" button.
|
||||
|
||||
**Solution**: Enhanced the `restoreTab` method to properly restore tab content:
|
||||
- Added logic to check if the tab was loaded with passage data
|
||||
- If saved text exists, restore it directly
|
||||
- If no saved text, automatically reload the passage
|
||||
- Ensures the tab is fully functional after restoration
|
||||
|
||||
### 2. Eraser Actions Not Being Undone
|
||||
**Problem**: Eraser actions were being treated as regular DRAW actions, causing them to not be properly tracked and undone.
|
||||
|
||||
**Solution**:
|
||||
- Added `ERASE` to the `ACTION_TYPES` enum
|
||||
- Modified `endDrawing` function to differentiate between DRAW and ERASE actions
|
||||
- Updated `captureStateBeforeAction` to handle ERASE actions
|
||||
- Updated undo/redo handlers to treat ERASE the same as DRAW
|
||||
|
||||
### 3. Pen Annotations Moving Instead of Being Removed
|
||||
**Problem**: The undo system was restoring full canvas states, which could cause all annotations to move or behave unexpectedly.
|
||||
|
||||
**Solution**:
|
||||
- Improved state capture to store the exact canvas state before each action
|
||||
- Enhanced state restoration to properly restore the previous state
|
||||
- Ensured that only the last action is undone, not all annotations
|
||||
|
||||
### 4. Highlighter Annotations Not Being Undone
|
||||
**Problem**: Same issue as pen annotations - highlighter strokes weren't being properly undone.
|
||||
|
||||
**Solution**:
|
||||
- Applied the same state-based approach used for pen annotations
|
||||
- Highlighter actions now properly capture and restore canvas states
|
||||
- Each highlighter stroke can be individually undone
|
||||
|
||||
### 5. Pen Size Tool Priority Issues
|
||||
**Problem**: The pen tool was showing the color dropdown when clicked, making it difficult to access the size slider.
|
||||
|
||||
**Solution**:
|
||||
- Changed pen button behavior: click shows size slider, right-click shows color picker
|
||||
- Reduced hold time from 350ms to 200ms for better responsiveness
|
||||
- Added direct click access to the size slider popup
|
||||
- Made the size slider easier to access and use
|
||||
|
||||
## Technical Implementation
|
||||
|
||||
### Action Types
|
||||
```javascript
|
||||
const ACTION_TYPES = {
|
||||
DRAW: 'draw',
|
||||
ERASE: 'erase', // NEW
|
||||
CLEAR: 'clear',
|
||||
TOOL_CHANGE: 'tool_change',
|
||||
COLOR_CHANGE: 'color_change',
|
||||
SIZE_CHANGE: 'size_change',
|
||||
TAB_CREATE: 'tab_create',
|
||||
TAB_CLOSE: 'tab_close',
|
||||
TAB_SWITCH: 'tab_switch',
|
||||
PASSAGE_LOAD: 'passage_load'
|
||||
};
|
||||
```
|
||||
|
||||
### Enhanced Tab Restoration
|
||||
```javascript
|
||||
restoreTab(tabData, makeActive = false) {
|
||||
// ... existing code ...
|
||||
|
||||
// If the tab was loaded, restore the content
|
||||
if (restoredTab.loaded && restoredTab.book && restoredTab.chapter && restoredTab.verse) {
|
||||
if (restoredTab.savedText) {
|
||||
this.restoreTabContent(restoredTab);
|
||||
} else {
|
||||
this.loadPassage(restoredTab.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Improved Pen Tool UI
|
||||
```javascript
|
||||
// Click shows size slider
|
||||
penBtn.addEventListener('click', (e) => {
|
||||
if (currentTool === 'pen') {
|
||||
showPenSizeSlider();
|
||||
penColorDropdown.classList.remove('show');
|
||||
}
|
||||
// ... rest of logic
|
||||
});
|
||||
|
||||
// Right-click shows color picker
|
||||
penBtn.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault();
|
||||
if (currentTool === 'pen') {
|
||||
penColorDropdown.classList.toggle('show');
|
||||
penSizeSliderPopup.classList.remove('show');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Use the `test-undo-fixes.html` file to verify all fixes:
|
||||
|
||||
1. **Tab Operations**: Create/close tabs and verify undo/redo works with text restoration
|
||||
2. **Drawing Tools**: Test pen, highlighter, and eraser undo/redo
|
||||
3. **Pen Size Tool**: Verify size slider priority and ease of use
|
||||
4. **Keyboard Shortcuts**: Test Ctrl+Z and Ctrl+Y functionality
|
||||
|
||||
## Benefits
|
||||
|
||||
- **Better UX**: Users can now undo any action without unexpected behavior
|
||||
- **Improved Workflow**: Pen size tool is easier to access and use
|
||||
- **Reliable State Management**: All user actions are properly tracked and can be undone
|
||||
- **Consistent Behavior**: All drawing tools (pen, highlighter, eraser) work consistently with undo/redo
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
All fixes maintain backward compatibility with existing annotations and user data. The enhanced undo/redo system works alongside the existing annotation persistence system.
|
||||
Reference in New Issue
Block a user