From 3be21fbac91b4dc880767c3ae845ad98bdb8c9d0 Mon Sep 17 00:00:00 2001 From: Ellet Date: Wed, 6 Dec 2023 21:09:20 +0300 Subject: [PATCH] Prepare dev version 6 --- CHANGELOG.md | 1 + .../lib/presentation/quill/quill_screen.dart | 13 +++++++++++++ flutter_quill_extensions/CHANGELOG.md | 7 +++++++ flutter_quill_extensions/pubspec.yaml | 2 +- flutter_quill_test/CHANGELOG.md | 7 +++++++ flutter_quill_test/pubspec.yaml | 2 +- .../extensions/quill_configurations_ext.dart | 12 ++++++------ .../models/config/editor/element_options.dart | 9 +++++++++ .../editor/elements/list/ordered_list.dart | 14 ++++++++++++++ .../editor/elements/list/unordered_list.dart | 14 ++++++++++++++ .../toolbar/buttons/indent_configurations.dart | 3 ++- .../widgets/style_widgets/bullet_point.dart | 10 +++++++++- .../widgets/style_widgets/number_point.dart | 9 ++++++++- .../buttons/select_header_style_button.dart | 1 + .../toolbar/buttons/toggle_style_button.dart | 10 +++++----- lib/src/widgets/utils/provider.dart | 18 +++++++++--------- packages/quill_html_converter/CHANGELOG.md | 7 +++++++ packages/quill_html_converter/pubspec.yaml | 2 +- pubspec.yaml | 2 +- version.dart | 2 +- 20 files changed, 117 insertions(+), 28 deletions(-) create mode 100644 lib/src/models/config/editor/elements/list/ordered_list.dart create mode 100644 lib/src/models/config/editor/elements/list/unordered_list.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index a07d0fde8..4102bf777 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ## 9.0.0-dev-6 * Move the `child` from `QuillToolbarConfigurations` into `QuillToolbar` directly * Bug fixes +* Add the ability to change the background and font color of the ol/ul elements dots and numbers * Flutter Quill Extensions: * **Breaking Change**: The `imageProviderBuilder`is now providing the context and image url diff --git a/example/lib/presentation/quill/quill_screen.dart b/example/lib/presentation/quill/quill_screen.dart index 0cf6eea0b..e032cb446 100644 --- a/example/lib/presentation/quill/quill_screen.dart +++ b/example/lib/presentation/quill/quill_screen.dart @@ -115,6 +115,19 @@ class _QuillScreenState extends State { sharedConfigurations: _sharedConfigurations, controller: _controller, readOnly: _isReadOnly, + 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, diff --git a/flutter_quill_extensions/CHANGELOG.md b/flutter_quill_extensions/CHANGELOG.md index 14612cdd2..4102bf777 100644 --- a/flutter_quill_extensions/CHANGELOG.md +++ b/flutter_quill_extensions/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## 9.0.0-dev-6 +* Move the `child` from `QuillToolbarConfigurations` into `QuillToolbar` directly +* Bug fixes +* Add the ability to change the background and font color of the ol/ul elements dots and numbers +* Flutter Quill Extensions: + * **Breaking Change**: The `imageProviderBuilder`is now providing the context and image url + ## 9.0.0-dev-5 * The `QuillToolbar` is now accepting only `child` with no configurations so you can customize everything you wants, the `QuillToolbar.simple()` or `QuillSimpleToolbar` implements a simple toolbar that is based on `QuillToolbar`, you are free to use it but it just an example and not standard * Flutter Quill Extensions: diff --git a/flutter_quill_extensions/pubspec.yaml b/flutter_quill_extensions/pubspec.yaml index 9d96edaf0..c80463aa3 100644 --- a/flutter_quill_extensions/pubspec.yaml +++ b/flutter_quill_extensions/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill_extensions description: Embed extensions for flutter_quill including image, video, formula and etc. -version: 9.0.0-dev-5 +version: 9.0.0-dev-6 homepage: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions/ repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_extensions/ issue_tracker: https://github.com/singerdmx/flutter-quill/issues/ diff --git a/flutter_quill_test/CHANGELOG.md b/flutter_quill_test/CHANGELOG.md index 14612cdd2..4102bf777 100644 --- a/flutter_quill_test/CHANGELOG.md +++ b/flutter_quill_test/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## 9.0.0-dev-6 +* Move the `child` from `QuillToolbarConfigurations` into `QuillToolbar` directly +* Bug fixes +* Add the ability to change the background and font color of the ol/ul elements dots and numbers +* Flutter Quill Extensions: + * **Breaking Change**: The `imageProviderBuilder`is now providing the context and image url + ## 9.0.0-dev-5 * The `QuillToolbar` is now accepting only `child` with no configurations so you can customize everything you wants, the `QuillToolbar.simple()` or `QuillSimpleToolbar` implements a simple toolbar that is based on `QuillToolbar`, you are free to use it but it just an example and not standard * Flutter Quill Extensions: diff --git a/flutter_quill_test/pubspec.yaml b/flutter_quill_test/pubspec.yaml index 2283a901b..e936801db 100644 --- a/flutter_quill_test/pubspec.yaml +++ b/flutter_quill_test/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill_test description: Test utilities for flutter_quill which includes methods to simplify interacting with the editor in test cases. -version: 9.0.0-dev-5 +version: 9.0.0-dev-6 homepage: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_test/ repository: https://github.com/singerdmx/flutter-quill/tree/master/flutter_quill_test/ issue_tracker: https://github.com/singerdmx/flutter-quill/issues/ diff --git a/lib/src/extensions/quill_configurations_ext.dart b/lib/src/extensions/quill_configurations_ext.dart index a7da7df35..5ca2e5e17 100644 --- a/lib/src/extensions/quill_configurations_ext.dart +++ b/lib/src/extensions/quill_configurations_ext.dart @@ -29,12 +29,12 @@ extension QuillSharedExt on BuildContext { extension QuillEditorExt on BuildContext { /// return [QuillEditorConfigurations] as not null QuillEditorConfigurations get requireQuillEditorConfigurations { - return QuillEditorProvider.ofNotNull(this).editorConfigurations; + return QuillEditorProvider.of(this).editorConfigurations; } /// return nullable [QuillEditorConfigurations] QuillEditorConfigurations? get quillEditorConfigurations { - return QuillEditorProvider.of(this)?.editorConfigurations; + return QuillEditorProvider.maybeOf(this)?.editorConfigurations; } /// return nullable [QuillToolbarBaseButtonOptions]. Since the quill @@ -57,12 +57,12 @@ extension QuillEditorExt on BuildContext { extension QuillSimpleToolbarExt on BuildContext { /// return [QuillSimpleToolbarConfigurations] as not null QuillSimpleToolbarConfigurations get requireQuillSimpleToolbarConfigurations { - return QuillSimpleToolbarProvider.ofNotNull(this).toolbarConfigurations; + return QuillSimpleToolbarProvider.of(this).toolbarConfigurations; } /// return nullable [QuillSimpleToolbarConfigurations] QuillSimpleToolbarConfigurations? get quillSimpleToolbarConfigurations { - return QuillSimpleToolbarProvider.of(this)?.toolbarConfigurations; + return QuillSimpleToolbarProvider.maybeOf(this)?.toolbarConfigurations; } /// return nullable [QuillToolbarBaseButtonOptions]. @@ -83,11 +83,11 @@ extension QuillSimpleToolbarExt on BuildContext { extension QuillToolbarExt on BuildContext { /// return [QuillToolbarConfigurations] as not null QuillToolbarConfigurations get requireQuillToolbarConfigurations { - return QuillToolbarProvider.ofNotNull(this).toolbarConfigurations; + return QuillToolbarProvider.of(this).toolbarConfigurations; } /// return nullable [QuillToolbarConfigurations]. QuillToolbarConfigurations? get quillToolbarConfigurations { - return QuillToolbarProvider.of(this)?.toolbarConfigurations; + return QuillToolbarProvider.maybeOf(this)?.toolbarConfigurations; } } diff --git a/lib/src/models/config/editor/element_options.dart b/lib/src/models/config/editor/element_options.dart index a2c20171e..f083f692e 100644 --- a/lib/src/models/config/editor/element_options.dart +++ b/lib/src/models/config/editor/element_options.dart @@ -2,16 +2,25 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart' show immutable; import 'elements/code_block.dart'; +import 'elements/list/ordered_list.dart'; +import 'elements/list/unordered_list.dart'; export 'elements/code_block.dart'; +export 'elements/list/ordered_list.dart'; +export 'elements/list/unordered_list.dart'; @immutable class QuillEditorElementOptions extends Equatable { const QuillEditorElementOptions({ this.codeBlock = const QuillEditorCodeBlockElementOptions(), + this.orderedList = const QuillEditorOrderedListElementOptions(), + this.unorderedList = const QuillEditorUnOrderedListElementOptions(), }); final QuillEditorCodeBlockElementOptions codeBlock; + + final QuillEditorOrderedListElementOptions orderedList; + final QuillEditorUnOrderedListElementOptions unorderedList; @override List get props => [ codeBlock, diff --git a/lib/src/models/config/editor/elements/list/ordered_list.dart b/lib/src/models/config/editor/elements/list/ordered_list.dart new file mode 100644 index 000000000..b48252991 --- /dev/null +++ b/lib/src/models/config/editor/elements/list/ordered_list.dart @@ -0,0 +1,14 @@ +import 'package:equatable/equatable.dart'; +import 'package:flutter/foundation.dart' show immutable; +import 'package:flutter/widgets.dart' show Color; + +@immutable +class QuillEditorOrderedListElementOptions extends Equatable { + const QuillEditorOrderedListElementOptions( + {this.backgroundColor, this.fontColor}); + + final Color? backgroundColor; + final Color? fontColor; + @override + List get props => []; +} diff --git a/lib/src/models/config/editor/elements/list/unordered_list.dart b/lib/src/models/config/editor/elements/list/unordered_list.dart new file mode 100644 index 000000000..3fe570eb2 --- /dev/null +++ b/lib/src/models/config/editor/elements/list/unordered_list.dart @@ -0,0 +1,14 @@ +import 'package:equatable/equatable.dart'; +import 'package:flutter/foundation.dart' show immutable; +import 'package:flutter/widgets.dart' show Color; + +@immutable +class QuillEditorUnOrderedListElementOptions extends Equatable { + const QuillEditorUnOrderedListElementOptions( + {this.backgroundColor, this.fontColor}); + + final Color? backgroundColor; + final Color? fontColor; + @override + List get props => []; +} diff --git a/lib/src/models/config/toolbar/buttons/indent_configurations.dart b/lib/src/models/config/toolbar/buttons/indent_configurations.dart index 4328796ad..559217e7b 100644 --- a/lib/src/models/config/toolbar/buttons/indent_configurations.dart +++ b/lib/src/models/config/toolbar/buttons/indent_configurations.dart @@ -12,7 +12,8 @@ class QuillToolbarIndentButtonExtraOptions } @immutable -class QuillToolbarIndentButtonOptions extends QuillToolbarBaseButtonOptions { +class QuillToolbarIndentButtonOptions extends QuillToolbarBaseButtonOptions< + QuillToolbarIndentButtonOptions, QuillToolbarIndentButtonExtraOptions> { const QuillToolbarIndentButtonOptions({ super.iconData, super.afterButtonPressed, diff --git a/lib/src/widgets/style_widgets/bullet_point.dart b/lib/src/widgets/style_widgets/bullet_point.dart index 1dd1b4cf5..629c68e6d 100644 --- a/lib/src/widgets/style_widgets/bullet_point.dart +++ b/lib/src/widgets/style_widgets/bullet_point.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import '../../extensions/quill_configurations_ext.dart'; + class QuillEditorBulletPoint extends StatelessWidget { const QuillEditorBulletPoint({ required this.style, @@ -18,7 +20,13 @@ class QuillEditorBulletPoint extends StatelessWidget { alignment: AlignmentDirectional.topEnd, width: width, padding: EdgeInsetsDirectional.only(end: padding), - child: Text('•', style: style), + color: context.quillEditorElementOptions?.unorderedList.backgroundColor, + child: Text( + '•', + style: style.copyWith( + color: context.quillEditorElementOptions?.unorderedList.fontColor, + ), + ), ); } } diff --git a/lib/src/widgets/style_widgets/number_point.dart b/lib/src/widgets/style_widgets/number_point.dart index 9809f4ac7..307a8ebe2 100644 --- a/lib/src/widgets/style_widgets/number_point.dart +++ b/lib/src/widgets/style_widgets/number_point.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; +import '../../extensions/quill_configurations_ext.dart'; import '../../models/documents/attribute.dart'; import '../others/text_block.dart'; @@ -67,7 +68,13 @@ class QuillEditorNumberPoint extends StatelessWidget { alignment: AlignmentDirectional.topEnd, width: width, padding: EdgeInsetsDirectional.only(end: padding), - child: Text(withDot ? '$s.' : s, style: style), + color: context.quillEditorElementOptions?.orderedList.backgroundColor, + child: Text( + withDot ? '$s.' : s, + style: style.copyWith( + color: context.quillEditorElementOptions?.orderedList.fontColor, + ), + ), ); } diff --git a/lib/src/widgets/toolbar/buttons/select_header_style_button.dart b/lib/src/widgets/toolbar/buttons/select_header_style_button.dart index 59f66d8d7..189146a8e 100644 --- a/lib/src/widgets/toolbar/buttons/select_header_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/select_header_style_button.dart @@ -20,6 +20,7 @@ class QuillToolbarSelectHeaderStyleButton extends StatefulWidget { }); final QuillController controller; + // TODO: Needs to be reviewed final QuillToolbarSelectHeaderStyleButtonsOptions options; @override diff --git a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart index 2ea43f97b..345f339d9 100644 --- a/lib/src/widgets/toolbar/buttons/toggle_style_button.dart +++ b/lib/src/widgets/toolbar/buttons/toggle_style_button.dart @@ -76,12 +76,12 @@ class QuillToolbarToggleStyleButtonState VoidCallback? get afterButtonPressed { return options.afterButtonPressed ?? - context.requireQuillToolbarBaseButtonOptions.afterButtonPressed; + context.quillToolbarBaseButtonOptions?.afterButtonPressed; } QuillIconTheme? get iconTheme { return options.iconTheme ?? - context.requireQuillToolbarBaseButtonOptions.iconTheme; + context.quillToolbarBaseButtonOptions?.iconTheme; } (String, IconData) get _defaultTooltipAndIconData { @@ -132,13 +132,13 @@ class QuillToolbarToggleStyleButtonState String? get tooltip { return options.tooltip ?? - context.requireQuillToolbarBaseButtonOptions.tooltip ?? + context.quillToolbarBaseButtonOptions?.tooltip ?? _defaultTooltipAndIconData.$1; } IconData get iconData { return options.iconData ?? - context.requireQuillToolbarBaseButtonOptions.iconData ?? + context.quillToolbarBaseButtonOptions?.iconData ?? _defaultTooltipAndIconData.$2; } @@ -150,7 +150,7 @@ class QuillToolbarToggleStyleButtonState @override Widget build(BuildContext context) { final childBuilder = options.childBuilder ?? - context.requireQuillToolbarBaseButtonOptions.childBuilder; + context.quillToolbarBaseButtonOptions?.childBuilder; if (childBuilder != null) { return childBuilder( QuillToolbarToggleStyleButtonOptions( diff --git a/lib/src/widgets/utils/provider.dart b/lib/src/widgets/utils/provider.dart index 57f9cf15f..c0d40e73a 100644 --- a/lib/src/widgets/utils/provider.dart +++ b/lib/src/widgets/utils/provider.dart @@ -20,14 +20,14 @@ class QuillSimpleToolbarProvider extends InheritedWidget { return oldWidget.toolbarConfigurations != toolbarConfigurations; } - static QuillSimpleToolbarProvider? of(BuildContext context) { + static QuillSimpleToolbarProvider? maybeOf(BuildContext context) { /// The configurations for the quill editor widget of flutter quill return context .dependOnInheritedWidgetOfExactType(); } - static QuillSimpleToolbarProvider ofNotNull(BuildContext context) { - final provider = of(context); + static QuillSimpleToolbarProvider of(BuildContext context) { + final provider = maybeOf(context); if (provider == null) { if (kDebugMode) { debugPrint( @@ -79,13 +79,13 @@ class QuillToolbarProvider extends InheritedWidget { return oldWidget.toolbarConfigurations != toolbarConfigurations; } - static QuillToolbarProvider? of(BuildContext context) { + static QuillToolbarProvider? maybeOf(BuildContext context) { /// The configurations for the quill editor widget of flutter quill return context.dependOnInheritedWidgetOfExactType(); } - static QuillToolbarProvider ofNotNull(BuildContext context) { - final provider = of(context); + static QuillToolbarProvider of(BuildContext context) { + final provider = maybeOf(context); if (provider == null) { if (kDebugMode) { debugPrint( @@ -136,13 +136,13 @@ class QuillEditorProvider extends InheritedWidget { return oldWidget.editorConfigurations != editorConfigurations; } - static QuillEditorProvider? of(BuildContext context) { + static QuillEditorProvider? maybeOf(BuildContext context) { /// The configurations for the quill editor widget of flutter quill return context.dependOnInheritedWidgetOfExactType(); } - static QuillEditorProvider ofNotNull(BuildContext context) { - final provider = of(context); + static QuillEditorProvider of(BuildContext context) { + final provider = maybeOf(context); if (provider == null) { if (kDebugMode) { debugPrint( diff --git a/packages/quill_html_converter/CHANGELOG.md b/packages/quill_html_converter/CHANGELOG.md index 14612cdd2..4102bf777 100644 --- a/packages/quill_html_converter/CHANGELOG.md +++ b/packages/quill_html_converter/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. +## 9.0.0-dev-6 +* Move the `child` from `QuillToolbarConfigurations` into `QuillToolbar` directly +* Bug fixes +* Add the ability to change the background and font color of the ol/ul elements dots and numbers +* Flutter Quill Extensions: + * **Breaking Change**: The `imageProviderBuilder`is now providing the context and image url + ## 9.0.0-dev-5 * The `QuillToolbar` is now accepting only `child` with no configurations so you can customize everything you wants, the `QuillToolbar.simple()` or `QuillSimpleToolbar` implements a simple toolbar that is based on `QuillToolbar`, you are free to use it but it just an example and not standard * Flutter Quill Extensions: diff --git a/packages/quill_html_converter/pubspec.yaml b/packages/quill_html_converter/pubspec.yaml index dd996a3f8..4f5d6e553 100644 --- a/packages/quill_html_converter/pubspec.yaml +++ b/packages/quill_html_converter/pubspec.yaml @@ -1,6 +1,6 @@ name: quill_html_converter description: A extension for flutter_quill package to add support for dealing with conversion to/from html -version: 9.0.0-dev-5 +version: 9.0.0-dev-6 homepage: https://github.com/singerdmx/flutter-quill/tree/master/packages/quill_html_converter/ repository: https://github.com/singerdmx/flutter-quill/tree/master/packages/quill_html_converter/ issue_tracker: https://github.com/singerdmx/flutter-quill/issues/ diff --git a/pubspec.yaml b/pubspec.yaml index a57fa2262..9f99953bc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_quill description: A rich text editor built for the modern Android, iOS, web and desktop platforms. It is the WYSIWYG editor and a Quill component for Flutter. -version: 9.0.0-dev-5 +version: 9.0.0-dev-6 homepage: https://1o24bbs.com/c/bulletjournal/108/ repository: https://github.com/singerdmx/flutter-quill/ issue_tracker: https://github.com/singerdmx/flutter-quill/issues/ diff --git a/version.dart b/version.dart index 5b59c4d6b..123f4db07 100644 --- a/version.dart +++ b/version.dart @@ -1 +1 @@ -const version = '9.0.0-dev-5'; +const version = '9.0.0-dev-6';