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>
39 lines
613 B
TypeScript
39 lines
613 B
TypeScript
/**
|
|
* 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();
|
|
}
|
|
}
|