From 0f90dd2a522188a9a5b889ed01a92cf819a11184 Mon Sep 17 00:00:00 2001 From: singerdmx Date: Tue, 15 Dec 2020 21:27:49 -0800 Subject: [PATCH] Add HeaderAttribute --- lib/models/documents/attribute.dart | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/models/documents/attribute.dart b/lib/models/documents/attribute.dart index 5351ae77..412d7a9c 100644 --- a/lib/models/documents/attribute.dart +++ b/lib/models/documents/attribute.dart @@ -7,22 +7,40 @@ enum AttributeScope { class Attribute { final String key; final AttributeScope scope; + T value; - Attribute(this.key, this.scope); + Attribute(this.key, this.scope, this.value); } class BoldAttribute extends Attribute { - BoldAttribute() : super('bold', AttributeScope.INLINE); + BoldAttribute() : super('bold', AttributeScope.INLINE, null); } class ItalicAttribute extends Attribute { - ItalicAttribute() : super('italic', AttributeScope.INLINE); + ItalicAttribute() : super('italic', AttributeScope.INLINE, null); } class UnderlineAttribute extends Attribute { - UnderlineAttribute() : super('underline', AttributeScope.INLINE); + UnderlineAttribute() : super('underline', AttributeScope.INLINE, null); } class StrikeThroughAttribute extends Attribute { - StrikeThroughAttribute() : super('strike', AttributeScope.INLINE); + StrikeThroughAttribute() : super('strike', AttributeScope.INLINE, null); +} + +class LinkAttribute extends Attribute { + LinkAttribute() : super('link', AttributeScope.INLINE, null); +} + +class HeaderAttribute extends Attribute { + HeaderAttribute(int level) : super('header', AttributeScope.BLOCK, level); + + // H1 in HTML + Attribute get level1 => Attribute(key, scope, 1); + + // H2 in HTML + Attribute get level2 => Attribute(key, scope, 2); + + // H3 in HTML + Attribute get level3 => Attribute(key, scope, 3); }