feat: implement undo/redo functionality in video editor#174
Open
FabLrc wants to merge 4 commits intosiddharthvaddem:mainfrom
Open
feat: implement undo/redo functionality in video editor#174FabLrc wants to merge 4 commits intosiddharthvaddem:mainfrom
FabLrc wants to merge 4 commits intosiddharthvaddem:mainfrom
Conversation
shivaylamba
reviewed
Feb 28, 2026
| import { DEFAULT_CROP_REGION } from "@/components/video-editor/types"; | ||
| import type { AspectRatio } from "@/utils/aspectRatioUtils"; | ||
|
|
||
| // Undoable state — selection IDs are intentionally excluded (undoing a |
ebfa687 to
0e85679
Compare
# Conflicts: # src/components/video-editor/KeyboardShortcutsHelp.tsx # src/components/video-editor/VideoEditor.tsx # src/components/video-editor/timeline/TimelineEditor.tsx
# Conflicts: # src/components/video-editor/VideoEditor.tsx
Owner
|
LGTM, can you make sure to rebase this on top of main? I added linter checks, so the PR will fail these checks until you fix them. I would like this in for the next release. |
siddharthvaddem
approved these changes
Mar 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request : implement undo/redo functionality in video editor
Description
Adds a full undo/redo system to the video editor, backed by a custom
useEditorHistoryhook using a snapshot history pattern. Includes keyboard shortcuts and a slider commit support.Motivation
The editor had no way to revert accidental changes (deleted zoom region, wrong crop, slider overshoot, etc.). Users needed standard undo/redo behaviour without introducing a heavy state management library.
Type of Change
Related Issue(s)
#170
Screenshot
Changes
New:
src/hooks/useEditorHistory.tspushState— discrete undo point (region add/delete, aspect ratio change, etc.)updateState— live preview during drag/slider interaction; auto-saves a checkpoint on first call via adirtyRefcommitState— resets the dirty flag when the interaction ends (pointer-up, slider commit)resolve()andwithCheckpoint()keep the hook stateless and testableModified:
VideoEditor.tsxuseStatehooks for undoable fields with a singleuseEditorHistorycallpushState), slider interactions (updateState/commitState), and zoom focus drags wired accordinglyCtrl+Z(undo),Ctrl+Shift+ZandCtrl+Y(redo); usese.key.toLowerCase()to handle the uppercase'Z'returned by browsers when Shift is heldModified:
VideoPlayback.tsxonZoomFocusDragEnd?: () => voidprop, called on pointer-up/leave, so dragging the zoom focus point creates a single undo entry instead of one per frameModified:
timeline/TimelineEditor.tsxZ,T,A,F) guarded with!e.ctrlKey && !e.metaKey && !e.altKeyto prevent conflict withCtrl+ZModified:
SettingsPanel.tsxonShadowCommit,onBorderRadiusCommit,onPaddingCommitprops wired to Radix Slider'sonValueCommit, completing theupdateState/commitStatepattern for all slidersModified:
KeyboardShortcutsHelp.tsxCtrl+Z) and Redo (Ctrl+Shift+Z/Ctrl+Y) rows to the shortcuts tooltipTesting
Tested on Windows
Checklist