elmethis_notion/
block.rs

1use serde::Serialize;
2
3#[derive(Serialize, Clone)]
4#[serde(tag = "type")]
5pub enum Block {
6    ElmListItem(ElmListItem),
7    ElmBulletedList(ElmBulletedList),
8    ElmNumberedList(ElmNumberedList),
9    ElmBookmark(ElmBookmark),
10    ElmCodeBlock(ElmCodeBlock),
11    ElmDivider(ElmDivider),
12    ElmCallout(ElmCallout),
13    ElmColumnList(ElmColumnList),
14    ElmColumn(ElmColumn),
15    ElmFile(ElmFile),
16    ElmHeading1(ElmHeading1),
17    ElmHeading2(ElmHeading2),
18    ElmHeading3(ElmHeading3),
19    ElmImage(ElmImage),
20    ElmKatex(ElmKatex),
21    ElmParagraph(ElmParagraph),
22    ElmBlockQuote(ElmBlockQuote),
23    ElmCheckbox(ElmCheckbox),
24    ElmToggle(ElmToggle),
25    ElmTable(ElmTable),
26    ElmTableHeader(ElmTableHeader),
27    ElmTableBody(ElmTableBody),
28    ElmTableRow(ElmTableRow),
29    ElmTableCell(ElmTableCell),
30    ElmInlineText(ElmInlineText),
31}
32
33// ListItem
34#[derive(Serialize, Clone)]
35pub struct ElmListItem {
36    pub children: Vec<Block>,
37}
38
39#[derive(Serialize, Clone)]
40pub struct ElmBulletedList {
41    pub children: Vec<Block>,
42}
43
44#[derive(Serialize, Clone)]
45pub struct ElmNumberedList {
46    pub children: Vec<Block>,
47}
48
49// ElmBookmark
50#[derive(Serialize, Clone)]
51pub struct ElmBookmark {
52    pub props: ElmBookmarkProps,
53}
54
55#[derive(Serialize, Clone, Default)]
56pub struct ElmBookmarkProps {
57    pub title: Option<String>,
58    pub description: Option<String>,
59    pub image: Option<String>,
60    pub url: String,
61    pub margin: String,
62}
63
64// CodeBlock
65#[derive(Serialize, Clone)]
66pub struct ElmCodeBlock {
67    pub props: ElmCodeBlockProps,
68}
69
70#[derive(Serialize, Clone)]
71pub struct ElmCodeBlockProps {
72    pub code: String,
73    pub language: String,
74    pub caption: String,
75    pub margin: String,
76}
77
78// Divider
79#[derive(Serialize, Clone)]
80pub struct ElmDivider {
81    pub props: ElmDividerProps,
82}
83
84#[derive(Serialize, Clone)]
85pub struct ElmDividerProps {
86    pub margin: String,
87}
88
89// Callout
90#[derive(Serialize, Clone)]
91pub struct ElmCallout {
92    pub props: ElmCalloutProps,
93    pub children: Vec<Block>,
94}
95
96#[derive(Serialize, Clone)]
97pub struct ElmCalloutProps {
98    pub r#type: String,
99}
100
101// ColumnList
102#[derive(Serialize, Clone)]
103pub struct ElmColumnList {
104    pub children: Vec<Block>,
105}
106
107// ColumnList
108#[derive(Serialize, Clone)]
109pub struct ElmColumn {
110    pub children: Vec<Block>,
111}
112
113// Equation
114#[derive(Serialize, Clone)]
115pub struct ElmKatex {
116    pub props: ElmKatexProps,
117}
118
119#[derive(Serialize, Clone)]
120pub struct ElmKatexProps {
121    pub expression: String,
122    pub block: bool,
123}
124
125// File
126#[derive(Serialize, Clone)]
127pub struct ElmFile {
128    pub props: ElmFileProps,
129}
130
131#[derive(Serialize, Clone)]
132pub struct ElmFileProps {
133    #[serde(skip_serializing_if = "Option::is_none")]
134    pub name: Option<String>,
135    pub src: String,
136    pub margin: String,
137}
138
139// Heading1
140#[derive(Serialize, Clone)]
141pub struct ElmHeading1 {
142    pub props: ElmHeadingProps,
143}
144
145#[derive(Serialize, Clone)]
146pub struct ElmHeading2 {
147    pub props: ElmHeadingProps,
148}
149
150#[derive(Serialize, Clone)]
151pub struct ElmHeading3 {
152    pub props: ElmHeadingProps,
153}
154
155#[derive(Serialize, Clone)]
156pub struct ElmHeadingProps {
157    pub text: String,
158}
159
160// Image
161#[derive(Serialize, Clone)]
162pub struct ElmImage {
163    pub props: ElmImageProps,
164}
165
166#[derive(Serialize, Clone)]
167pub struct ElmImageProps {
168    pub src: String,
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub alt: Option<String>,
171    #[serde(rename = "enableModal")]
172    pub enable_modal: bool,
173    pub margin: String,
174}
175
176// Paragraph
177#[derive(Serialize, Clone)]
178pub struct ElmParagraph {
179    pub children: Vec<Block>,
180}
181
182// Quote
183#[derive(Serialize, Clone)]
184pub struct ElmBlockQuote {
185    pub children: Vec<Block>,
186}
187
188// ElmCheck
189#[derive(Serialize, Clone)]
190pub struct ElmCheckbox {
191    pub props: ElmCheckboxProps,
192}
193
194#[derive(Serialize, Clone)]
195pub struct ElmCheckboxProps {
196    pub label: String,
197}
198
199// Toggle
200#[derive(Serialize, Clone)]
201pub struct ElmToggle {
202    pub props: ElmToggleProps,
203    pub children: Vec<Block>,
204}
205
206#[derive(Serialize, Clone)]
207pub struct ElmToggleProps {
208    pub summary: String,
209    pub margin: String,
210}
211
212// ElmTable
213#[derive(Serialize, Clone)]
214pub struct ElmTable {
215    pub children: Vec<Block>,
216}
217
218#[derive(Serialize, Clone)]
219pub struct ElmTableHeader {
220    pub children: Vec<Block>,
221}
222
223#[derive(Serialize, Clone)]
224pub struct ElmTableBody {
225    pub children: Vec<Block>,
226}
227
228#[derive(Serialize, Clone)]
229pub struct ElmTableRow {
230    pub children: Vec<Block>,
231}
232
233#[derive(Serialize, Clone)]
234pub struct ElmTableCell {
235    pub props: ElmTableCellProps,
236}
237
238#[derive(Serialize, Clone)]
239pub struct ElmTableCellProps {
240    pub text: String,
241    #[serde(rename = "hasHeader")]
242    pub has_header: bool,
243}
244
245// InlineText
246#[derive(Serialize, Clone)]
247pub struct ElmInlineText {
248    pub props: ElmInlineTextProps,
249}
250
251#[derive(Serialize, Clone)]
252pub struct ElmInlineTextProps {
253    pub text: String,
254    pub bold: bool,
255    pub italic: bool,
256    pub underline: bool,
257    pub strikethrough: bool,
258    pub code: bool,
259    pub color: Option<String>,
260}