From f5572a92919f79989c2f94f07c18657040518626 Mon Sep 17 00:00:00 2001 From: Ellet Date: Wed, 17 Jul 2024 12:54:47 -0700 Subject: [PATCH] refactor: move LineHeightAttribute class to custom_attributes.dart --- lib/src/document/attribute.dart | 24 +++--------------------- lib/src/document/custom_attributes.dart | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 lib/src/document/custom_attributes.dart diff --git a/lib/src/document/attribute.dart b/lib/src/document/attribute.dart index deea5a15..1590adc5 100644 --- a/lib/src/document/attribute.dart +++ b/lib/src/document/attribute.dart @@ -4,6 +4,9 @@ import 'package:equatable/equatable.dart'; import 'package:meta/meta.dart' show immutable; import 'package:quiver/core.dart'; +import 'custom_attributes.dart'; +export 'custom_attributes.dart'; + enum AttributeScope { inline, // refer to https://quilljs.com/docs/formats/#inline block, // refer to https://quilljs.com/docs/formats/#block @@ -354,27 +357,6 @@ class HeaderAttribute extends Attribute { : super('header', AttributeScope.block, level); } -/// This attribute represents the space between text lines. The line height can be -/// adjusted using predefined constants or custom values -/// -/// The attribute at the json looks like: "attributes":{"line-height": 1.5 } -class LineHeightAttribute extends Attribute { - const LineHeightAttribute({double? lineHeight}) - : super('line-height', AttributeScope.block, lineHeight); - - static const Attribute lineHeightNormal = - LineHeightAttribute(lineHeight: 1); - - static const Attribute lineHeightTight = - LineHeightAttribute(lineHeight: 1.15); - - static const Attribute lineHeightOneAndHalf = - LineHeightAttribute(lineHeight: 1.5); - - static const Attribute lineHeightDouble = - LineHeightAttribute(lineHeight: 2); -} - class IndentAttribute extends Attribute { const IndentAttribute({int? level}) : super('indent', AttributeScope.block, level); diff --git a/lib/src/document/custom_attributes.dart b/lib/src/document/custom_attributes.dart new file mode 100644 index 00000000..625dab1d --- /dev/null +++ b/lib/src/document/custom_attributes.dart @@ -0,0 +1,25 @@ +import 'attribute.dart'; + +// Attributes that don't conform to standard Quill Delta +// and are not compatible with https://quilljs.com/docs/delta/ + +/// This attribute represents the space between text lines. The line height can be +/// adjusted using predefined constants or custom values +/// +/// The attribute at the json looks like: "attributes":{"line-height": 1.5 } +class LineHeightAttribute extends Attribute { + const LineHeightAttribute({double? lineHeight}) + : super('line-height', AttributeScope.block, lineHeight); + + static const Attribute lineHeightNormal = + LineHeightAttribute(lineHeight: 1); + + static const Attribute lineHeightTight = + LineHeightAttribute(lineHeight: 1.15); + + static const Attribute lineHeightOneAndHalf = + LineHeightAttribute(lineHeight: 1.5); + + static const Attribute lineHeightDouble = + LineHeightAttribute(lineHeight: 2); +}