fix(emojis): Handle multipoint emojis (e.g. country flags) (#4221)
This commit is contained in:
		
							parent
							
								
									d4b097a88c
								
							
						
					
					
						commit
						1d2616b79b
					
				| @ -136,7 +136,7 @@ export default class ComposeForm extends ImmutablePureComponent { | |||||||
| 
 | 
 | ||||||
|   handleEmojiPick = (data) => { |   handleEmojiPick = (data) => { | ||||||
|     const position     = this.autosuggestTextarea.textarea.selectionStart; |     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._restoreCaret = position + emojiChar.length + 1; | ||||||
|     this.props.onPickEmoji(position, data); |     this.props.onPickEmoji(position, data); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -118,7 +118,7 @@ const insertSuggestion = (state, position, token, completion) => { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const insertEmoji = (state, position, emojiData) => { | 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 => { |   return state.withMutations(map => { | ||||||
|     map.update('text', oldText => `${oldText.slice(0, position)}${emoji} ${oldText.slice(position)}`); |     map.update('text', oldText => `${oldText.slice(0, position)}${emoji} ${oldText.slice(position)}`); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user