feat(timeline): ripple delete on Del, extract/lift on Shift+Del

This commit is contained in:
Zac Gaetano 2026-05-19 23:45:41 -04:00
parent a5823effe9
commit 89771a2380

View file

@ -430,10 +430,33 @@
if (e.key === 'h' || e.key === 'H') { setTool('hand'); return; }
}
// Delete selected clip
// Delete / ripple-delete selected clip
if ((e.key === 'Delete' || e.key === 'Backspace') && s.selectedId) {
e.preventDefault();
s.clips = s.clips.filter(function (c) { return c._id !== s.selectedId; });
var clip = s.clips.find(function (c) { return c._id === s.selectedId; });
if (!clip) return;
if (e.shiftKey) {
// Shift+Delete: extract / lift — remove clip and leave the gap
s.clips = s.clips.filter(function (c) { return c._id !== s.selectedId; });
} else {
// Delete: ripple — close the gap by shifting later clips on the same track
var clipDur = clip.timeline_out_frames - clip.timeline_in_frames;
var cutPoint = clip.timeline_in_frames;
var trackId = clip.track;
s.clips = s.clips
.filter(function (c) { return c._id !== s.selectedId; })
.map(function (c) {
if (c.track === trackId && c.timeline_in_frames >= cutPoint) {
return Object.assign({}, c, {
timeline_in_frames: c.timeline_in_frames - clipDur,
timeline_out_frames: c.timeline_out_frames - clipDur,
});
}
return c;
});
}
s.selectedId = null;
_renderClips();
if (s.onClipsChanged) s.onClipsChanged(s.clips.slice());