File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/react/src/views/ChatInput Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ import useShowCommands from '../../hooks/useShowCommands';
3434import useSearchMentionUser from '../../hooks/useSearchMentionUser' ;
3535import formatSelection from '../../lib/formatSelection' ;
3636import { parseEmoji } from '../../lib/emoji' ;
37- import { Markdown } from '../Markdown' ;
3837
3938const ChatInput = ( { scrollToBottom } ) => {
4039 const { styleOverrides, classNames } = useComponentOverrides ( 'ChatInput' ) ;
@@ -172,7 +171,15 @@ const ChatInput = ({ scrollToBottom }) => {
172171 } ;
173172
174173 const handleNewLine = ( e , addLine = true ) => {
175- if ( addLine ) messageRef . current . value += '\n' ;
174+ if ( addLine ) {
175+ const { selectionStart, selectionEnd, value } = messageRef . current ;
176+ messageRef . current . value = `${ value . substring (
177+ 0 ,
178+ selectionStart
179+ ) } \n${ value . substring ( selectionEnd ) } `;
180+ messageRef . current . selectionStart = messageRef . current . selectionEnd ;
181+ messageRef . current . selectionEnd = selectionStart + 1 ;
182+ }
176183
177184 e . target . style . height = 'auto' ;
178185 if ( e . target . scrollHeight <= 150 ) {
You can’t perform that action at this time.
0 commit comments