refactor: restructure project into modular architecture for flutter_quill (#2032)
* refactor: restructure project into modular architecture for flutter_quill * refactor: move LineHeightAttribute class to custom_attributes.dart * chore: remove nullable controller extensionpull/2033/head
parent
af3679840b
commit
9764f75006
153 changed files with 747 additions and 761 deletions
@ -1,7 +1,7 @@ |
|||||||
library flutter_quill.extensions; |
library flutter_quill.extensions; |
||||||
|
|
||||||
export 'src/models/documents/nodes/leaf.dart'; |
export 'src/common/utils/platform.dart'; |
||||||
export 'src/models/rules/insert.dart'; |
export 'src/common/utils/string.dart'; |
||||||
export 'src/utils/platform.dart'; |
export 'src/common/utils/widgets.dart'; |
||||||
export 'src/utils/string.dart'; |
export 'src/document/nodes/leaf.dart'; |
||||||
export 'src/utils/widgets.dart'; |
export 'src/rules/insert.dart'; |
||||||
|
@ -1,38 +1,42 @@ |
|||||||
library flutter_quill; |
library flutter_quill; |
||||||
|
|
||||||
export '/src/widgets/raw_editor/quill_single_child_scroll_view.dart'; |
export 'src/common/structs/image_url.dart'; |
||||||
export 'src/extensions/quill_configurations_ext.dart'; |
export 'src/common/structs/offset_value.dart'; |
||||||
export 'src/models/config/quill_configurations.dart'; |
export 'src/common/structs/optional_size.dart'; |
||||||
export 'src/models/config/raw_editor/raw_editor_configurations.dart'; |
export 'src/common/structs/vertical_spacing.dart'; |
||||||
export 'src/models/config/toolbar/toolbar_configurations.dart'; |
export 'src/common/utils/embeds.dart'; |
||||||
export 'src/models/documents/attribute.dart'; |
export 'src/controller/provider.dart'; |
||||||
export 'src/models/documents/document.dart'; |
export 'src/controller/quill_controller.dart'; |
||||||
export 'src/models/documents/nodes/block.dart'; |
export 'src/document/attribute.dart'; |
||||||
export 'src/models/documents/nodes/embeddable.dart'; |
export 'src/document/document.dart'; |
||||||
export 'src/models/documents/nodes/leaf.dart'; |
export 'src/document/nodes/block.dart'; |
||||||
export 'src/models/documents/nodes/line.dart'; |
export 'src/document/nodes/embeddable.dart'; |
||||||
export 'src/models/documents/nodes/node.dart'; |
export 'src/document/nodes/leaf.dart'; |
||||||
export 'src/models/documents/style.dart'; |
export 'src/document/nodes/line.dart'; |
||||||
export 'src/models/structs/doc_change.dart'; |
export 'src/document/nodes/node.dart'; |
||||||
export 'src/models/structs/image_url.dart'; |
export 'src/document/structs/doc_change.dart'; |
||||||
export 'src/models/structs/link_dialog_action.dart'; |
export 'src/document/style.dart'; |
||||||
export 'src/models/structs/offset_value.dart'; |
export 'src/editor/editor.dart'; |
||||||
export 'src/models/structs/optional_size.dart'; |
export 'src/editor/embed/embed_editor_builder.dart'; |
||||||
export 'src/models/structs/vertical_spacing.dart'; |
export 'src/editor/provider.dart'; |
||||||
export 'src/models/themes/quill_dialog_theme.dart'; |
export 'src/editor/raw_editor/config/raw_editor_configurations.dart'; |
||||||
export 'src/models/themes/quill_icon_theme.dart'; |
export 'src/editor/raw_editor/quill_single_child_scroll_view.dart'; |
||||||
export 'src/utils/embeds.dart'; |
export 'src/editor/raw_editor/raw_editor.dart'; |
||||||
export 'src/widgets/editor/editor.dart'; |
export 'src/editor/raw_editor/raw_editor_state.dart'; |
||||||
export 'src/widgets/others/cursor.dart'; |
export 'src/editor/style_widgets/style_widgets.dart'; |
||||||
export 'src/widgets/others/default_styles.dart'; |
export 'src/editor/widgets/cursor.dart'; |
||||||
export 'src/widgets/others/link.dart'; |
export 'src/editor/widgets/default_styles.dart'; |
||||||
export 'src/widgets/quill/embeds.dart'; |
export 'src/editor/widgets/link.dart'; |
||||||
export 'src/widgets/quill/quill_controller.dart'; |
export 'src/editor_toolbar_controller_shared/quill_configurations.dart'; |
||||||
export 'src/widgets/raw_editor/raw_editor.dart'; |
export 'src/editor_toolbar_shared/quill_configurations_ext.dart'; |
||||||
export 'src/widgets/raw_editor/raw_editor_state.dart'; |
export 'src/toolbar/base_toolbar.dart'; |
||||||
export 'src/widgets/style_widgets/style_widgets.dart'; |
export 'src/toolbar/buttons/alignment/select_alignment_button.dart'; |
||||||
export 'src/widgets/toolbar/base_toolbar.dart'; |
export 'src/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart'; |
||||||
export 'src/widgets/toolbar/buttons/alignment/select_alignment_button.dart'; |
export 'src/toolbar/config/toolbar_configurations.dart'; |
||||||
export 'src/widgets/toolbar/buttons/hearder_style/select_header_style_dropdown_button.dart'; |
export 'src/toolbar/embed/embed_button_builder.dart'; |
||||||
export 'src/widgets/toolbar/simple_toolbar.dart'; |
export 'src/toolbar/provider.dart'; |
||||||
export 'src/widgets/utils/provider.dart'; |
export 'src/toolbar/simple_toolbar.dart'; |
||||||
|
export 'src/toolbar/simple_toolbar_provider.dart'; |
||||||
|
export 'src/toolbar/structs/link_dialog_action.dart'; |
||||||
|
export 'src/toolbar/theme/quill_dialog_theme.dart'; |
||||||
|
export 'src/toolbar/theme/quill_icon_theme.dart'; |
||||||
|
@ -1,5 +1,7 @@ |
|||||||
library quill_markdown; |
library quill_markdown; |
||||||
|
|
||||||
|
// TODO: Might avoid exposing the quill_markdown package |
||||||
|
|
||||||
export 'src/packages/quill_markdown/delta_to_markdown.dart'; |
export 'src/packages/quill_markdown/delta_to_markdown.dart'; |
||||||
export 'src/packages/quill_markdown/embeddable_table_syntax.dart'; |
export 'src/packages/quill_markdown/embeddable_table_syntax.dart'; |
||||||
export 'src/packages/quill_markdown/markdown_to_delta.dart'; |
export 'src/packages/quill_markdown/markdown_to_delta.dart'; |
||||||
|
@ -1,7 +1,7 @@ |
|||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../documents/nodes/leaf.dart'; |
import '../../document/nodes/leaf.dart'; |
||||||
import '../documents/nodes/line.dart'; |
import '../../document/nodes/line.dart'; |
||||||
|
|
||||||
@immutable |
@immutable |
||||||
class SegmentLeafNode { |
class SegmentLeafNode { |
@ -1,8 +1,8 @@ |
|||||||
import 'dart:math'; |
import 'dart:math'; |
||||||
|
|
||||||
import '../models/documents/nodes/leaf.dart'; |
import '../../controller/quill_controller.dart'; |
||||||
import '../models/structs/offset_value.dart'; |
import '../../document/nodes/leaf.dart'; |
||||||
import '../widgets/quill/quill_controller.dart'; |
import '../structs/offset_value.dart'; |
||||||
|
|
||||||
OffsetValue<Embed> getEmbedNode(QuillController controller, int offset) { |
OffsetValue<Embed> getEmbedNode(QuillController controller, int offset) { |
||||||
var offset = controller.selection.start; |
var offset = controller.selection.start; |
@ -1,4 +1,4 @@ |
|||||||
import '../../flutter_quill.dart'; |
import '../../../flutter_quill.dart'; |
||||||
|
|
||||||
dynamic getFontSize(dynamic sizeValue) { |
dynamic getFontSize(dynamic sizeValue) { |
||||||
if (sizeValue is String && |
if (sizeValue is String && |
@ -0,0 +1,19 @@ |
|||||||
|
import 'package:flutter/widgets.dart' show BuildContext; |
||||||
|
|
||||||
|
import '../editor/provider.dart'; |
||||||
|
import '../toolbar/simple_toolbar_provider.dart'; |
||||||
|
import 'quill_controller.dart'; |
||||||
|
|
||||||
|
extension QuillControllerExt on BuildContext { |
||||||
|
QuillController? get quilController { |
||||||
|
return quillSimpleToolbarConfigurations?.controller ?? |
||||||
|
quillEditorConfigurations?.controller; |
||||||
|
} |
||||||
|
|
||||||
|
QuillController get requireQuillController { |
||||||
|
return quillSimpleToolbarConfigurations?.controller ?? |
||||||
|
quillEditorConfigurations?.controller ?? |
||||||
|
(throw ArgumentError( |
||||||
|
'The quill provider is required, you must only call requireQuillController inside the QuillToolbar and QuillEditor')); |
||||||
|
} |
||||||
|
} |
@ -1,11 +1,11 @@ |
|||||||
import 'dart:math' as math; |
import 'dart:math' as math; |
||||||
import 'dart:ui'; |
import 'dart:ui' show TextDirection; |
||||||
|
|
||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
import '../models/documents/attribute.dart'; |
import '../document/attribute.dart'; |
||||||
import '../models/documents/nodes/node.dart'; |
import '../document/nodes/node.dart'; |
||||||
|
|
||||||
// Diff between two texts - old text and new text |
// Diff between two texts - old text and new text |
||||||
@immutable |
@immutable |
@ -1,8 +1,8 @@ |
|||||||
import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart'; |
import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart'; |
||||||
import 'package:markdown/markdown.dart' as md; |
import 'package:markdown/markdown.dart' as md; |
||||||
import 'package:meta/meta.dart'; |
import 'package:meta/meta.dart'; |
||||||
import '../../../markdown_quill.dart'; |
import '../../markdown_quill.dart'; |
||||||
import '../../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
|
|
||||||
@immutable |
@immutable |
||||||
@experimental |
@experimental |
@ -0,0 +1,25 @@ |
|||||||
|
import 'attribute.dart'; |
||||||
|
|
||||||
|
// Attributes that don't conform to standard Quill Delta |
||||||
|
// and are not compatible with https://quilljs.com/docs/delta/ |
||||||
|
|
||||||
|
/// This attribute represents the space between text lines. The line height can be |
||||||
|
/// adjusted using predefined constants or custom values |
||||||
|
/// |
||||||
|
/// The attribute at the json looks like: "attributes":{"line-height": 1.5 } |
||||||
|
class LineHeightAttribute extends Attribute<double?> { |
||||||
|
const LineHeightAttribute({double? lineHeight}) |
||||||
|
: super('line-height', AttributeScope.block, lineHeight); |
||||||
|
|
||||||
|
static const Attribute<double?> lineHeightNormal = |
||||||
|
LineHeightAttribute(lineHeight: 1); |
||||||
|
|
||||||
|
static const Attribute<double?> lineHeightTight = |
||||||
|
LineHeightAttribute(lineHeight: 1.15); |
||||||
|
|
||||||
|
static const Attribute<double?> lineHeightOneAndHalf = |
||||||
|
LineHeightAttribute(lineHeight: 1.5); |
||||||
|
|
||||||
|
static const Attribute<double?> lineHeightDouble = |
||||||
|
LineHeightAttribute(lineHeight: 2); |
||||||
|
} |
@ -1,7 +1,7 @@ |
|||||||
import '../../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
import '../structs/doc_change.dart'; |
|
||||||
import '../structs/history_changed.dart'; |
|
||||||
import 'document.dart'; |
import 'document.dart'; |
||||||
|
import 'structs/doc_change.dart'; |
||||||
|
import 'structs/history_changed.dart'; |
||||||
|
|
||||||
class History { |
class History { |
||||||
History({ |
History({ |
@ -1,6 +1,6 @@ |
|||||||
import 'dart:collection'; |
import 'dart:collection' show LinkedList; |
||||||
|
|
||||||
import '../../../widgets/quill/embeds.dart'; |
import '../../editor/embed/embed_editor_builder.dart'; |
||||||
import '../style.dart'; |
import '../style.dart'; |
||||||
import 'leaf.dart'; |
import 'leaf.dart'; |
||||||
import 'line.dart'; |
import 'line.dart'; |
@ -1,7 +1,7 @@ |
|||||||
import 'dart:collection'; |
import 'dart:collection'; |
||||||
|
|
||||||
import '../../../../quill_delta.dart'; |
import '../../../../quill_delta.dart'; |
||||||
import '../../../widgets/quill/embeds.dart'; |
import '../../editor/embed/embed_editor_builder.dart'; |
||||||
import '../attribute.dart'; |
import '../attribute.dart'; |
||||||
import '../style.dart'; |
import '../style.dart'; |
||||||
import 'container.dart'; |
import 'container.dart'; |
@ -1,7 +1,7 @@ |
|||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../../../quill_delta.dart'; |
import '../../../quill_delta.dart'; |
||||||
import '../documents/document.dart'; |
import '../document.dart'; |
||||||
|
|
||||||
@immutable |
@immutable |
||||||
class DocChange { |
class DocChange { |
@ -1,6 +1,6 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/widgets.dart'; |
||||||
|
|
||||||
import '../raw_editor/raw_editor.dart'; |
import 'raw_editor/raw_editor.dart'; |
||||||
|
|
||||||
typedef QuillEditorBuilder = Widget Function( |
typedef QuillEditorBuilder = Widget Function( |
||||||
BuildContext context, |
BuildContext context, |
@ -0,0 +1,78 @@ |
|||||||
|
import 'package:flutter/foundation.dart' show debugPrint, kDebugMode; |
||||||
|
import 'package:flutter/widgets.dart' |
||||||
|
show BuildContext, InheritedWidget, Widget; |
||||||
|
|
||||||
|
import 'config/editor_configurations.dart'; |
||||||
|
|
||||||
|
class QuillEditorProvider extends InheritedWidget { |
||||||
|
const QuillEditorProvider({ |
||||||
|
required super.child, |
||||||
|
required this.editorConfigurations, |
||||||
|
super.key, |
||||||
|
}); |
||||||
|
|
||||||
|
final QuillEditorConfigurations editorConfigurations; |
||||||
|
|
||||||
|
@override |
||||||
|
bool updateShouldNotify(covariant QuillEditorProvider oldWidget) { |
||||||
|
return oldWidget.editorConfigurations != editorConfigurations; |
||||||
|
} |
||||||
|
|
||||||
|
static QuillEditorProvider? maybeOf(BuildContext context) { |
||||||
|
return context.dependOnInheritedWidgetOfExactType<QuillEditorProvider>(); |
||||||
|
} |
||||||
|
|
||||||
|
static QuillEditorProvider of(BuildContext context) { |
||||||
|
final provider = maybeOf(context); |
||||||
|
if (provider == null) { |
||||||
|
if (kDebugMode) { |
||||||
|
debugPrint( |
||||||
|
'The quill editor provider must be provided in the widget tree.', |
||||||
|
); |
||||||
|
} |
||||||
|
throw ArgumentError.checkNotNull( |
||||||
|
'You are using a widget in the Flutter quill library that require ' |
||||||
|
'The Quill editor provider widget to be in the parent widget tree ' |
||||||
|
'because ' |
||||||
|
'The provider is $provider. Please make sure to wrap this widget' |
||||||
|
' with' |
||||||
|
' QuillEditorProvider widget. ' |
||||||
|
'You might using QuillEditor so make sure to' |
||||||
|
' wrap them with the quill provider widget and setup the required ' |
||||||
|
'configurations', |
||||||
|
'QuillEditorProvider', |
||||||
|
); |
||||||
|
} |
||||||
|
return provider; |
||||||
|
} |
||||||
|
|
||||||
|
/// To pass the [QuillEditorProvider] instance as value instead of creating |
||||||
|
/// new widget |
||||||
|
static QuillEditorProvider value({ |
||||||
|
required QuillEditorProvider value, |
||||||
|
required Widget child, |
||||||
|
}) { |
||||||
|
return QuillEditorProvider( |
||||||
|
editorConfigurations: value.editorConfigurations, |
||||||
|
child: child, |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
extension QuillEditorExt on BuildContext { |
||||||
|
QuillEditorConfigurations get requireQuillEditorConfigurations { |
||||||
|
return QuillEditorProvider.of(this).editorConfigurations; |
||||||
|
} |
||||||
|
|
||||||
|
QuillEditorConfigurations? get quillEditorConfigurations { |
||||||
|
return QuillEditorProvider.maybeOf(this)?.editorConfigurations; |
||||||
|
} |
||||||
|
|
||||||
|
QuillEditorElementOptions? get quillEditorElementOptions { |
||||||
|
return quillEditorConfigurations?.elementOptions; |
||||||
|
} |
||||||
|
|
||||||
|
QuillEditorElementOptions get requireQuillEditorElementOptions { |
||||||
|
return requireQuillEditorConfigurations.elementOptions; |
||||||
|
} |
||||||
|
} |
@ -1,11 +1,11 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../translations.dart'; |
import '../../../translations.dart'; |
||||||
import '../../models/documents/attribute.dart'; |
import '../../document/attribute.dart'; |
||||||
import '../editor/editor.dart'; |
import '../../toolbar/buttons/link_style2_button.dart'; |
||||||
import '../others/link.dart'; |
import '../../toolbar/buttons/search/search_dialog.dart'; |
||||||
import '../toolbar/buttons/link_style2_button.dart'; |
import '../editor.dart'; |
||||||
import '../toolbar/buttons/search/search_dialog.dart'; |
import '../widgets/link.dart'; |
||||||
import 'raw_editor_state.dart'; |
import 'raw_editor_state.dart'; |
||||||
import 'raw_editor_text_boundaries.dart'; |
import 'raw_editor_text_boundaries.dart'; |
||||||
|
|
@ -1,9 +1,9 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
import 'package:flutter/rendering.dart' show ViewportOffset; |
import 'package:flutter/rendering.dart' show ViewportOffset; |
||||||
|
|
||||||
import '../../models/documents/document.dart'; |
import '../../document/document.dart'; |
||||||
import '../editor/editor.dart'; |
import '../editor.dart'; |
||||||
import '../others/cursor.dart'; |
import '../widgets/cursor.dart'; |
||||||
|
|
||||||
class QuillRawEditorMultiChildRenderObject |
class QuillRawEditorMultiChildRenderObject |
||||||
extends MultiChildRenderObjectWidget { |
extends MultiChildRenderObjectWidget { |
@ -1,6 +1,6 @@ |
|||||||
import 'package:flutter/widgets.dart'; |
import 'package:flutter/widgets.dart'; |
||||||
|
|
||||||
import '../../extensions/quill_configurations_ext.dart'; |
import '../provider.dart'; |
||||||
|
|
||||||
class QuillEditorBulletPoint extends StatelessWidget { |
class QuillEditorBulletPoint extends StatelessWidget { |
||||||
const QuillEditorBulletPoint({ |
const QuillEditorBulletPoint({ |
@ -1,7 +1,7 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/widgets.dart'; |
||||||
|
|
||||||
import '../../../flutter_quill.dart'; |
import '../../../flutter_quill.dart'; |
||||||
import '../quill/text_block.dart'; |
import '../widgets/text/text_block.dart'; |
||||||
|
|
||||||
class QuillEditorNumberPoint extends StatelessWidget { |
class QuillEditorNumberPoint extends StatelessWidget { |
||||||
const QuillEditorNumberPoint({ |
const QuillEditorNumberPoint({ |
@ -1,6 +1,6 @@ |
|||||||
import 'package:flutter/rendering.dart'; |
import 'package:flutter/rendering.dart'; |
||||||
|
|
||||||
import '../../models/documents/nodes/container.dart'; |
import '../../document/nodes/container.dart'; |
||||||
|
|
||||||
/// A common interface to render boxes which represent a piece of rich text |
/// A common interface to render boxes which represent a piece of rich text |
||||||
/// content. |
/// content. |
@ -1,9 +1,9 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../models/documents/attribute.dart'; |
import '../../common/structs/vertical_spacing.dart'; |
||||||
import '../../models/documents/style.dart'; |
import '../../common/utils/platform.dart'; |
||||||
import '../../models/structs/vertical_spacing.dart'; |
import '../../document/attribute.dart'; |
||||||
import '../../utils/platform.dart'; |
import '../../document/style.dart'; |
||||||
import '../style_widgets/checkbox_point.dart'; |
import '../style_widgets/checkbox_point.dart'; |
||||||
|
|
||||||
class QuillStyles extends InheritedWidget { |
class QuillStyles extends InheritedWidget { |
@ -1,26 +1,27 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
import 'package:flutter/rendering.dart'; |
import 'package:flutter/rendering.dart'; |
||||||
|
|
||||||
import '../../extensions/quill_configurations_ext.dart'; |
import '../../../common/structs/vertical_spacing.dart'; |
||||||
import '../../models/documents/attribute.dart'; |
import '../../../common/utils/font.dart'; |
||||||
import '../../models/documents/nodes/block.dart'; |
import '../../../controller/quill_controller.dart'; |
||||||
import '../../models/documents/nodes/line.dart'; |
import '../../../delta/delta_diff.dart'; |
||||||
import '../../models/structs/vertical_spacing.dart'; |
import '../../../document/attribute.dart'; |
||||||
import '../../utils/delta.dart'; |
import '../../../document/nodes/block.dart'; |
||||||
import '../../utils/font.dart'; |
import '../../../document/nodes/line.dart'; |
||||||
import '../editor/editor.dart'; |
import '../../../toolbar/base_toolbar.dart'; |
||||||
import '../others/box.dart'; |
import '../../editor.dart'; |
||||||
import '../others/cursor.dart'; |
import '../../embed/embed_editor_builder.dart'; |
||||||
import '../others/default_styles.dart'; |
import '../../provider.dart'; |
||||||
import '../others/delegate.dart'; |
import '../../style_widgets/bullet_point.dart'; |
||||||
import '../others/link.dart'; |
import '../../style_widgets/checkbox_point.dart'; |
||||||
import '../others/text_selection.dart'; |
import '../../style_widgets/number_point.dart'; |
||||||
import '../style_widgets/bullet_point.dart'; |
import '../box.dart'; |
||||||
import '../style_widgets/checkbox_point.dart'; |
import '../cursor.dart'; |
||||||
import '../style_widgets/number_point.dart'; |
import '../default_styles.dart'; |
||||||
import '../toolbar/base_toolbar.dart'; |
import '../delegate.dart'; |
||||||
import 'quill_controller.dart'; |
import '../link.dart'; |
||||||
import 'text_line.dart'; |
import 'text_line.dart'; |
||||||
|
import 'text_selection.dart'; |
||||||
|
|
||||||
const List<int> arabianRomanNumbers = [ |
const List<int> arabianRomanNumbers = [ |
||||||
1000, |
1000, |
@ -0,0 +1,5 @@ |
|||||||
|
export '../controller/quill_controller_configurations.dart'; |
||||||
|
export '../editor/config/editor_configurations.dart'; |
||||||
|
export '../editor_toolbar_shared/config/quill_shared_configurations.dart'; |
||||||
|
export '../toolbar/config/simple_toolbar_configurations.dart'; |
||||||
|
export '../toolbar/config/toolbar_configurations.dart'; |
@ -0,0 +1,13 @@ |
|||||||
|
import 'package:flutter/widgets.dart' show BuildContext; |
||||||
|
|
||||||
|
import '../editor/provider.dart'; |
||||||
|
import '../toolbar/simple_toolbar_provider.dart'; |
||||||
|
import 'config/quill_shared_configurations.dart'; |
||||||
|
|
||||||
|
extension QuillSharedExt on BuildContext { |
||||||
|
/// return nullable [QuillSharedConfigurations] |
||||||
|
QuillSharedConfigurations? get quillSharedConfigurations { |
||||||
|
return quillSimpleToolbarConfigurations?.sharedConfigurations ?? |
||||||
|
quillEditorConfigurations?.sharedConfigurations; |
||||||
|
} |
||||||
|
} |
@ -1,84 +0,0 @@ |
|||||||
import 'package:flutter/widgets.dart' show BuildContext; |
|
||||||
|
|
||||||
import '../../flutter_quill.dart'; |
|
||||||
|
|
||||||
extension QuillControllerExt on BuildContext { |
|
||||||
/// return nullable [QuillController] |
|
||||||
QuillController? get quilController { |
|
||||||
return quillSimpleToolbarConfigurations?.controller ?? |
|
||||||
quillEditorConfigurations?.controller; |
|
||||||
} |
|
||||||
|
|
||||||
/// return [QuillController] as not null |
|
||||||
QuillController get requireQuillController { |
|
||||||
return quillSimpleToolbarConfigurations?.controller ?? |
|
||||||
quillEditorConfigurations?.controller ?? |
|
||||||
(throw ArgumentError( |
|
||||||
'The quill provider is required, you must only call requireQuillController inside the QuillToolbar and QuillEditor')); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
extension QuillSharedExt on BuildContext { |
|
||||||
/// return nullable [QuillSharedConfigurations] |
|
||||||
QuillSharedConfigurations? get quillSharedConfigurations { |
|
||||||
return quillSimpleToolbarConfigurations?.sharedConfigurations ?? |
|
||||||
quillEditorConfigurations?.sharedConfigurations; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
extension QuillEditorExt on BuildContext { |
|
||||||
/// return [QuillEditorConfigurations] as not null |
|
||||||
QuillEditorConfigurations get requireQuillEditorConfigurations { |
|
||||||
return QuillEditorProvider.of(this).editorConfigurations; |
|
||||||
} |
|
||||||
|
|
||||||
/// return nullable [QuillEditorConfigurations] |
|
||||||
QuillEditorConfigurations? get quillEditorConfigurations { |
|
||||||
return QuillEditorProvider.maybeOf(this)?.editorConfigurations; |
|
||||||
} |
|
||||||
|
|
||||||
/// return nullable [QuillToolbarBaseButtonOptions]. 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 |
|
||||||
/// throw exception if [QuillEditorProvider] is not in the widget tree |
|
||||||
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 |
|
||||||
QuillEditorElementOptions get requireQuillEditorElementOptions { |
|
||||||
return requireQuillEditorConfigurations.elementOptions; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
extension QuillSimpleToolbarExt on BuildContext { |
|
||||||
/// return [QuillSimpleToolbarConfigurations] as not null |
|
||||||
QuillSimpleToolbarConfigurations get requireQuillSimpleToolbarConfigurations { |
|
||||||
return QuillSimpleToolbarProvider.of(this).toolbarConfigurations; |
|
||||||
} |
|
||||||
|
|
||||||
/// return nullable [QuillSimpleToolbarConfigurations] |
|
||||||
QuillSimpleToolbarConfigurations? get quillSimpleToolbarConfigurations { |
|
||||||
return QuillSimpleToolbarProvider.maybeOf(this)?.toolbarConfigurations; |
|
||||||
} |
|
||||||
|
|
||||||
/// return nullable [QuillToolbarBaseButtonOptions]. |
|
||||||
QuillToolbarBaseButtonOptions? get quillToolbarBaseButtonOptions { |
|
||||||
return quillSimpleToolbarConfigurations?.buttonOptions.base; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
extension QuillToolbarExt on BuildContext { |
|
||||||
/// return [QuillToolbarConfigurations] as not null |
|
||||||
QuillToolbarConfigurations get requireQuillToolbarConfigurations { |
|
||||||
return QuillToolbarProvider.of(this).toolbarConfigurations; |
|
||||||
} |
|
||||||
|
|
||||||
/// return nullable [QuillToolbarConfigurations]. |
|
||||||
QuillToolbarConfigurations? get quillToolbarConfigurations { |
|
||||||
return QuillToolbarProvider.maybeOf(this)?.toolbarConfigurations; |
|
||||||
} |
|
||||||
} |
|
@ -1,17 +0,0 @@ |
|||||||
import 'package:flutter/widgets.dart' show BuildContext; |
|
||||||
|
|
||||||
import '../../flutter_quill.dart' show QuillController; |
|
||||||
import 'quill_configurations_ext.dart'; |
|
||||||
|
|
||||||
extension QuillControllerNullableExt on QuillController? { |
|
||||||
/// Simple logic to use the current passed controller if not null |
|
||||||
/// if null then we will have to use the default one |
|
||||||
/// using the [context] |
|
||||||
QuillController notNull(BuildContext context) { |
|
||||||
final controller = this; |
|
||||||
if (controller != null) { |
|
||||||
return controller; |
|
||||||
} |
|
||||||
return context.requireQuillController; |
|
||||||
} |
|
||||||
} |
|
@ -1,28 +0,0 @@ |
|||||||
// import 'package:equatable/equatable.dart'; |
|
||||||
// import 'package:meta/meta.dart' show experimental, immutable; |
|
||||||
|
|
||||||
// @immutable |
|
||||||
// @experimental |
|
||||||
// class QuillAnimationConfigurations extends Equatable { |
|
||||||
// const QuillAnimationConfigurations({ |
|
||||||
// required this.checkBoxPointItem, |
|
||||||
// }); |
|
||||||
|
|
||||||
// factory QuillAnimationConfigurations.disableAll() => |
|
||||||
// const QuillAnimationConfigurations( |
|
||||||
// checkBoxPointItem: false, |
|
||||||
// ); |
|
||||||
|
|
||||||
// factory QuillAnimationConfigurations.enableAll() => |
|
||||||
// const QuillAnimationConfigurations( |
|
||||||
// checkBoxPointItem: true, |
|
||||||
// ); |
|
||||||
|
|
||||||
// /// This currently has issue which the whole checkbox list will rebuilt |
|
||||||
// /// and the animation will replay when some value changes |
|
||||||
// /// which is why disabled by default |
|
||||||
// final bool checkBoxPointItem; |
|
||||||
|
|
||||||
// @override |
|
||||||
// List<Object?> get props => []; |
|
||||||
// } |
|
@ -1,4 +0,0 @@ |
|||||||
export 'editor/editor_configurations.dart'; |
|
||||||
export 'quill_controller_configurations.dart'; |
|
||||||
export 'quill_shared_configurations.dart'; |
|
||||||
export 'toolbar/simple_toolbar_configurations.dart'; |
|
@ -1,9 +1,9 @@ |
|||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
import '../../models/documents/document.dart'; |
import '../document/attribute.dart'; |
||||||
import '../documents/attribute.dart'; |
import '../document/document.dart'; |
||||||
import '../documents/nodes/embeddable.dart'; |
import '../document/nodes/embeddable.dart'; |
||||||
import 'rule.dart'; |
import 'rule.dart'; |
||||||
|
|
||||||
/// A heuristic rule for delete operations. |
/// A heuristic rule for delete operations. |
@ -1,8 +1,8 @@ |
|||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
import '../../models/documents/document.dart'; |
import '../document/attribute.dart'; |
||||||
import '../documents/attribute.dart'; |
import '../document/document.dart'; |
||||||
import 'rule.dart'; |
import 'rule.dart'; |
||||||
|
|
||||||
/// A heuristic rule for format (retain) operations. |
/// A heuristic rule for format (retain) operations. |
@ -1,11 +1,11 @@ |
|||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
import '../../extensions/uri_ext.dart'; |
import '../common/extensions/uri_ext.dart'; |
||||||
import '../../models/documents/document.dart'; |
import '../document/attribute.dart'; |
||||||
import '../documents/attribute.dart'; |
import '../document/document.dart'; |
||||||
import '../documents/nodes/embeddable.dart'; |
import '../document/nodes/embeddable.dart'; |
||||||
import '../documents/style.dart'; |
import '../document/style.dart'; |
||||||
import 'rule.dart'; |
import 'rule.dart'; |
||||||
|
|
||||||
/// A heuristic rule for insert operations. |
/// A heuristic rule for insert operations. |
@ -1,8 +1,8 @@ |
|||||||
import 'package:meta/meta.dart' show immutable; |
import 'package:meta/meta.dart' show immutable; |
||||||
|
|
||||||
import '../../../quill_delta.dart'; |
import '../../quill_delta.dart'; |
||||||
import '../documents/attribute.dart'; |
import '../document/attribute.dart'; |
||||||
import '../documents/document.dart'; |
import '../document/document.dart'; |
||||||
import 'delete.dart'; |
import 'delete.dart'; |
||||||
import 'format.dart'; |
import 'format.dart'; |
||||||
import 'insert.dart'; |
import 'insert.dart'; |
@ -1,6 +1,6 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../../flutter_quill.dart'; |
import '../../../flutter_quill.dart'; |
||||||
|
|
||||||
/// The [T] is the options for the button |
/// The [T] is the options for the button |
||||||
/// The [E] is the extra options for the button |
/// The [E] is the extra options for the button |
@ -1,9 +1,11 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../extensions/quill_configurations_ext.dart'; |
import '../../controller/quill_controller.dart'; |
||||||
import '../../../models/themes/quill_icon_theme.dart'; |
import '../config/simple_toolbar_configurations.dart'; |
||||||
import '../../quill/quill_controller.dart'; |
import '../simple_toolbar_provider.dart'; |
||||||
import '../base_toolbar.dart'; |
import '../theme/quill_icon_theme.dart'; |
||||||
|
|
||||||
|
// TODO: Use this later or remove it |
||||||
|
|
||||||
/// The [T] is the options for the button, usually should refresnce itself |
/// The [T] is the options for the button, usually should refresnce itself |
||||||
/// it's used in [childBuilder] so the developer can custmize this when using it |
/// it's used in [childBuilder] so the developer can custmize this when using it |
@ -1,7 +1,7 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../../models/documents/attribute.dart'; |
import '../../../controller/quill_controller.dart'; |
||||||
import '../../../quill/quill_controller.dart'; |
import '../../../document/attribute.dart'; |
||||||
|
|
||||||
enum _AlignmentOptions { |
enum _AlignmentOptions { |
||||||
left(attribute: Attribute.leftAlignment), |
left(attribute: Attribute.leftAlignment), |
@ -1,7 +1,7 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../../models/documents/attribute.dart'; |
import '../../../controller/quill_controller.dart'; |
||||||
import '../../../quill/quill_controller.dart'; |
import '../../../document/attribute.dart'; |
||||||
import '../../base_toolbar.dart'; |
import '../../base_toolbar.dart'; |
||||||
|
|
||||||
class QuillToolbarSelectAlignmentButtons extends StatelessWidget { |
class QuillToolbarSelectAlignmentButtons extends StatelessWidget { |
@ -1,7 +1,7 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../l10n/extensions/localizations.dart'; |
import '../../document/attribute.dart'; |
||||||
import '../../../models/documents/attribute.dart'; |
import '../../l10n/extensions/localizations_ext.dart'; |
||||||
import '../base_button/stateless_base_button.dart'; |
import '../base_button/stateless_base_button.dart'; |
||||||
import '../base_toolbar.dart'; |
import '../base_toolbar.dart'; |
||||||
|
|
@ -1,13 +1,14 @@ |
|||||||
import 'package:flutter/material.dart'; |
import 'package:flutter/material.dart'; |
||||||
|
|
||||||
import '../../../../extensions/quill_configurations_ext.dart'; |
import '../../../common/utils/color.dart'; |
||||||
import '../../../../l10n/extensions/localizations.dart'; |
import '../../../document/attribute.dart'; |
||||||
import '../../../../l10n/widgets/localizations.dart'; |
import '../../../document/style.dart'; |
||||||
import '../../../../models/documents/attribute.dart'; |
import '../../../editor_toolbar_shared/quill_configurations_ext.dart'; |
||||||
import '../../../../models/documents/style.dart'; |
import '../../../l10n/extensions/localizations_ext.dart'; |
||||||
import '../../../../utils/color.dart'; |
import '../../../l10n/widgets/localizations.dart'; |
||||||
import '../../base_button/base_value_button.dart'; |
import '../../base_button/base_value_button.dart'; |
||||||
import '../../base_toolbar.dart'; |
import '../../config/buttons/color_configurations.dart'; |
||||||
|
import '../quill_icon_button.dart'; |
||||||
import 'color_dialog.dart'; |
import 'color_dialog.dart'; |
||||||
|
|
||||||
typedef QuillToolbarColorBaseButton = QuillToolbarBaseButton< |
typedef QuillToolbarColorBaseButton = QuillToolbarBaseButton< |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue