React Registry

hookEditing Hooks@techsquidtv/canvas-timeline-react/hooks

Editing Hooks

Hooks for edit modes, typed commands, previews, range edits, selection, clipboard, and history.

Selected: nonemain selected

Editing action preview

A focused action strip for selection, clipboard, history, and marker hooks.

Open full demo

Installation

pnpm
pnpm add @techsquidtv/canvas-timeline-react
  1. 1

    Install the package.

    The command above adds the React bindings and their package dependencies.

  2. 2

    Import from the React entrypoint.

    @techsquidtv/canvas-timeline-react/hooks

Usage

EditActions.tsx
import { fromSeconds } from '@techsquidtv/canvas-timeline-utils';
import {
useTimelineClips,
useTimelineClipboard,
useTimelineEditCommands,
useTimelineEditMode,
useTimelineEditPreview,
useTimelineHistory,
useTimelineRangeSelection,
} from '@techsquidtv/canvas-timeline-react/hooks';
export function EditActions() {
const { selectedClip } = useTimelineClips();
const { copySelection } = useTimelineClipboard();
const editMode = useTimelineEditMode();
const editCommands = useTimelineEditCommands();
const editPreview = useTimelineEditPreview();
const rangeSelection = useTimelineRangeSelection();
const { canUndo, undo } = useTimelineHistory();
return (
<>
{editPreview.previewing && <span>{editPreview.impacts.length} clips affected</span>}
<button onClick={() => editMode.setMode('trim')}>Trim</button>
<button disabled={!selectedClip} onClick={copySelection}>Copy</button>
<button
disabled={!selectedClip}
onClick={() =>
selectedClip &&
editCommands.moveClip({
clipId: selectedClip.id,
startTime: fromSeconds(4),
})
}
>
Move
</button>
<button disabled={!rangeSelection.hasRange} onClick={() => rangeSelection.liftRange()}>
Lift
</button>
<button disabled={!canUndo} onClick={undo}>Undo</button>
</>
);
}

Notes

  • useActiveMarkers is a live playhead hook; compose it only in marker readouts or navigation that should update while scrubbing.
  • useTimelineEditCommands calls TimelineEngine command APIs for validation, preview, commit, and cancel flows.
  • useTimelineEditPreview is the shared command preview hook for custom guide affordances and renderer-facing impact state.
  • useTimelineEditImpacts is a live interaction hook; compose it in UI that needs drag-time edit consequences, not broad toolbar state.
  • useTimelineClipDropFeedback is a live interaction hook; compose it in focused drag affordances instead of broad editor chrome.

API Reference

Editing Hooks

Hooks for edit modes, typed commands, previews, range edits, selection, clipboard, and history.

Exports

clip editing
NameReferenceDescription
useTimelineClipsAPI referenceReads timeline clips and exposes canonical clip editing commands.
useTimelineEditModeAPI referenceOwns local edit-mode state for product toolbar chrome.
useTimelineEditCommandsAPI referenceBuilds, previews, validates, commits, and cancels typed edit commands.
selection
NameReferenceDescription
useTimelineSelectionAPI referenceReads selected clip and track state with selection commands.
useTimelineRangeSelectionAPI referenceAdapts In/Out points to delete-range and lift-range edit commands.
track editing
NameReferenceDescription
useTimelineTracksAPI referenceReads track state and exposes track management commands.
useTimelineTrackAPI referenceReads one track, canvas-aligned row geometry, and track commands.
useTimelineTrackHeaderAPI referenceReturns DOM-ready track header props for one track row.
control adapter
NameReferenceDescription
useTimelineTrackLockControlAPI referenceReturns semantic button props for toggling one track lock.
marker editing
NameReferenceDescription
useTimelineMarkersAPI referenceReads markers and exposes marker editing commands.
useActiveMarkersAPI referenceSubscribes to live active, nearest, previous, and next markers.
clipboard
NameReferenceDescription
useTimelineClipboardAPI referenceProvides copy, cut, and paste commands for timeline clips.
history
NameReferenceDescription
useTimelineHistoryAPI referenceExposes undo and redo availability with history commands.
edit preview
NameReferenceDescription
useClipEditPreviewAPI referenceReads transient clip edit preview state during trims and cuts.
useTimelineEditImpactsAPI referenceSubscribes to live edit impacts produced by active timeline interactions.
useTimelineEditPreviewAPI referenceSubscribes to the shared command-layer edit preview.
drag drop
NameReferenceDescription
useTimelineClipDragAPI referenceProvides headless clip body dragging, including cross-track drop resolution.
useTimelineTrackDropTargetsAPI referenceExposes track row drop targets and default same-kind track compatibility.
useTimelineClipDropFeedbackAPI referenceSubscribes to live cross-track clip drop feedback for custom affordances.
keyframe editing
NameReferenceDescription
useTimelineKeyframeDragAPI referenceProvides headless keyframe handle dragging with live property preview updates.
useTimelineKeyframeCurveDragAPI referenceProvides headless Bezier curve handle dragging with live easing preview updates.