@@ -44,6 +44,9 @@ const propTypes = {
44
44
/** Does this fragment belong to a reportAction that has not yet loaded? */
45
45
loading : PropTypes . bool ,
46
46
47
+ /** The reportAction's source */
48
+ source : PropTypes . string ,
49
+
47
50
/** Should this fragment be contained in a single line? */
48
51
isSingleLine : PropTypes . bool ,
49
52
@@ -64,6 +67,7 @@ const defaultProps = {
64
67
loading : false ,
65
68
isSingleLine : false ,
66
69
tooltipText : '' ,
70
+ source : '' ,
67
71
} ;
68
72
69
73
const ReportActionItemFragment = ( props ) => {
@@ -86,39 +90,52 @@ const ReportActionItemFragment = (props) => {
86
90
)
87
91
) ;
88
92
}
93
+ let { html, text} = props . fragment ;
89
94
90
95
// If the only difference between fragment.text and fragment.html is <br /> tags
91
96
// we replace them with line breaks and render it as text, not as html.
92
97
// This is done to render emojis with line breaks between them as text.
93
- const differByLineBreaksOnly = props . fragment . html . replaceAll ( '<br />' , ' ' ) === props . fragment . text ;
98
+ const differByLineBreaksOnly = html . replaceAll ( '<br />' , ' ' ) === text ;
94
99
if ( differByLineBreaksOnly ) {
95
- const textWithLineBreaks = props . fragment . html . replaceAll ( '<br />' , '\n' ) ;
100
+ const textWithLineBreaks = html . replaceAll ( '<br />' , '\n' ) ;
96
101
// eslint-disable-next-line no-param-reassign
97
- props . fragment = { ...props . fragment , text : textWithLineBreaks , html : textWithLineBreaks } ;
102
+ html = textWithLineBreaks ;
103
+ text = textWithLineBreaks ;
98
104
}
99
105
100
106
// Only render HTML if we have html in the fragment
101
- return props . fragment . html !== props . fragment . text
102
- ? (
107
+ if ( html !== text ) {
108
+ if ( props . source === 'email' ) {
109
+ // Messages from email replies usually have complex HTML structure and they don't rely in white-space: pre to preserve spacing,
110
+ // instead, the normally use
111
+ return (
112
+ < RenderHTML
113
+ html = { `<email-comment>${ html + ( props . fragment . isEdited ? '<edited></edited>' : '' ) } </email-comment>` }
114
+ />
115
+ ) ;
116
+ }
117
+ return (
103
118
< RenderHTML
104
- html = { `<comment>${ props . fragment . html + ( props . fragment . isEdited ? '<edited></edited>' : '' ) } </comment>` }
119
+ html = { `<comment>${ html + ( props . fragment . isEdited ? '<edited></edited>' : '' ) } </comment>` }
105
120
/>
106
- ) : (
107
- < Text
108
- selectable = { ! canUseTouchScreen ( ) || ! props . isSmallScreenWidth }
109
- style = { EmojiUtils . containsOnlyEmojis ( props . fragment . text ) ? styles . onlyEmojisText : undefined }
110
- >
111
- { Str . htmlDecode ( props . fragment . text ) }
112
- { props . fragment . isEdited && (
113
- < Text
114
- fontSize = { variables . fontSizeSmall }
115
- color = { themeColors . textSupporting }
116
- >
117
- { ` ${ props . translate ( 'reportActionCompose.edited' ) } ` }
118
- </ Text >
119
- ) }
120
- </ Text >
121
121
) ;
122
+ }
123
+ return (
124
+ < Text
125
+ selectable = { ! canUseTouchScreen ( ) || ! props . isSmallScreenWidth }
126
+ style = { EmojiUtils . containsOnlyEmojis ( text ) ? styles . onlyEmojisText : undefined }
127
+ >
128
+ { Str . htmlDecode ( text ) }
129
+ { props . fragment . isEdited && (
130
+ < Text
131
+ fontSize = { variables . fontSizeSmall }
132
+ color = { themeColors . textSupporting }
133
+ >
134
+ { ` ${ props . translate ( 'reportActionCompose.edited' ) } ` }
135
+ </ Text >
136
+ ) }
137
+ </ Text >
138
+ ) ;
122
139
}
123
140
case 'TEXT' :
124
141
return (
0 commit comments