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