Skip to content

Commit

Permalink
Chore: rename class names to make more sense with their functions
Browse files Browse the repository at this point in the history
  • Loading branch information
CatHood0 committed Nov 28, 2024
1 parent 4bbd064 commit 3a37acd
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 50 deletions.
10 changes: 4 additions & 6 deletions lib/src/editor/config/editor_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,10 @@ class QuillEditorConfig {
/// customBlockAttributesKeys: null,
///),
///```
final PlaceholderComponentsConfiguration? placeholderComponentsConfiguration;
final PlaceholderConfig? placeholderComponentsConfiguration;

/// This argument configure how will be showed the placeholder at right or left of the cursor
final CursorParagrahPlaceholderConfiguration?
cursorParagrahPlaceholderConfiguration;
final CursorPlaceholderConfig? cursorParagrahPlaceholderConfiguration;

/// A handler for keys that are pressed when the editor is focused.
///
Expand Down Expand Up @@ -543,10 +542,9 @@ class QuillEditorConfig {
ContentInsertionConfiguration? contentInsertionConfiguration,
GlobalKey<EditorState>? editorKey,
TextSelectionThemeData? textSelectionThemeData,
PlaceholderComponentsConfiguration? placeholderComponentsConfiguration,
PlaceholderConfig? placeholderComponentsConfiguration,
bool? requestKeyboardFocusOnCheckListChanged,
CursorParagrahPlaceholderConfiguration?
cursorParagrahPlaceholderConfiguration,
CursorPlaceholderConfig? cursorParagrahPlaceholderConfiguration,
TextMagnifierConfiguration? magnifierConfiguration,
TextInputAction? textInputAction,
bool? enableScribble,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// This file is only for internal use
import 'package:flutter/material.dart'
show
Expanded,
Row,
StrutStyle,
Text,
TextAlign,
TextDirection,
TextStyle,
TextWidthBasis,
WidgetSpan,
immutable;
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import '../../../../document/attribute.dart' show Attribute, AttributeScope;
import '../../../../document/nodes/line.dart';
Expand All @@ -36,9 +25,9 @@ class PlaceholderBuilder {
required this.configuration,
});

final PlaceholderComponentsConfiguration configuration;
final PlaceholderConfig configuration;

Map<String, PlaceholderConfigurationBuilder> get builders =>
Map<String, PlaceholderComponentBuilder> get builders =>
configuration.builders;
Set<String>? get customBlockAttributesKeys =>
configuration.customBlockAttributesKeys;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import 'package:flutter/material.dart' show TextStyle, immutable;
import '../../../../document/attribute.dart';

typedef PlaceholderConfigurationBuilder = PlaceholderArguments? Function(
typedef PlaceholderComponentBuilder = PlaceholderTextBuilder? Function(
Attribute, TextStyle);

@immutable
class PlaceholderComponentsConfiguration {
const PlaceholderComponentsConfiguration({
class PlaceholderConfig {
const PlaceholderConfig({
required this.builders,
this.customBlockAttributesKeys,
});

factory PlaceholderComponentsConfiguration.base() {
return const PlaceholderComponentsConfiguration(builders: {});
factory PlaceholderConfig.base() {
return const PlaceholderConfig(builders: {});
}

/// These attributes are used with the default ones
/// to let us add placeholder to custom block attributes
final Set<String>? customBlockAttributesKeys;
final Map<String, PlaceholderConfigurationBuilder> builders;
final Map<String, PlaceholderComponentBuilder> builders;

PlaceholderComponentsConfiguration copyWith({
Map<String, PlaceholderConfigurationBuilder>? builders,
PlaceholderConfig copyWith({
Map<String, PlaceholderComponentBuilder>? builders,
Set<String>? customBlockAttributesKeys,
}) {
return PlaceholderComponentsConfiguration(
return PlaceholderConfig(
builders: builders ?? this.builders,
customBlockAttributesKeys:
customBlockAttributesKeys ?? this.customBlockAttributesKeys,
Expand All @@ -34,10 +34,9 @@ class PlaceholderComponentsConfiguration {

@immutable

/// Represents the arguments that builds the text that will
/// be displayed
class PlaceholderArguments {
const PlaceholderArguments({
/// Represents the text that will be displayed
class PlaceholderTextBuilder {
const PlaceholderTextBuilder({
required this.placeholderText,
required this.style,
});
Expand Down
3 changes: 1 addition & 2 deletions lib/src/editor/raw_editor/config/raw_editor_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ class QuillRawEditorConfig {
final List<SpaceShortcutEvent> spaceShortcutEvents;

/// This argument configure how will be showed the placeholder at right or left of the cursor
final CursorParagrahPlaceholderConfiguration?
cursorParagrahPlaceholderConfiguration;
final CursorPlaceholderConfig? cursorParagrahPlaceholderConfiguration;

/// A handler for keys that are pressed when the editor is focused.
///
Expand Down
1 change: 0 additions & 1 deletion lib/src/editor/widgets/cursor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/widgets.dart';
import '../../common/utils/platform.dart';
import '../../document/nodes/line.dart';
import 'box.dart';
import 'cursor_configuration/cursor_configuration.dart';

/// Style properties of editing cursor.
class CursorStyle {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';

const TextStyle _defaultPlaceholderStyle =
TextStyle(color: Colors.grey, fontStyle: FontStyle.italic);

/// This class contains all necessary configurations
/// to show the wanted placeholder at the level of the cursor
///
/// You can see this as some Rich Text Editors can contains a feature
/// where if the line is empty and not contains any block style (like
/// header, align, codeblock, etc), then will show a text
/// like (assume that "|" is the cursor): "| start writing"
const TextStyle _defaultPlaceholderStyle =
TextStyle(color: Colors.grey, fontStyle: FontStyle.italic);

@immutable
class CursorParagrahPlaceholderConfiguration extends Equatable {
const CursorParagrahPlaceholderConfiguration({
class CursorPlaceholderConfig {
const CursorPlaceholderConfig({
required this.paragraphPlaceholderText,
required this.style,
required this.show,
});

factory CursorParagrahPlaceholderConfiguration.withPlaceholder(
{TextStyle? style}) {
return CursorParagrahPlaceholderConfiguration(
factory CursorPlaceholderConfig.basic({TextStyle? style}) {
return CursorPlaceholderConfig(
paragraphPlaceholderText: 'Enter text...',
style: style ?? _defaultPlaceholderStyle,
show: true,
);
}

factory CursorParagrahPlaceholderConfiguration.noPlaceholder() {
return const CursorParagrahPlaceholderConfiguration(
factory CursorPlaceholderConfig.noPlaceholder() {
return const CursorPlaceholderConfig(
paragraphPlaceholderText: '',
style: TextStyle(),
show: false,
Expand All @@ -48,5 +45,14 @@ class CursorParagrahPlaceholderConfiguration extends Equatable {
final bool show;

@override
List<Object?> get props => [paragraphPlaceholderText, style, show];
int get hashCode =>
paragraphPlaceholderText.hashCode ^ style.hashCode ^ show.hashCode;

@override
bool operator ==(covariant CursorPlaceholderConfig other) {
if (identical(this, other)) return true;
return other.show == show &&
other.paragraphPlaceholderText == paragraphPlaceholderText &&
other.style == style;
}
}
1 change: 0 additions & 1 deletion lib/src/editor/widgets/text/text_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import '../../raw_editor/builders/leading_block_builder.dart';
import '../../raw_editor/builders/placeholder/placeholder_builder_internal.dart';
import '../box.dart';
import '../cursor.dart';
import '../cursor_configuration/cursor_configuration.dart';
import '../default_leading_components/leading_components.dart';
import '../default_styles.dart';
import '../delegate.dart';
Expand Down

0 comments on commit 3a37acd

Please sign in to comment.