-
Notifications
You must be signed in to change notification settings - Fork 9
/
types.d.ts
196 lines (170 loc) · 4 KB
/
types.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import { Code, Data, Literal, Parent, Blockquote, Node, Root, Text, Table, BlockContent } from 'mdast';
import { NodeTypes } from './enums';
import { Element } from 'hast';
import { MDXContent, MDXModule } from 'mdx/types';
import { MdxJsxFlowElementHast } from 'mdast-util-mdx-jsx';
type Callout = Omit<Blockquote, 'type'> & {
type: NodeTypes.callout;
data: Data & {
hName: 'Callout';
hProperties: {
icon: string;
empty: boolean;
};
};
};
interface CodeTabs extends Parent {
type: NodeTypes.codeTabs;
children: Code[];
data: Data & {
hName: 'CodeTabs';
};
}
interface EmbedBlock extends Node {
type: NodeTypes.embedBlock;
title?: string;
label?: string;
url?: string;
data: Data & {
hName: 'embed';
hProperties: {
title: string;
html?: string;
providerName?: string;
providerUrl?: string;
url: string;
image?: string;
favicon?: string;
iframe?: boolean;
};
};
}
interface Figure extends Node {
type: NodeTypes.figure;
data: {
hName: 'figure';
};
children: [ImageBlock & { url: string }, FigCaption];
}
interface FigCaption extends Node {
type: NodeTypes.figcaption;
data: {
hName: 'figcaption';
};
children: BlockContent[];
}
interface HTMLBlock extends Node {
type: NodeTypes.htmlBlock;
children: Text[];
data: Data & {
hName: 'html-block';
hProperties: {
runScripts?: boolean | string;
html: string;
};
};
}
interface ImageBlockAttrs {
align?: string;
alt: string;
border?: string;
caption?: string;
className?: string;
height?: string;
lazy?: boolean;
src: string;
title: string;
width?: string;
}
interface ImageBlock extends ImageBlockAttrs, Parent {
type: NodeTypes.imageBlock;
data: Data & {
hName: 'img';
hProperties: ImageBlockAttrs;
};
}
interface Gemoji extends Literal {
type: NodeTypes.emoji;
name: string;
}
interface FaEmoji extends Literal {
type: NodeTypes.i;
}
interface Tableau extends Omit<Table, 'type'> {
type: NodeTypes.tableau;
}
interface TutorialTile extends Node {
backgroundColor: string;
emoji: string;
id: string;
link: string;
slug: string;
title: string;
type: NodeTypes.tutorialTile;
}
interface Variable extends Node {
data: Data & {
hName: 'Variable';
hProperties: {
name: string;
};
};
value: string;
}
declare module 'mdast' {
interface BlockContentMap {
[NodeTypes.callout]: Callout;
[NodeTypes.codeTabs]: CodeTabs;
[NodeTypes.embedBlock]: EmbedBlock;
[NodeTypes.figure]: Figure;
[NodeTypes.htmlBlock]: HTMLBlock;
[NodeTypes.imageBlock]: ImageBlock;
[NodeTypes.tableau]: Tableau;
[NodeTypes.tutorialTile]: TutorialTile;
}
interface PhrasingContentMap {
[NodeTypes.emoji]: Gemoji;
[NodeTypes.i]: FaEmoji;
[NodeTypes.variable]: Variable;
}
interface RootContentMap {
[NodeTypes.callout]: Callout;
[NodeTypes.codeTabs]: CodeTabs;
[NodeTypes.embedBlock]: EmbedBlock;
[NodeTypes.emoji]: Gemoji;
[NodeTypes.figure]: Figure;
[NodeTypes.htmlBlock]: HTMLBlock;
[NodeTypes.i]: FaEmoji;
[NodeTypes.imageBlock]: ImageBlock;
[NodeTypes.tableau]: Tableau;
[NodeTypes.tutorialTile]: TutorialTile;
[NodeTypes.variable]: Variable;
}
}
interface HastHeading extends Element {
tagName: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
depth: number;
}
interface TocList extends Element {
tagName: 'ul';
children: TocListItem[];
}
interface Variables {
user: Record<string, string>;
defaults: { name: string; default: string }[];
}
interface TocListItem extends Element {
tagName: 'li';
children: (TocList | TocEntry)[];
}
interface TocEntry extends Element {
tagName: 'a';
children: (Element | Literal)[];
}
type IndexableElements = HastHeading | MdxJsxFlowElementHast;
interface RMDXModule extends MDXModule {
toc: IndexableElements[];
Toc: MDXContent;
}
interface CustomComponents extends Record<string, RMDXModule> {}
interface MdastComponents extends Record<string, Root> {}