Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(editor): clamp captions and hide keyboard segments past trim boundary

Minitd77facd09c07
diff --git a/apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx b/apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx
index c7f67ca76..9743f6217 100644
--- a/apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx
+++ b/apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx
@@ -34,7 +34,11 @@ export function CaptionsTrack(props: {
const minDuration = () =>
Math.max(MIN_SEGMENT_SECS, secsPerPixel() * MIN_SEGMENT_PIXELS);
- const captionSegments = () => project.timeline?.captionSegments ?? [];
+ const captionSegments = createMemo(() =>
+ (project.timeline?.captionSegments ?? []).filter(
+ (s) => s.start < totalDuration(),
+ ),
+ );
const selectedCaptionIndices = createMemo(() => {
const selection = editorState.timeline.selection;
if (!selection || selection.type !== "caption") return null;
@@ -169,7 +173,7 @@ export function CaptionsTrack(props: {
isSelected() ? "border-green-7" : "border-transparent",
)}
innerClass="ring-green-6"
- segment={segment}
+ segment={{ start: segment.start, end: Math.min(segment.end, totalDuration()) }}
onMouseDown={(e) => {
e.stopPropagation();
if (editorState.timeline.interactMode === "split") {
diff --git a/apps/desktop/src/routes/editor/Timeline/KeyboardTrack.tsx b/apps/desktop/src/routes/editor/Timeline/KeyboardTrack.tsx
index 52c3d6feb..b61b02ecc 100644
--- a/apps/desktop/src/routes/editor/Timeline/KeyboardTrack.tsx
+++ b/apps/desktop/src/routes/editor/Timeline/KeyboardTrack.tsx
@@ -32,7 +32,11 @@ export function KeyboardTrack(props: {
const minDuration = () =>
Math.max(MIN_SEGMENT_SECS, secsPerPixel() * MIN_SEGMENT_PIXELS);
- const keyboardSegments = () => project.timeline?.keyboardSegments ?? [];
+ const keyboardSegments = createMemo(() =>
+ (project.timeline?.keyboardSegments ?? []).filter(
+ (s) => s.start < totalDuration(),
+ ),
+ );
const selectedKeyboardIndices = createMemo(() => {
const selection = editorState.timeline.selection;
if (!selection || selection.type !== "keyboard") return null;