Skip to content

Commit

Permalink
Fix bug #1562
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellet committed Dec 13, 2023
1 parent 15bf6c7 commit 717ecc2
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.
* Add the new translations for ru, uk arb files by [#1575](https://github.com/singerdmx/flutter-quill/pull/1575)
* Add a new dropdown button by [#1575](https://github.com/singerdmx/flutter-quill/pull/1575)
* Update the default style values by [#1575](https://github.com/singerdmx/flutter-quill/pull/1575)
* Fix bug [#1562](https://github.com/singerdmx/flutter-quill/issues/1562)

## 9.0.2-dev.1
* Add configurations for the new dropdown `QuillToolbarSelectHeaderStyleButton`, you can use the orignal one or this
Expand Down
16 changes: 16 additions & 0 deletions example/lib/presentation/quill/my_quill_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ class MyQuillEditor extends StatelessWidget {
scrollController: scrollController,
focusNode: focusNode,
configurations: configurations.copyWith(
elementOptions: const QuillEditorElementOptions(
codeBlock: QuillEditorCodeBlockElementOptions(
enableLineNumbers: true,
),
// orderedList: QuillEditorOrderedListElementOptions(
// backgroundColor: Colors.amber,
// fontColor: Colors.black,
// ),
// unorderedList: QuillEditorUnOrderedListElementOptions(
// backgroundColor: Colors.green,
// fontColor: Colors.red,
// ),
unorderedList: QuillEditorUnOrderedListElementOptions(
useTextColorForDot: false,
),
),
customStyles: const DefaultStyles(
h1: DefaultTextBlockStyle(
TextStyle(
Expand Down
14 changes: 0 additions & 14 deletions example/lib/presentation/quill/quill_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,6 @@ class _QuillScreenState extends State<QuillScreen> {
sharedConfigurations: _sharedConfigurations,
controller: _controller,
readOnly: _isReadOnly,
customStyles: const DefaultStyles(),
elementOptions: const QuillEditorElementOptions(
codeBlock: QuillEditorCodeBlockElementOptions(
enableLineNumbers: true,
),
// orderedList: QuillEditorOrderedListElementOptions(
// backgroundColor: Colors.amber,
// fontColor: Colors.black,
// ),
// unorderedList: QuillEditorUnOrderedListElementOptions(
// backgroundColor: Colors.green,
// fontColor: Colors.red,
// ),
),
),
scrollController: _editorScrollController,
focusNode: _editorFocusNode,
Expand Down
8 changes: 6 additions & 2 deletions lib/src/models/config/editor/elements/list/ordered_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import 'package:flutter/widgets.dart' show Color;

@immutable
class QuillEditorOrderedListElementOptions extends Equatable {
const QuillEditorOrderedListElementOptions(
{this.backgroundColor, this.fontColor});
const QuillEditorOrderedListElementOptions({
this.backgroundColor,
this.fontColor,
this.useTextColorForDot = true,
});

final Color? backgroundColor;
final Color? fontColor;
final bool useTextColorForDot;
@override
List<Object?> get props => [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import 'package:flutter/widgets.dart' show Color;

@immutable
class QuillEditorUnOrderedListElementOptions extends Equatable {
const QuillEditorUnOrderedListElementOptions(
{this.backgroundColor, this.fontColor});
const QuillEditorUnOrderedListElementOptions({
this.backgroundColor,
this.fontColor,
this.useTextColorForDot = true,
});

final Color? backgroundColor;
final Color? fontColor;
final bool useTextColorForDot;
@override
List<Object?> get props => [];
}
30 changes: 27 additions & 3 deletions lib/src/widgets/quill/text_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../others/text_selection.dart';
import '../style_widgets/bullet_point.dart';
import '../style_widgets/checkbox_point.dart';
import '../style_widgets/number_point.dart';
import '../toolbar/base_toolbar.dart';
import 'quill_controller.dart';
import 'text_line.dart';

Expand Down Expand Up @@ -211,12 +212,29 @@ class EditableTextBlock extends StatelessWidget {
final fontSize = defaultStyles.paragraph?.style.fontSize ?? 16;
final attrs = line.style.attributes;

final fontColor =
line.toDelta().operations.first.attributes?[Attribute.color.key] != null
? hexToColor(
line
.toDelta()
.operations
.first
.attributes?[Attribute.color.key],
)
: null;

if (attrs[Attribute.list.key] == Attribute.ol) {
return QuillEditorNumberPoint(
index: index,
indentLevelCounts: indentLevelCounts,
count: count,
style: defaultStyles.leading!.style,
style: defaultStyles.leading!.style.copyWith(
color: context.quillEditorElementOptions?.orderedList
.useTextColorForDot ==
true
? fontColor
: null,
),
attrs: attrs,
width: _numberPointWidth(fontSize, count),
padding: fontSize / 2,
Expand All @@ -225,8 +243,14 @@ class EditableTextBlock extends StatelessWidget {

if (attrs[Attribute.list.key] == Attribute.ul) {
return QuillEditorBulletPoint(
style:
defaultStyles.leading!.style.copyWith(fontWeight: FontWeight.bold),
style: defaultStyles.leading!.style.copyWith(
fontWeight: FontWeight.bold,
color: context.quillEditorElementOptions?.unorderedList
.useTextColorForDot ==
true
? fontColor
: null,
),
width: fontSize * 2,
padding: fontSize / 2,
);
Expand Down

0 comments on commit 717ecc2

Please sign in to comment.