From 156ffd1334fd465ded3c99dbd643264e47a9557d Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 26 Oct 2018 17:01:44 +0100 Subject: [PATCH] Fix autoreplacement of ascii emoji More slate API updates in code paths I didn't test Fixes https://github.com/vector-im/riot-web/issues/7509 --- src/components/views/rooms/MessageComposerInput.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 570cb8a59b..6f56d35105 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -544,7 +544,7 @@ export default class MessageComposerInput extends React.Component { if (editorState.startText !== null) { const text = editorState.startText.text; - const currentStartOffset = editorState.startOffset; + const currentStartOffset = editorState.selection.start.offset; // Automatic replacement of plaintext emoji to Unicode emoji if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) { @@ -558,11 +558,11 @@ export default class MessageComposerInput extends React.Component { const range = Range.create({ anchor: { - key: editorState.selection.startKey, + key: editorState.startText.key, offset: currentStartOffset - emojiMatch[1].length - 1, }, focus: { - key: editorState.selection.startKey, + key: editorState.startText.key, offset: currentStartOffset - 1, }, });