Skip to content

Commit ff4ed43

Browse files
authored
Merge pull request #4 from Brainyoo/add-default-text-style-to-default-styles
Add default text style to default styles
2 parents 8055029 + d135f9b commit ff4ed43

File tree

10 files changed

+184
-34
lines changed

10 files changed

+184
-34
lines changed

lib/src/editor/config/editor_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class QuillEditorConfig {
293293
final double? maxContentWidth;
294294

295295
/// Allows to override [DefaultStyles].
296-
final DefaultStyles? customStyles;
296+
final DefaultStylesOverride? customStyles;
297297

298298
/// Whether this editor's height will be sized to fill its parent.
299299
///
@@ -502,7 +502,7 @@ class QuillEditorConfig {
502502
double? minHeight,
503503
double? maxHeight,
504504
double? maxContentWidth,
505-
DefaultStyles? customStyles,
505+
DefaultStylesOverride? customStyles,
506506
bool? expands,
507507
TextCapitalization? textCapitalization,
508508
Brightness? keyboardAppearance,

lib/src/editor/raw_editor/builders/leading_block_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class LeadingConfig {
2323
required this.value,
2424
required this.onCheckboxTap,
2525
required this.attrs,
26+
this.listPointAlignment,
2627
this.withDot = true,
2728
this.index,
2829
this.lineSize,
@@ -40,6 +41,7 @@ class LeadingConfig {
4041
final TextStyle? style;
4142
final double? width;
4243
final double? padding;
44+
final AlignmentDirectional? listPointAlignment;
4345

4446
// these values are used if the leading is from a check list
4547
final QuillCheckboxBuilder? uiBuilder;

lib/src/editor/raw_editor/config/raw_editor_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ class QuillRawEditorConfig {
285285
/// horizontally centered. This is mostly useful on devices with wide screens.
286286
final double? maxContentWidth;
287287

288-
/// Allows to override [DefaultStyles].
289-
final DefaultStyles? customStyles;
288+
/// Allows to override [DefaultStylesOverride].
289+
final DefaultStylesOverride? customStyles;
290290

291291
/// Whether this widget's height will be sized to fill its parent.
292292
///

lib/src/editor/raw_editor/raw_editor_state.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,13 +942,15 @@ class QuillRawEditorState extends EditorState
942942
void didChangeDependencies() {
943943
super.didChangeDependencies();
944944
final parentStyles = QuillStyles.getStyles(context, true);
945-
final defaultStyles = DefaultStyles.getInstance(context);
945+
final stylesOverride = widget.config.customStyles;
946+
final defaultStyles = DefaultStyles.getInstance(context,
947+
baseStyleOverride: stylesOverride?.defaultTextStyle);
946948
_styles = (parentStyles != null)
947949
? defaultStyles.merge(parentStyles)
948950
: defaultStyles;
949951

950952
if (widget.config.customStyles != null) {
951-
_styles = _styles!.merge(widget.config.customStyles!);
953+
_styles = _styles!.applyOverrides(widget.config.customStyles!);
952954
}
953955

954956
_requestAutoFocusIfShould();
@@ -1001,9 +1003,10 @@ class QuillRawEditorState extends EditorState
10011003
}
10021004
}
10031005

1006+
final stylesOverride = widget.config.customStyles;
10041007
// in case customStyles changed in new widget
1005-
if (widget.config.customStyles != null) {
1006-
_styles = _styles!.merge(widget.config.customStyles!);
1008+
if (stylesOverride != null) {
1009+
_styles = _styles!.applyOverrides(stylesOverride);
10071010
}
10081011

10091012
if (widget.config.actionConfiguration !=

lib/src/editor/style_widgets/bullet_point.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ class QuillBulletPoint extends StatelessWidget {
77
this.padding = 0,
88
this.backgroundColor,
99
this.textAlign,
10+
AlignmentDirectional? alignment,
1011
super.key,
11-
});
12+
}) : alignment = alignment ?? AlignmentDirectional.topEnd;
1213

1314
final TextStyle style;
1415
final double width;
1516
final double padding;
1617
final Color? backgroundColor;
1718
final TextAlign? textAlign;
19+
final AlignmentDirectional alignment;
1820

1921
@override
2022
Widget build(BuildContext context) {
2123
return Container(
22-
alignment: AlignmentDirectional.topEnd,
24+
alignment: alignment,
2325
width: width,
2426
padding: EdgeInsetsDirectional.only(end: padding),
2527
color: backgroundColor,

lib/src/editor/style_widgets/number_point.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class QuillNumberPoint extends StatelessWidget {
1212
this.textAlign,
1313
this.withDot = true,
1414
this.padding = 0.0,
15-
super.key,
1615
this.backgroundColor,
17-
});
16+
AlignmentDirectional? alignment,
17+
super.key,
18+
}) : alignment = alignment ?? AlignmentDirectional.topEnd;
1819

1920
final String index;
2021
final Map<int?, int> indentLevelCounts;
@@ -26,12 +27,13 @@ class QuillNumberPoint extends StatelessWidget {
2627
final double padding;
2728
final Color? backgroundColor;
2829
final TextAlign? textAlign;
30+
final AlignmentDirectional alignment;
2931

3032
@override
3133
Widget build(BuildContext context) {
3234
if (!attrs.containsKey(Attribute.indent.key) && indentLevelCounts.isEmpty) {
3335
return Container(
34-
alignment: AlignmentDirectional.topEnd,
36+
alignment: alignment,
3537
width: width,
3638
padding: EdgeInsetsDirectional.only(end: padding),
3739
color: backgroundColor,
@@ -43,7 +45,7 @@ class QuillNumberPoint extends StatelessWidget {
4345
);
4446
}
4547
return Container(
46-
alignment: AlignmentDirectional.topEnd,
48+
alignment: alignment,
4749
width: width,
4850
padding: EdgeInsetsDirectional.only(end: padding),
4951
color: backgroundColor,

lib/src/editor/widgets/default_leading_components/bullet_point_leading.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Widget bulletPointLeading(LeadingConfig config) => QuillBulletPoint(
66
style: config.style!,
77
width: config.width!,
88
padding: config.padding!,
9+
alignment: config.listPointAlignment,
910
);

lib/src/editor/widgets/default_leading_components/number_point_leading.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Widget numberPointLeading(LeadingConfig config) => QuillNumberPoint(
1010
attrs: config.attrs,
1111
width: config.width!,
1212
padding: config.padding!,
13+
alignment: config.listPointAlignment,
1314
);

0 commit comments

Comments
 (0)