From 04ed863a6dd3a4b14bc760ff741ca516764b567f Mon Sep 17 00:00:00 2001 From: singerdmx Date: Tue, 15 Dec 2020 22:26:13 -0800 Subject: [PATCH] Update Style class --- lib/models/documents/attribute.dart | 2 ++ lib/models/documents/style.dart | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/models/documents/attribute.dart b/lib/models/documents/attribute.dart index 3159ee20..f3e8715c 100644 --- a/lib/models/documents/attribute.dart +++ b/lib/models/documents/attribute.dart @@ -41,6 +41,8 @@ class Attribute { static BlockQuoteAttribute blockQuoteAttribute = BlockQuoteAttribute(); + bool get isInline => scope == AttributeScope.INLINE; + static Attribute fromKeyValue(String key, dynamic value) { if (!_registry.containsKey(key)) { throw ArgumentError.value(key, 'key "$key" not found.'); diff --git a/lib/models/documents/style.dart b/lib/models/documents/style.dart index 43025310..490f6107 100644 --- a/lib/models/documents/style.dart +++ b/lib/models/documents/style.dart @@ -19,4 +19,18 @@ class Style { }); return Style.attr(result); } + + Iterable get keys => _attributes.keys; + + Iterable get values => _attributes.values; + + bool get isEmpty => _attributes.isEmpty; + + bool get isNotEmpty => _attributes.isNotEmpty; + + bool get isInline => isNotEmpty && values.every((item) => item.isInline); + + Attribute get single => _attributes.values.single; + + bool containsKey(String key) => _attributes.containsKey(key); }