Skip to content

Commit c31876c

Browse files
Copilothuangyiirene
andcommitted
Add JSDoc documentation for markdown component
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent d9a2987 commit c31876c

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

packages/components/src/renderers/data-display/markdown.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
import { ComponentRegistry } from '@object-ui/core';
22
import { Markdown } from '@/ui';
33

4+
/**
5+
* Markdown Renderer Component
6+
*
7+
* A schema-driven renderer that displays markdown content in Object UI applications.
8+
* This component follows the "Schema First" principle, enabling markdown rendering
9+
* through pure JSON/YAML configuration without writing custom code.
10+
*
11+
* @example
12+
* ```json
13+
* {
14+
* "type": "markdown",
15+
* "content": "# Hello World\n\nThis is **markdown** text."
16+
* }
17+
* ```
18+
*
19+
* Features:
20+
* - GitHub Flavored Markdown support (tables, strikethrough, task lists)
21+
* - XSS protection via rehype-sanitize
22+
* - Dark mode support
23+
* - Tailwind CSS prose styling
24+
*/
425
ComponentRegistry.register('markdown',
526
({ schema, className, ...props }) => (
627
<Markdown

packages/components/src/ui/markdown.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,29 @@ import remarkGfm from "remark-gfm"
44
import rehypeSanitize from "rehype-sanitize"
55
import { cn } from "@/lib/utils"
66

7+
/**
8+
* Props for the Markdown component.
9+
*
10+
* This component renders markdown content using react-markdown with GitHub Flavored Markdown support.
11+
* All content is sanitized to prevent XSS attacks.
12+
*/
713
export interface MarkdownProps {
14+
/**
15+
* The markdown content to render. Supports GitHub Flavored Markdown including:
16+
* - Headers (H1-H6)
17+
* - Bold, italic, and inline code
18+
* - Links and images
19+
* - Lists (ordered, unordered, and nested)
20+
* - Tables
21+
* - Blockquotes
22+
* - Code blocks
23+
*/
824
content: string
25+
26+
/**
27+
* Optional CSS class name to apply custom styling to the markdown container.
28+
* The component uses Tailwind CSS prose classes for typography by default.
29+
*/
930
className?: string
1031
}
1132

0 commit comments

Comments
 (0)