@twick/timeline / Exports / TimelineEditor
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
Properties
Methods
- addElementToTrack
- addTrack
- cloneElement
- getContext
- getLatestVersion
- getTimelineData
- getTrackById
- getTrackByName
- getVideoAudio
- loadProject
- pauseVideo
- redo
- refresh
- removeElement
- removeTrack
- removeTrackById
- reorderTracks
- resetHistory
- setTimelineData
- splitElement
- undo
- updateElement
- updateHistory
Constructors
constructor
• new TimelineEditor(context): TimelineEditor
Parameters
| Name | Type |
|---|---|
context | TimelineOperationContext |
Returns
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:45
Properties
context
• Private context: TimelineOperationContext
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:42
totalDuration
• Private totalDuration: number = 0
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:43
Methods
addElementToTrack
▸ addElementToTrack(track, element): Promise<boolean>
Add an element to a specific track using the visitor pattern
Parameters
| Name | Type | Description |
|---|---|---|
track | Track | The track to add the element to |
element | TrackElement | The element to add |
Returns
Promise<boolean>
Promise<boolean> true if element was added successfully
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:143
addTrack
▸ addTrack(name): Track
Parameters
| Name | Type |
|---|---|
name | string |
Returns
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:94
cloneElement
▸ cloneElement(element): null | TrackElement
Clone an element using the visitor pattern
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to clone |
Returns
null | TrackElement
TrackElement | null - the cloned element or null if cloning failed
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:272
getContext
▸ getContext(): TimelineOperationContext
Returns
TimelineOperationContext
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:51
getLatestVersion
▸ getLatestVersion(): number
Returns
number
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:69
getTimelineData
▸ getTimelineData(): null | TimelineTrackData
Returns
null | TimelineTrackData
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:64
getTrackById
▸ getTrackById(id): null | Track
Parameters
| Name | Type |
|---|---|
id | string |
Returns
null | Track
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:103
getTrackByName
▸ getTrackByName(name): null | Track
Parameters
| Name | Type |
|---|---|
name | string |
Returns
null | Track
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:109
getVideoAudio
▸ getVideoAudio(): Promise<string>
Returns
Promise<string>
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:398
loadProject
▸ loadProject(«destructured»): void
Parameters
| Name | Type |
|---|---|
«destructured» | Object |
› tracks | TrackJSON[] |
› version | number |
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:377
pauseVideo
▸ pauseVideo(): void
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:55
redo
▸ redo(): void
Trigger redo operation and update timeline data
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:327
refresh
▸ refresh(): void
Refresh the timeline data
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:130
removeElement
▸ removeElement(element): boolean
Remove an element from a specific track using the visitor pattern
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to remove |
Returns
boolean
boolean true if element was removed successfully
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:173
removeTrack
▸ removeTrack(track): void
Parameters
| Name | Type |
|---|---|
track | Track |
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:121
removeTrackById
▸ removeTrackById(id): void
Parameters
| Name | Type |
|---|---|
id | string |
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:115
reorderTracks
▸ reorderTracks(tracks): void
Parameters
| Name | Type |
|---|---|
tracks | Track[] |
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:281
resetHistory
▸ resetHistory(): void
Reset history and clear timeline data
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:355
setTimelineData
▸ setTimelineData(tracks, version?): TimelineTrackData
Parameters
| Name | Type |
|---|---|
tracks | Track[] |
version? | number |
Returns
TimelineTrackData
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:75
splitElement
▸ splitElement(element, splitTime): Promise<SplitResult>
Split an element at a specific time point using the visitor pattern
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to split |
splitTime | number | The time point to split at |
Returns
Promise<SplitResult>
SplitResult with first element, second element, and success status
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:234
undo
▸ undo(): void
Trigger undo operation and update timeline data
Returns
void
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:299
updateElement
▸ updateElement(element): boolean
Update an element in a specific track using the visitor pattern
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The updated element |
Returns
boolean
boolean true if element was updated successfully
Defined in
packages/timeline/src/core/editor/timeline.editor.ts:203
updateHistory
▸ updateHistory(timelineTrackData): void
Parameters
| Name | Type |
|---|---|
timelineTrackData | TimelineTrackData |
Returns
void