/** * The render-function component contract and the neutral default renderers. * * `@sigx/lynx-markdown` is **generic**: the defaults here use only plain inline * styles (numbers + theme-agnostic colors) so the renderer works standalone on * any platform/theme with zero design-system coupling. A design system (e.g. * `@sigx/lynx-daisyui`) supplies its own {@link MarkdownComponents} to control * the look — see the `components` prop on ``. * * Each component receives its already-rendered `children` plus the raw AST * `node`; the engine owns AST recursion and stable streaming keys, so a * component only decides *what element to wrap children in*. */ import type { JSXElement } from '@sigx/lynx'; import type { BlockquoteBlock, CodeBlock, HeadingBlock, HeadingLevel, InlineAutolink, InlineCodeSpan, InlineDel, InlineEm, InlineExtension, InlineImage, InlineLink, InlineStrong, ListBlock, ListItem, ParagraphBlock, TableAlign, TableBlock, ThematicBreakBlock } from '../ast.js'; /** A renderable child: a JSX element or a raw string (for text/`
`). */ export type MarkdownChild = JSXElement | string; export interface RootProps { children: MarkdownChild[]; } export interface HeadingProps { level: HeadingLevel; children: MarkdownChild[]; node: HeadingBlock; } export interface ParagraphProps { children: MarkdownChild[]; node: ParagraphBlock; } export interface BlockquoteProps { children: MarkdownChild[]; node: BlockquoteBlock; } export interface ListProps { ordered: boolean; start: number; tight: boolean; children: MarkdownChild[]; node: ListBlock; } export interface ListItemProps { ordered: boolean; /** Zero-based index within the list. */ index: number; /** Display number for ordered lists (`start + index`). */ number: number; /** GFM task state, or `null` when not a task item. */ checked: boolean | null; children: MarkdownChild[]; item: ListItem; } export interface CodeProps { lang?: string; value: string; /** `false` while the fence is still streaming/unterminated. */ closed: boolean; node: CodeBlock; } export interface ThematicBreakProps { node: ThematicBreakBlock; } export interface TableProps { align: (TableAlign | null)[]; children: MarkdownChild[]; node: TableBlock; } export interface TableRowProps { header: boolean; children: MarkdownChild[]; node: TableBlock; } export interface TableCellProps { header: boolean; align: TableAlign | null; children: MarkdownChild[]; node: TableBlock; } export interface StrongProps { children: MarkdownChild[]; node: InlineStrong; } export interface EmProps { children: MarkdownChild[]; node: InlineEm; } export interface DelProps { children: MarkdownChild[]; node: InlineDel; } export interface CodeSpanProps { value: string; node: InlineCodeSpan; } export interface LinkProps { href: string; title?: string; children: MarkdownChild[]; onLink?: (href: string) => void; node: InlineLink; } export interface AutolinkProps { href: string; value: string; onLink?: (href: string) => void; node: InlineAutolink; } export interface ImageProps { src: string; alt: string; title?: string; onImageTap?: (src: string) => void; node: InlineImage; } export interface ExtensionProps { name: string; attrs: Record; /** Rendered `node.children`; `[]` for leaf extensions. */ children: MarkdownChild[]; node: InlineExtension; } /** * Map of node type → render function. Pass a partial map to `` to override any subset; unspecified types fall back to the * neutral {@link defaultComponents}. */ export interface MarkdownComponents { root(props: RootProps): JSXElement; heading(props: HeadingProps): JSXElement; paragraph(props: ParagraphProps): JSXElement; blockquote(props: BlockquoteProps): JSXElement; list(props: ListProps): JSXElement; listItem(props: ListItemProps): JSXElement; code(props: CodeProps): JSXElement; thematicBreak(props: ThematicBreakProps): JSXElement; table(props: TableProps): JSXElement; tableRow(props: TableRowProps): JSXElement; tableCell(props: TableCellProps): JSXElement; strong(props: StrongProps): MarkdownChild; em(props: EmProps): MarkdownChild; del(props: DelProps): MarkdownChild; codeSpan(props: CodeSpanProps): MarkdownChild; link(props: LinkProps): MarkdownChild; autolink(props: AutolinkProps): MarkdownChild; image(props: ImageProps): MarkdownChild; br(): MarkdownChild; /** * Renderers for plugin inline extensions, keyed by extension name. A node * with no matching renderer falls back to its `raw` source as plain text. */ extension?: Record MarkdownChild>; } export declare const defaultComponents: MarkdownComponents;