]> cat aescling's git repositories - mastodon.git/commitdiff
fix(emojis): Handle multipoint emojis (e.g. country flags) (#4221)
authorSorin Davidoi <sorin.davidoi@gmail.com>
Mon, 17 Jul 2017 08:57:45 +0000 (10:57 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 17 Jul 2017 08:57:45 +0000 (10:57 +0200)
app/javascript/mastodon/features/compose/components/compose_form.js
app/javascript/mastodon/reducers/compose.js

index f0755294794c76a7f6e2a8963276bc76093f80b2..98e82355502faeb11e495ef09d646a7ff2154e15 100644 (file)
@@ -136,7 +136,7 @@ export default class ComposeForm extends ImmutablePureComponent {
 
   handleEmojiPick = (data) => {
     const position     = this.autosuggestTextarea.textarea.selectionStart;
-    const emojiChar    = String.fromCodePoint(parseInt(data.unicode, 16));
+    const emojiChar    = data.unicode.split('-').map(code => String.fromCodePoint(parseInt(code, 16))).join('');
     this._restoreCaret = position + emojiChar.length + 1;
     this.props.onPickEmoji(position, data);
   }
index ea3b78b67a1ec90ee48b7e2c75f38fd0715d2206..781e6e11b95fb44ccfa8ad0851a01b1b9fe6d9ba 100644 (file)
@@ -118,7 +118,7 @@ const insertSuggestion = (state, position, token, completion) => {
 };
 
 const insertEmoji = (state, position, emojiData) => {
-  const emoji = String.fromCodePoint(parseInt(emojiData.unicode, 16));
+  const emoji = emojiData.unicode.split('-').map(code => String.fromCodePoint(parseInt(code, 16))).join('');
 
   return state.withMutations(map => {
     map.update('text', oldText => `${oldText.slice(0, position)}${emoji} ${oldText.slice(position)}`);