import { ChopinMark } from "./agent-mark"; import { Face } from "@chopin/editor"; import { useEffect } from "react"; import { referenceOptionId } from "./reference-picker"; import type { MentionCandidate } from "./mentions"; /** At most this many rows show before the list scrolls: 8 × 2rem plus the 0.25rem padding. */ const LIST_HEIGHT = "16.5rem"; export function MentionPicker( { active, id, onActive, onSelect, options, }: { active: number; id: string; onActive: (index: number) => void; onSelect: (candidate: MentionCandidate) => void; options: readonly MentionCandidate[]; }, ) { useEffect(() => { let frame = requestAnimationFrame(() => { document.getElementById(referenceOptionId(id, active))?.scrollIntoView({ block: "nearest" }); }); return () => cancelAnimationFrame(frame); }, [active, id]); return (