Open History to see the last commit
1import { createContext } from "react";
2
3// Keep folded text mounted for find; reveal only the selected match.
4export const MarkdownFindContext = createContext(false);
5
6/** Create during render with stable `onReveal`; find dispatches `beforematch` to ancestors. */
7export 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}