{ "$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
\n setOpen(true)}\n className=\"cursor-pointer inline-flex size-9 items-center justify-center text-foreground transition-colors hover:text-accent-foreground\"\n >\n \n \n {hoverText ? (\n \n {hoverText}\n \n ) : null}\n
\n\n \n
\n

{heading}

\n setOpen(false)}\n className=\"inline-flex size-8 items-center justify-center rounded-md border transition-colors hover:bg-accent hover:text-accent-foreground\"\n >\n \n \n
\n\n {isLoading ? (\n

Loading documentation...

\n ) : error ? (\n

{error}

\n ) : markdown ? (\n \n ) : (\n

\n No documentation content available.\n

\n )}\n \n \n )\n}\n\nexport { DocumentationProvider }\n", "type": "registry:ui" }, { "path": "registry/components/documentation-provider/markdown.tsx", "content": "\"use client\"\n\nimport * as React from \"react\"\nimport ReactMarkdown from \"react-markdown\"\nimport rehypeRaw from \"rehype-raw\"\nimport rehypeSanitize, { defaultSchema } from \"rehype-sanitize\"\nimport remarkGfm from \"remark-gfm\"\nimport type { Options as SanitizeOptions } from \"rehype-sanitize\"\n\n/** Extends GitHub-style defaults with `