1
+ import 'dart:collection' ;
2
+
1
3
import 'package:quiver/core.dart' ;
2
4
3
5
enum AttributeScope {
@@ -14,7 +16,7 @@ class Attribute<T> {
14
16
final AttributeScope scope;
15
17
final T value;
16
18
17
- static final Map <String , Attribute > _registry = {
19
+ static final Map <String , Attribute > _registry = LinkedHashMap . of ( {
18
20
Attribute .bold.key: Attribute .bold,
19
21
Attribute .italic.key: Attribute .italic,
20
22
Attribute .underline.key: Attribute .underline,
@@ -26,16 +28,16 @@ class Attribute<T> {
26
28
Attribute .background.key: Attribute .background,
27
29
Attribute .placeholder.key: Attribute .placeholder,
28
30
Attribute .header.key: Attribute .header,
29
- Attribute .indent.key: Attribute .indent,
30
31
Attribute .align.key: Attribute .align,
31
32
Attribute .list.key: Attribute .list,
32
33
Attribute .codeBlock.key: Attribute .codeBlock,
33
34
Attribute .blockQuote.key: Attribute .blockQuote,
35
+ Attribute .indent.key: Attribute .indent,
34
36
Attribute .width.key: Attribute .width,
35
37
Attribute .height.key: Attribute .height,
36
38
Attribute .style.key: Attribute .style,
37
39
Attribute .token.key: Attribute .token,
38
- };
40
+ }) ;
39
41
40
42
static final BoldAttribute bold = BoldAttribute ();
41
43
@@ -88,22 +90,22 @@ class Attribute<T> {
88
90
Attribute .placeholder.key,
89
91
};
90
92
91
- static final Set <String > blockKeys = {
93
+ static final Set <String > blockKeys = LinkedHashSet . of ( {
92
94
Attribute .header.key,
93
- Attribute .indent.key,
94
95
Attribute .align.key,
95
96
Attribute .list.key,
96
97
Attribute .codeBlock.key,
97
98
Attribute .blockQuote.key,
98
- };
99
+ Attribute .indent.key,
100
+ });
99
101
100
- static final Set <String > blockKeysExceptHeader = {
102
+ static final Set <String > blockKeysExceptHeader = LinkedHashSet . of ( {
101
103
Attribute .list.key,
102
- Attribute .indent.key,
103
104
Attribute .align.key,
104
105
Attribute .codeBlock.key,
105
106
Attribute .blockQuote.key,
106
- };
107
+ Attribute .indent.key,
108
+ });
107
109
108
110
static Attribute <int ?> get h1 => HeaderAttribute (level: 1 );
109
111
@@ -172,6 +174,18 @@ class Attribute<T> {
172
174
return attribute;
173
175
}
174
176
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
+
175
189
static Attribute clone (Attribute origin, dynamic value) {
176
190
return Attribute (origin.key, origin.scope, value);
177
191
}
0 commit comments