Skip to content

Commit af3d8e4

Browse files
authored
Merge pull request #9 from jonathangomz/v1.1.0
* Add more blocks support for `(PATCH): block children` endpoint * `BulletedListItem` block * `NumberedListItem` block * `Toggle` block * Add `children` field for blocks: * `BulletedListItem` * `NumberedListItem` * `ToDo` * `Toggle` * `Paragraph` * Add methods to manipulate `content` and `children` for blocks: * `addText(String text, {TextAnnotations? annotations})` * `addChild(Block block)` * `addChildren(List<Block> blocks)` * Add `Children.withBlocks(List<Block> blocks)` constructor * Add `final` for `type` fields to not allow overwrite: * Objects * Blocks * Add `BaseClient` class to avoid duplicated code for clients * Add `deprecated` annotations for future changes: * Remove `textSeparation` parameter/field * Remove `add(Text text)` function * Remove `texts` getter for `Paragraph` * Remove named parameters for `Children` class * Update documentation
2 parents f88a5bc + 983e67e commit af3d8e4

39 files changed

Lines changed: 1043 additions & 203 deletions

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
TEST_DATABASE_ID: ${{ secrets.TEST_DATABASE_ID }}
3030
TEST_PAGE_ID: ${{ secrets.TEST_PAGE_ID }}
3131
TEST_BLOCK_ID: ${{ secrets.TEST_BLOCK_ID }}
32+
TEST_BLOCK_HEADING_ID: ${{ secrets.TEST_BLOCK_HEADING_ID }}
3233
EXEC_ENV: 'github_actions'
3334

3435
- name: Format coverage

CHANGELOG.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,32 @@
7777
> Release date: 05/Jul/2021
7878
* Fix warnings for documentation
7979
* Improve documentation
80-
* Add contribution rules
80+
* Add contribution rules
81+
82+
## v1.1.0:
83+
> Release date: 10/Jul/2021
84+
* Add more blocks support for `(PATCH): block children` endpoint
85+
* `BulletedListItem` block
86+
* `NumberedListItem` block
87+
* `Toggle` block
88+
* Add `children` field for blocks:
89+
* `BulletedListItem`
90+
* `NumberedListItem`
91+
* `ToDo`
92+
* `Toggle`
93+
* `Paragraph`
94+
* Add methods to manipulate `content` and `children` for blocks:
95+
* `addText(String text, {TextAnnotations? annotations})`
96+
* `addChild(Block block)`
97+
* `addChildren(List<Block> blocks)`
98+
* Add `Children.withBlocks(List<Block> blocks)` constructor
99+
* Add `final` for `type` fields to not allow overwrite:
100+
* Objects
101+
* Blocks
102+
* Add `BaseClient` class to avoid duplicated code for clients
103+
* Add `deprecated` annotations for future changes:
104+
* Remove `textSeparation` parameter/field
105+
* Remove `add(Text text)` function
106+
* Remove `texts` getter for `Paragraph`
107+
* Remove named parameters for `Children` class
108+
* Update documentation

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ See the [ROADMAP](ROADMAP.md) file to see what is coming next.
1616
- [Tests](#tests)
1717
- [Example:](#example)
1818
- [Next release](#next-release)
19-
- [v1.1.0:](#v110)
2019

2120
# Usage
2221
**Important**: The methods return a `NotionResponse`. You can find how to use it in its [documentation][1].
@@ -47,7 +46,7 @@ _To see more examples [go here](https://github.com/jonathangomz/notion_api/blob/
4746
### Append blocks children
4847
```dart
4948
// Create children instance:
50-
Children children = Children().addAll([
49+
Children children = Children.withBlocks([
5150
Heading(text: Text('Test')),
5251
Paragraph(texts: [
5352
Text('Lorem ipsum (A)'),
@@ -98,6 +97,7 @@ To be able to run the tests you will have to have a `.env` file on the root dire
9897
* TEST_DATABASE_ID: The database id where you will be working on.
9998
* TEST_PAGE_ID: Some page id inside the database specified above.
10099
* TEST_BLOCK_ID: Some block id inside the page specified above.
100+
* TEST_BLOCK_HEADING_ID: Some heading block id inside the page specified above.
101101

102102
### Example:
103103
_The values are not valid of course._
@@ -106,19 +106,10 @@ TOKEN=secret_Oa24V8FbJ49JluJankVOQihyLiMXwqSQeeHuSFobQDW
106106
TEST_DATABASE_ID=366da3d646bb458128071fdb2fbbf427
107107
TEST_PAGE_ID=c3b53019-4470-443b-a141-95a3a1a44g60
108108
TEST_BLOCK_ID=c8hac4bb32af48889228bf483d938e34
109+
TEST_BLOCK_HEADING_ID=c8hac4bb32af48889228bf483d938e34
109110
```
110111

111112
# Next release
112-
## v1.1.0:
113-
> Release date: 10/Jul/2021
114-
* Add more blocks for `(PATCH): block children` endpoint
115-
* `BulletedList` block
116-
* `NumberedList` block
117-
* `Toggle` block
118-
* Add `Children.with(List<Block> blocks)` constructor
119-
* Add singleton (_if possible_)
120-
* Add `final` for override types to not allow change the field:
121-
* Objects
122-
* Blocks
113+
I don't know yet. If you have suggestions feel free to create an Issue or to create a PR with the feature.
123114

124115
[1]:https://pub.dev/documentation/notion_api/1.0.0-beta1/responses_notion_response/NotionResponse-class.html

ROADMAP.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
# Roadmap
22

33
## More coming soon...
4+
I don't know yet. If you have suggestions feel free to create an Issue or to create a PR with the feature.
45

5-
## v1.1.0:
6+
## v1.1.0:
67
> Release date: 10/Jul/2021
7-
* Add more blocks for `(PATCH): block children` endpoint
8-
* `BulletedList` block
9-
* `NumberedList` block
8+
* Add more blocks support for `(PATCH): block children` endpoint
9+
* `BulletedListItem` block
10+
* `NumberedListItem` block
1011
* `Toggle` block
11-
* Add `Children.with(List<Block> blocks)` constructor
12-
* Add singleton (_if possible_)
13-
* Add `final` for override types to not allow change the field:
14-
* Objects
15-
* Blocks
12+
* Add `children` field for blocks:
13+
* `BulletedListItem`
14+
* `NumberedListItem`
15+
* `ToDo`
16+
* `Toggle`
17+
* `Paragraph`
18+
* Add methods to manipulate `content` and `children` for blocks:
19+
* `addText(String text, {TextAnnotations? annotations})`
20+
* `addChild(Block block)`
21+
* `addChildren(List<Block> blocks)`
22+
* Add `Children.withBlocks(List<Block> blocks)` constructor
23+
* Add `final` for `type` fields to not allow overwrite:
24+
* Objects
25+
* Blocks
26+
* Add `BaseClient` class to avoid duplicated code for clients
27+
* Add `deprecated` annotations for future changes:
28+
* Remove `textSeparation` parameter/field
29+
* Remove `add(Text text)` function
30+
* Remove `texts` getter for `Paragraph`
31+
* Remove named parameters for `Children` class
32+
* Update documentation
1633

1734
## v1.0.2: ✅
1835
> Release date: 05/Jul/2021

example/example.md

Lines changed: 149 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
- [Block children](#block-children)
1212
- [Retrieve block children](#retrieve-block-children)
1313
- [Append block children](#append-block-children)
14-
- [Example](#example)
15-
- [Heading & Paragraph](#heading--paragraph)
16-
- [Code](#code)
17-
- [Result](#result)
18-
- [To do](#to-do)
19-
- [Code](#code-1)
20-
- [Result](#result-1)
14+
- [Heading & Paragraph](#heading--paragraph)
15+
- [To do](#to-do)
16+
- [Toggle](#toggle)
17+
- [Bulleted List Item](#bulleted-list-item)
18+
- [Numbered List Item](#numbered-list-item)
2119

2220
# Initialization
2321
## Full instance
@@ -99,12 +97,11 @@ _Parameters:_
9997
- The `Paragraph` object can contain only `Text` objects.
10098
- `Text` can receive a `TextAnnotations` class with the style of the text.
10199

102-
### Example
103-
#### Heading & Paragraph
104-
##### Code
100+
### Heading & Paragraph
101+
**Code**
105102
```dart
106103
// Create children instance:
107-
// * Old way
104+
// * Deprecated way
108105
// Children oldWay = Children(
109106
// heading: Heading('Test'),
110107
// paragraph: Paragraph(
@@ -127,42 +124,69 @@ Children childrenA = Children().addAll([
127124
Heading(text: Text('Test')),
128125
Paragraph(texts: [
129126
Text('Lorem ipsum (A)'),
130-
Text('Lorem ipsum (B)',
131-
annotations: TextAnnotations(
132-
bold: true,
133-
underline: true,
134-
color: ColorsTypes.Orange,
135-
))
136-
])
127+
Text(
128+
'Lorem ipsum (B)',
129+
annotations: TextAnnotations(
130+
bold: true,
131+
underline: true,
132+
color: ColorsTypes.Orange,
133+
),
134+
),
135+
], children: [
136+
Heading(text: Text('Subtitle'), type: 3),
137+
]),
137138
]);
138139
139140
// * New way using single `add()`
140141
Children childrenB =
141142
Children().add(Heading(text: Text('Test'))).add(Paragraph(texts: [
142143
Text('Lorem ipsum (A)'),
143144
Text('Lorem ipsum (B)',
144-
annotations: TextAnnotations(
145-
bold: true,
146-
underline: true,
147-
color: ColorsTypes.Orange,
148-
))
149-
]));
145+
annotations: TextAnnotations(
146+
bold: true,
147+
underline: true,
148+
color: ColorsTypes.Orange,
149+
),
150+
),
151+
], children: [
152+
Heading(text: Text('Subtitle'), type: 3),
153+
],
154+
));
155+
156+
// * New way using `withBlocks()` constructor
157+
Children childrenC = Children.withBlocks([
158+
Heading(text: Text('Test')),
159+
Paragraph(texts: [
160+
Text('Lorem ipsum (A)'),
161+
Text(
162+
'Lorem ipsum (B)',
163+
annotations: TextAnnotations(
164+
bold: true,
165+
underline: true,
166+
color: ColorsTypes.Orange,
167+
),
168+
),
169+
], children: [
170+
Heading(text: Text('Subtitle'), type: 3),
171+
]),
172+
]);
150173
151174
// Send the instance to Notion
152175
notion.blocks.append(
153176
to: 'YOUR_BLOCK_ID',
154-
children: childrenB, // or `childrenA`, both are the same.
177+
children: childrenA, // or `childrenB` or `childrenC`, any of these will produce the same result.
155178
);
156179
```
157180

158-
##### Result
159-
![heading&paragraph](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/heading_paragraph.png)
181+
**Result**
182+
183+
![heading&paragraph](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/headingAndParagraph.png)
160184

161-
#### To do
162-
##### Code
185+
### To do
186+
**Code**
163187
```dart
164188
// Create children instance:
165-
// * Old way
189+
// * Deprecated way
166190
// Children children =
167191
// Children(
168192
// toDo: [
@@ -181,7 +205,7 @@ notion.blocks.append(
181205
//
182206
// * New way
183207
Children children =
184-
Children().addAll([
208+
Children.withBlocks([
185209
ToDo(text: Text('This is a todo item A')),
186210
ToDo(
187211
texts: [
@@ -192,6 +216,10 @@ Children children =
192216
),
193217
],
194218
),
219+
ToDo(text: Text('Todo item with children'), children: [
220+
BulletedListItem(text: Text('A')),
221+
BulletedListItem(text: Text('B')),
222+
]),
195223
],
196224
);
197225
@@ -202,7 +230,96 @@ notion.blocks.append(
202230
);
203231
```
204232

205-
##### Result
233+
**Result**
206234
![todo](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/todo.png)
207235

236+
### Toggle
237+
**Code**
238+
```dart
239+
Children children =
240+
Children.withBlocks([
241+
Toggle(
242+
text: Text('This is a toggle block'),
243+
children: [
244+
Paragraph(
245+
texts: [
246+
Text(
247+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas venenatis dolor sed ex egestas, et vehicula tellus faucibus. Sed pellentesque tellus eget imperdiet vulputate.')
248+
],
249+
),
250+
BulletedListItem(text: Text('A')),
251+
BulletedListItem(text: Text('B')),
252+
BulletedListItem(text: Text('B')),
253+
],
254+
),
255+
],
256+
);
257+
258+
// Send the instance to Notion
259+
notion.blocks.append(
260+
to: 'YOUR_BLOCK_ID',
261+
children: children,
262+
);
263+
```
264+
**Result**
265+
![toggle](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/toggle.png)
266+
267+
### Bulleted List Item
268+
**Code**
269+
```dart
270+
Children children =
271+
Children.withBlocks([
272+
BulletedListItem(text: Text('This is a bulleted list item A')),
273+
BulletedListItem(text: Text('This is a bulleted list item B')),
274+
BulletedListItem(
275+
text: Text('This is a bulleted list item with children'),
276+
children: [
277+
Paragraph(texts: [
278+
Text('A'),
279+
Text('B'),
280+
Text('C'),
281+
])
282+
],
283+
),
284+
],
285+
);
286+
287+
// Send the instance to Notion
288+
notion.blocks.append(
289+
to: 'YOUR_BLOCK_ID',
290+
children: children,
291+
);
292+
```
293+
**Result**
294+
![bulletedListItem](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/bulletedListItem.png)
295+
296+
### Numbered List Item
297+
**Code**
298+
```dart
299+
Children children =
300+
Children.withBlocks([
301+
NumberedListItem(text: Text('This is a numbered list item A')),
302+
NumberedListItem(text: Text('This is a numbered list item B')),
303+
NumberedListItem(
304+
text: Text('This is a bulleted list item with children'),
305+
children: [
306+
Paragraph(texts: [
307+
Text('A'),
308+
Text('B'),
309+
Text('C'),
310+
])
311+
],
312+
),
313+
],
314+
);
315+
316+
// Send the instance to Notion
317+
notion.blocks.append(
318+
to: 'YOUR_BLOCK_ID',
319+
children: children,
320+
);
321+
```
322+
**Result**
323+
![numberedListItem](https://raw.githubusercontent.com/jonathangomz/notion_api/main/example/images/numberedListItem.png)
324+
208325
[1]: https://developers.notion.com/reference/get-databases
13.9 KB
Loading
10.1 KB
Loading
14.4 KB
Loading

example/images/todo.png

6.69 KB
Loading

example/images/toggle.png

24.1 KB
Loading

0 commit comments

Comments
 (0)