Skip to content

Commit cad93d7

Browse files
committed
removed Container from Attributes.dart
1 parent 6e7753e commit cad93d7

File tree

2 files changed

+5
-52
lines changed

2 files changed

+5
-52
lines changed

packages/notus/lib/src/convert/html.dart

-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ class _NotusHTMLEncoder extends Converter<Delta, String> {
283283
_writeBlockTag(buffer, attribute, close: close);
284284
} else if (attribute.key == NotusAttribute.embed.key) {
285285
_writeEmbedTag(buffer, attribute, close: close);
286-
} else if (attribute.key == NotusAttribute.container.key) {
287-
// do nothing
288286
} else {
289287
throw new ArgumentError('Cannot handle $attribute');
290288
}

packages/notus/lib/src/document/attributes.dart

+5-50
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ abstract class NotusAttributeBuilder<T> implements NotusAttributeKey<T> {
4040

4141
final String key;
4242
final NotusAttributeScope scope;
43+
4344
NotusAttribute<T> get unset => new NotusAttribute<T>._(key, scope, null);
45+
4446
NotusAttribute<T> withValue(T value) =>
4547
new NotusAttribute<T>._(key, scope, value);
4648
}
@@ -77,7 +79,6 @@ class NotusAttribute<T> implements NotusAttributeBuilder<T> {
7779
NotusAttribute.heading.key: NotusAttribute.heading,
7880
NotusAttribute.block.key: NotusAttribute.block,
7981
NotusAttribute.embed.key: NotusAttribute.embed,
80-
NotusAttribute.container.key: NotusAttribute.container,
8182
};
8283

8384
// Inline attributes
@@ -123,9 +124,6 @@ class NotusAttribute<T> implements NotusAttributeBuilder<T> {
123124
/// Embed style attribute.
124125
static const embed = const EmbedAttributeBuilder._();
125126

126-
/// Container attribute
127-
static const container = const ContainerAttributeBuilder._();
128-
129127
static NotusAttribute _fromKeyValue(String key, dynamic value) {
130128
if (!_registry.containsKey(key))
131129
throw new ArgumentError.value(
@@ -332,6 +330,7 @@ class _ItalicAttribute extends NotusAttribute<bool> {
332330
/// [NotusAttribute.link] instead.
333331
class LinkAttributeBuilder extends NotusAttributeBuilder<String> {
334332
static const _kLink = 'a';
333+
335334
const LinkAttributeBuilder._() : super._(_kLink, NotusAttributeScope.inline);
336335

337336
/// Creates a link attribute with specified link [value].
@@ -345,6 +344,7 @@ class LinkAttributeBuilder extends NotusAttributeBuilder<String> {
345344
/// [NotusAttribute.heading] instead.
346345
class HeadingAttributeBuilder extends NotusAttributeBuilder<int> {
347346
static const _kHeading = 'heading';
347+
348348
const HeadingAttributeBuilder._()
349349
: super._(_kHeading, NotusAttributeScope.line);
350350

@@ -364,6 +364,7 @@ class HeadingAttributeBuilder extends NotusAttributeBuilder<int> {
364364
/// [NotusAttribute.block] instead.
365365
class BlockAttributeBuilder extends NotusAttributeBuilder<String> {
366366
static const _kBlock = 'block';
367+
367368
const BlockAttributeBuilder._() : super._(_kBlock, NotusAttributeScope.line);
368369

369370
/// Formats a block of lines as a bullet list.
@@ -453,49 +454,3 @@ class EmbedAttribute extends NotusAttribute<Map<String, dynamic>> {
453454
return hashObjects(objects);
454455
}
455456
}
456-
457-
class ContainerAttributeBuilder
458-
extends NotusAttributeBuilder<Map<String, dynamic>> {
459-
const ContainerAttributeBuilder._()
460-
: super._(ContainerAttribute._kContainer, NotusAttributeScope.inline);
461-
462-
@override
463-
NotusAttribute<Map<String, dynamic>> get unset => ContainerAttribute._(null);
464-
465-
NotusAttribute<Map<String, dynamic>> withValue(Map<String, dynamic> value) =>
466-
ContainerAttribute._(value);
467-
}
468-
469-
class ContainerAttribute extends NotusAttribute<Map<String, dynamic>> {
470-
static const _kValueEquality = const MapEquality<String, dynamic>();
471-
static const _kContainer = 'container';
472-
473-
ContainerAttribute._(Map<String, dynamic> value)
474-
: super._(_kContainer, NotusAttributeScope.inline, value);
475-
476-
@override
477-
NotusAttribute<Map<String, dynamic>> get unset => ContainerAttribute._(null);
478-
479-
@override
480-
bool operator ==(other) {
481-
if (identical(this, other)) return true;
482-
if (other is! ContainerAttribute) return false;
483-
ContainerAttribute typedOther = other;
484-
return key == typedOther.key &&
485-
scope == typedOther.scope &&
486-
_kValueEquality.equals(value, typedOther.value);
487-
}
488-
489-
@override
490-
int get hashCode {
491-
final objects = [key, scope];
492-
if (value != null) {
493-
final valueHashes =
494-
value.entries.map((entry) => hash2(entry.key, entry.value));
495-
objects.addAll(valueHashes);
496-
} else {
497-
objects.add(value);
498-
}
499-
return hashObjects(objects);
500-
}
501-
}

0 commit comments

Comments
 (0)