feat: implement Phase 5 - undo/redo system with command pattern
Added comprehensive undo/redo functionality: - Command pattern interface and base classes - HistoryManager with 50-operation stack - EditCommand for all edit operations (cut, delete, paste, trim) - Full keyboard shortcuts (Ctrl+Z undo, Ctrl+Y/Ctrl+Shift+Z redo) - HistoryControls UI component with visual feedback - Integrated history system with all edit operations - Toast notifications for undo/redo actions - History state tracking and display New files: - lib/history/command.ts - Command interface and BaseCommand - lib/history/history-manager.ts - HistoryManager class - lib/history/commands/edit-command.ts - EditCommand and factory functions - lib/hooks/useHistory.ts - React hook for history management - components/editor/HistoryControls.tsx - History UI component Modified files: - components/editor/AudioEditor.tsx - Integrated history system - components/editor/EditControls.tsx - Updated keyboard shortcuts display 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
38
lib/history/command.ts
Normal file
38
lib/history/command.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Command Pattern for Undo/Redo System
|
||||
*/
|
||||
|
||||
export interface Command {
|
||||
/**
|
||||
* Execute the command
|
||||
*/
|
||||
execute(): void;
|
||||
|
||||
/**
|
||||
* Undo the command
|
||||
*/
|
||||
undo(): void;
|
||||
|
||||
/**
|
||||
* Redo the command (default: call execute again)
|
||||
*/
|
||||
redo(): void;
|
||||
|
||||
/**
|
||||
* Get a description of the command for UI display
|
||||
*/
|
||||
getDescription(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base command class with default redo implementation
|
||||
*/
|
||||
export abstract class BaseCommand implements Command {
|
||||
abstract execute(): void;
|
||||
abstract undo(): void;
|
||||
abstract getDescription(): string;
|
||||
|
||||
redo(): void {
|
||||
this.execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user