fix: better organization for line height attribute

pull/1972/head
CatHood0 9 months ago
parent c651691999
commit f4d7636b55
  1. 28
      lib/src/models/documents/attribute.dart
  2. 9
      lib/src/widgets/quill/text_line.dart

@ -181,22 +181,6 @@ class Attribute<T> extends Equatable {
/// "attributes":{"header": 6 }
static const Attribute<int?> h6 = HeaderAttribute(level: 6);
/// "attributes":{"line-height": 1.0 }
static const Attribute<double?> lineHeightNormal =
LineHeightAttribute(lineHeight: 1);
/// "attributes":{"line-height": 1.15 }
static const Attribute<double?> lineHeightTight =
LineHeightAttribute(lineHeight: 1.15);
/// "attributes":{"line-height": 1.5 }
static const Attribute<double?> lineHeightOneAndHalf =
LineHeightAttribute(lineHeight: 1.5);
/// "attributes":{"line-height": 2.0 }
static const Attribute<double?> lineHeightDouble =
LineHeightAttribute(lineHeight: 2);
// "attributes":{"align":"left"}
static const Attribute<String?> leftAlignment = AlignAttribute('left');
@ -361,6 +345,18 @@ class HeaderAttribute extends Attribute<int?> {
class LineHeightAttribute extends Attribute<double?> {
const LineHeightAttribute({double? lineHeight})
: super('line-height', AttributeScope.block, lineHeight);
/// "attributes":{"line-height": 1.0 }
static const Attribute<double?> lineHeightNormal = LineHeightAttribute(lineHeight: 1);
/// "attributes":{"line-height": 1.15 }
static const Attribute<double?> lineHeightTight = LineHeightAttribute(lineHeight: 1.15);
/// "attributes":{"line-height": 1.5 }
static const Attribute<double?> lineHeightOneAndHalf = LineHeightAttribute(lineHeight: 1.5);
/// "attributes":{"line-height": 2.0 }
static const Attribute<double?> lineHeightDouble = LineHeightAttribute(lineHeight: 2);
}
class IndentAttribute extends Attribute<int?> {

@ -8,6 +8,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../flutter_quill.dart';
import '../../models/documents/attribute.dart';
import '../../models/documents/nodes/container.dart' as container_node;
import '../../models/documents/nodes/embeddable.dart';
@ -304,10 +305,10 @@ class _TextLineState extends State<TextLine> {
final lineHeight = widget.line.style.attributes[Attribute.lineHeight.key];
final x = <Attribute, TextStyle>{
Attribute.lineHeightNormal: defaultStyles.lineHeightNormal!.style,
Attribute.lineHeightTight: defaultStyles.lineHeightTight!.style,
Attribute.lineHeightOneAndHalf: defaultStyles.lineHeightOneAndHalf!.style,
Attribute.lineHeightDouble: defaultStyles.lineHeightDouble!.style,
LineHeightAttribute.lineHeightNormal: defaultStyles.lineHeightNormal!.style,
LineHeightAttribute.lineHeightTight: defaultStyles.lineHeightTight!.style,
LineHeightAttribute.lineHeightOneAndHalf: defaultStyles.lineHeightOneAndHalf!.style,
LineHeightAttribute.lineHeightDouble: defaultStyles.lineHeightDouble!.style,
};
textStyle =

Loading…
Cancel
Save