Skip to content

Commit 23d7354

Browse files
author
CatHood0
committed
Chore: some fixes in documentation
1 parent 701605f commit 23d7354

File tree

5 files changed

+88
-21
lines changed

5 files changed

+88
-21
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.1.3
2+
3+
* Fix: `Line` class description in README.
4+
* Chore: added documentation in migration about the change in `Line` class
5+
16
## 1.1.2
27

38
* Fix: typo in documentation about `mergerBuilder` in `DocumentParser`.

README.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A Flutter package designed to transform `Flutter Quill` content into a structure
44

55
> [!TIP]
66
>
7-
> If you're using version 1.0.6 or minor versions, see [the migration guide to migrate to 1.1.2](https://github.com/CatHood0/flutter_quill_delta_easy_parser/blob/Main/doc/v106_to_v112.md).
7+
> If you're using version 1.0.6 or minor versions, see [the migration guide to migrate to 1.1.3](https://github.com/CatHood0/flutter_quill_delta_easy_parser/blob/Main/doc/v106_to_v113.md).
88
99
## Usage Example
1010

@@ -128,6 +128,20 @@ final Document document = Document(paragraphs: [
128128
*/
129129
```
130130

131+
## MergerBuilder
132+
133+
`MergerBuilder` is an abstract class that allows us to implement our own logic to join different paragraphs. By default, `DocumentParser` implements `CommonMergerBuilder`, which focuses on joining paragraphs that maintain the same types, or the same block-attributes.
134+
135+
Currently, only **3** implementations are available:
136+
137+
* `NoMergerBuilder`: does not execute any code and returns the paragraphs as they are created.
138+
* `BlockMergerBuilder`: joins all paragraphs that contain the same block-attributes (in a row, from the first to the last, not randomly).
139+
* `CommonMergerBuilder` (we already described it above).
140+
141+
```dart
142+
final parser = DocumentParser(mergerBuilder: <the-merger-that-you-want>);
143+
```
144+
131145
## About the `Paragraph`, `Line` and `TextFragment` API
132146

133147
### The Paragraph Format
@@ -171,7 +185,7 @@ class Paragraph {
171185

172186
### Line
173187

174-
A `Line` represents a segment of content within a `Paragraph`. This content can be a simple `String` of characters or a more complex structure such as an `embed`.
188+
`Line` class represents a section of the `paragraph` separates of its siblings.
175189

176190
```dart
177191
class Line {
@@ -193,6 +207,37 @@ class Line {
193207
}
194208
```
195209

210+
This is useful when we have a **list**, **code-block** or **blockquote**, because every "`Line`" represents another item an allow us create them without make a manual accumulation. By default, all of them are merged using `mergerBuilder` and passing `CommonMergerBuilder` in `DocumentParser`, but, if you want to avoid merge any `Paragraph` with its similar parts, then just use `NoMergerBuilder`.
211+
212+
You can see now it, like this plain text diagram representation:
213+
```
214+
--------------Paragraph------------------
215+
| 1. This is a ordered list item |
216+
| 2. This is another ordered list item |
217+
| 3. Just a different ordered list item |
218+
-----------------------------------------
219+
```
220+
221+
Its similar to create a `Paragraph` like (just when `BlockMergerBuilder` or `CommonMergerBuilder` is being used):
222+
223+
```dart
224+
Paragraph(
225+
lines: [
226+
Line(fragments: [
227+
TextFragment(data: 'This is a ordered list item')
228+
]),
229+
Line(fragments: [
230+
TextFragment(data: 'This is another ordered list item'),
231+
]),
232+
Line(fragments: [
233+
TextFragment(data: 'Just a different ordered list item'),
234+
]),
235+
],
236+
blockAttributes: {'list': 'ordered'},
237+
type: ParagraphType.block,
238+
);
239+
```
240+
196241
### TextFragment
197242

198243
A `TextFragment` represents a segment of content within a `Paragraph`. This content can be a simple String of characters or a more complex structure such as an embed.
@@ -242,20 +287,6 @@ final Paragraph bulletListParagraph = Paragraph(
242287
);
243288
```
244289

245-
## MergerBuilder
246-
247-
`MergerBuilder` is an abstract class that allows us to implement our own logic to join different paragraphs. By default, `DocumentParser` implements `CommonMergerBuilder`, which focuses on joining paragraphs that maintain the same types, or the same block-attributes.
248-
249-
Currently, only **3** implementations are available:
250-
251-
* `NoMergerBuilder`: does not execute any code and returns the paragraphs as they are created.
252-
* `BlockMergerBuilder`: joins all paragraphs that contain the same block-attributes (in a row, from the first to the last, not randomly).
253-
* `CommonMergerBuilder` (we already described it above).
254-
255-
```dart
256-
final parser = DocumentParser(mergerBuilder: <the-merger-that-you-want>);
257-
```
258-
259290
See the test folder for detailed usage examples and test cases.
260291

261292
## License

doc/migrations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## Migration Guides
22

3-
* [1.0.6 to 1.1.2](https://github.com/CatHood0/flutter_quill_delta_easy_parser/blob/Main/doc/v106_to_v112.md)
3+
* [1.0.6 to 1.1.3](https://github.com/CatHood0/flutter_quill_delta_easy_parser/blob/Main/doc/v106_to_v113.md)
Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# 🔄 Migration from 1.0.* to 1.1.2
1+
# 🔄 Migration from 1.0.* to 1.1.3
22

3-
If you're using version **v1.0.6** or minor, we recommend fixing all the deprecations before migrating to **v1.1.2** for a smoother migration.
3+
If you're using version **v1.0.6** or minor, we recommend fixing all the deprecations before migrating to **v1.1.3** for a smoother migration.
44

5-
## Parser
5+
## RichTextParser deprecation
66

77
The `RichTextParser` has been deprecated and will not have any type of support. By this, we strongly recommend use `DocumentParser` instead.
88

@@ -11,6 +11,37 @@ The `RichTextParser` has been deprecated and will not have any type of support.
1111
+ DocumentParser().parseDelta(delta: delta);
1212
```
1313

14+
## Line
15+
16+
Now, `Line` class represents a section of the `paragraph` separates of its siblings. This is useful when we have a **list**, **code-block** or **blockquote**, because every "`Line`" represents another item an allow us create them without make a manual accumulation. By default, all of them are merged using `mergerBuilder` and passing `CommonMergerBuilder` in `DocumentParser`, but, if you want to avoid merge any `Paragraph` with its similar parts, then just use `NoMergerBuilder`.
17+
18+
You can see now it, like this representation:
19+
```
20+
--------------Paragraph------------------
21+
| 1. This is a ordered list item |
22+
| 2. This is another ordered list item |
23+
| 3. Just a different ordered list item |
24+
-----------------------------------------
25+
```
26+
27+
Its similar to create a `Paragraph` like:
28+
```dart
29+
Paragraph(
30+
lines: [
31+
Line(fragments: [
32+
TextFragment(data: 'This is a ordered list item')
33+
]),
34+
Line(fragments: [
35+
TextFragment(data: 'This is another ordered list item'),
36+
]),
37+
Line(fragments: [
38+
TextFragment(data: 'Just a different ordered list item'),
39+
]),
40+
],
41+
blockAttributes: {'list': 'ordered'},
42+
type: ParagraphType.block,
43+
);
44+
```
1445
## Paragraph
1546

1647
The `Paragraph` now use another type of format, where the `Line` represents a new section of the `Paragraph`.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_quill_delta_easy_parser
22
description: "Convert your Quill Delta into a simple document format, that makes more simple manipulate text/block attributes"
3-
version: 1.1.2
3+
version: 1.1.3
44
documentation: https://github.com/CatHood0/flutter_quill_delta_easy_parser
55
homepage: https://github.com/CatHood0/flutter_quill_delta_easy_parser
66
issue_tracker: https://github.com/CatHood0/flutter_quill_delta_easy_parser/issues

0 commit comments

Comments
 (0)