From f4d7636b55c3859c9aed4349e78c39307ceae45a Mon Sep 17 00:00:00 2001 From: CatHood0 Date: Thu, 4 Jul 2024 21:16:09 -0400 Subject: [PATCH] fix: better organization for line height attribute --- lib/src/models/documents/attribute.dart | 28 +++++++++++-------------- lib/src/widgets/quill/text_line.dart | 9 ++++---- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/lib/src/models/documents/attribute.dart b/lib/src/models/documents/attribute.dart index bd87d024..eccb503a 100644 --- a/lib/src/models/documents/attribute.dart +++ b/lib/src/models/documents/attribute.dart @@ -181,22 +181,6 @@ class Attribute extends Equatable { /// "attributes":{"header": 6 } static const Attribute h6 = HeaderAttribute(level: 6); - /// "attributes":{"line-height": 1.0 } - static const Attribute lineHeightNormal = - LineHeightAttribute(lineHeight: 1); - - /// "attributes":{"line-height": 1.15 } - static const Attribute lineHeightTight = - LineHeightAttribute(lineHeight: 1.15); - - /// "attributes":{"line-height": 1.5 } - static const Attribute lineHeightOneAndHalf = - LineHeightAttribute(lineHeight: 1.5); - - /// "attributes":{"line-height": 2.0 } - static const Attribute lineHeightDouble = - LineHeightAttribute(lineHeight: 2); - // "attributes":{"align":"left"} static const Attribute leftAlignment = AlignAttribute('left'); @@ -361,6 +345,18 @@ class HeaderAttribute extends Attribute { class LineHeightAttribute extends Attribute { const LineHeightAttribute({double? lineHeight}) : super('line-height', AttributeScope.block, lineHeight); + + /// "attributes":{"line-height": 1.0 } + static const Attribute lineHeightNormal = LineHeightAttribute(lineHeight: 1); + + /// "attributes":{"line-height": 1.15 } + static const Attribute lineHeightTight = LineHeightAttribute(lineHeight: 1.15); + + /// "attributes":{"line-height": 1.5 } + static const Attribute lineHeightOneAndHalf = LineHeightAttribute(lineHeight: 1.5); + + /// "attributes":{"line-height": 2.0 } + static const Attribute lineHeightDouble = LineHeightAttribute(lineHeight: 2); } class IndentAttribute extends Attribute { diff --git a/lib/src/widgets/quill/text_line.dart b/lib/src/widgets/quill/text_line.dart index 454dee42..f009550d 100644 --- a/lib/src/widgets/quill/text_line.dart +++ b/lib/src/widgets/quill/text_line.dart @@ -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 { final lineHeight = widget.line.style.attributes[Attribute.lineHeight.key]; final x = { - 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 =