tinacms
Version:
[](https://github.com/tinacms/tinacms/blob/main/LICENSE) [](https://www.npmjs.com/package/tinacms) [![Bui
143 lines (141 loc) • 2.95 kB
TypeScript
/**
*/
import React from 'react';
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;
};
mermaid?: {
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;
};
};
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 type Components<ComponentAndProps extends object> = {
[K in keyof ComponentAndProps]: (props: ComponentAndProps[K]) => JSX.Element;
} & BaseComponentSignature;
export 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; }>;
}) => React.JSX.Element;
export {};