From e78a571b145c8491fd43a6d99dd8fe19122b567b Mon Sep 17 00:00:00 2001 From: Ahmed Hnewa <73608287+freshtechtips@users.noreply.github.com> Date: Wed, 25 Oct 2023 04:31:43 +0300 Subject: [PATCH] Change blocks to element --- .../models/config/editor/block_options.dart | 19 ------------------- .../models/config/editor/configurations.dart | 12 ++++++------ .../models/config/editor/element_options.dart | 19 +++++++++++++++++++ .../{blocks => elements}/code_block.dart | 4 ++-- lib/src/utils/extensions/build_context.dart | 8 ++++---- lib/src/widgets/text_block.dart | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 lib/src/models/config/editor/block_options.dart create mode 100644 lib/src/models/config/editor/element_options.dart rename lib/src/models/config/editor/{blocks => elements}/code_block.dart (79%) diff --git a/lib/src/models/config/editor/block_options.dart b/lib/src/models/config/editor/block_options.dart deleted file mode 100644 index 09ac456c..00000000 --- a/lib/src/models/config/editor/block_options.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:flutter/foundation.dart' show immutable; - -import 'blocks/code_block.dart'; - -export 'blocks/code_block.dart'; - -@immutable -class QuillEditorBlockOptions extends Equatable { - const QuillEditorBlockOptions({ - this.code = const QuillEditorCodeBlockOptions(), - }); - - final QuillEditorCodeBlockOptions code; - @override - List get props => [ - code, - ]; -} diff --git a/lib/src/models/config/editor/configurations.dart b/lib/src/models/config/editor/configurations.dart index 5c5ec174..6696b26a 100644 --- a/lib/src/models/config/editor/configurations.dart +++ b/lib/src/models/config/editor/configurations.dart @@ -11,9 +11,9 @@ import '../../../widgets/embeds.dart'; import '../../../widgets/link.dart'; import '../../../widgets/raw_editor/raw_editor.dart'; import '../../themes/quill_dialog_theme.dart'; -import 'block_options.dart'; +import 'element_options.dart'; -export 'block_options.dart'; +export 'element_options.dart'; /// The configurations for the quill editor widget of flutter quill @immutable @@ -64,7 +64,7 @@ class QuillEditorConfigurations extends Equatable { this.contextMenuBuilder, this.editorKey, this.requestKeyboardFocusOnCheckListChanged = false, - this.blockOptions = const QuillEditorBlockOptions(), + this.elementOptions = const QuillEditorElementOptions(), }); /// The text placeholder in the quill editor @@ -293,7 +293,7 @@ class QuillEditorConfigurations extends Equatable { final bool requestKeyboardFocusOnCheckListChanged; /// This is not complete yet and might changed - final QuillEditorBlockOptions blockOptions; + final QuillEditorElementOptions elementOptions; @override List get props => [ @@ -344,7 +344,7 @@ class QuillEditorConfigurations extends Equatable { GlobalKey? editorKey, TextSelectionThemeData? textSelectionThemeData, bool? requestKeyboardFocusOnCheckListChanged, - QuillEditorBlockOptions? blockOptions, + QuillEditorElementOptions? elementOptions, }) { return QuillEditorConfigurations( placeholder: placeholder ?? this.placeholder, @@ -396,7 +396,7 @@ class QuillEditorConfigurations extends Equatable { requestKeyboardFocusOnCheckListChanged: requestKeyboardFocusOnCheckListChanged ?? this.requestKeyboardFocusOnCheckListChanged, - blockOptions: blockOptions ?? this.blockOptions, + elementOptions: elementOptions ?? this.elementOptions, ); } } diff --git a/lib/src/models/config/editor/element_options.dart b/lib/src/models/config/editor/element_options.dart new file mode 100644 index 00000000..a88433c4 --- /dev/null +++ b/lib/src/models/config/editor/element_options.dart @@ -0,0 +1,19 @@ +import 'package:equatable/equatable.dart'; +import 'package:flutter/foundation.dart' show immutable; + +import 'elements/code_block.dart'; + +export 'elements/code_block.dart'; + +@immutable +class QuillEditorElementOptions extends Equatable { + const QuillEditorElementOptions({ + this.code = const QuillEditorCodeBlockElementOptions(), + }); + + final QuillEditorCodeBlockElementOptions code; + @override + List get props => [ + code, + ]; +} diff --git a/lib/src/models/config/editor/blocks/code_block.dart b/lib/src/models/config/editor/elements/code_block.dart similarity index 79% rename from lib/src/models/config/editor/blocks/code_block.dart rename to lib/src/models/config/editor/elements/code_block.dart index 2a390bce..136d2cb9 100644 --- a/lib/src/models/config/editor/blocks/code_block.dart +++ b/lib/src/models/config/editor/elements/code_block.dart @@ -2,8 +2,8 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/foundation.dart' show immutable; @immutable -class QuillEditorCodeBlockOptions extends Equatable { - const QuillEditorCodeBlockOptions({ +class QuillEditorCodeBlockElementOptions extends Equatable { + const QuillEditorCodeBlockElementOptions({ this.enableLineNumbers = false, }); diff --git a/lib/src/utils/extensions/build_context.dart b/lib/src/utils/extensions/build_context.dart index 7e9ca3a6..636b3e1c 100644 --- a/lib/src/utils/extensions/build_context.dart +++ b/lib/src/utils/extensions/build_context.dart @@ -125,15 +125,15 @@ extension BuildContextExt on BuildContext { /// quill editor block options is in the [QuillEditorProvider] then we need to /// get the provider widget first and then we will return block options /// throw exception if [QuillEditorProvider] is not in the widget tree - QuillEditorBlockOptions? get quillEditorBlockOptions { - return quillEditorConfigurations?.blockOptions; + QuillEditorElementOptions? get quillEditorElementOptions { + return quillEditorConfigurations?.elementOptions; } /// return [QuillToolbarBaseButtonOptions] as not null. Since the quill /// quill editor block options is in the [QuillEditorProvider] then we need to /// get the provider widget first and then we will return block options /// don't throw exception if [QuillEditorProvider] is not in the widget tree - QuillEditorBlockOptions get requireQuillEditorBlockOptions { - return requireQuillEditorConfigurations.blockOptions; + QuillEditorElementOptions get requireQuillEditorElementOptions { + return requireQuillEditorConfigurations.elementOptions; } } diff --git a/lib/src/widgets/text_block.dart b/lib/src/widgets/text_block.dart index fd454e45..e2671ce5 100644 --- a/lib/src/widgets/text_block.dart +++ b/lib/src/widgets/text_block.dart @@ -232,7 +232,7 @@ class EditableTextBlock extends StatelessWidget { ); } if (attrs.containsKey(Attribute.codeBlock.key) && - context.requireQuillEditorBlockOptions.code.enableLineNumbers) { + context.requireQuillEditorElementOptions.code.enableLineNumbers) { return QuillNumberPoint( index: index, indentLevelCounts: indentLevelCounts,