insert mention all attribute

pull/1326/head
QuangLM 2 years ago
parent 1b706e356a
commit d85bdc353f
  1. 59
      lib/src/models/documents/attribute.dart

@ -50,11 +50,9 @@ class Attribute<T> {
static const BoldAttribute bold = BoldAttribute();
static final ScriptAttribute subscript =
ScriptAttribute(ScriptAttributes.sub);
static final ScriptAttribute subscript = ScriptAttribute(ScriptAttributes.sub);
static final ScriptAttribute superscript =
ScriptAttribute(ScriptAttributes.sup);
static final ScriptAttribute superscript = ScriptAttribute(ScriptAttributes.sup);
static const ItalicAttribute italic = ItalicAttribute();
@ -116,6 +114,8 @@ class Attribute<T> {
static const MentionAttribute mention = MentionAttribute(null);
static const MentionAllAttribute mentionAll = MentionAllAttribute(null);
static const VideoAttribute video = VideoAttribute(null);
static final Set<String> inlineKeys = {
@ -163,6 +163,7 @@ class Attribute<T> {
Attribute.video.key,
Attribute.file.key,
Attribute.mention.key,
Attribute.mentionAll.key,
};
static const Attribute<int?> h1 = HeaderAttribute(level: 1);
@ -256,9 +257,7 @@ class Attribute<T> {
if (identical(this, other)) return true;
if (other is! Attribute) return false;
final typedOther = other;
return key == typedOther.key &&
scope == typedOther.scope &&
value == typedOther.value;
return key == typedOther.key && scope == typedOther.scope && value == typedOther.value;
}
@override
@ -307,29 +306,24 @@ class LinkAttribute extends Attribute<String?> {
}
class ColorAttribute extends Attribute<String?> {
const ColorAttribute(String? val)
: super('color', AttributeScope.INLINE, val);
const ColorAttribute(String? val) : super('color', AttributeScope.INLINE, val);
}
class BackgroundAttribute extends Attribute<String?> {
const BackgroundAttribute(String? val)
: super('background', AttributeScope.INLINE, val);
const BackgroundAttribute(String? val) : super('background', AttributeScope.INLINE, val);
}
/// This is custom attribute for hint
class PlaceholderAttribute extends Attribute<bool> {
const PlaceholderAttribute()
: super('placeholder', AttributeScope.INLINE, true);
const PlaceholderAttribute() : super('placeholder', AttributeScope.INLINE, true);
}
class HeaderAttribute extends Attribute<int?> {
const HeaderAttribute({int? level})
: super('header', AttributeScope.BLOCK, level);
const HeaderAttribute({int? level}) : super('header', AttributeScope.BLOCK, level);
}
class IndentAttribute extends Attribute<int?> {
const IndentAttribute({int? level})
: super('indent', AttributeScope.BLOCK, level);
const IndentAttribute({int? level}) : super('indent', AttributeScope.BLOCK, level);
}
class AlignAttribute extends Attribute<String?> {
@ -349,23 +343,19 @@ class BlockQuoteAttribute extends Attribute<bool> {
}
class DirectionAttribute extends Attribute<String?> {
const DirectionAttribute(String? val)
: super('direction', AttributeScope.BLOCK, val);
const DirectionAttribute(String? val) : super('direction', AttributeScope.BLOCK, val);
}
class WidthAttribute extends Attribute<String?> {
const WidthAttribute(String? val)
: super('width', AttributeScope.IGNORE, val);
const WidthAttribute(String? val) : super('width', AttributeScope.IGNORE, val);
}
class HeightAttribute extends Attribute<String?> {
const HeightAttribute(String? val)
: super('height', AttributeScope.IGNORE, val);
const HeightAttribute(String? val) : super('height', AttributeScope.IGNORE, val);
}
class StyleAttribute extends Attribute<String?> {
const StyleAttribute(String? val)
: super('style', AttributeScope.IGNORE, val);
const StyleAttribute(String? val) : super('style', AttributeScope.IGNORE, val);
}
class TokenAttribute extends Attribute<String> {
@ -373,8 +363,7 @@ class TokenAttribute extends Attribute<String> {
}
class ScriptAttribute extends Attribute<String?> {
ScriptAttribute(ScriptAttributes? val)
: super('script', AttributeScope.INLINE, val?.value);
ScriptAttribute(ScriptAttributes? val) : super('script', AttributeScope.INLINE, val?.value);
}
enum ScriptAttributes {
@ -387,21 +376,21 @@ enum ScriptAttributes {
}
class ImageAttribute extends Attribute<String?> {
const ImageAttribute(String? url)
: super('img', AttributeScope.EMBEDS, url);
const ImageAttribute(String? url) : super('img', AttributeScope.EMBEDS, url);
}
class VideoAttribute extends Attribute<String?> {
const VideoAttribute(String? url)
: super('video', AttributeScope.EMBEDS, url);
const VideoAttribute(String? url) : super('video', AttributeScope.EMBEDS, url);
}
class FileAttribute extends Attribute<String?> {
const FileAttribute(String? url)
: super('file', AttributeScope.EMBEDS, url);
const FileAttribute(String? url) : super('file', AttributeScope.EMBEDS, url);
}
class MentionAttribute extends Attribute<String?> {
const MentionAttribute(String? url)
: super('mention', AttributeScope.EMBEDS, url);
const MentionAttribute(String? url) : super('mention', AttributeScope.EMBEDS, url);
}
class MentionAllAttribute extends Attribute<String?> {
const MentionAllAttribute(String? url) : super('mention_all', AttributeScope.EMBEDS, url);
}

Loading…
Cancel
Save