@@ -495,6 +495,27 @@ class ImageEmojiNode extends EmojiNode {
495
495
496
496
////////////////////////////////////////////////////////////////
497
497
498
+ // Ported from https://github.com/zulip/zulip-mobile/blob/c979530d6804db33310ed7d14a4ac62017432944/src/emoji/data.js#L108-L112
499
+ //
500
+ // Which was in turn ported from https://github.com/zulip/zulip/blob/63c9296d5339517450f79f176dc02d77b08020c8/zerver/models.py#L3235-L3242
501
+ // and that describes the encoding as follows:
502
+ //
503
+ // > * For Unicode emoji, [emoji_code is] a dash-separated hex encoding of
504
+ // > the sequence of Unicode codepoints that define this emoji in the
505
+ // > Unicode specification. For examples, see "non_qualified" or
506
+ // > "unified" in the following data, with "non_qualified" taking
507
+ // > precedence when both present:
508
+ // > https://github.com/raw/iamcal/emoji-data/master/emoji_pretty.json
509
+ String ? tryParseEmojiCodeToUnicode (String code) {
510
+ try {
511
+ return String .fromCharCodes (code.split ('-' ).map ((hex) => int .parse (hex, radix: 16 )));
512
+ } on FormatException { // thrown by `int.parse`
513
+ return null ;
514
+ } on ArgumentError { // thrown by `String.fromCharCodes`
515
+ return null ;
516
+ }
517
+ }
518
+
498
519
/// What sort of nodes a [_ZulipContentParser] is currently expecting to find.
499
520
enum _ParserContext {
500
521
/// The parser is currently looking for block nodes.
@@ -525,27 +546,6 @@ class _ZulipContentParser {
525
546
526
547
static final _emojiClassRegexp = RegExp (r"^emoji(-[0-9a-f]+)*$" );
527
548
528
- // Ported from https://github.com/zulip/zulip-mobile/blob/c979530d6804db33310ed7d14a4ac62017432944/src/emoji/data.js#L108-L112
529
- //
530
- // Which was in turn ported from https://github.com/zulip/zulip/blob/63c9296d5339517450f79f176dc02d77b08020c8/zerver/models.py#L3235-L3242
531
- // and that describes the encoding as follows:
532
- //
533
- // > * For Unicode emoji, [emoji_code is] a dash-separated hex encoding of
534
- // > the sequence of Unicode codepoints that define this emoji in the
535
- // > Unicode specification. For examples, see "non_qualified" or
536
- // > "unified" in the following data, with "non_qualified" taking
537
- // > precedence when both present:
538
- // > https://github.com/raw/iamcal/emoji-data/master/emoji_pretty.json
539
- String ? tryParseEmojiCodeToUnicode (String code) {
540
- try {
541
- return String .fromCharCodes (code.split ('-' ).map ((hex) => int .parse (hex, radix: 16 )));
542
- } on FormatException { // thrown by `int.parse`
543
- return null ;
544
- } on ArgumentError { // thrown by `String.fromCharCodes`
545
- return null ;
546
- }
547
- }
548
-
549
549
InlineContentNode parseInlineContent (dom.Node node) {
550
550
assert (_debugParserContext == _ParserContext .inline);
551
551
final debugHtmlNode = kDebugMode ? node : null ;
0 commit comments