From 91a227913ae862107d8d28a242dc1facc8e254c4 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Fri, 5 Jun 2020 21:43:08 -0400 Subject: [PATCH] Added emoji support for composer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added: - emoji support for composer - new emoji sheet • Updated: - Textarea to accomodate - Reducers and actions to retrieve caretPosition on text change when typing • Removed: - Unused input type on AutosuggestTextbox - Old emoji sheet.png --- app/javascript/gabsocial/actions/compose.js | 10 +- .../components/autosuggest_textbox.js | 97 ++++++------------ .../popover/emoji_picker_popover.js | 4 +- .../compose/components/compose_form.js | 26 +++-- .../containers/compose_form_container.js | 4 +- app/javascript/gabsocial/reducers/compose.js | 14 +-- public/emoji/sheet.png | Bin 2502605 -> 0 bytes public/emoji/sheet_32.png | Bin 0 -> 858920 bytes 8 files changed, 65 insertions(+), 90 deletions(-) delete mode 100644 public/emoji/sheet.png create mode 100644 public/emoji/sheet_32.png diff --git a/app/javascript/gabsocial/actions/compose.js b/app/javascript/gabsocial/actions/compose.js index 251b0d92..74a94f8c 100644 --- a/app/javascript/gabsocial/actions/compose.js +++ b/app/javascript/gabsocial/actions/compose.js @@ -81,7 +81,7 @@ export const ensureComposeIsVisible = (getState, routerHistory) => { } }; -export function changeCompose(text, markdown, replyId, isStandalone) { +export function changeCompose(text, markdown, replyId, isStandalone, caretPosition) { return function (dispatch, getState) { const reduxReplyToId = getState().getIn(['compose', 'in_reply_to']) const existingText = getState().getIn(['compose', 'text']).trim() @@ -105,6 +105,7 @@ export function changeCompose(text, markdown, replyId, isStandalone) { type: COMPOSE_CHANGE, text: text, markdown: markdown, + caretPosition: caretPosition, }) } else if (existingText.length > 0 && text.trim().length > 0) { dispatch(openModal('CONFIRM', { @@ -119,6 +120,7 @@ export function changeCompose(text, markdown, replyId, isStandalone) { type: COMPOSE_CHANGE, text: text, markdown: markdown, + caretPosition: caretPosition, }) } })) @@ -136,6 +138,7 @@ export function changeCompose(text, markdown, replyId, isStandalone) { type: COMPOSE_CHANGE, text: text, markdown: markdown, + caretPosition: caretPosition, }) } else if (existingText.length > 0 && text.trim().length > 0) { dispatch(openModal('CONFIRM', { @@ -149,6 +152,7 @@ export function changeCompose(text, markdown, replyId, isStandalone) { type: COMPOSE_CHANGE, text: text, markdown: markdown, + caretPosition: caretPosition, }) }, })) @@ -160,6 +164,7 @@ export function changeCompose(text, markdown, replyId, isStandalone) { type: COMPOSE_CHANGE, text: text, markdown: markdown, + caretPosition: caretPosition, }) } } @@ -642,10 +647,9 @@ export function changeComposeVisibility(value) { }; }; -export function insertEmojiCompose(position, emoji, needsSpace) { +export function insertEmojiCompose(emoji, needsSpace) { return { type: COMPOSE_EMOJI_INSERT, - position, emoji, needsSpace, }; diff --git a/app/javascript/gabsocial/components/autosuggest_textbox.js b/app/javascript/gabsocial/components/autosuggest_textbox.js index 7cfaf963..ca3cd46b 100644 --- a/app/javascript/gabsocial/components/autosuggest_textbox.js +++ b/app/javascript/gabsocial/components/autosuggest_textbox.js @@ -255,61 +255,27 @@ export default class AutosuggestTextbox extends ImmutablePureComponent { justifyContentCenter: small, }) - if (textarea) { - return ( - -
-