forked from remarkjs/react-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
93 lines (71 loc) · 2.46 KB
/
index.d.ts
File metadata and controls
93 lines (71 loc) · 2.46 KB
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
// TypeScript Version: 3.4
import {ElementType, ReactNode, ReactElement} from 'react'
import {PluggableList} from 'unified'
import * as unist from 'unist'
import * as mdast from 'mdast'
type Not<T> = {
[key in keyof T]?: never
}
type MutuallyExclusive<T, U> = (T & Not<U>) | (U & Not<T>)
declare namespace ReactMarkdown {
type Point = unist.Point
type Position = unist.Position
type NodeType = mdast.Content['type']
type AlignType = mdast.AlignType
type ReferenceType = mdast.ReferenceType
type LinkTargetResolver = (uri: string, text: string, title?: string) => string
type Renderer<T> = (props: T) => ElementType<T>
interface Renderers {
[key: string]: string | Renderer<any>
}
interface ReactMarkdownPropsBase {
readonly className?: string
readonly sourcePos?: boolean
readonly includeNodeIndex?: boolean
readonly rawSourcePos?: boolean
readonly allowNode?: (node: mdast.Content, index: number, parent: NodeType) => boolean
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 renderers?: {[nodeType: string]: ElementType}
readonly astPlugins?: PluggableList
readonly plugins?: PluggableList
}
interface SourceProp {
/** @deprecated use children */
readonly source: string
}
interface ChildrenProp {
readonly children: string
}
interface AllowedTypesProp {
readonly allowedTypes?: NodeType[]
}
interface DisallowedTypesProp {
readonly disallowedTypes: NodeType[]
readonly unwrapDisallowed?: boolean
}
interface AllowDangerousHtmlProp {
readonly allowDangerousHtml?: boolean
}
interface EscapeHtmlProp {
/** @deprecated use allowDangerousHtml */
readonly escapeHtml?: boolean
}
interface SkipHtmlProp {
readonly skipHtml?: boolean
}
type ReactMarkdownProps = ReactMarkdownPropsBase &
MutuallyExclusive<ChildrenProp, SourceProp> &
MutuallyExclusive<AllowedTypesProp, DisallowedTypesProp> &
MutuallyExclusive<EscapeHtmlProp, MutuallyExclusive<SkipHtmlProp, AllowDangerousHtmlProp>>
const types: NodeType[]
const renderers: Renderers
function uriTransformer(uri: string): string
}
declare function ReactMarkdown(props: ReactMarkdown.ReactMarkdownProps): ReactElement
export = ReactMarkdown