UNPKG

tinacms

Version:

> The Fastest Way to Edit Next.js Content

140 lines (138 loc) 2.93 kB
/** */ /// <reference types="react" /> declare type BaseComponents = { h1?: { children: JSX.Element; }; h2?: { children: JSX.Element; }; h3?: { children: JSX.Element; }; h4?: { children: JSX.Element; }; h5?: { children: JSX.Element; }; h6?: { children: JSX.Element; }; p?: { children: JSX.Element; }; a?: { url: string; children: JSX.Element; }; italic?: { children: JSX.Element; }; bold?: { children: JSX.Element; }; strikethrough?: { children: JSX.Element; }; underline?: { children: JSX.Element; }; code?: { children: JSX.Element; }; text?: { children: string; }; ul?: { children: JSX.Element; }; ol?: { children: JSX.Element; }; li?: { children: JSX.Element; }; lic?: { children: JSX.Element; }; block_quote?: { children: JSX.Element; }; code_block?: { lang?: string; value: string; }; img?: { url: string; caption?: string; alt?: string; }; hr?: {}; break?: {}; maybe_mdx?: { children: JSX.Element; }; html?: { value: string; }; html_inline?: { value: string; }; table?: { align?: ('left' | 'right' | 'center')[]; tableRows: { tableCells: { value: TinaMarkdownContent; }[]; }[]; }; component_missing?: { name: string; }; }; declare type BaseComponentSignature = { [BK in keyof BaseComponents]: (props: BaseComponents[BK]) => JSX.Element; }; /** * Define the allowed components and their props * ```ts * const components: * Components<{ * BlockQuote: { * children: TinaMarkdownContent; * authorName: string; * }; * }> = { * BlockQuote: (props: { * children: TinaMarkdownContent; * authorName: string; * }) => { * return ( * <div> * <blockquote> * <TinaMarkdown content={props.children} /> * {props.authorName} * </blockquote> * </div> * ); * } * } * } * ``` */ export declare type Components<ComponentAndProps extends object> = { [K in keyof ComponentAndProps]: (props: ComponentAndProps[K]) => JSX.Element; } & BaseComponentSignature; export declare type TinaMarkdownContent = { type: string; children: TinaMarkdownContent[]; }; export declare const TinaMarkdown: <CustomComponents extends { [key: string]: object; } = any>({ content, components, }: { content: TinaMarkdownContent | TinaMarkdownContent[]; components?: Components<{}> | Components<{ [BK in keyof CustomComponents]: (props: CustomComponents[BK]) => JSX.Element; }>; }) => JSX.Element; export {};