{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "documentation-provider", "title": "Documentation Provider", "description": "Info icon trigger with a right drawer that renders API content as GitHub-flavored markdown (images, tables, fenced code) and safe HTML (e.g. video).", "dependencies": [ "@radix-ui/react-dialog", "lucide-react", "react-markdown", "remark-gfm", "rehype-raw", "rehype-sanitize" ], "files": [ { "path": "registry/components/documentation-provider.tsx", "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Info, X } from \"lucide-react\"\n\nimport { DocumentationMarkdown } from \"./documentation-provider/markdown\"\nimport { useDocumentation } from \"./documentation-provider/use-documentation\"\n\ntype DocumentationProviderProps = {\n productKey?: string\n placementKey?: string\n endpoint?: string\n hoverText?: string\n}\n\nfunction DocumentationProvider({\n productKey = \"lms\",\n placementKey = \"test-media\",\n endpoint = \"https://drive.masaischool.com/api/document\",\n hoverText,\n}: DocumentationProviderProps) {\n const [open, setOpen] = React.useState(false)\n const hoverTextId = React.useId()\n const panelWidthPx = 420\n const { data, isLoading, error } = useDocumentation({\n productKey,\n placementKey,\n endpoint,\n enabled: open,\n })\n const heading = data?.heading ?? \"Documentation\"\n const markdown = data?.content ?? \"\"\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return\n\n const isDesktop = window.matchMedia(\"(min-width: 1024px)\").matches\n if (!isDesktop) return\n\n const body = document.body\n const previousMarginRight = body.style.marginRight\n const previousTransition = body.style.transition\n\n body.style.transition = previousTransition\n ? `${previousTransition}, margin-right 220ms ease`\n : \"margin-right 220ms ease\"\n body.style.marginRight = open ? `${panelWidthPx}px` : \"0px\"\n\n return () => {\n body.style.marginRight = previousMarginRight\n body.style.transition = previousTransition\n }\n }, [open])\n\n React.useEffect(() => {\n if (!open) return\n\n function handleEscape(event: KeyboardEvent) {\n if (event.key === \"Escape\") {\n setOpen(false)\n }\n }\n\n window.addEventListener(\"keydown\", handleEscape)\n return () => {\n window.removeEventListener(\"keydown\", handleEscape)\n }\n }, [open])\n\n return (\n <>\n