Skip to main content

Class: TimelineEditor

TimelineEditor

This class provides an interface to execute all timeline operations using a direct, class-based approach with track-based management. It also handles undo/redo operations internally.

Table of contents

Constructors

Methods

Constructors

constructor

new TimelineEditor(context): TimelineEditor

Parameters

NameType
contextTimelineOperationContext

Returns

TimelineEditor

Defined in

core/editor/timeline.editor.ts:86

Methods

registerElementType

registerElementType(type, deserializer): void

Parameters

NameType
typestring
deserializer(json: ElementJSON) => null | TrackElement

Returns

void

Defined in

core/editor/timeline.editor.ts:92


unregisterElementType

unregisterElementType(type): void

Parameters

NameType
typestring

Returns

void

Defined in

core/editor/timeline.editor.ts:99


on

on(event, handler): void

Subscribe to timeline mutation events.

Parameters

NameType
eventTimelineEditorEvent
handler(payload: unknown) => void

Returns

void

Defined in

core/editor/timeline.editor.ts:106


off

off(event, handler): void

Unsubscribe from timeline mutation events.

Parameters

NameType
eventTimelineEditorEvent
handler(payload: unknown) => void

Returns

void

Defined in

core/editor/timeline.editor.ts:118


getContext

getContext(): TimelineOperationContext

Returns

TimelineOperationContext

Defined in

core/editor/timeline.editor.ts:126


pauseVideo

pauseVideo(): void

Returns

void

Defined in

core/editor/timeline.editor.ts:130


getTimelineData

getTimelineData(): null | TimelineTrackData

Returns

null | TimelineTrackData

Defined in

core/editor/timeline.editor.ts:139


getLatestVersion

getLatestVersion(): number

Returns

number

Defined in

core/editor/timeline.editor.ts:144


addTrack

addTrack(name, type?): Track

Parameters

NameTypeDefault value
namestringundefined
typestringTRACK_TYPES.ELEMENT

Returns

Track

Defined in

core/editor/timeline.editor.ts:198


getTrackById

getTrackById(id): null | Track

Parameters

NameType
idstring

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:208


getTrackByName

getTrackByName(name): null | Track

Parameters

NameType
namestring

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:214


getCaptionsTrack

getCaptionsTrack(): null | Track

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:220


getTracksByType

getTracksByType(type): Track[]

Parameters

NameType
typestring

Returns

Track[]

Defined in

core/editor/timeline.editor.ts:226


getTracksByPredicate

getTracksByPredicate(predicate): Track[]

Parameters

NameType
predicate(track: Track, index: number) => boolean

Returns

Track[]

Defined in

core/editor/timeline.editor.ts:232


updateTrackProps

updateTrackProps(trackId, propsPatch): null | Track

Parameters

NameType
trackIdstring
propsPatchRecord<string, unknown>

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:238


replaceTrackProps

replaceTrackProps(trackId, nextProps): null | Track

Parameters

NameType
trackIdstring
nextPropsRecord<string, unknown>

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:255


upsertTrack

upsertTrack(input): Track

Parameters

NameType
inputTrackUpsertInput

Returns

Track

Defined in

core/editor/timeline.editor.ts:265


validateTrackOverlaps

validateTrackOverlaps(trackId): Object

Parameters

NameType
trackIdstring

Returns

Object

NameType
validboolean
issuesTrackOverlapIssue[]

Defined in

core/editor/timeline.editor.ts:297


removeTrackById

removeTrackById(id): void

Parameters

NameType
idstring

Returns

void

Defined in

core/editor/timeline.editor.ts:329


removeTrack

removeTrack(track): void

Parameters

NameType
trackTrack

Returns

void

Defined in

core/editor/timeline.editor.ts:336


refresh

refresh(): void

Refresh the timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:346


addElementToTrack

addElementToTrack(track, element): Promise<boolean>

Add an element to a specific track using the visitor pattern.

Parameters

NameTypeDescription
trackTrackThe track to add the element to.
elementTrackElementThe element to add.

Returns

Promise<boolean>

A promise that resolves to true if the element was added successfully, otherwise false.

Defined in

core/editor/timeline.editor.ts:359


removeElement

removeElement(element): boolean

Remove an element from a specific track using the visitor pattern.

Parameters

NameTypeDescription
elementTrackElementThe element to remove.

Returns

boolean

true if the element was removed successfully, otherwise false.

Defined in

core/editor/timeline.editor.ts:396


updateElement

updateElement(element): TrackElement

Update an element in a specific track using the visitor pattern.

Parameters

NameTypeDescription
elementTrackElementThe updated element.

Returns

TrackElement

The updated TrackElement.

Defined in

core/editor/timeline.editor.ts:427


splitElement

splitElement(element, splitTime): Promise<SplitResult>

Split an element at a specific time point using the visitor pattern

Parameters

NameTypeDescription
elementTrackElementThe element to split
splitTimenumberThe time point to split at

Returns

Promise<SplitResult>

SplitResult with first element, second element, and success status

Defined in

core/editor/timeline.editor.ts:459


cloneElement

cloneElement(element): null | TrackElement

Clone an element using the visitor pattern

Parameters

NameTypeDescription
elementTrackElementThe element to clone

Returns

null | TrackElement

TrackElement | null - the cloned element or null if cloning failed

Defined in

core/editor/timeline.editor.ts:532


reorderTracks

reorderTracks(tracks): void

Parameters

NameType
tracksTrack[]

Returns

void

Defined in

core/editor/timeline.editor.ts:541


moveElementToNewTrackAt

moveElementToNewTrackAt(element, targetTrackIndex, startSec): Promise<boolean>

Move an element to a new track inserted at the given index (OpenVideo-style separator drop). Removes the element from its current track, creates a new track at targetTrackIndex, sets element start/end, and adds the element to the new track.

Parameters

NameType
elementTrackElement
targetTrackIndexnumber
startSecnumber

Returns

Promise<boolean>

Defined in

core/editor/timeline.editor.ts:551


updateHistory

updateHistory(timelineTrackData): void

Parameters

NameType
timelineTrackDataTimelineTrackData

Returns

void

Defined in

core/editor/timeline.editor.ts:596


undo

undo(): void

Trigger undo operation and update timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:616


redo

redo(): void

Trigger redo operation and update timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:656


resetHistory

resetHistory(): void

Reset history and clear timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:696


loadProject

loadProject(«destructured»): void

Parameters

NameType
«destructured»Object
› tracksTrackJSON[]
› versionnumber
› backgroundColor?string
› metadata?ProjectMetadata

Returns

void

Defined in

core/editor/timeline.editor.ts:720


loadProjectSnapshot

loadProjectSnapshot(«destructured»): void

Parameters

NameType
«destructured»Object
› tracksTrackJSON[]
› versionnumber
› backgroundColor?string
› metadata?ProjectMetadata

Returns

void

Defined in

core/editor/timeline.editor.ts:766


getWatermark

getWatermark(): null | Watermark

Returns

null | Watermark

Defined in

core/editor/timeline.editor.ts:800


setWatermark

setWatermark(watermark): void

Parameters

NameType
watermarkWatermark

Returns

void

Defined in

core/editor/timeline.editor.ts:805


removeWatermark

removeWatermark(): void

Returns

void

Defined in

core/editor/timeline.editor.ts:816


getVideoAudio

getVideoAudio(): Promise<string>

Returns

Promise<string>

Defined in

core/editor/timeline.editor.ts:826


addTransition

addTransition(fromElementId, toElementId, kind, duration): boolean

Add transition metadata from one element to the next (e.g. crossfade). Sets optional transition on the "from" element; visualizer can interpret it when implemented.

Parameters

NameType
fromElementIdstring
toElementIdstring
kindstring
durationnumber

Returns

boolean

Defined in

core/editor/timeline.editor.ts:836


removeTransition

removeTransition(elementId): boolean

Remove transition metadata from an element.

Parameters

NameType
elementIdstring

Returns

boolean

Defined in

core/editor/timeline.editor.ts:857


getProject

getProject(): ProjectJSON

Get the current project as ProjectJSON (same shape consumed by visualizer).

Returns

ProjectJSON

Defined in

core/editor/timeline.editor.ts:877


getBackgroundColor

getBackgroundColor(): undefined | string

Returns

undefined | string

Defined in

core/editor/timeline.editor.ts:898


setBackgroundColor

setBackgroundColor(backgroundColor): void

Parameters

NameType
backgroundColorstring

Returns

void

Defined in

core/editor/timeline.editor.ts:902


getMetadata

getMetadata(): undefined | ProjectMetadata

Returns

undefined | ProjectMetadata

Defined in

core/editor/timeline.editor.ts:914


setMetadata

setMetadata(metadata): void

Parameters

NameType
metadataProjectMetadata

Returns

void

Defined in

core/editor/timeline.editor.ts:918


rippleDelete

rippleDelete(fromTime, toTime): Promise<void>

Ripple delete: remove content in [fromTime, toTime] and shift later content left. Single undo step.

Parameters

NameType
fromTimenumber
toTimenumber

Returns

Promise<void>

Defined in

core/editor/timeline.editor.ts:934


trimElement

trimElement(element, newStart, newEnd): boolean

Trim an element to new start and end times. Validates bounds and updates via updateElement.

Parameters

NameType
elementTrackElement
newStartnumber
newEndnumber

Returns

boolean

Defined in

core/editor/timeline.editor.ts:990


updateElements

updateElements(updates): void

Apply multiple element updates in one batch; single setTimelineData and undo step.

Parameters

NameType
updates{ elementId: string ; updates: Partial<ElementJSON> }[]

Returns

void

Defined in

core/editor/timeline.editor.ts:1008


removeElements

removeElements(elementIds): void

Remove multiple elements by id in one batch; single setTimelineData and undo step.

Parameters

NameType
elementIdsstring[]

Returns

void

Defined in

core/editor/timeline.editor.ts:1212


replaceElementsBySource

replaceElementsBySource(src, newElementJson): number

Replace all elements with the given src (e.g. placeholder or same URL) with a new element definition. Preserves id, s, e, and track for each replaced element. Single setTimelineData at end.

Parameters

NameType
srcstring
newElementJsonElementJSON

Returns

number

Defined in

core/editor/timeline.editor.ts:1239


centerElementInScene

centerElementInScene(elementId, sceneWidth, sceneHeight): boolean

Center an element in the scene by setting its position to the center of scene dimensions.

Parameters

NameType
elementIdstring
sceneWidthnumber
sceneHeightnumber

Returns

boolean

Defined in

core/editor/timeline.editor.ts:1278


scaleElementToFit

scaleElementToFit(elementId, sceneWidth, sceneHeight): boolean

Scale an element to fit within scene dimensions while preserving aspect ratio. Updates width/height in props or frame when present.

Parameters

NameType
elementIdstring
sceneWidthnumber
sceneHeightnumber

Returns

boolean

Defined in

core/editor/timeline.editor.ts:1299


duplicateElements

duplicateElements(elementIds): Promise<TrackElement[]>

Duplicate multiple elements by id; adds clones to the same track. Single setTimelineData at end.

Parameters

NameType
elementIdsstring[]

Returns

Promise<TrackElement[]>

Defined in

core/editor/timeline.editor.ts:1329