mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Merge pull request #6965 from SimonBrandner/feature/end-of-line-emoji
Convert emoticon to emoji at the end of a line on send even if the cursor isn't there
This commit is contained in:
commit
df5f4409ad
1 changed files with 7 additions and 3 deletions
|
@ -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,
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue