feature 10,11

This commit is contained in:
2026-04-15 20:57:43 -06:00
parent f121d71f5f
commit 3fa67383c4
5 changed files with 191 additions and 12 deletions

View File

@ -3,6 +3,11 @@ import { useEditorStore } from '../store/editorStore';
export function useKeyboardShortcuts() {
const addCutRange = useEditorStore((s) => s.addCutRange);
const markInTime = useEditorStore((s) => s.markInTime);
const markOutTime = useEditorStore((s) => s.markOutTime);
const setMarkInTime = useEditorStore((s) => s.setMarkInTime);
const setMarkOutTime = useEditorStore((s) => s.setMarkOutTime);
const clearMarkRange = useEditorStore((s) => s.clearMarkRange);
const selectedWordIndices = useEditorStore((s) => s.selectedWordIndices);
const words = useEditorStore((s) => s.words);
@ -38,6 +43,17 @@ export function useKeyboardShortcuts() {
const startTime = words[sorted[0]].start;
const endTime = words[sorted[sorted.length - 1]].end;
addCutRange(startTime, endTime);
return;
}
if (markInTime !== null && markOutTime !== null) {
e.preventDefault();
const start = Math.min(markInTime, markOutTime);
const end = Math.max(markInTime, markOutTime);
if (end - start >= 0.01) {
addCutRange(start, end);
}
clearMarkRange();
}
return;
}
@ -103,17 +119,17 @@ export function useKeyboardShortcuts() {
return;
}
// --- [ mark in-point (home) ---
case e.key === '[': {
// --- I: mark in-point ---
case e.key === 'i' || e.key === 'I': {
e.preventDefault();
if (video) video.currentTime = 0;
if (video) setMarkInTime(video.currentTime);
return;
}
// --- ] mark out-point (end) ---
case e.key === ']': {
// --- O: mark out-point ---
case e.key === 'o' || e.key === 'O': {
e.preventDefault();
if (video) video.currentTime = video.duration;
if (video) setMarkOutTime(video.currentTime);
return;
}
@ -149,7 +165,7 @@ export function useKeyboardShortcuts() {
window.addEventListener('keydown', handler);
return () => window.removeEventListener('keydown', handler);
}, [addCutRange, selectedWordIndices, words]);
}, [addCutRange, markInTime, markOutTime, setMarkInTime, setMarkOutTime, clearMarkRange, selectedWordIndices, words]);
}
async function saveProject() {
@ -210,6 +226,7 @@ function toggleCheatsheet() {
['K', 'Pause'],
['L', 'Forward / Speed up'],
['\u2190 / \u2192', 'Seek \u00b15 seconds'],
['I / O', 'Mark in / out points'],
['Delete', 'Cut selected words'],
['Ctrl+Z', 'Undo'],
['Ctrl+Shift+Z', 'Redo'],