* feat: populate macOS menu bar with File, Edit, View, Window menus Add complete native macOS menu structure with all app actions: - Laputa menu: About, Settings (Cmd+,), Hide/Quit - File: New Note (Cmd+N), Quick Open (Cmd+P), Save (Cmd+S), Close Tab (Cmd+W) - Edit: standard Undo/Redo/Cut/Copy/Paste/Select All - View: Editor Only (Cmd+1), Editor+Notes (Cmd+2), All Panels (Cmd+3), Toggle Inspector, Command Palette (Cmd+K) - Window: Minimize, Maximize, Close Window All accelerators registered via Tauri menu API. Menu events dispatched to frontend via useMenuEvents hook. Save/Close Tab items dynamically disabled when no note tab is active. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: wrap Enter selection assertion in waitFor for effect re-registration * fix: resolve rebase conflict markers in menu.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
28 lines
850 B
TypeScript
28 lines
850 B
TypeScript
import { useState, useCallback } from 'react'
|
|
|
|
export type ViewMode = 'editor-only' | 'editor-list' | 'all'
|
|
|
|
const STORAGE_KEY = 'laputa-view-mode'
|
|
|
|
function loadViewMode(): ViewMode {
|
|
try {
|
|
const stored = localStorage.getItem(STORAGE_KEY)
|
|
if (stored === 'editor-only' || stored === 'editor-list' || stored === 'all') return stored
|
|
} catch { /* ignore */ }
|
|
return 'all'
|
|
}
|
|
|
|
export function useViewMode() {
|
|
const [viewMode, setViewModeState] = useState<ViewMode>(loadViewMode)
|
|
|
|
const setViewMode = useCallback((mode: ViewMode) => {
|
|
setViewModeState(mode)
|
|
try { localStorage.setItem(STORAGE_KEY, mode) } catch { /* ignore */ }
|
|
}, [])
|
|
|
|
const sidebarVisible = viewMode === 'all'
|
|
const noteListVisible = viewMode === 'all' || viewMode === 'editor-list'
|
|
|
|
return { viewMode, setViewMode, sidebarVisible, noteListVisible }
|
|
}
|