diff --git a/lib/src/models/config/editor/editor_configurations.dart b/lib/src/models/config/editor/editor_configurations.dart index 74cc66c8..98219fa5 100644 --- a/lib/src/models/config/editor/editor_configurations.dart +++ b/lib/src/models/config/editor/editor_configurations.dart @@ -53,6 +53,7 @@ class QuillEditorConfigurations extends Equatable { this.onSingleLongTapStart, this.onSingleLongTapMoveUpdate, this.onSingleLongTapEnd, + this.enableMarkdownStyleConversion = true, this.embedBuilders, this.unknownEmbedBuilder, this.linkActionPickerDelegate = defaultLinkActionPickerDelegate, @@ -127,6 +128,13 @@ class QuillEditorConfigurations extends Equatable { final bool scrollable; final double scrollBottomInset; + /// Configuration to enable or disable automatic Markdown style conversions. + /// + /// This setting controls the behavior of input. Specifically, when enabled, + /// entering '1.' followed by a space or '-' followed by a space + /// will automatically convert the input into a Markdown list format. + final bool enableMarkdownStyleConversion; + /// Additional space around the content of this editor. /// by default will be [EdgeInsets.zero] final EdgeInsetsGeometry padding; @@ -385,6 +393,7 @@ class QuillEditorConfigurations extends Equatable { bool? checkBoxReadOnly, bool? disableClipboard, bool? scrollable, + bool? enableMarkdownStyleConversion, double? scrollBottomInset, EdgeInsetsGeometry? padding, bool? autoFocus, @@ -439,6 +448,8 @@ class QuillEditorConfigurations extends Equatable { scrollable: scrollable ?? this.scrollable, scrollBottomInset: scrollBottomInset ?? this.scrollBottomInset, padding: padding ?? this.padding, + enableMarkdownStyleConversion: + enableMarkdownStyleConversion ?? this.enableMarkdownStyleConversion, autoFocus: autoFocus ?? this.autoFocus, isOnTapOutsideEnabled: isOnTapOutsideEnabled ?? this.isOnTapOutsideEnabled, diff --git a/lib/src/models/config/raw_editor/raw_editor_configurations.dart b/lib/src/models/config/raw_editor/raw_editor_configurations.dart index b774b9a2..22aa42b3 100644 --- a/lib/src/models/config/raw_editor/raw_editor_configurations.dart +++ b/lib/src/models/config/raw_editor/raw_editor_configurations.dart @@ -67,6 +67,7 @@ class QuillRawEditorConfigurations extends Equatable { this.customActions, this.expands = false, this.isOnTapOutsideEnabled = true, + this.enableMarkdownStyleConversion = true, this.onTapOutside, this.keyboardAppearance, this.enableInteractiveSelection = true, @@ -100,6 +101,8 @@ class QuillRawEditorConfigurations extends Equatable { /// Additional space around the editor contents. final EdgeInsetsGeometry padding; + final bool enableMarkdownStyleConversion; + /// Whether the text can be changed. /// /// When this is set to true, the text cannot be modified diff --git a/lib/src/widgets/editor/editor.dart b/lib/src/widgets/editor/editor.dart index ad81ea20..7af8da25 100644 --- a/lib/src/widgets/editor/editor.dart +++ b/lib/src/widgets/editor/editor.dart @@ -236,6 +236,8 @@ class QuillEditorState extends State focusNode: widget.focusNode, scrollController: widget.scrollController, scrollable: configurations.scrollable, + enableMarkdownStyleConversion: + configurations.enableMarkdownStyleConversion, scrollBottomInset: configurations.scrollBottomInset, padding: configurations.padding, readOnly: configurations.readOnly, diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index 9f175d3b..963de027 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -785,10 +785,12 @@ class QuillRawEditorState extends EditorState const olKeyPhrase = '1.'; const ulKeyPhrase = '-'; + final enableMdConversion = + widget.configurations.enableMarkdownStyleConversion; - if (text.value == olKeyPhrase) { + if (text.value == olKeyPhrase && enableMdConversion) { _updateSelectionForKeyPhrase(olKeyPhrase, Attribute.ol); - } else if (text.value == ulKeyPhrase) { + } else if (text.value == ulKeyPhrase && enableMdConversion) { _updateSelectionForKeyPhrase(ulKeyPhrase, Attribute.ul); } else { return KeyEventResult.ignored;