about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/compose.js
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2018-04-17 20:50:33 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-04-17 13:50:33 +0200
commit727917e91eea3582586d3ce710826ef33ae26ffb (patch)
treeb18850f9824f06d98d0192669cf431929a8ded69 /app/javascript/mastodon/reducers/compose.js
parent609bf9302976768c56116f9d920f34a430d538b5 (diff)
Fix caret position after inserting emoji (#7167)
Diffstat (limited to 'app/javascript/mastodon/reducers/compose.js')
-rw-r--r--app/javascript/mastodon/reducers/compose.js7
1 files changed, 2 insertions, 5 deletions
diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js
index 87049ea79..46d9d6c8e 100644
--- a/app/javascript/mastodon/reducers/compose.js
+++ b/app/javascript/mastodon/reducers/compose.js
@@ -36,8 +36,6 @@ import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrde
 import uuid from '../uuid';
 import { me } from '../initial_state';
 
-const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d';
-
 const initialState = ImmutableMap({
   mounted: 0,
   sensitive: false,
@@ -137,9 +135,8 @@ const updateSuggestionTags = (state, token) => {
   });
 };
 
-const insertEmoji = (state, position, emojiData) => {
+const insertEmoji = (state, position, emojiData, needsSpace) => {
   const oldText = state.get('text');
-  const needsSpace = emojiData.custom && position > 0 && !allowedAroundShortCode.includes(oldText[position - 1]);
   const emoji = needsSpace ? ' ' + emojiData.native : emojiData.native;
 
   return state.merge({
@@ -288,7 +285,7 @@ export default function compose(state = initialState, action) {
       return state;
     }
   case COMPOSE_EMOJI_INSERT:
-    return insertEmoji(state, action.position, action.emoji);
+    return insertEmoji(state, action.position, action.emoji, action.needsSpace);
   case COMPOSE_UPLOAD_CHANGE_SUCCESS:
     return state
       .set('is_submitting', false)