Fix headers

pull/1575/head
Aleksei 1 year ago
parent 177afea889
commit fd2a941e8c
  1. 28
      lib/src/widgets/default_styles.dart
  2. 15
      lib/src/widgets/raw_editor/raw_editor_state.dart
  3. 3
      lib/src/widgets/text_line.dart

@ -67,6 +67,9 @@ class InlineCodeStyle {
this.header1, this.header1,
this.header2, this.header2,
this.header3, this.header3,
this.header4,
this.header5,
this.header6,
this.backgroundColor, this.backgroundColor,
this.radius, this.radius,
}); });
@ -83,6 +86,15 @@ class InlineCodeStyle {
/// Style override for inline code in headings level 3. /// Style override for inline code in headings level 3.
final TextStyle? header3; 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. /// Background color for inline code.
final Color? backgroundColor; final Color? backgroundColor;
@ -101,6 +113,15 @@ class InlineCodeStyle {
if (lineStyle.containsKey(Attribute.h3.key)) { if (lineStyle.containsKey(Attribute.h3.key)) {
return header3 ?? style; 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; return style;
} }
@ -116,13 +137,16 @@ class InlineCodeStyle {
other.header1 == header1 && other.header1 == header1 &&
other.header2 == header2 && other.header2 == header2 &&
other.header3 == header3 && other.header3 == header3 &&
other.header4 == header4 &&
other.header5 == header5 &&
other.header6 == header6 &&
other.backgroundColor == backgroundColor && other.backgroundColor == backgroundColor &&
other.radius == radius; other.radius == radius;
} }
@override @override
int get hashCode => int get hashCode => Object.hash(style, header1, header2, header3, header4,
Object.hash(style, header1, header2, header3, backgroundColor, radius); header5, header6, backgroundColor, radius);
} }
@immutable @immutable

@ -448,6 +448,21 @@ class QuillRawEditorState extends EditorState
control: !isDesktopMacOS, control: !isDesktopMacOS,
meta: isDesktopMacOS, meta: isDesktopMacOS,
): const QuillEditorApplyHeaderIntent(Attribute.h3), ): 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( SingleActivator(
LogicalKeyboardKey.digit0, LogicalKeyboardKey.digit0,
control: !isDesktopMacOS, control: !isDesktopMacOS,

@ -271,6 +271,9 @@ class _TextLineState extends State<TextLine> {
Attribute.h1: defaultStyles.h1!.style, Attribute.h1: defaultStyles.h1!.style,
Attribute.h2: defaultStyles.h2!.style, Attribute.h2: defaultStyles.h2!.style,
Attribute.h3: defaultStyles.h3!.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); textStyle = textStyle.merge(m[header] ?? defaultStyles.paragraph!.style);

Loading…
Cancel
Save