Add the ability to use custom widgets for lists

pull/1613/head
Ellet 1 year ago
parent 13bec3bdd2
commit d1b8e36ff0
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 3
      CHANGELOG.md
  2. 13
      example/lib/presentation/quill/my_quill_editor.dart
  3. 3
      lib/src/models/config/editor/elements/list/ordered_list.dart
  4. 3
      lib/src/models/config/editor/elements/list/unordered_list.dart
  5. 14
      lib/src/widgets/style_widgets/bullet_point.dart
  6. 26
      lib/src/widgets/style_widgets/number_point.dart

@ -2,6 +2,9 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## 9.0.4
* Feature: [#1611](https://github.com/singerdmx/flutter-quill/issues/1611)
## 9.0.3 ## 9.0.3
* Flutter Quill Extensions: * Flutter Quill Extensions:
* Fix file image support for web image emebed builder * Fix file image support for web image emebed builder

@ -37,16 +37,11 @@ class MyQuillEditor extends StatelessWidget {
codeBlock: QuillEditorCodeBlockElementOptions( codeBlock: QuillEditorCodeBlockElementOptions(
enableLineNumbers: true, enableLineNumbers: true,
), ),
// orderedList: QuillEditorOrderedListElementOptions( orderedList: QuillEditorOrderedListElementOptions(
// backgroundColor: Colors.amber, customWidget: Icon(Icons.add),
// fontColor: Colors.black, ),
// ),
// unorderedList: QuillEditorUnOrderedListElementOptions(
// backgroundColor: Colors.green,
// fontColor: Colors.red,
// ),
unorderedList: QuillEditorUnOrderedListElementOptions( unorderedList: QuillEditorUnOrderedListElementOptions(
useTextColorForDot: false, useTextColorForDot: true,
), ),
), ),
customStyles: const DefaultStyles( customStyles: const DefaultStyles(

@ -1,13 +1,16 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/foundation.dart' show immutable;
import 'package:flutter/widgets.dart' show Widget;
@immutable @immutable
class QuillEditorOrderedListElementOptions extends Equatable { class QuillEditorOrderedListElementOptions extends Equatable {
const QuillEditorOrderedListElementOptions({ const QuillEditorOrderedListElementOptions({
this.useTextColorForDot = true, this.useTextColorForDot = true,
this.customWidget,
}); });
final bool useTextColorForDot; final bool useTextColorForDot;
final Widget? customWidget;
@override @override
List<Object?> get props => []; List<Object?> get props => [];
} }

@ -1,13 +1,16 @@
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/foundation.dart' show immutable;
import 'package:flutter/widgets.dart' show Widget;
@immutable @immutable
class QuillEditorUnOrderedListElementOptions extends Equatable { class QuillEditorUnOrderedListElementOptions extends Equatable {
const QuillEditorUnOrderedListElementOptions({ const QuillEditorUnOrderedListElementOptions({
this.useTextColorForDot = true, this.useTextColorForDot = true,
this.customWidget,
}); });
final bool useTextColorForDot; final bool useTextColorForDot;
final Widget? customWidget;
@override @override
List<Object?> get props => []; List<Object?> get props => [];
} }

@ -1,5 +1,7 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import '../../extensions/quill_configurations_ext.dart';
class QuillEditorBulletPoint extends StatelessWidget { class QuillEditorBulletPoint extends StatelessWidget {
const QuillEditorBulletPoint({ const QuillEditorBulletPoint({
required this.style, required this.style,
@ -23,11 +25,13 @@ class QuillEditorBulletPoint extends StatelessWidget {
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: padding), padding: EdgeInsetsDirectional.only(end: padding),
color: backgroundColor, color: backgroundColor,
child: Text( child: context.quillEditorConfigurations?.elementOptions.unorderedList
'', .customWidget ??
style: style, Text(
textAlign: textAlign, '',
), style: style,
textAlign: textAlign,
),
); );
} }
} }

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../models/documents/attribute.dart'; import '../../../flutter_quill.dart';
import '../quill/text_block.dart'; import '../quill/text_block.dart';
class QuillEditorNumberPoint extends StatelessWidget { class QuillEditorNumberPoint extends StatelessWidget {
@ -41,11 +41,13 @@ class QuillEditorNumberPoint extends StatelessWidget {
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: padding), padding: EdgeInsetsDirectional.only(end: padding),
color: backgroundColor, color: backgroundColor,
child: Text( child: context.quillEditorConfigurations?.elementOptions.orderedList
withDot ? '$s.' : s, .customWidget ??
style: style, Text(
textAlign: textAlign, withDot ? '$s.' : s,
), style: style,
textAlign: textAlign,
),
); );
} }
if (attrs.containsKey(Attribute.indent.key)) { if (attrs.containsKey(Attribute.indent.key)) {
@ -77,11 +79,13 @@ class QuillEditorNumberPoint extends StatelessWidget {
width: width, width: width,
padding: EdgeInsetsDirectional.only(end: padding), padding: EdgeInsetsDirectional.only(end: padding),
color: backgroundColor, color: backgroundColor,
child: Text( child: context.quillEditorConfigurations?.elementOptions.orderedList
withDot ? '$s.' : s, .customWidget ??
style: style, Text(
textAlign: textAlign, withDot ? '$s.' : s,
), style: style,
textAlign: textAlign,
),
); );
} }

Loading…
Cancel
Save