@@ -19,6 +19,7 @@ import MentionUserLabel from '../MentionUserLabel';
19
19
import Icon , { IconTypes , IconColors } from '../Icon' ;
20
20
import Label , { LabelTypography , LabelColors } from '../Label' ;
21
21
import { LocalizationContext } from '../../lib/LocalizationContext' ;
22
+ import { sanitizeString } from './utils' ;
22
23
import {
23
24
arrayEqual ,
24
25
getClassName ,
@@ -114,6 +115,7 @@ const MessageInput = React.forwardRef((props, ref) => {
114
115
}
115
116
) , [ ] ) ;
116
117
118
+ // #Edit mode
117
119
// for easilly initialize input value from outside, but
118
120
// useEffect(_, [channelUrl]) erase it
119
121
const initialValue = props ?. value ;
@@ -136,7 +138,7 @@ const MessageInput = React.forwardRef((props, ref) => {
136
138
}
137
139
} , [ channelUrl ] ) ;
138
140
139
- // #Mention | Fill message input values
141
+ // #Mention & #Edit | Fill message input values
140
142
useEffect ( ( ) => {
141
143
if ( isEdit && message ?. messageId ) {
142
144
// const textField = document.getElementById(textFieldId);
@@ -150,9 +152,7 @@ const MessageInput = React.forwardRef((props, ref) => {
150
152
textField . innerHTML = message ?. mentionedMessageTemplate ?. split ( ' ' ) . map ( ( word ) => (
151
153
convertWordToStringObj ( word , mentionedUsers ) . map ( ( stringObj ) => {
152
154
const { type, value, userId } = stringObj ;
153
- if ( type === StringObjType . mention
154
- && mentionedUsers . some ( ( user ) => user ?. userId === userId )
155
- ) {
155
+ if ( type === StringObjType . mention && mentionedUsers . some ( ( user ) => user ?. userId === userId ) ) {
156
156
return renderToString (
157
157
< MentionUserLabel userId = { userId } >
158
158
{
@@ -164,13 +164,13 @@ const MessageInput = React.forwardRef((props, ref) => {
164
164
</ MentionUserLabel > ,
165
165
) ;
166
166
}
167
- return value ;
167
+ return sanitizeString ( value ) ;
168
168
} ) . join ( '' )
169
169
) ) . join ( ' ' ) ;
170
170
} else {
171
171
/* mention disabled */
172
172
try {
173
- textField . innerHTML = message ?. message ;
173
+ textField . innerHTML = sanitizeString ( message ?. message ) ;
174
174
} catch { }
175
175
setMentionedUserIds ( [ ] ) ;
176
176
}
@@ -428,7 +428,7 @@ const MessageInput = React.forwardRef((props, ref) => {
428
428
} }
429
429
onPaste = { ( e ) => {
430
430
e . preventDefault ( ) ;
431
- document . execCommand ( "insertHTML" , false , e ?. clipboardData . getData ( 'text' ) ) ;
431
+ document . execCommand ( "insertHTML" , false , sanitizeString ( e ?. clipboardData . getData ( 'text' ) ) ) ;
432
432
} }
433
433
/>
434
434
{ /* placeholder */ }
0 commit comments