Change blocks to element

pull/1471/head
Ahmed Hnewa 2 years ago
parent 38a8661f42
commit e78a571b14
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 19
      lib/src/models/config/editor/block_options.dart
  2. 12
      lib/src/models/config/editor/configurations.dart
  3. 19
      lib/src/models/config/editor/element_options.dart
  4. 4
      lib/src/models/config/editor/elements/code_block.dart
  5. 8
      lib/src/utils/extensions/build_context.dart
  6. 2
      lib/src/widgets/text_block.dart

@ -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<Object?> get props => [
code,
];
}

@ -11,9 +11,9 @@ import '../../../widgets/embeds.dart';
import '../../../widgets/link.dart'; import '../../../widgets/link.dart';
import '../../../widgets/raw_editor/raw_editor.dart'; import '../../../widgets/raw_editor/raw_editor.dart';
import '../../themes/quill_dialog_theme.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 /// The configurations for the quill editor widget of flutter quill
@immutable @immutable
@ -64,7 +64,7 @@ class QuillEditorConfigurations extends Equatable {
this.contextMenuBuilder, this.contextMenuBuilder,
this.editorKey, this.editorKey,
this.requestKeyboardFocusOnCheckListChanged = false, this.requestKeyboardFocusOnCheckListChanged = false,
this.blockOptions = const QuillEditorBlockOptions(), this.elementOptions = const QuillEditorElementOptions(),
}); });
/// The text placeholder in the quill editor /// The text placeholder in the quill editor
@ -293,7 +293,7 @@ class QuillEditorConfigurations extends Equatable {
final bool requestKeyboardFocusOnCheckListChanged; final bool requestKeyboardFocusOnCheckListChanged;
/// This is not complete yet and might changed /// This is not complete yet and might changed
final QuillEditorBlockOptions blockOptions; final QuillEditorElementOptions elementOptions;
@override @override
List<Object?> get props => [ List<Object?> get props => [
@ -344,7 +344,7 @@ class QuillEditorConfigurations extends Equatable {
GlobalKey<EditorState>? editorKey, GlobalKey<EditorState>? editorKey,
TextSelectionThemeData? textSelectionThemeData, TextSelectionThemeData? textSelectionThemeData,
bool? requestKeyboardFocusOnCheckListChanged, bool? requestKeyboardFocusOnCheckListChanged,
QuillEditorBlockOptions? blockOptions, QuillEditorElementOptions? elementOptions,
}) { }) {
return QuillEditorConfigurations( return QuillEditorConfigurations(
placeholder: placeholder ?? this.placeholder, placeholder: placeholder ?? this.placeholder,
@ -396,7 +396,7 @@ class QuillEditorConfigurations extends Equatable {
requestKeyboardFocusOnCheckListChanged: requestKeyboardFocusOnCheckListChanged:
requestKeyboardFocusOnCheckListChanged ?? requestKeyboardFocusOnCheckListChanged ??
this.requestKeyboardFocusOnCheckListChanged, this.requestKeyboardFocusOnCheckListChanged,
blockOptions: blockOptions ?? this.blockOptions, elementOptions: elementOptions ?? this.elementOptions,
); );
} }
} }

@ -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<Object?> get props => [
code,
];
}

@ -2,8 +2,8 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart' show immutable; import 'package:flutter/foundation.dart' show immutable;
@immutable @immutable
class QuillEditorCodeBlockOptions extends Equatable { class QuillEditorCodeBlockElementOptions extends Equatable {
const QuillEditorCodeBlockOptions({ const QuillEditorCodeBlockElementOptions({
this.enableLineNumbers = false, this.enableLineNumbers = false,
}); });

@ -125,15 +125,15 @@ extension BuildContextExt on BuildContext {
/// quill editor block options is in the [QuillEditorProvider] then we need to /// quill editor block options is in the [QuillEditorProvider] then we need to
/// get the provider widget first and then we will return block options /// get the provider widget first and then we will return block options
/// throw exception if [QuillEditorProvider] is not in the widget tree /// throw exception if [QuillEditorProvider] is not in the widget tree
QuillEditorBlockOptions? get quillEditorBlockOptions { QuillEditorElementOptions? get quillEditorElementOptions {
return quillEditorConfigurations?.blockOptions; return quillEditorConfigurations?.elementOptions;
} }
/// return [QuillToolbarBaseButtonOptions] as not null. Since the quill /// return [QuillToolbarBaseButtonOptions] as not null. Since the quill
/// quill editor block options is in the [QuillEditorProvider] then we need to /// quill editor block options is in the [QuillEditorProvider] then we need to
/// get the provider widget first and then we will return block options /// get the provider widget first and then we will return block options
/// don't throw exception if [QuillEditorProvider] is not in the widget tree /// don't throw exception if [QuillEditorProvider] is not in the widget tree
QuillEditorBlockOptions get requireQuillEditorBlockOptions { QuillEditorElementOptions get requireQuillEditorElementOptions {
return requireQuillEditorConfigurations.blockOptions; return requireQuillEditorConfigurations.elementOptions;
} }
} }

@ -232,7 +232,7 @@ class EditableTextBlock extends StatelessWidget {
); );
} }
if (attrs.containsKey(Attribute.codeBlock.key) && if (attrs.containsKey(Attribute.codeBlock.key) &&
context.requireQuillEditorBlockOptions.code.enableLineNumbers) { context.requireQuillEditorElementOptions.code.enableLineNumbers) {
return QuillNumberPoint( return QuillNumberPoint(
index: index, index: index,
indentLevelCounts: indentLevelCounts, indentLevelCounts: indentLevelCounts,

Loading…
Cancel
Save