From fd2a941e8c73432e8f64df06902f771bc3857457 Mon Sep 17 00:00:00 2001 From: Aleksei <130981115+MacDeveloper1@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:47:03 +0100 Subject: [PATCH] Fix headers --- lib/src/widgets/default_styles.dart | 28 +++++++++++++++++-- .../widgets/raw_editor/raw_editor_state.dart | 15 ++++++++++ lib/src/widgets/text_line.dart | 3 ++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/default_styles.dart b/lib/src/widgets/default_styles.dart index ed224b78..0c7f7c9e 100644 --- a/lib/src/widgets/default_styles.dart +++ b/lib/src/widgets/default_styles.dart @@ -67,6 +67,9 @@ class InlineCodeStyle { this.header1, this.header2, this.header3, + this.header4, + this.header5, + this.header6, this.backgroundColor, this.radius, }); @@ -83,6 +86,15 @@ class InlineCodeStyle { /// Style override for inline code in headings level 3. final TextStyle? header3; + /// Style override for inline code in headings level 4. + final TextStyle? header4; + + /// Style override for inline code in headings level 5. + final TextStyle? header5; + + /// Style override for inline code in headings level 6. + final TextStyle? header6; + /// Background color for inline code. final Color? backgroundColor; @@ -101,6 +113,15 @@ class InlineCodeStyle { if (lineStyle.containsKey(Attribute.h3.key)) { return header3 ?? style; } + if (lineStyle.containsKey(Attribute.h4.key)) { + return header4 ?? style; + } + if (lineStyle.containsKey(Attribute.h5.key)) { + return header5 ?? style; + } + if (lineStyle.containsKey(Attribute.h6.key)) { + return header6 ?? style; + } return style; } @@ -116,13 +137,16 @@ class InlineCodeStyle { other.header1 == header1 && other.header2 == header2 && other.header3 == header3 && + other.header4 == header4 && + other.header5 == header5 && + other.header6 == header6 && other.backgroundColor == backgroundColor && other.radius == radius; } @override - int get hashCode => - Object.hash(style, header1, header2, header3, backgroundColor, radius); + int get hashCode => Object.hash(style, header1, header2, header3, header4, + header5, header6, backgroundColor, radius); } @immutable diff --git a/lib/src/widgets/raw_editor/raw_editor_state.dart b/lib/src/widgets/raw_editor/raw_editor_state.dart index 9d732205..4a9cf67c 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state.dart @@ -448,6 +448,21 @@ class QuillRawEditorState extends EditorState control: !isDesktopMacOS, meta: isDesktopMacOS, ): const QuillEditorApplyHeaderIntent(Attribute.h3), + SingleActivator( + LogicalKeyboardKey.digit4, + control: !isDesktopMacOS, + meta: isDesktopMacOS, + ): const QuillEditorApplyHeaderIntent(Attribute.h4), + SingleActivator( + LogicalKeyboardKey.digit5, + control: !isDesktopMacOS, + meta: isDesktopMacOS, + ): const QuillEditorApplyHeaderIntent(Attribute.h5), + SingleActivator( + LogicalKeyboardKey.digit6, + control: !isDesktopMacOS, + meta: isDesktopMacOS, + ): const QuillEditorApplyHeaderIntent(Attribute.h6), SingleActivator( LogicalKeyboardKey.digit0, control: !isDesktopMacOS, diff --git a/lib/src/widgets/text_line.dart b/lib/src/widgets/text_line.dart index c79e8da3..24a0f03d 100644 --- a/lib/src/widgets/text_line.dart +++ b/lib/src/widgets/text_line.dart @@ -271,6 +271,9 @@ class _TextLineState extends State { Attribute.h1: defaultStyles.h1!.style, Attribute.h2: defaultStyles.h2!.style, Attribute.h3: defaultStyles.h3!.style, + Attribute.h4: defaultStyles.h4!.style, + Attribute.h5: defaultStyles.h5!.style, + Attribute.h6: defaultStyles.h6!.style, }; textStyle = textStyle.merge(m[header] ?? defaultStyles.paragraph!.style);