refactor: move LineHeightAttribute class to custom_attributes.dart

pull/2032/head
Ellet 9 months ago
parent 8c5e155d10
commit f5572a9291
No known key found for this signature in database
GPG Key ID: 40CCC70E96F82970
  1. 24
      lib/src/document/attribute.dart
  2. 25
      lib/src/document/custom_attributes.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<int?> {
: 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<double?> {
const LineHeightAttribute({double? lineHeight})
: super('line-height', AttributeScope.block, lineHeight);
static const Attribute<double?> lineHeightNormal =
LineHeightAttribute(lineHeight: 1);
static const Attribute<double?> lineHeightTight =
LineHeightAttribute(lineHeight: 1.15);
static const Attribute<double?> lineHeightOneAndHalf =
LineHeightAttribute(lineHeight: 1.5);
static const Attribute<double?> lineHeightDouble =
LineHeightAttribute(lineHeight: 2);
}
class IndentAttribute extends Attribute<int?> {
const IndentAttribute({int? level})
: super('indent', AttributeScope.block, level);

@ -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<double?> {
const LineHeightAttribute({double? lineHeight})
: super('line-height', AttributeScope.block, lineHeight);
static const Attribute<double?> lineHeightNormal =
LineHeightAttribute(lineHeight: 1);
static const Attribute<double?> lineHeightTight =
LineHeightAttribute(lineHeight: 1.15);
static const Attribute<double?> lineHeightOneAndHalf =
LineHeightAttribute(lineHeight: 1.5);
static const Attribute<double?> lineHeightDouble =
LineHeightAttribute(lineHeight: 2);
}
Loading…
Cancel
Save