1// Type definitions for react-markdown > v3.3.0 2// Project: https://github.com/rexxars/react-markdown 3// Definitions by: 4// - Ruslan Ibragimov <https://github.com/IRus> 5// - Kohei Asai <me@axross.io> 6// - ClassicDarkChocolate <https://github.com/ClassicDarkChocolate> 7// - Espen Hovlandsdal <https://espen.codes/> 8// - Ted Piotrowski <https://github.com/ted-piotrowski> 9 10import {Component, ReactElement, ReactNode, ReactType} from 'react' 11 12declare class ReactMarkdown extends Component<ReactMarkdown.ReactMarkdownProps, {}> {} 13 14declare namespace ReactMarkdown { 15 interface Point { 16 readonly line: number 17 readonly column: number 18 readonly offset?: number 19 } 20 21 interface Position { 22 readonly start: Point 23 readonly end: Point 24 readonly indent?: number[] 25 } 26 27 interface RemarkParseOptions { 28 gfm: boolean 29 commonmark: boolean 30 footnotes: boolean 31 blocks: string[] 32 pedantic: boolean 33 } 34 35 export type NodeType = 36 | 'root' 37 | 'text' 38 | 'break' 39 | 'paragraph' 40 | 'emphasis' 41 | 'strong' 42 | 'thematicBreak' 43 | 'blockquote' 44 | 'delete' 45 | 'link' 46 | 'image' 47 | 'linkReference' 48 | 'imageReference' 49 | 'table' 50 | 'tableHead' 51 | 'tableBody' 52 | 'tableRow' 53 | 'tableCell' 54 | 'list' 55 | 'listItem' 56 | 'definition' 57 | 'heading' 58 | 'inlineCode' 59 | 'code' 60 | 'html' 61 | 'virtualHtml' 62 63 export type AlignType = 64 | "left" 65 | "right" 66 | "center" 67 | null 68 69 export type ReferenceType = 70 | "shortcut" 71 | "collapsed" 72 | "full" 73 74 export type LinkTargetResolver = (uri: string, text: string, title?: string) => string 75 76 export interface ReactMarkdownProps { 77 readonly className?: string 78 readonly source?: string 79 readonly sourcePos?: boolean 80 readonly includeNodeIndex?: boolean 81 readonly rawSourcePos?: boolean 82 readonly escapeHtml?: boolean 83 readonly skipHtml?: boolean 84 readonly allowNode?: (node: MarkdownAbstractSyntaxTree, index: number, parent: NodeType) => boolean 85 readonly allowedTypes?: NodeType[] 86 readonly disallowedTypes?: NodeType[] 87 readonly linkTarget?: string | LinkTargetResolver 88 readonly transformLinkUri?: ((uri: string, children?: ReactNode, title?: string) => string) | null 89 readonly transformImageUri?: ((uri: string, children?: ReactNode, title?: string, alt?: string) => string) | null 90 readonly unwrapDisallowed?: boolean 91 readonly renderers?: {[nodeType: string]: ReactType} 92 readonly astPlugins?: MdastPlugin[] 93 readonly plugins?: any[] | (() => void) 94 readonly parserOptions?: Partial<RemarkParseOptions> 95 } 96 97 interface RenderProps extends ReactMarkdownProps { 98 readonly definitions?: object 99 } 100 101 type Renderer<T> = (props: T) => ReactElement<T> 102 interface Renderers { 103 [key: string]: string | Renderer<any> 104 } 105 106 interface MarkdownAbstractSyntaxTree { 107 align?: AlignType[] 108 alt?: string | null 109 checked?: boolean | null 110 children?: MarkdownAbstractSyntaxTree[] 111 data?: {[key: string]: any} 112 index?: number 113 depth?: number 114 height?: number 115 identifier?: string 116 lang?: string | null 117 loose?: boolean 118 ordered?: boolean 119 position?: Position 120 referenceType?: ReferenceType 121 start?: number | null 122 title?: string | null 123 type: string 124 url?: string 125 value?: string 126 width?: number 127 } 128 129 type MdastPlugin = (node: MarkdownAbstractSyntaxTree, renderProps?: RenderProps) => MarkdownAbstractSyntaxTree 130 131 export var types: NodeType[] 132 export var renderers: Renderers 133 export var uriTransformer: (uri: string) => string 134} 135 136export = ReactMarkdown 137 138