Merge branch 'soru/update-emotes' into 'master'

Add data-mx-emote to emotes as per MSC

See merge request famedly/famedlysdk!397
This commit is contained in:
Christian Pauly 2020-07-25 11:56:23 +00:00
commit 7cc14687c4
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:');
}); });