Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ModelSelector, {
} from "./ModelSelector";
import ImportTranscriptOption from "./ImportTranscriptOption";
import { MODEL_ORDER } from "@/lib/models";
import { isTypingTarget } from "@/lib/keyboard";

/** How long the desktop mode-change overlay stays up. Matches the macOS
* `setBounds(..., animate)` duration plus a small buffer so the layout
Expand Down Expand Up @@ -254,9 +255,7 @@ export default function Editor() {
// (which would double-toggle playback and look like the hotkey "didn't work").
useEffect(() => {
const handler = (e: KeyboardEvent) => {
const target = e.target as HTMLElement;
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)
return;
if (isTypingTarget(e.target)) return;
const s = useEditorStore.getState();
if (e.code === "Space" && s.videoEl && !s.exportOpen) {
e.preventDefault();
Expand Down
9 changes: 3 additions & 6 deletions components/TranscriptPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { useTranscriptPlayheadFollow } from "@/hooks/useTranscriptPlayheadFollow
import { useWordAnchorFloating } from "@/hooks/useWordAnchorFloating";
import { useCutRanges } from "@/hooks/useCutRanges";
import { findActiveWordId, groupWordsBySpeaker } from "@/lib/transcript";
import { isTypingTarget } from "@/lib/keyboard";

const WordSpan = memo(function WordSpan({
word,
Expand Down Expand Up @@ -306,9 +307,7 @@ export default function TranscriptPanel() {
useEffect(() => {
const handler = (e: KeyboardEvent) => {
if (e.key !== "Escape") return;
const target = e.target as HTMLElement;
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)
return;
if (isTypingTarget(e.target)) return;
if (selectedWordIds.length === 0) return;
e.preventDefault();
clearSelection();
Expand All @@ -321,9 +320,7 @@ export default function TranscriptPanel() {
useEffect(() => {
const handler = (e: KeyboardEvent) => {
if (e.key !== "@" || e.metaKey || e.ctrlKey || e.altKey) return;
const target = e.target as HTMLElement;
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)
return;
if (isTypingTarget(e.target)) return;
if (!selection || assigningSpeaker || correcting) return;
e.preventDefault();
openSpeakerAssign();
Expand Down
14 changes: 14 additions & 0 deletions lib/keyboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* True when a keystroke belongs to a text field rather than the global
* shortcuts. File inputs are excluded on purpose: the desktop File › Open
* Project… menu and the transcript Import label both click a hidden
* `<input type="file">`, which keeps focus after the picker closes — treating
* that as "typing" silently killed the spacebar play/pause hotkey.
*/
export function isTypingTarget(target: EventTarget | null): boolean {
const el = target as HTMLElement | null;
if (!el) return false;
if (el.isContentEditable) return true;
if (el.tagName === "TEXTAREA") return true;
return el.tagName === "INPUT" && (el as HTMLInputElement).type !== "file";
}
Loading