'use client'; import { useEffect, useRef } from 'react'; import { PlusIcon } from '@heroicons/react/24/outline'; import { useTranslations } from 'next-intl'; import { Button } from '@/components/ui/button'; import NoteModalForm from '@/app/(authenticated)/boards/[id]/notes/components/NoteModalForm'; type QuickNoteProps = { boards: { id: number; title: string }[]; }; export default function QuickNote({ boards }: QuickNoteProps) { const t = useTranslations('NoteModal'); const triggerRef = useRef(null); useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { // e.code: on macOS Option+N yields a dead key, not 'n'. if (!e.altKey || e.code !== 'KeyN') return; const el = e.target; // Don't hijack typing (e.g. Option+N → ñ) inside editable fields. if ( el instanceof HTMLElement && (el.isContentEditable || el.closest('input, textarea, select')) ) return; e.preventDefault(); triggerRef.current?.click(); }; document.addEventListener('keydown', handleKeyDown); return () => document.removeEventListener('keydown', handleKeyDown); }, []); if (boards.length === 0) return null; return ( {t('quickNote')} } /> ); }