-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.d.ts
185 lines (176 loc) · 5.11 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
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
declare module "storyblok-rich-text-react-renderer" {
import { ReactNode } from "react";
type LinkCustomAttributes = {
rel?: string;
title?: string;
[key: string]: any;
};
export type StoryblokRichtextContentType =
| "heading"
| "code_block"
| "paragraph"
| "blockquote"
| "ordered_list"
| "bullet_list"
| "list_item"
| "horizontal_rule"
| "hard_break"
| "image"
| "emoji"
| "blok"
| "text";
export type StoryblokRichtextMark =
| "bold"
| "italic"
| "strike"
| "underline"
| "code"
| "link"
| "styled"
| "subscript"
| "superscript"
| "highlight"
| "textStyle"
| "anchor";
export type StoryblokRichtextContent = {
type: StoryblokRichtextContentType;
attrs?: {
level?: number;
class?: string;
src?: string;
alt?: string;
title?: string;
order?: number;
body?: Array<{
_uid: string;
}>;
};
marks?: {
type: StoryblokRichtextMark;
attrs?: {
linktype?: string;
href?: string;
target?: string;
anchor?: string;
uuid?: string;
class?: string;
color?: string;
id?: string;
custom?: LinkCustomAttributes;
};
}[];
text?: string;
content?: StoryblokRichtextContent[];
};
export type StoryblokRichtext = {
type: "doc";
content: StoryblokRichtextContent[];
};
export const NODE_HEADING = "heading";
export const NODE_CODEBLOCK = "code_block";
export const NODE_PARAGRAPH = "paragraph";
export const NODE_QUOTE = "blockquote";
export const NODE_OL = "ordered_list";
export const NODE_UL = "bullet_list";
export const NODE_LI = "list_item";
export const NODE_HR = "horizontal_rule";
export const NODE_BR = "hard_break";
export const NODE_IMAGE = "image";
export const NODE_EMOJI = "emoji";
export const MARK_BOLD = "bold";
export const MARK_ITALIC = "italic";
export const MARK_STRIKE = "strike";
export const MARK_UNDERLINE = "underline";
export const MARK_CODE = "code";
export const MARK_LINK = "link";
export const MARK_STYLED = "styled";
export const MARK_SUBSCRIPT = "subscript";
export const MARK_SUPERSCRIPT = "superscript";
export const MARK_HIGHLIGHT = "highlight";
export const MARK_TEXT_STYLE = "textStyle";
export const MARK_ANCHOR = "anchor";
export interface RenderOptions {
blokResolvers?: {
[key: string]: (props: Record<string, unknown>) => JSX.Element | null;
};
defaultBlokResolver?: (
name: string,
props: Record<string, unknown> & { _uid: string }
) => JSX.Element | null;
markResolvers?: {
[MARK_BOLD]?: (children: ReactNode) => JSX.Element | null;
[MARK_CODE]?: (children: ReactNode) => JSX.Element | null;
[MARK_ITALIC]?: (children: ReactNode) => JSX.Element | null;
[MARK_STRIKE]?: (children: ReactNode) => JSX.Element | null;
[MARK_UNDERLINE]?: (children: ReactNode) => JSX.Element | null;
[MARK_SUBSCRIPT]?: (children: ReactNode) => JSX.Element | null;
[MARK_SUPERSCRIPT]?: (children: ReactNode) => JSX.Element | null;
[MARK_LINK]?: (
children: ReactNode,
props: {
linktype?: string;
href?: string;
target?: string;
anchor?: string;
uuid?: string;
custom?: LinkCustomAttributes;
}
) => JSX.Element | null;
[MARK_STYLED]?: (
children: ReactNode,
props: { class?: string }
) => JSX.Element | null;
[MARK_HIGHLIGHT]?: (
children: ReactNode,
props: { color?: string }
) => JSX.Element | null;
[MARK_TEXT_STYLE]?: (
children: ReactNode,
props: { color?: string }
) => JSX.Element | null;
[MARK_ANCHOR]?: (
children: ReactNode,
props: { id?: string }
) => JSX.Element | null;
};
nodeResolvers?: {
[NODE_BR]?: () => JSX.Element | null;
[NODE_CODEBLOCK]?: (
children: ReactNode,
props: { class: string }
) => JSX.Element | null;
[NODE_HEADING]?: (
children: ReactNode,
props: { level: 1 | 2 | 3 | 4 | 5 | 6 }
) => JSX.Element | null;
[NODE_HR]?: () => JSX.Element | null;
[NODE_IMAGE]?: (
children: ReactNode,
props: {
alt?: string;
title?: string;
src?: string;
}
) => JSX.Element | null;
[NODE_EMOJI]?: (
children: ReactNode,
props: {
name?: string;
emoji?: string;
fallbackImage?: string;
}
) => JSX.Element | null;
[NODE_LI]?: (children: ReactNode) => JSX.Element | null;
[NODE_OL]?: (children: ReactNode) => JSX.Element | null;
[NODE_PARAGRAPH]?: (children: ReactNode) => JSX.Element | null;
[NODE_QUOTE]?: (children: ReactNode) => JSX.Element | null;
[NODE_UL]?: (children: ReactNode) => JSX.Element | null;
};
defaultStringResolver?: (str: string) => JSX.Element;
textResolver?: (str: string) => string;
}
export function render(
document: StoryblokRichtext | unknown,
options?: RenderOptions
);
}