Composer: Prevent extra line breaks when pasting text

This commit is contained in:
Alexander Zinchuk 2021-06-30 00:23:04 +03:00
parent 3c35b82484
commit 821594dc0f

View File

@ -19,7 +19,7 @@ import {
import { LangCode } from '../../../types'; import { LangCode } from '../../../types';
import { EDITABLE_INPUT_ID, SCHEDULED_WHEN_ONLINE } from '../../../config'; import { EDITABLE_INPUT_ID, SCHEDULED_WHEN_ONLINE } from '../../../config';
import { IS_VOICE_RECORDING_SUPPORTED, IS_SINGLE_COLUMN_LAYOUT, IS_EMOJI_SUPPORTED } from '../../../util/environment'; import { IS_VOICE_RECORDING_SUPPORTED, IS_SINGLE_COLUMN_LAYOUT } from '../../../util/environment';
import { import {
selectChat, selectChat,
selectIsChatWithBot, selectIsChatWithBot,
@ -324,13 +324,8 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
if (selection.rangeCount) { if (selection.rangeCount) {
const selectionRange = selection.getRangeAt(0); const selectionRange = selection.getRangeAt(0);
if (isSelectionInsideInput(selectionRange, inputId)) { if (isSelectionInsideInput(selectionRange, inputId)) {
if (IS_EMOJI_SUPPORTED) { insertHtmlInSelection(newHtml);
// Insertion will trigger `onChange` in MessageInput, so no need to setHtml in state messageInput.dispatchEvent(new Event('input', { bubbles: true }));
document.execCommand('insertText', false, text);
} else {
insertHtmlInSelection(newHtml);
messageInput.dispatchEvent(new Event('input', { bubbles: true }));
}
return; return;
} }
} }