Skip to content

Commit b6763fe

Browse files
committed
Revert "Indent attribute is consider block but may have null value"
This reverts commit 4c5f728.
1 parent 4c5f728 commit b6763fe

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

lib/models/documents/attribute.dart

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:collection';
2-
31
import 'package:quiver/core.dart';
42

53
enum AttributeScope {
@@ -16,7 +14,7 @@ class Attribute<T> {
1614
final AttributeScope scope;
1715
final T value;
1816

19-
static final Map<String, Attribute> _registry = LinkedHashMap.of({
17+
static final Map<String, Attribute> _registry = {
2018
Attribute.bold.key: Attribute.bold,
2119
Attribute.italic.key: Attribute.italic,
2220
Attribute.underline.key: Attribute.underline,
@@ -28,16 +26,16 @@ class Attribute<T> {
2826
Attribute.background.key: Attribute.background,
2927
Attribute.placeholder.key: Attribute.placeholder,
3028
Attribute.header.key: Attribute.header,
29+
Attribute.indent.key: Attribute.indent,
3130
Attribute.align.key: Attribute.align,
3231
Attribute.list.key: Attribute.list,
3332
Attribute.codeBlock.key: Attribute.codeBlock,
3433
Attribute.blockQuote.key: Attribute.blockQuote,
35-
Attribute.indent.key: Attribute.indent,
3634
Attribute.width.key: Attribute.width,
3735
Attribute.height.key: Attribute.height,
3836
Attribute.style.key: Attribute.style,
3937
Attribute.token.key: Attribute.token,
40-
});
38+
};
4139

4240
static final BoldAttribute bold = BoldAttribute();
4341

@@ -90,22 +88,22 @@ class Attribute<T> {
9088
Attribute.placeholder.key,
9189
};
9290

93-
static final Set<String> blockKeys = LinkedHashSet.of({
91+
static final Set<String> blockKeys = {
9492
Attribute.header.key,
93+
Attribute.indent.key,
9594
Attribute.align.key,
9695
Attribute.list.key,
9796
Attribute.codeBlock.key,
9897
Attribute.blockQuote.key,
99-
Attribute.indent.key,
100-
});
98+
};
10199

102-
static final Set<String> blockKeysExceptHeader = LinkedHashSet.of({
100+
static final Set<String> blockKeysExceptHeader = {
103101
Attribute.list.key,
102+
Attribute.indent.key,
104103
Attribute.align.key,
105104
Attribute.codeBlock.key,
106105
Attribute.blockQuote.key,
107-
Attribute.indent.key,
108-
});
106+
};
109107

110108
static Attribute<int?> get h1 => HeaderAttribute(level: 1);
111109

@@ -174,18 +172,6 @@ class Attribute<T> {
174172
return attribute;
175173
}
176174

177-
static int getRegistryOrder(Attribute attribute) {
178-
var order = 0;
179-
for (final attr in _registry.values) {
180-
if (attr.key == attribute.key) {
181-
break;
182-
}
183-
order++;
184-
}
185-
186-
return order;
187-
}
188-
189175
static Attribute clone(Attribute origin, dynamic value) {
190176
return Attribute(origin.key, origin.scope, value);
191177
}

lib/models/documents/style.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class Style {
3030

3131
Iterable<String> get keys => _attributes.keys;
3232

33-
Iterable<Attribute> get values => _attributes.values.sorted(
34-
(a, b) => Attribute.getRegistryOrder(a) - Attribute.getRegistryOrder(b));
33+
Iterable<Attribute> get values => _attributes.values;
3534

3635
Map<String, Attribute> get attributes => _attributes;
3736

0 commit comments

Comments
 (0)