import { useEffect } from "react"; /** Tag names whose descendants can receive free-form text input. */ const INPUT_TAGS = new Set(["INPUT", "TEXTAREA", "SELECT"]); /** * Returns true when the keyboard event originated inside a free-form * text field, in which case we should NOT consume j/k/escape/`?` — * the user is typing, not navigating the drawer. * * - `INPUT` / `TEXTAREA` / `SELECT` are the obvious cases. * - `contenteditable` elements (e.g. rich text editors) are the * non-obvious one: `target.isContentEditable` is the standard check. */ function isEditableTarget(target: EventTarget | null): boolean { if (!(target instanceof HTMLElement)) return false; if (INPUT_TAGS.has(target.tagName)) return true; return target.isContentEditable; } /** * Wires the spec-driven drawer keyboard shortcuts to the drawer's * callbacks. When `enabled` is true, listens for `keydown` on `window` * and dispatches: * * j / ArrowDown → onNext * k / ArrowUp → onPrev * Escape → onClose * ? → onToggleHelp * * Keys are ignored when an ``, `