Skip to content

Commit 1f32cea

Browse files
addEmoji - auto space added
1 parent dae5373 commit 1f32cea

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/app/organisms/room/RoomViewInput.jsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,22 @@ function RoomViewInput({
467467

468468
textArea.focus();
469469

470-
if (typeof selectionStart === 'number') {
470+
if (typeof selectionStart === 'number' && typeof selectionEnd === 'number') {
471471

472-
textArea.val(textArea.val().substring(0, selectionStart) + emoji.unicode + textArea.val().substring(selectionEnd, textArea.val().length));
472+
let part1 = textArea.val().substring(0, selectionStart);
473+
let part2 = textArea.val().substring(selectionEnd, textArea.val().length);
474+
475+
if (part1.endsWith(':')) {
476+
part1 += ' ';
477+
selectionStart++;
478+
}
479+
480+
if (part2.startsWith(':')) {
481+
part2 = ` ${part2}`;
482+
selectionEnd++;
483+
}
484+
485+
textArea.val(part1 + emoji.unicode + part2);
473486

474487
textAreaRef.current.selectionStart = selectionStart + emoji.unicode.length;
475488
textAreaRef.current.selectionEnd = selectionStart + emoji.unicode.length;

0 commit comments

Comments
 (0)