diff options
Diffstat (limited to 'apps/web/src/stores')
| -rw-r--r-- | apps/web/src/stores/keybindings-store.ts | 15 | ||||
| -rw-r--r-- | apps/web/src/stores/timeline-store.ts | 58 |
2 files changed, 38 insertions, 35 deletions
diff --git a/apps/web/src/stores/keybindings-store.ts b/apps/web/src/stores/keybindings-store.ts index f36f2632..3e525b86 100644 --- a/apps/web/src/stores/keybindings-store.ts +++ b/apps/web/src/stores/keybindings-store.ts @@ -25,10 +25,6 @@ export const defaultKeybindings: KeybindingConfig = { "ctrl+z": "undo", "ctrl+shift+z": "redo", "ctrl+y": "redo", - "ctrl+=": "zoom-in", - "ctrl+-": "zoom-out", - "ctrl+0": "zoom-reset", - "ctrl+9": "zoom-fit", delete: "delete-selected", backspace: "delete-selected", }; @@ -199,6 +195,7 @@ function generateKeybindingString(ev: KeyboardEvent): ShortcutKey | null { function getPressedKey(ev: KeyboardEvent): string | null { // Sometimes the property code is not available on the KeyboardEvent object const key = (ev.key ?? "").toLowerCase(); + const code = ev.code ?? ""; // Check arrow keys if (key.startsWith("arrow")) { @@ -217,7 +214,15 @@ function getPressedKey(ev: KeyboardEvent): string | null { const isLetter = key.length === 1 && key >= "a" && key <= "z"; if (isLetter) return key; - // Check if number keys + // Check number keys using physical position for AZERTY support + if (code.startsWith("Digit")) { + const digit = code.slice(5); + if (digit.length === 1 && digit >= "0" && digit <= "9") { + return digit; + } + } + + // Fallback for other layouts const isDigit = key.length === 1 && key >= "0" && key <= "9"; if (isDigit) return key; diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts index f21a4d57..01ad1635 100644 --- a/apps/web/src/stores/timeline-store.ts +++ b/apps/web/src/stores/timeline-store.ts @@ -106,17 +106,20 @@ interface TimelineStore { trackId: string, elementId: string, trimStart: number, - trimEnd: number + trimEnd: number, + pushHistory?: boolean ) => void; updateElementDuration: ( trackId: string, elementId: string, - duration: number + duration: number, + pushHistory?: boolean ) => void; updateElementStartTime: ( trackId: string, elementId: string, - startTime: number + startTime: number, + pushHistory?: boolean ) => void; toggleTrackMute: (trackId: string) => void; @@ -158,8 +161,6 @@ interface TimelineStore { // Computed values getTotalDuration: () => number; - getContentWidth: (zoomLevel: number) => number; - calculateFitToWindowZoom: (containerWidth: number) => number; // History actions undo: () => void; @@ -689,8 +690,14 @@ export const useTimelineStore = create<TimelineStore>((set, get) => { updateTracksAndSave(newTracks); }, - updateElementTrim: (trackId, elementId, trimStart, trimEnd) => { - get().pushHistory(); + updateElementTrim: ( + trackId, + elementId, + trimStart, + trimEnd, + pushHistory = true + ) => { + if (pushHistory) get().pushHistory(); updateTracksAndSave( get()._tracks.map((track) => track.id === trackId @@ -707,8 +714,13 @@ export const useTimelineStore = create<TimelineStore>((set, get) => { ); }, - updateElementDuration: (trackId, elementId, duration) => { - get().pushHistory(); + updateElementDuration: ( + trackId, + elementId, + duration, + pushHistory = true + ) => { + if (pushHistory) get().pushHistory(); updateTracksAndSave( get()._tracks.map((track) => track.id === trackId @@ -723,8 +735,13 @@ export const useTimelineStore = create<TimelineStore>((set, get) => { ); }, - updateElementStartTime: (trackId, elementId, startTime) => { - get().pushHistory(); + updateElementStartTime: ( + trackId, + elementId, + startTime, + pushHistory = true + ) => { + if (pushHistory) get().pushHistory(); updateTracksAndSave( get()._tracks.map((track) => track.id === trackId @@ -1159,25 +1176,6 @@ export const useTimelineStore = create<TimelineStore>((set, get) => { return Math.max(...trackEndTimes, 0); }, - getContentWidth: (zoomLevel: number) => { - const totalDuration = get().getTotalDuration(); - return totalDuration * TIMELINE_CONSTANTS.PIXELS_PER_SECOND * zoomLevel; - }, - - calculateFitToWindowZoom: (containerWidth: number) => { - const totalDuration = get().getTotalDuration(); - if (totalDuration === 0) return 1; - - // Leave some padding (10% on each side) - const CONTAINER_PADDING_FACTOR = 0.8; - const availableWidth = containerWidth * CONTAINER_PADDING_FACTOR; - const requiredWidth = totalDuration * TIMELINE_CONSTANTS.PIXELS_PER_SECOND; - const calculatedZoom = availableWidth / requiredWidth; - - // Clamp between min and max zoom levels - return Math.max(TIMELINE_CONSTANTS.MIN_ZOOM, Math.min(TIMELINE_CONSTANTS.MAX_ZOOM, calculatedZoom)); - }, - redo: () => { const { redoStack } = get(); if (redoStack.length === 0) return; |
