Actions are the trigger layer for user-initiated operations in OpenCut. They provide a unified interface for keyboard shortcuts, UI interactions, and programmatic invocations.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OpenCut-app/OpenCut/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The actions system separates “what to do” (the action) from “how to trigger it” (shortcuts, buttons, menu items). All action definitions live in a single source of truth:@/lib/actions/definitions.ts.
When to use actions
UseinvokeAction() for user-triggered operations in components:
editor.xxx() calls are for internal use (commands, tests, complex multi-step operations).
invokeAction()
Invokes an action by name, optionally passing arguments and trigger information.The action name to invoke (e.g.,
"toggle-play", "split", "undo")Arguments for actions that accept parameters. Only required for actions with args:
seek-forward/seek-backward:{ seconds: number }jump-forward/jump-backward:{ seconds: number }
How the action was triggered. Values:
"keypress" or "mouseclick". Used for analytics and conditional behavior.Examples
Action handlers
Actions are handled using theuseActionHandler hook in React components. This connects action invocations to their implementations.
useActionHandler
Registers a handler for a specific action.The action name to handle
Function to execute when action is invoked. Receives action arguments and optional trigger.
Controls when the handler is active:
undefined: Always activeboolean: Static active stateMutableRefObject<boolean>: Dynamic active state (useful for conditional handlers)
Available actions
All actions are defined in theACTIONS constant in @/lib/actions/definitions.ts.
Playback
| Action | Description | Default Shortcuts | Arguments |
|---|---|---|---|
toggle-play | Play/Pause | space, k | - |
stop-playback | Stop playback | - | - |
seek-forward | Seek forward 1 second | l | { seconds?: number } |
seek-backward | Seek backward 1 second | j | { seconds?: number } |
Navigation
| Action | Description | Default Shortcuts | Arguments |
|---|---|---|---|
frame-step-forward | Frame step forward | right | - |
frame-step-backward | Frame step backward | left | - |
jump-forward | Jump forward 5 seconds | shift+right | { seconds?: number } |
jump-backward | Jump backward 5 seconds | shift+left | { seconds?: number } |
goto-start | Go to timeline start | home, enter | - |
goto-end | Go to timeline end | end | - |
Editing
| Action | Description | Default Shortcuts | Arguments |
|---|---|---|---|
split | Split elements at playhead | s | - |
split-left | Split and remove left | q | - |
split-right | Split and remove right | w | - |
delete-selected | Delete selected elements | backspace, delete | - |
copy-selected | Copy selected elements | ctrl+c | - |
paste-copied | Paste elements at playhead | ctrl+v | - |
toggle-snapping | Toggle snapping | n | - |
Selection
| Action | Description | Default Shortcuts | Arguments |
|---|---|---|---|
select-all | Select all elements | ctrl+a | - |
duplicate-selected | Duplicate selected element | ctrl+d | - |
toggle-elements-muted-selected | Mute/unmute selected elements | - | - |
toggle-elements-visibility-selected | Show/hide selected elements | - | - |
History
| Action | Description | Default Shortcuts | Arguments |
|---|---|---|---|
undo | Undo | ctrl+z | - |
redo | Redo | ctrl+shift+z, ctrl+y | - |
Timeline
| Action | Description | Default Shortcuts | Arguments |
|---|---|---|---|
toggle-bookmark | Toggle bookmark at playhead | - | - |
Action definition
Each action is defined with the following properties:Human-readable description of what the action does
Category for grouping actions. Values:
"playback", "navigation", "editing", "selection", "history", "timeline", "controls"Array of default keyboard shortcuts for this action
Schema defining the arguments this action accepts
Adding new actions
To add a new action:- Define the action in
@/lib/actions/definitions.ts:
- Add the handler in
@/hooks/use-editor-actions.ts(or your component):
- If the action takes arguments, add type definitions in
@/lib/actions/types.ts:
Related
- Commands - Command pattern for undo/redo
- CommandManager - Managing command history