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:71

Methods

registerElementType

registerElementType(type, deserializer): void

Parameters

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

Returns

void

Defined in

core/editor/timeline.editor.ts:77


unregisterElementType

unregisterElementType(type): void

Parameters

NameType
typestring

Returns

void

Defined in

core/editor/timeline.editor.ts:84


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:91


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:103


getContext

getContext(): TimelineOperationContext

Returns

TimelineOperationContext

Defined in

core/editor/timeline.editor.ts:111


pauseVideo

pauseVideo(): void

Returns

void

Defined in

core/editor/timeline.editor.ts:115


getTimelineData

getTimelineData(): null | TimelineTrackData

Returns

null | TimelineTrackData

Defined in

core/editor/timeline.editor.ts:124


getLatestVersion

getLatestVersion(): number

Returns

number

Defined in

core/editor/timeline.editor.ts:129


addTrack

addTrack(name, type?): Track

Parameters

NameTypeDefault value
namestringundefined
typestringTRACK_TYPES.ELEMENT

Returns

Track

Defined in

core/editor/timeline.editor.ts:183


getTrackById

getTrackById(id): null | Track

Parameters

NameType
idstring

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:193


getTrackByName

getTrackByName(name): null | Track

Parameters

NameType
namestring

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:199


getCaptionsTrack

getCaptionsTrack(): null | Track

Returns

null | Track

Defined in

core/editor/timeline.editor.ts:205


removeTrackById

removeTrackById(id): void

Parameters

NameType
idstring

Returns

void

Defined in

core/editor/timeline.editor.ts:211


removeTrack

removeTrack(track): void

Parameters

NameType
trackTrack

Returns

void

Defined in

core/editor/timeline.editor.ts:218


refresh

refresh(): void

Refresh the timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:228


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:241


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:278


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:309


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:341


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:382


reorderTracks

reorderTracks(tracks): void

Parameters

NameType
tracksTrack[]

Returns

void

Defined in

core/editor/timeline.editor.ts:391


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:401


updateHistory

updateHistory(timelineTrackData): void

Parameters

NameType
timelineTrackDataTimelineTrackData

Returns

void

Defined in

core/editor/timeline.editor.ts:442


undo

undo(): void

Trigger undo operation and update timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:462


redo

redo(): void

Trigger redo operation and update timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:502


resetHistory

resetHistory(): void

Reset history and clear timeline data

Returns

void

Defined in

core/editor/timeline.editor.ts:542


loadProject

loadProject(«destructured»): void

Parameters

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

Returns

void

Defined in

core/editor/timeline.editor.ts:566


getWatermark

getWatermark(): null | Watermark

Returns

null | Watermark

Defined in

core/editor/timeline.editor.ts:612


setWatermark

setWatermark(watermark): void

Parameters

NameType
watermarkWatermark

Returns

void

Defined in

core/editor/timeline.editor.ts:617


removeWatermark

removeWatermark(): void

Returns

void

Defined in

core/editor/timeline.editor.ts:628


getVideoAudio

getVideoAudio(): Promise<string>

Returns

Promise<string>

Defined in

core/editor/timeline.editor.ts:638


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:648


removeTransition

removeTransition(elementId): boolean

Remove transition metadata from an element.

Parameters

NameType
elementIdstring

Returns

boolean

Defined in

core/editor/timeline.editor.ts:669


getProject

getProject(): ProjectJSON

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

Returns

ProjectJSON

Defined in

core/editor/timeline.editor.ts:689


getBackgroundColor

getBackgroundColor(): undefined | string

Returns

undefined | string

Defined in

core/editor/timeline.editor.ts:710


setBackgroundColor

setBackgroundColor(backgroundColor): void

Parameters

NameType
backgroundColorstring

Returns

void

Defined in

core/editor/timeline.editor.ts:714


getMetadata

getMetadata(): undefined | ProjectMetadata

Returns

undefined | ProjectMetadata

Defined in

core/editor/timeline.editor.ts:726


setMetadata

setMetadata(metadata): void

Parameters

NameType
metadataProjectMetadata

Returns

void

Defined in

core/editor/timeline.editor.ts:730


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:746


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:802


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:820


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:863


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:890


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:929


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:950


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:980