'use client' import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { ArrowLeft, Bookmark, Check, ChevronRight, CornerUpRight, FileDown, FileText, Pin, PinOff } from 'lucide-react' import type { NotePage, NoteSummary } from '@/lib/notes-api' import { pageHasFlashcards } from '../model/flashcards' export default function NotePageMenu({ page, pages, invalidParents, busy, onClose, onMetadata, onInsertFavorite, onExport, }: { page: NotePage pages: NoteSummary[] invalidParents: Set busy: boolean onClose: () => void onMetadata: (patch: Partial) => void onInsertFavorite: () => void onExport: (format: 'md' | 'docx' | 'anki') => void }) { const { t } = useTranslation() const [moving, setMoving] = useState(false) const [query, setQuery] = useState('') const menuRef = useRef(null) useEffect(() => { // The parent can open before this on-demand chunk has mounted. menuRef.current?.querySelector('[role="menuitem"]:not(:disabled)')?.focus() }, []) const targets = pages .filter(p => p.id !== page?.id && !invalidParents.has(p.id)) .filter(p => (p.title || '').toLowerCase().includes(query.trim().toLowerCase())) const move = (parent_id: string | null) => { onClose() onMetadata({ parent_id }) } return (
{moving ? ( <> setQuery(e.target.value)} />
{!query.trim() && ( )} {targets.map(target => ( ))} {!targets.length && query.trim() && (

{t('No matching pages')}

)}
) : ( <>
{pageHasFlashcards(page.blocks) && ( )}

{t('Word export keeps text and source links; interactive blocks become static.')}

)}
) }