Add HeaderAttribute

pull/13/head
singerdmx 4 years ago
parent 9ac35562de
commit 0f90dd2a52
  1. 28
      lib/models/documents/attribute.dart

@ -7,22 +7,40 @@ enum AttributeScope {
class Attribute<T> { class Attribute<T> {
final String key; final String key;
final AttributeScope scope; final AttributeScope scope;
T value;
Attribute(this.key, this.scope); Attribute(this.key, this.scope, this.value);
} }
class BoldAttribute extends Attribute<bool> { class BoldAttribute extends Attribute<bool> {
BoldAttribute() : super('bold', AttributeScope.INLINE); BoldAttribute() : super('bold', AttributeScope.INLINE, null);
} }
class ItalicAttribute extends Attribute<bool> { class ItalicAttribute extends Attribute<bool> {
ItalicAttribute() : super('italic', AttributeScope.INLINE); ItalicAttribute() : super('italic', AttributeScope.INLINE, null);
} }
class UnderlineAttribute extends Attribute<bool> { class UnderlineAttribute extends Attribute<bool> {
UnderlineAttribute() : super('underline', AttributeScope.INLINE); UnderlineAttribute() : super('underline', AttributeScope.INLINE, null);
} }
class StrikeThroughAttribute extends Attribute<bool> { class StrikeThroughAttribute extends Attribute<bool> {
StrikeThroughAttribute() : super('strike', AttributeScope.INLINE); StrikeThroughAttribute() : super('strike', AttributeScope.INLINE, null);
}
class LinkAttribute extends Attribute<String> {
LinkAttribute() : super('link', AttributeScope.INLINE, null);
}
class HeaderAttribute extends Attribute<int> {
HeaderAttribute(int level) : super('header', AttributeScope.BLOCK, level);
// H1 in HTML
Attribute<int> get level1 => Attribute<int>(key, scope, 1);
// H2 in HTML
Attribute<int> get level2 => Attribute<int>(key, scope, 2);
// H3 in HTML
Attribute<int> get level3 => Attribute<int>(key, scope, 3);
} }

Loading…
Cancel
Save