Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop): limit transcript video cuts to plain Shift+Delete

Richie McIlroy6f0a133e6f73
diff --git a/apps/desktop/src/routes/editor/transcript-edits.test.ts b/apps/desktop/src/routes/editor/transcript-edits.test.ts
index 131c09de6..3aac60cac 100644
--- a/apps/desktop/src/routes/editor/transcript-edits.test.ts
+++ b/apps/desktop/src/routes/editor/transcript-edits.test.ts
@@ -168,7 +168,18 @@ describe("transcript seeking", () => {
});
describe("transcript keyboard actions", () => {
- const key = (key: string, shiftKey = false) => ({ key, shiftKey });
+ const key = (
+ key: string,
+ shiftKey = false,
+ modifiers: { ctrlKey?: boolean; metaKey?: boolean; altKey?: boolean } = {},
+ ) => ({
+ key,
+ shiftKey,
+ ctrlKey: false,
+ metaKey: false,
+ altKey: false,
+ ...modifiers,
+ });
it("offers caption deletion and video cuts from the keyboard", () => {
for (const name of ["Backspace", "Delete"]) {
@@ -178,6 +189,19 @@ describe("transcript keyboard actions", () => {
}
});
+ it("only cuts video for Shift without other modifiers", () => {
+ for (const name of ["Backspace", "Delete"]) {
+ for (const modifier of ["ctrlKey", "metaKey", "altKey"] as const) {
+ expect(
+ transcriptKeyAction(key(name, true, { [modifier]: true }), 1, true),
+ ).toBe("delete");
+ expect(
+ transcriptKeyAction(key(name, false, { [modifier]: true }), 1, true),
+ ).toBe("delete");
+ }
+ }
+ });
+
it("leaves Enter to focused word action buttons", () => {
expect(transcriptKeyAction(key("Enter"), 1, true)).toBe("edit");
expect(transcriptKeyAction(key("Enter"), 1, false)).toBeNull();
diff --git a/apps/desktop/src/routes/editor/transcript-edits.ts b/apps/desktop/src/routes/editor/transcript-edits.ts
index b100aeab1..f1f8e3d67 100644
--- a/apps/desktop/src/routes/editor/transcript-edits.ts
+++ b/apps/desktop/src/routes/editor/transcript-edits.ts
@@ -148,7 +148,10 @@ export type TranscriptKeyAction =
| "next";
export function transcriptKeyAction(
- event: Pick<KeyboardEvent, "key" | "shiftKey">,
+ event: Pick<
+ KeyboardEvent,
+ "key" | "shiftKey" | "ctrlKey" | "metaKey" | "altKey"
+ >,
selectedCount: number,
fromContainer: boolean,
): TranscriptKeyAction | null {
@@ -158,7 +161,9 @@ export function transcriptKeyAction(
return fromContainer && selectedCount === 1 ? "edit" : null;
case "Backspace":
case "Delete":
- return event.shiftKey ? "cut" : "delete";
+ return event.shiftKey && !event.ctrlKey && !event.metaKey && !event.altKey
+ ? "cut"
+ : "delete";
case "ArrowLeft":
return "previous";
case "ArrowRight":