Skip to content

Commit

Permalink
Merge pull request #429 from greybutton/try-fix-emoji
Browse files Browse the repository at this point in the history
try fix emoji
  • Loading branch information
vtm9 committed Jan 19, 2019
2 parents 4ea1b8a + 6eb7dc2 commit c8477af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion services/app/assets/js/widgets/components/InputWithEmoji.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ class InputWithEmoji extends PureComponent {
}
};

getEmoji = (emoji) => {
const codes = emoji.unified.split('-').map(c => `0x${c}`);
return String.fromCodePoint(...codes);
}

addEmoji = (emoji, closeEmoji) => {
const { value, handleChange } = this.props;
const input = this.inputRef.current;
const cursorPosition = input.selectionStart;
const start = value.substring(0, input.selectionStart);
const end = value.substring(input.selectionEnd);
const updatedValue = `${start}${emoji.native}${end}`;
const emojiPic = this.getEmoji(emoji);
const updatedValue = `${start}${emojiPic}${end}`;

handleChange(updatedValue);
closeEmoji();
Expand Down

0 comments on commit c8477af

Please sign in to comment.