The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { createContext } from "react"; |
| 2 | |
| 3 | // Keep folded text mounted for find; reveal only the selected match. |
| 4 | export const MarkdownFindContext = createContext(false); |
| 5 | |
| 6 | /** Create during render with stable `onReveal`; find dispatches `beforematch` to ancestors. */ |
| 7 | export function findRevealRef(onReveal: () => void) { |
| 8 | return (element: HTMLElement | null) => { |
| 9 | if (!element) return; |
| 10 | element.addEventListener("beforematch", onReveal); |
| 11 | return () => element.removeEventListener("beforematch", onReveal); |
| 12 | }; |
| 13 | } |