use zerowidth spaces for emojis

master
Ondřej Hruška 7 years ago
parent daa04c39b6
commit 723890b6fa
No known key found for this signature in database
GPG Key ID: 2C5FD5035250423D
  1. 4
      app/javascript/mastodon/components/autosuggest_textarea.js
  2. 4
      app/javascript/mastodon/reducers/compose.js

@ -11,8 +11,8 @@ import classNames from 'classnames';
const textAtCursorMatchesToken = (str, caretPosition) => { const textAtCursorMatchesToken = (str, caretPosition) => {
let word; let word;
let left = str.slice(0, caretPosition).search(/\S+$/); let left = str.slice(0, caretPosition).search(/[^\s\u200B]+$/);
let right = str.slice(caretPosition).search(/\s/); let right = str.slice(caretPosition).search(/[\s\u200B]/);
if (right < 0) { if (right < 0) {
word = str.slice(left); word = str.slice(left);

@ -123,7 +123,7 @@ function removeMedia(state, mediaId) {
const insertSuggestion = (state, position, token, completion) => { const insertSuggestion = (state, position, token, completion) => {
return state.withMutations(map => { return state.withMutations(map => {
map.update('text', oldText => `${oldText.slice(0, position)}${completion} ${oldText.slice(position + token.length)}`); map.update('text', oldText => `${oldText.slice(0, position)}${completion}\u200B${oldText.slice(position + token.length)}`);
map.set('suggestion_token', null); map.set('suggestion_token', null);
map.update('suggestions', ImmutableList(), list => list.clear()); map.update('suggestions', ImmutableList(), list => list.clear());
map.set('focusDate', new Date()); map.set('focusDate', new Date());
@ -135,7 +135,7 @@ const insertEmoji = (state, position, emojiData) => {
const emoji = emojiData.native; const emoji = emojiData.native;
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}\u200B${oldText.slice(position)}`);
map.set('focusDate', new Date()); map.set('focusDate', new Date());
map.set('idempotencyKey', uuid()); map.set('idempotencyKey', uuid());
}); });

Loading…
Cancel
Save