@@ -6,7 +6,6 @@ import React, {
66 useCallback ,
77 useContext ,
88} from 'react' ;
9- import { renderToString } from 'react-dom/server' ;
109import PropTypes from 'prop-types' ;
1110
1211import './index.scss' ;
@@ -15,7 +14,7 @@ import { MessageInputKeys, NodeNames, NodeTypes } from './const';
1514import { USER_MENTION_TEMP_CHAR } from '../../smart-components/Channel/context/const' ;
1615import IconButton from '../IconButton' ;
1716import Button , { ButtonTypes , ButtonSizes } from '../Button' ;
18- import MentionUserLabel from '../MentionUserLabel' ;
17+ import renderMentionLabelToString from '../MentionUserLabel/renderToString ' ;
1918import Icon , { IconTypes , IconColors } from '../Icon' ;
2019import Label , { LabelTypography , LabelColors } from '../Label' ;
2120import { LocalizationContext } from '../../lib/LocalizationContext' ;
@@ -161,16 +160,11 @@ const MessageInput = React.forwardRef((props, ref) => {
161160 convertWordToStringObj ( word , mentionedUsers ) . map ( ( stringObj ) => {
162161 const { type, value, userId } = stringObj ;
163162 if ( type === StringObjType . mention && mentionedUsers . some ( ( user ) => user ?. userId === userId ) ) {
164- return renderToString (
165- < MentionUserLabel userId = { userId } >
166- {
167- `${ USER_MENTION_TEMP_CHAR } ${ mentionedUsers . find ( ( user ) => user ?. userId === userId ) ?. nickname
168- || value
169- || stringSet . MENTION_NAME__NO_NAME
170- } `
171- }
172- </ MentionUserLabel > ,
173- ) ;
163+ const nickname = `${ USER_MENTION_TEMP_CHAR } ${ mentionedUsers . find ( ( user ) => user ?. userId === userId ) ?. nickname
164+ || value
165+ || stringSet . MENTION_NAME__NO_NAME
166+ } `
167+ return renderMentionLabelToString ( { userId, nickname } ) ;
174168 }
175169 return sanitizeString ( value ) ;
176170 } ) . join ( '' )
@@ -220,11 +214,10 @@ const MessageInput = React.forwardRef((props, ref) => {
220214 const backTextNode = document ?. createTextNode (
221215 `\u00A0${ childNodes [ endNodeIndex ] ?. textContent . slice ( endOffsetIndex ) } ` ,
222216 ) ;
223- const mentionLabel = renderToString (
224- < MentionUserLabel userId = { mentionSelectedUser ?. userId } >
225- { `${ USER_MENTION_TEMP_CHAR } ${ mentionSelectedUser ?. nickname || stringSet . MENTION_NAME__NO_NAME } ` }
226- </ MentionUserLabel > ,
227- ) ;
217+ const mentionLabel = renderMentionLabelToString ( {
218+ userId : mentionSelectedUser ?. userId ,
219+ nickname : `${ USER_MENTION_TEMP_CHAR } ${ mentionSelectedUser ?. nickname || stringSet . MENTION_NAME__NO_NAME } ` ,
220+ } ) ;
228221 const div = document . createElement ( 'div' ) ;
229222 div . innerHTML = mentionLabel ;
230223 const newNodes = [
0 commit comments