Skip to main content

Class: ElementAdder

ElementAdder visitor for adding elements to tracks. Uses the visitor pattern to handle different element types and implements the Friend Class Pattern for explicit access control. Automatically calculates start and end times for elements based on existing track content.

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new ElementAdder(track): ElementAdder

Creates a new ElementAdder instance for the specified track.

Parameters

NameTypeDescription
trackTrackThe track to add elements to

Returns

ElementAdder

Example

const adder = new ElementAdder(track);
const success = await adder.visitVideoElement(videoElement);

Defined in

core/visitor/element-adder.ts:39

Methods

visitVideoElement

visitVideoElement(element): Promise<boolean>

Adds a video element to the track. Updates video metadata and calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementVideoElementThe video element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitVideoElement(videoElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitVideoElement

Defined in

core/visitor/element-adder.ts:58


visitAudioElement

visitAudioElement(element): Promise<boolean>

Adds an audio element to the track. Updates audio metadata and calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementAudioElementThe audio element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitAudioElement(audioElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitAudioElement

Defined in

core/visitor/element-adder.ts:88


visitImageElement

visitImageElement(element): Promise<boolean>

Adds an image element to the track. Updates image metadata and calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementImageElementThe image element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitImageElement(imageElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitImageElement

Defined in

core/visitor/element-adder.ts:118


visitTextElement

visitTextElement(element): Promise<boolean>

Adds a text element to the track. Calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementTextElementThe text element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitTextElement(textElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitTextElement

Defined in

core/visitor/element-adder.ts:147


visitCaptionElement

visitCaptionElement(element): Promise<boolean>

Adds a caption element to the track. Calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementCaptionElementThe caption element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitCaptionElement(captionElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitCaptionElement

Defined in

core/visitor/element-adder.ts:175


visitIconElement

visitIconElement(element): Promise<boolean>

Adds an icon element to the track. Calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementIconElementThe icon element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitIconElement(iconElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitIconElement

Defined in

core/visitor/element-adder.ts:203


visitCircleElement

visitCircleElement(element): Promise<boolean>

Adds a circle element to the track. Calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementCircleElementThe circle element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitCircleElement(circleElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitCircleElement

Defined in

core/visitor/element-adder.ts:231


visitRectElement

visitRectElement(element): Promise<boolean>

Adds a rectangle element to the track. Calculates appropriate start/end times based on existing track elements.

Parameters

NameTypeDescription
elementRectElementThe rectangle element to add

Returns

Promise<boolean>

Promise resolving to true if element was added successfully

Example

const success = await adder.visitRectElement(rectElement);
// success = true if element was added successfully

Implementation of

ElementVisitor.visitRectElement

Defined in

core/visitor/element-adder.ts:259


visitPlaceholderElement

visitPlaceholderElement(element): Promise<boolean>

Parameters

NameType
elementPlaceholderElement

Returns

Promise<boolean>

Implementation of

ElementVisitor.visitPlaceholderElement

Defined in

core/visitor/element-adder.ts:274


visitLineElement

visitLineElement(element): Promise<boolean>

Adds a line element to the track. Uses the same default duration semantics as other simple shapes.

Parameters

NameType
elementLineElement

Returns

Promise<boolean>

Implementation of

ElementVisitor.visitLineElement

Defined in

core/visitor/element-adder.ts:293


visitArrowElement

visitArrowElement(element): Promise<boolean>

Parameters

NameType
elementArrowElement

Returns

Promise<boolean>

Implementation of

ElementVisitor.visitArrowElement

Defined in

core/visitor/element-adder.ts:307


visitEffectElement

visitEffectElement(element): Promise<boolean>

Adds an effect element to the track. For now, uses the same default duration semantics as other simple elements.

Parameters

NameType
elementEffectElement

Returns

Promise<boolean>

Implementation of

ElementVisitor.visitEffectElement

Defined in

core/visitor/element-adder.ts:325