Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6965 from SimonBrandner/feature/end-of-line-emoji
Browse files Browse the repository at this point in the history
Convert emoticon to emoji at the end of a line on send even if the cursor isn't there
  • Loading branch information
dbkr committed Oct 18, 2021
2 parents 77e6e1c + 1935620 commit df5f440
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/views/rooms/SendMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import QuestionDialog from "../dialogs/QuestionDialog";
import { ActionPayload } from "../../../dispatcher/payloads";
import { decorateStartSendingTime, sendRoundTripMetric } from "../../../sendTimePerformanceMetrics";
import RoomContext from '../../../contexts/RoomContext';
import DocumentPosition from "../../../editor/position";

function addReplyToMessageContent(
content: IContent,
Expand Down Expand Up @@ -391,9 +392,12 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro

// Replace emoticon at the end of the message
if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) {
const caret = this.editorRef.current?.getCaret();
const position = model.positionForOffset(caret.offset, caret.atNodeEnd);
this.editorRef.current?.replaceEmoticon(position, REGEX_EMOTICON);
const indexOfLastPart = model.parts.length - 1;
const positionInLastPart = model.parts[indexOfLastPart].text.length;
this.editorRef.current?.replaceEmoticon(
new DocumentPosition(indexOfLastPart, positionInLastPart),
REGEX_EMOTICON,
);
}

const replyToEvent = this.props.replyToEvent;
Expand Down

0 comments on commit df5f440

Please sign in to comment.