From b6763fe2fcda949e28b8c429582aca0c4781801a Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Thu, 22 Apr 2021 16:10:46 -0700 Subject: [PATCH] Revert "Indent attribute is consider block but may have null value" This reverts commit 4c5f72826c0aee09cd8a0bade2b5ac8f990efdfc. --- lib/models/documents/attribute.dart | 32 ++++++++--------------------- lib/models/documents/style.dart | 3 +-- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/lib/models/documents/attribute.dart b/lib/models/documents/attribute.dart index 1b9043b9..09564e4e 100644 --- a/lib/models/documents/attribute.dart +++ b/lib/models/documents/attribute.dart @@ -1,5 +1,3 @@ -import 'dart:collection'; - import 'package:quiver/core.dart'; enum AttributeScope { @@ -16,7 +14,7 @@ class Attribute { final AttributeScope scope; final T value; - static final Map _registry = LinkedHashMap.of({ + static final Map _registry = { Attribute.bold.key: Attribute.bold, Attribute.italic.key: Attribute.italic, Attribute.underline.key: Attribute.underline, @@ -28,16 +26,16 @@ class Attribute { Attribute.background.key: Attribute.background, Attribute.placeholder.key: Attribute.placeholder, Attribute.header.key: Attribute.header, + Attribute.indent.key: Attribute.indent, Attribute.align.key: Attribute.align, Attribute.list.key: Attribute.list, Attribute.codeBlock.key: Attribute.codeBlock, Attribute.blockQuote.key: Attribute.blockQuote, - Attribute.indent.key: Attribute.indent, Attribute.width.key: Attribute.width, Attribute.height.key: Attribute.height, Attribute.style.key: Attribute.style, Attribute.token.key: Attribute.token, - }); + }; static final BoldAttribute bold = BoldAttribute(); @@ -90,22 +88,22 @@ class Attribute { Attribute.placeholder.key, }; - static final Set blockKeys = LinkedHashSet.of({ + static final Set blockKeys = { Attribute.header.key, + Attribute.indent.key, Attribute.align.key, Attribute.list.key, Attribute.codeBlock.key, Attribute.blockQuote.key, - Attribute.indent.key, - }); + }; - static final Set blockKeysExceptHeader = LinkedHashSet.of({ + static final Set blockKeysExceptHeader = { Attribute.list.key, + Attribute.indent.key, Attribute.align.key, Attribute.codeBlock.key, Attribute.blockQuote.key, - Attribute.indent.key, - }); + }; static Attribute get h1 => HeaderAttribute(level: 1); @@ -174,18 +172,6 @@ class Attribute { return attribute; } - static int getRegistryOrder(Attribute attribute) { - var order = 0; - for (final attr in _registry.values) { - if (attr.key == attribute.key) { - break; - } - order++; - } - - return order; - } - static Attribute clone(Attribute origin, dynamic value) { return Attribute(origin.key, origin.scope, value); } diff --git a/lib/models/documents/style.dart b/lib/models/documents/style.dart index 7f3a39ac..c805280d 100644 --- a/lib/models/documents/style.dart +++ b/lib/models/documents/style.dart @@ -30,8 +30,7 @@ class Style { Iterable get keys => _attributes.keys; - Iterable get values => _attributes.values.sorted( - (a, b) => Attribute.getRegistryOrder(a) - Attribute.getRegistryOrder(b)); + Iterable get values => _attributes.values; Map get attributes => _attributes;