summaryrefslogtreecommitdiff
path: root/apps/web/src/components/editor/timeline/timeline-toolbar.tsx
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2025-09-02 23:07:11 +0200
committerMaze Winther <mazewinther@gmail.com>2025-09-02 23:07:11 +0200
commit167e2b83dc072f5d80ab0bf0d3f786a993248c70 (patch)
tree95230791811fb0e89f70f8773e4d7c7aa934300b /apps/web/src/components/editor/timeline/timeline-toolbar.tsx
parentc5c32a1e34d8ddeb586a99139ab97327c5c8b465 (diff)
downloadopencut-167e2b83dc072f5d80ab0bf0d3f786a993248c70.tar.gz
feat: add support for deleting/splitting multiple elements instead of single
Diffstat (limited to 'apps/web/src/components/editor/timeline/timeline-toolbar.tsx')
-rw-r--r--apps/web/src/components/editor/timeline/timeline-toolbar.tsx35
1 files changed, 4 insertions, 31 deletions
diff --git a/apps/web/src/components/editor/timeline/timeline-toolbar.tsx b/apps/web/src/components/editor/timeline/timeline-toolbar.tsx
index bec4458c..80c6ce08 100644
--- a/apps/web/src/components/editor/timeline/timeline-toolbar.tsx
+++ b/apps/web/src/components/editor/timeline/timeline-toolbar.tsx
@@ -52,11 +52,10 @@ export function TimelineToolbar({
tracks,
addTrack,
addElementToTrack,
- removeElementFromTrack,
- removeElementFromTrackWithRipple,
selectedElements,
clearSelectedElements,
- splitElement,
+ deleteSelected,
+ splitSelected,
splitAndKeepLeft,
splitAndKeepRight,
separateAudio,
@@ -70,25 +69,7 @@ export function TimelineToolbar({
const { scenes, currentScene } = useSceneStore();
const handleSplitSelected = () => {
- if (selectedElements.length === 0) return;
- let splitCount = 0;
- selectedElements.forEach(({ trackId, elementId }) => {
- const track = tracks.find((t) => t.id === trackId);
- const element = track?.elements.find((c) => c.id === elementId);
- if (element && track) {
- const effectiveStart = element.startTime;
- const effectiveEnd =
- element.startTime +
- (element.duration - element.trimStart - element.trimEnd);
- if (currentTime > effectiveStart && currentTime < effectiveEnd) {
- const newElementId = splitElement(trackId, elementId, currentTime);
- if (newElementId) splitCount++;
- }
- }
- });
- if (splitCount === 0) {
- toast.error("Playhead must be within selected elements to split");
- }
+ splitSelected(currentTime);
};
const handleDuplicateSelected = () => {
@@ -173,15 +154,7 @@ export function TimelineToolbar({
};
const handleDeleteSelected = () => {
- if (selectedElements.length === 0) return;
- selectedElements.forEach(({ trackId, elementId }) => {
- if (rippleEditingEnabled) {
- removeElementFromTrackWithRipple(trackId, elementId);
- } else {
- removeElementFromTrack(trackId, elementId);
- }
- });
- clearSelectedElements();
+ deleteSelected();
};
const handleZoomIn = () => {