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.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

@ -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,

@ -271,6 +271,9 @@ class _TextLineState extends State<TextLine> {
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);

Loading…
Cancel
Save