@twick/video-editor 0.14.6 → 0.14.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,6 +55,24 @@ function App() {
55
55
  width: 720,
56
56
  height: 1280,
57
57
  },
58
+ // Optional: Customize timeline tick marks
59
+ timelineTickConfigs: [
60
+ { durationThreshold: 30, majorInterval: 5, minorTicks: 5 },
61
+ { durationThreshold: 300, majorInterval: 30, minorTicks: 6 }
62
+ ],
63
+ // Optional: Customize zoom behavior
64
+ timelineZoomConfig: {
65
+ min: 0.5, max: 2.0, step: 0.25, default: 1.0
66
+ },
67
+ // Optional: Customize element colors
68
+ elementColors: {
69
+ video: "#8B5FBF",
70
+ audio: "#3D8B8B",
71
+ image: "#D4956C",
72
+ text: "#A78EC8",
73
+ caption: "#9B8ACE",
74
+ fragment: "#1A1A1A"
75
+ }
58
76
  }}
59
77
  />
60
78
  </TimelineProvider>
@@ -99,14 +117,140 @@ function App() {
99
117
 
100
118
  - `leftPanel`: Custom left panel component
101
119
  - `rightPanel`: Custom right panel component
120
+ - `bottomPanel`: Custom bottom panel component
102
121
  - `editorConfig`: Editor configuration object
103
- - `videoProps`: Video properties configuration
122
+ - `defaultPlayControls`: Whether to show default playback controls
123
+
124
+ ### Configuration Options
125
+
126
+ #### `editorConfig`
127
+
128
+ ```typescript
129
+ interface VideoEditorConfig {
130
+ videoProps: {
131
+ width: number;
132
+ height: number;
133
+ backgroundColor?: string;
134
+ };
135
+ playerProps?: {
136
+ quality?: number;
137
+ maxWidth?: number;
138
+ maxHeight?: number;
139
+ };
140
+ canvasMode?: boolean;
141
+ timelineTickConfigs?: TimelineTickConfig[];
142
+ timelineZoomConfig?: TimelineZoomConfig;
143
+ elementColors?: ElementColors;
144
+ }
145
+ ```
146
+
147
+ #### Timeline Tick Configuration
148
+
149
+ Customize timeline tick marks for different duration ranges:
150
+
151
+ ```typescript
152
+ interface TimelineTickConfig {
153
+ durationThreshold: number; // Applies when duration < threshold
154
+ majorInterval: number; // Major tick interval in seconds
155
+ minorTicks: number; // Number of minor ticks between majors
156
+ }
157
+ ```
158
+
159
+ **Example:**
160
+ ```tsx
161
+ timelineTickConfigs: [
162
+ { durationThreshold: 30, majorInterval: 5, minorTicks: 5 }, // < 30s
163
+ { durationThreshold: 300, majorInterval: 30, minorTicks: 6 }, // < 5min
164
+ { durationThreshold: 3600, majorInterval: 300, minorTicks: 5 } // < 1hr
165
+ ]
166
+ ```
167
+
168
+ #### Zoom Configuration
169
+
170
+ Customize timeline zoom behavior:
171
+
172
+ ```typescript
173
+ interface TimelineZoomConfig {
174
+ min: number; // Minimum zoom level
175
+ max: number; // Maximum zoom level
176
+ step: number; // Zoom step increment/decrement
177
+ default: number; // Default zoom level
178
+ }
179
+ ```
180
+
181
+ **Example:**
182
+ ```tsx
183
+ timelineZoomConfig: {
184
+ min: 0.5, // 50% minimum zoom
185
+ max: 3.0, // 300% maximum zoom
186
+ step: 0.25, // 25% zoom steps
187
+ default: 1.5 // 150% default zoom
188
+ }
189
+ ```
190
+
191
+ #### Element Colors
192
+
193
+ Customize timeline element colors:
194
+
195
+ ```typescript
196
+ interface ElementColors {
197
+ video: string;
198
+ audio: string;
199
+ image: string;
200
+ text: string;
201
+ caption: string;
202
+ fragment: string;
203
+ }
204
+ ```
205
+
206
+ **Example:**
207
+ ```tsx
208
+ elementColors: {
209
+ video: "#8B5FBF",
210
+ audio: "#3D8B8B",
211
+ image: "#D4956C",
212
+ text: "#A78EC8",
213
+ caption: "#9B8ACE",
214
+ fragment: "#1A1A1A"
215
+ }
216
+ ```
217
+
218
+ ### Default Constants
219
+
220
+ The package exports default configurations that can be used or customized:
221
+
222
+ ```tsx
223
+ import {
224
+ DEFAULT_TIMELINE_TICK_CONFIGS,
225
+ DEFAULT_TIMELINE_ZOOM_CONFIG,
226
+ DEFAULT_ELEMENT_COLORS
227
+ } from '@twick/video-editor';
228
+
229
+ // Use defaults
230
+ <VideoEditor
231
+ editorConfig={{
232
+ videoProps: { width: 1920, height: 1080 },
233
+ timelineTickConfigs: DEFAULT_TIMELINE_TICK_CONFIGS,
234
+ timelineZoomConfig: DEFAULT_TIMELINE_ZOOM_CONFIG,
235
+ elementColors: DEFAULT_ELEMENT_COLORS
236
+ }}
237
+ />
238
+
239
+ // Or customize based on defaults
240
+ const customColors = {
241
+ ...DEFAULT_ELEMENT_COLORS,
242
+ video: "#FF0000", // Custom red for video
243
+ audio: "#00FF00" // Custom green for audio
244
+ };
245
+ ```
104
246
 
105
247
  ### Types
106
248
 
107
249
  - `VideoEditorProps`: Props interface for VideoEditor
108
- - `EditorConfig`: Editor configuration interface
109
- - `VideoProps`: Video properties interface
250
+ - `VideoEditorConfig`: Editor configuration interface
251
+ - `TimelineTickConfig`: Timeline tick configuration interface
252
+ - `TimelineZoomConfig`: Zoom configuration interface
253
+ - `ElementColors`: Element colors interface
110
254
 
111
255
  For complete API documentation, refer to the generated documentation.
112
256
 
@@ -1,5 +1,8 @@
1
- declare const ControlManager: ({ trackZoom, setTrackZoom, }: {
1
+ import { TimelineZoomConfig } from '../video-editor';
2
+
3
+ declare const ControlManager: ({ trackZoom, setTrackZoom, zoomConfig, }: {
2
4
  trackZoom: number;
3
5
  setTrackZoom: (zoom: number) => void;
6
+ zoomConfig: TimelineZoomConfig;
4
7
  }) => import("react/jsx-runtime").JSX.Element;
5
8
  export default ControlManager;
@@ -1,6 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { PLAYER_STATE } from '@twick/live-player';
3
3
  import { TrackElement, Track } from '@twick/timeline';
4
+ import { TimelineZoomConfig } from '../video-editor';
4
5
 
5
6
  /**
6
7
  * Props for the PlayerControls component.
@@ -54,6 +55,8 @@ export interface PlayerControlsProps {
54
55
  setZoomLevel?: (zoom: number) => void;
55
56
  /** Optional CSS class name for styling */
56
57
  className?: string;
58
+ /** Timeline zoom configuration (min, max, step, default) */
59
+ zoomConfig?: TimelineZoomConfig;
57
60
  }
58
61
  declare const PlayerControls: React.FC<PlayerControlsProps>;
59
62
  export default PlayerControls;
@@ -1,7 +1,10 @@
1
- declare const SeekControl: ({ duration, zoom, timelineCount, onSeek, }: {
1
+ import { TimelineTickConfig } from '../video-editor';
2
+
3
+ declare const SeekControl: ({ duration, zoom, timelineCount, onSeek, timelineTickConfigs, }: {
2
4
  duration: number;
3
5
  zoom: number;
4
6
  timelineCount: number;
5
7
  onSeek: (time: number) => void;
8
+ timelineTickConfigs?: TimelineTickConfig[];
6
9
  }) => import("react/jsx-runtime").JSX.Element;
7
10
  export default SeekControl;
@@ -1,4 +1,25 @@
1
1
 
2
+ /**
3
+ * PlayerManager component that manages video playback and canvas rendering.
4
+ * Integrates the live player with canvas operations, handling both video playback
5
+ * and static canvas display modes. Automatically updates canvas when paused and
6
+ * manages player state transitions.
7
+ *
8
+ * @param props - Component configuration props
9
+ * @param props.videoProps - Video dimensions and background color
10
+ * @param props.playerProps - Optional player quality settings
11
+ * @param props.canvasMode - Whether to show canvas overlay when paused
12
+ * @returns JSX element containing player and canvas components
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * <PlayerManager
17
+ * videoProps={{ width: 1920, height: 1080, backgroundColor: '#000' }}
18
+ * playerProps={{ quality: 720 }}
19
+ * canvasMode={true}
20
+ * />
21
+ * ```
22
+ */
2
23
  export declare const PlayerManager: ({ videoProps, playerProps, canvasMode, }: {
3
24
  videoProps: {
4
25
  width: number;
@@ -1,4 +1,9 @@
1
- declare const TimelineManager: ({ trackZoom, }: {
1
+ import { TimelineTickConfig } from '../video-editor';
2
+ import { ElementColors } from '../../helpers/types';
3
+
4
+ declare const TimelineManager: ({ trackZoom, timelineTickConfigs, elementColors, }: {
2
5
  trackZoom: number;
6
+ timelineTickConfigs?: TimelineTickConfig[];
7
+ elementColors?: ElementColors;
3
8
  }) => import("react/jsx-runtime").JSX.Element;
4
9
  export default TimelineManager;
@@ -1,6 +1,7 @@
1
1
  import { Track, TrackElement } from '@twick/timeline';
2
+ import { ElementColors } from '../../helpers/types';
2
3
 
3
- declare function TimelineView({ zoomLevel, selectedItem, duration, tracks, seekTrack, onAddTrack, onReorder, onSelectionChange, onElementDrag, }: {
4
+ declare function TimelineView({ zoomLevel, selectedItem, duration, tracks, seekTrack, onAddTrack, onReorder, onSelectionChange, onElementDrag, elementColors, }: {
4
5
  zoomLevel: number;
5
6
  duration: number;
6
7
  tracks: Track[];
@@ -19,5 +20,6 @@ declare function TimelineView({ zoomLevel, selectedItem, duration, tracks, seekT
19
20
  onSeek: (time: number) => void;
20
21
  onSelectionChange: (element: TrackElement | Track) => void;
21
22
  onDeletion: (element: TrackElement | Track) => void;
23
+ elementColors?: ElementColors;
22
24
  }): import("react/jsx-runtime").JSX.Element;
23
25
  export default TimelineView;
@@ -1,3 +1,4 @@
1
+ import { TimelineTickConfig } from '../video-editor';
1
2
 
2
3
  interface SeekTrackProps {
3
4
  currentTime: number;
@@ -5,6 +6,7 @@ interface SeekTrackProps {
5
6
  zoom?: number;
6
7
  onSeek: (time: number) => void;
7
8
  timelineCount?: number;
9
+ timelineTickConfigs?: TimelineTickConfig[];
8
10
  }
9
- export default function SeekTrack({ currentTime, duration, zoom, onSeek, timelineCount, }: SeekTrackProps): import("react/jsx-runtime").JSX.Element;
11
+ export default function SeekTrack({ currentTime, duration, zoom, onSeek, timelineCount, timelineTickConfigs, }: SeekTrackProps): import("react/jsx-runtime").JSX.Element;
10
12
  export {};
@@ -1,4 +1,5 @@
1
1
  import { Track, TrackElement } from '@twick/timeline';
2
+ import { ElementColors } from '../../helpers/types';
2
3
 
3
4
  interface TrackBaseProps {
4
5
  duration: number;
@@ -16,6 +17,7 @@ interface TrackBaseProps {
16
17
  end: number;
17
18
  };
18
19
  }) => void;
20
+ elementColors?: ElementColors;
19
21
  }
20
- declare const TrackBase: ({ duration, zoom, track, trackWidth, selectedItem, onItemSelection, onDrag, allowOverlap, }: TrackBaseProps) => import("react/jsx-runtime").JSX.Element;
22
+ declare const TrackBase: ({ duration, zoom, track, trackWidth, selectedItem, onItemSelection, onDrag, allowOverlap, elementColors, }: TrackBaseProps) => import("react/jsx-runtime").JSX.Element;
21
23
  export default TrackBase;
@@ -1,4 +1,5 @@
1
1
  import { TrackElement } from '@twick/timeline';
2
+ import { ElementColors } from '../../helpers/types';
2
3
 
3
4
  export declare const TrackElementView: React.FC<{
4
5
  element: TrackElement;
@@ -17,5 +18,6 @@ export declare const TrackElementView: React.FC<{
17
18
  end: number;
18
19
  };
19
20
  }) => void;
21
+ elementColors?: ElementColors;
20
22
  }>;
21
23
  export default TrackElementView;
@@ -1,5 +1,51 @@
1
1
  import { default as React } from 'react';
2
+ import { ElementColors } from '../helpers/types';
2
3
 
4
+ /**
5
+ * Configuration for timeline tick marks at specific duration ranges.
6
+ * Defines major tick interval and number of minor ticks between majors.
7
+ *
8
+ * @example
9
+ * ```js
10
+ * const tickConfig = {
11
+ * durationThreshold: 300, // applies when video < 5 minutes
12
+ * majorInterval: 30, // major tick every 30 seconds
13
+ * minorTicks: 6 // 6 minor ticks between majors (every 5 seconds)
14
+ * };
15
+ * ```
16
+ */
17
+ export interface TimelineTickConfig {
18
+ /** Duration threshold in seconds - this config applies when duration < threshold */
19
+ durationThreshold: number;
20
+ /** Major tick interval in seconds */
21
+ majorInterval: number;
22
+ /** Number of minor ticks between major ticks */
23
+ minorTicks: number;
24
+ }
25
+ /**
26
+ * Configuration for timeline zoom behavior.
27
+ * Defines the minimum, maximum, step, and default zoom levels.
28
+ *
29
+ * @example
30
+ * ```js
31
+ * const zoomConfig = {
32
+ * min: 0.5, // 50% minimum zoom
33
+ * max: 2.0, // 200% maximum zoom
34
+ * step: 0.25, // 25% zoom steps
35
+ * default: 1.0 // 100% default zoom
36
+ * };
37
+ * ```
38
+ */
39
+ export interface TimelineZoomConfig {
40
+ /** Minimum zoom level */
41
+ min: number;
42
+ /** Maximum zoom level */
43
+ max: number;
44
+ /** Zoom step increment/decrement */
45
+ step: number;
46
+ /** Default zoom level */
47
+ default: number;
48
+ }
3
49
  /**
4
50
  * Configuration options for the video editor.
5
51
  * Defines the video properties and editor behavior settings.
@@ -8,7 +54,19 @@ import { default as React } from 'react';
8
54
  * ```js
9
55
  * const editorConfig = {
10
56
  * videoProps: { width: 1920, height: 1080 },
11
- * canvasMode: true
57
+ * canvasMode: true,
58
+ * timelineTickConfigs: [
59
+ * { durationThreshold: 30, majorInterval: 5, minorTicks: 5 },
60
+ * { durationThreshold: 300, majorInterval: 30, minorTicks: 6 }
61
+ * ],
62
+ * timelineZoomConfig: {
63
+ * min: 0.5, max: 2.0, step: 0.25, default: 1.0
64
+ * },
65
+ * elementColors: {
66
+ * video: "#8B5FBF",
67
+ * audio: "#3D8B8B",
68
+ * // ... other element colors
69
+ * }
12
70
  * };
13
71
  * ```
14
72
  */
@@ -29,6 +87,12 @@ export interface VideoEditorConfig {
29
87
  };
30
88
  /** Whether to use canvas mode for rendering */
31
89
  canvasMode?: boolean;
90
+ /** Custom timeline tick configurations for different duration ranges */
91
+ timelineTickConfigs?: TimelineTickConfig[];
92
+ /** Custom timeline zoom configuration (min, max, step, default) */
93
+ timelineZoomConfig?: TimelineZoomConfig;
94
+ /** Custom element colors for timeline elements */
95
+ elementColors?: ElementColors;
32
96
  }
33
97
  /**
34
98
  * Props for the VideoEditor component.
@@ -1,4 +1,5 @@
1
1
  import { ElementColors } from './types';
2
+ import { TimelineTickConfig } from '../components/video-editor';
2
3
 
3
4
  /**
4
5
  * Initial timeline data structure for new video editor projects.
@@ -92,6 +93,55 @@ export declare const DRAG_TYPE: {
92
93
  * ```
93
94
  */
94
95
  export declare const DEFAULT_TIMELINE_ZOOM = 1.5;
96
+ /**
97
+ * Default timeline zoom configuration including min, max, step, and default values.
98
+ * Controls the zoom behavior and constraints for the timeline view.
99
+ *
100
+ * @example
101
+ * ```js
102
+ * import { DEFAULT_TIMELINE_ZOOM_CONFIG } from '@twick/video-editor';
103
+ *
104
+ * // Use default zoom configuration
105
+ * <VideoEditor
106
+ * editorConfig={{
107
+ * videoProps: { width: 1920, height: 1080 },
108
+ * timelineZoomConfig: DEFAULT_TIMELINE_ZOOM_CONFIG
109
+ * }}
110
+ * />
111
+ * ```
112
+ */
113
+ export declare const DEFAULT_TIMELINE_ZOOM_CONFIG: {
114
+ /** Minimum zoom level (10%) */
115
+ min: number;
116
+ /** Maximum zoom level (300%) */
117
+ max: number;
118
+ /** Zoom step increment/decrement (10%) */
119
+ step: number;
120
+ /** Default zoom level (150%) */
121
+ default: number;
122
+ };
123
+ /**
124
+ * Default timeline tick configurations for different duration ranges.
125
+ * Defines major tick intervals and number of minor ticks between majors
126
+ * to provide optimal timeline readability at various durations.
127
+ *
128
+ * Each configuration applies when the duration is less than the specified threshold.
129
+ * Configurations are ordered by duration threshold ascending.
130
+ *
131
+ * @example
132
+ * ```js
133
+ * import { DEFAULT_TIMELINE_TICK_CONFIGS } from '@twick/video-editor';
134
+ *
135
+ * // Use default configurations
136
+ * <VideoEditor
137
+ * editorConfig={{
138
+ * videoProps: { width: 1920, height: 1080 },
139
+ * timelineTickConfigs: DEFAULT_TIMELINE_TICK_CONFIGS
140
+ * }}
141
+ * />
142
+ * ```
143
+ */
144
+ export declare const DEFAULT_TIMELINE_TICK_CONFIGS: TimelineTickConfig[];
95
145
  /**
96
146
  * Default color scheme for different element types in the timeline.
97
147
  * Provides consistent visual distinction between various timeline elements.
@@ -0,0 +1,27 @@
1
+ import { TrackElement } from '@twick/timeline';
2
+
3
+ /**
4
+ * Custom hook for managing video editor operations.
5
+ * Provides functionality to add and update timeline elements with automatic
6
+ * collision detection and error handling. Integrates with live player context
7
+ * to position elements at the current playback time.
8
+ *
9
+ * @returns Object containing editor management functions
10
+ * @property {Function} addElement - Add a new element to the timeline
11
+ * @property {Function} updateElement - Update an existing timeline element
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const { addElement, updateElement } = useEditorManager();
16
+ *
17
+ * // Add a new element at current playback time
18
+ * await addElement(newElement);
19
+ *
20
+ * // Update an existing element
21
+ * updateElement(modifiedElement);
22
+ * ```
23
+ */
24
+ export declare const useEditorManager: () => {
25
+ addElement: (element: TrackElement) => Promise<void>;
26
+ updateElement: (element: TrackElement) => void;
27
+ };
@@ -32,6 +32,6 @@ export declare const useTimelineManager: () => {
32
32
  onReorder: (reorderedItems: Track[]) => void;
33
33
  onSeek: (time: number) => void;
34
34
  onSelectionChange: (selectedItem: TrackElement | Track | null) => void;
35
- selectedItem: TrackElement | Track | null;
35
+ selectedItem: Track | TrackElement | null;
36
36
  totalDuration: number;
37
37
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { default as VideoEditor, VideoEditorProps, VideoEditorConfig } from './components/video-editor';
1
+ import { default as VideoEditor, VideoEditorProps, VideoEditorConfig, TimelineTickConfig, TimelineZoomConfig } from './components/video-editor';
2
2
  import { default as PlayerControls, PlayerControlsProps } from './components/controls/player-controls';
3
3
  import { default as TimelineManager } from './components/timeline/timeline-manager';
4
4
  import { usePlayerControl } from './hooks/use-player-control';
5
+ import { useEditorManager } from './hooks/use-editor-manager';
5
6
  import { default as BrowserMediaManager } from './helpers/media-manager/browser-media-manager';
6
7
  import { MediaItem, PaginationOptions, SearchOptions, Animation, TextEffect, ElementColors } from './helpers/types';
7
8
  import { default as BaseMediaManager } from './helpers/media-manager/base-media-manager';
@@ -13,8 +14,8 @@ import { setElementColors } from './helpers/editor.utils';
13
14
 
14
15
  export { setElementColors };
15
16
  export type { MediaItem, PaginationOptions, SearchOptions, Animation, TextEffect, ElementColors };
16
- export type { PlayerControlsProps, VideoEditorProps, VideoEditorConfig };
17
+ export type { PlayerControlsProps, VideoEditorProps, VideoEditorConfig, TimelineTickConfig, TimelineZoomConfig };
17
18
  export { ANIMATIONS, TEXT_EFFECTS };
18
- export { usePlayerControl, BrowserMediaManager, BaseMediaManager, animationGifs, getAnimationGif, PlayerControls, TimelineManager, useTimelineControl };
19
+ export { usePlayerControl, useEditorManager, BrowserMediaManager, BaseMediaManager, animationGifs, getAnimationGif, PlayerControls, TimelineManager, useTimelineControl };
19
20
  export * from './helpers/constants';
20
21
  export default VideoEditor;