You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-16Lines changed: 47 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ A Flutter package designed to transform `Flutter Quill` content into a structure
4
4
5
5
> [!TIP]
6
6
>
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).
8
8
9
9
## Usage Example
10
10
@@ -128,6 +128,20 @@ final Document document = Document(paragraphs: [
128
128
*/
129
129
```
130
130
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
+
131
145
## About the `Paragraph`, `Line` and `TextFragment` API
132
146
133
147
### The Paragraph Format
@@ -171,7 +185,7 @@ class Paragraph {
171
185
172
186
### Line
173
187
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.
175
189
176
190
```dart
177
191
class Line {
@@ -193,6 +207,37 @@ class Line {
193
207
}
194
208
```
195
209
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
+
196
241
### TextFragment
197
242
198
243
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(
242
287
);
243
288
```
244
289
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
-
259
290
See the test folder for detailed usage examples and test cases.
Copy file name to clipboardExpand all lines: doc/v106_to_v113.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# 🔄 Migration from 1.0.* to 1.1.2
1
+
# 🔄 Migration from 1.0.* to 1.1.3
2
2
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.
4
4
5
-
## Parser
5
+
## RichTextParser deprecation
6
6
7
7
The `RichTextParser` has been deprecated and will not have any type of support. By this, we strongly recommend use `DocumentParser` instead.
8
8
@@ -11,6 +11,37 @@ The `RichTextParser` has been deprecated and will not have any type of support.
11
11
+ DocumentParser().parseDelta(delta: delta);
12
12
```
13
13
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
+
```
14
45
## Paragraph
15
46
16
47
The `Paragraph` now use another type of format, where the `Line` represents a new section of the `Paragraph`.
0 commit comments