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    ElmBlockImage(ElmBlockImage),
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    ElmInlineLink(ElmInlineLink),
32    ElmInlineIcon(ElmInlineIcon),
33}
34
35// ListItem
36#[derive(Serialize, Clone)]
37pub struct ElmListItem {
38    pub id: String,
39
40    #[serde(skip_serializing_if = "Vec::is_empty")]
41    pub children: Vec<Block>,
42}
43
44#[derive(Serialize, Clone)]
45pub struct ElmBulletedList {
46    pub id: String,
47
48    #[serde(skip_serializing_if = "Vec::is_empty")]
49    pub children: Vec<Block>,
50}
51
52#[derive(Serialize, Clone)]
53pub struct ElmNumberedList {
54    pub id: String,
55
56    #[serde(skip_serializing_if = "Vec::is_empty")]
57    pub children: Vec<Block>,
58}
59
60// ElmBookmark
61#[derive(Serialize, Clone)]
62pub struct ElmBookmark {
63    pub id: String,
64    pub props: ElmBookmarkProps,
65}
66
67#[derive(Serialize, Clone, Default)]
68pub struct ElmBookmarkProps {
69    pub title: Option<String>,
70    pub description: Option<String>,
71    pub image: Option<String>,
72    pub url: String,
73    pub margin: String,
74}
75
76// CodeBlock
77#[derive(Serialize, Clone)]
78pub struct ElmCodeBlock {
79    pub id: String,
80    pub props: ElmCodeBlockProps,
81}
82
83#[derive(Serialize, Clone)]
84pub struct ElmCodeBlockProps {
85    pub code: String,
86    pub language: String,
87    pub caption: String,
88    pub margin: String,
89}
90
91// Divider
92#[derive(Serialize, Clone)]
93pub struct ElmDivider {
94    pub id: String,
95    pub props: ElmDividerProps,
96}
97
98#[derive(Serialize, Clone)]
99pub struct ElmDividerProps {
100    pub margin: String,
101}
102
103// Callout
104#[derive(Serialize, Clone)]
105pub struct ElmCallout {
106    pub id: String,
107    pub props: ElmCalloutProps,
108
109    #[serde(skip_serializing_if = "Vec::is_empty")]
110    pub children: Vec<Block>,
111}
112
113#[derive(Serialize, Clone)]
114pub struct ElmCalloutProps {
115    pub r#type: String,
116}
117
118// ColumnList
119#[derive(Serialize, Clone)]
120pub struct ElmColumnList {
121    pub id: String,
122
123    #[serde(skip_serializing_if = "Vec::is_empty")]
124    pub children: Vec<Block>,
125}
126
127// ColumnList
128#[derive(Serialize, Clone)]
129pub struct ElmColumn {
130    pub id: String,
131
132    #[serde(skip_serializing_if = "Vec::is_empty")]
133    pub children: Vec<Block>,
134}
135
136// Equation
137#[derive(Serialize, Clone)]
138pub struct ElmKatex {
139    pub props: ElmKatexProps,
140}
141
142#[derive(Serialize, Clone)]
143pub struct ElmKatexProps {
144    pub expression: String,
145    pub block: bool,
146}
147
148// File
149#[derive(Serialize, Clone)]
150pub struct ElmFile {
151    pub id: String,
152    pub props: ElmFileProps,
153}
154
155#[derive(Serialize, Clone)]
156pub struct ElmFileProps {
157    #[serde(skip_serializing_if = "Option::is_none")]
158    pub name: Option<String>,
159    pub src: String,
160    pub margin: String,
161}
162
163// Heading1
164#[derive(Serialize, Clone)]
165pub struct ElmHeading1 {
166    pub id: String,
167    pub props: ElmHeadingProps,
168}
169
170#[derive(Serialize, Clone)]
171pub struct ElmHeading2 {
172    pub id: String,
173    pub props: ElmHeadingProps,
174}
175
176#[derive(Serialize, Clone)]
177pub struct ElmHeading3 {
178    pub id: String,
179    pub props: ElmHeadingProps,
180}
181
182#[derive(Serialize, Clone)]
183pub struct ElmHeadingProps {
184    pub text: String,
185}
186
187// Image
188#[derive(Serialize, Clone)]
189pub struct ElmBlockImage {
190    pub id: String,
191    pub props: ElmBlockImageProps,
192}
193
194#[derive(Serialize, Clone)]
195pub struct ElmBlockImageProps {
196    pub src: String,
197
198    #[serde(skip_serializing_if = "Option::is_none")]
199    pub alt: Option<String>,
200
201    #[serde(rename = "enableModal")]
202    pub enable_modal: bool,
203
204    pub margin: String,
205}
206
207// Paragraph
208#[derive(Serialize, Clone)]
209pub struct ElmParagraph {
210    pub id: String,
211
212    #[serde(skip_serializing_if = "Vec::is_empty")]
213    pub children: Vec<Block>,
214}
215
216// Quote
217#[derive(Serialize, Clone)]
218pub struct ElmBlockQuote {
219    pub id: String,
220
221    #[serde(skip_serializing_if = "Vec::is_empty")]
222    pub children: Vec<Block>,
223}
224
225// ElmCheck
226#[derive(Serialize, Clone)]
227pub struct ElmCheckbox {
228    pub id: String,
229    pub props: ElmCheckboxProps,
230}
231
232#[derive(Serialize, Clone)]
233pub struct ElmCheckboxProps {
234    pub label: String,
235}
236
237// Toggle
238#[derive(Serialize, Clone)]
239pub struct ElmToggle {
240    pub id: String,
241    pub props: ElmToggleProps,
242
243    #[serde(skip_serializing_if = "Vec::is_empty")]
244    pub children: Vec<Block>,
245}
246
247#[derive(Serialize, Clone)]
248pub struct ElmToggleProps {
249    pub summary: String,
250    pub margin: String,
251}
252
253// ElmTable
254#[derive(Serialize, Clone)]
255pub struct ElmTable {
256    #[serde(skip_serializing_if = "Vec::is_empty")]
257    pub children: Vec<Block>,
258}
259
260#[derive(Serialize, Clone)]
261pub struct ElmTableHeader {
262    #[serde(skip_serializing_if = "Vec::is_empty")]
263    pub children: Vec<Block>,
264}
265
266#[derive(Serialize, Clone)]
267pub struct ElmTableBody {
268    #[serde(skip_serializing_if = "Vec::is_empty")]
269    pub children: Vec<Block>,
270}
271
272#[derive(Serialize, Clone)]
273pub struct ElmTableRow {
274    #[serde(skip_serializing_if = "Vec::is_empty")]
275    pub children: Vec<Block>,
276}
277
278#[derive(Serialize, Clone)]
279pub struct ElmTableCell {
280    pub props: ElmTableCellProps,
281}
282
283#[derive(Serialize, Clone)]
284pub struct ElmTableCellProps {
285    pub text: String,
286    #[serde(rename = "hasHeader")]
287    pub has_header: bool,
288}
289
290// InlineText
291#[derive(Serialize, Clone)]
292pub struct ElmInlineText {
293    pub props: ElmInlineTextProps,
294}
295
296#[derive(Serialize, Clone)]
297pub struct ElmInlineTextProps {
298    pub text: String,
299
300    #[serde(skip_serializing_if = "std::ops::Not::not")]
301    pub bold: bool,
302
303    #[serde(skip_serializing_if = "std::ops::Not::not")]
304    pub italic: bool,
305
306    #[serde(skip_serializing_if = "std::ops::Not::not")]
307    pub underline: bool,
308
309    #[serde(skip_serializing_if = "std::ops::Not::not")]
310    pub strikethrough: bool,
311
312    #[serde(skip_serializing_if = "std::ops::Not::not")]
313    pub code: bool,
314
315    #[serde(skip_serializing_if = "Option::is_none")]
316    pub color: Option<String>,
317}
318
319// InlineLink
320#[derive(Serialize, Clone)]
321pub struct ElmInlineLink {
322    pub props: ElmInlineLinkProps,
323}
324
325#[derive(Serialize, Clone)]
326pub struct ElmInlineLinkProps {
327    pub text: String,
328    pub href: String,
329
330    #[serde(skip_serializing_if = "Option::is_none")]
331    pub favicon: Option<String>,
332}
333
334// InlineIcon
335#[derive(Serialize, Clone)]
336pub struct ElmInlineIcon {
337    pub id: String,
338    pub props: ElmInlineIconProps,
339}
340
341#[derive(Serialize, Clone)]
342pub struct ElmInlineIconProps {
343    pub src: String,
344    pub alt: String,
345}