Add data-mx-emote to emotes

This commit is contained in:
Sorunome 2020-07-24 17:59:39 +02:00
parent 772cb2cf1d
commit 6cd745bd1a
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
2 changed files with 4 additions and 3 deletions

View file

@ -65,6 +65,7 @@ class EmoteSyntax extends InlineSyntax {
return true; return true;
} }
final element = Element.empty('img'); final element = Element.empty('img');
element.attributes['data-mx-emote'] = '';
element.attributes['src'] = htmlEscape.convert(mxc); element.attributes['src'] = htmlEscape.convert(mxc);
element.attributes['alt'] = htmlEscape.convert(emote); element.attributes['alt'] = htmlEscape.convert(emote);
element.attributes['title'] = htmlEscape.convert(emote); element.attributes['title'] = htmlEscape.convert(emote);

View file

@ -54,11 +54,11 @@ void main() {
}); });
test('emotes', () { test('emotes', () {
expect(markdown(':fox:', emotePacks), expect(markdown(':fox:', emotePacks),
'<img src="mxc:&#47;&#47;roomfox" alt=":fox:" title=":fox:" height="32" vertical-align="middle" />'); '<img data-mx-emote="" src="mxc:&#47;&#47;roomfox" alt=":fox:" title=":fox:" height="32" vertical-align="middle" />');
expect(markdown(':user~fox:', emotePacks), expect(markdown(':user~fox:', emotePacks),
'<img src="mxc:&#47;&#47;userfox" alt=":fox:" title=":fox:" height="32" vertical-align="middle" />'); '<img data-mx-emote="" src="mxc:&#47;&#47;userfox" alt=":fox:" title=":fox:" height="32" vertical-align="middle" />');
expect(markdown(':raccoon:', emotePacks), expect(markdown(':raccoon:', emotePacks),
'<img src="mxc:&#47;&#47;raccoon" alt=":raccoon:" title=":raccoon:" height="32" vertical-align="middle" />'); '<img data-mx-emote="" src="mxc:&#47;&#47;raccoon" alt=":raccoon:" title=":raccoon:" height="32" vertical-align="middle" />');
expect(markdown(':invalid:', emotePacks), ':invalid:'); expect(markdown(':invalid:', emotePacks), ':invalid:');
expect(markdown(':room~invalid:', emotePacks), ':room~invalid:'); expect(markdown(':room~invalid:', emotePacks), ':room~invalid:');
}); });