Skip to content

Commit a3f8cbc

Browse files
authored
Merge pull request Expensify#66686 from nkdengineer/fix/62848-replace-space-at-the-beginning
replace the space at the beginning of each line with nbsp
2 parents 5dcacfe + 6891534 commit a3f8cbc

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/pages/home/report/comment/TextCommentFragment.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM
7676
const containsEmojis = CONST.REGEX.ALL_EMOJIS.test(text ?? '');
7777
if (!shouldRenderAsText(html, text ?? '') && !(containsOnlyEmojis && styleAsDeleted) && (containsOnlyEmojis || !containsCustomEmoji(text))) {
7878
const editedTag = fragment?.isEdited ? `<edited ${styleAsDeleted ? 'deleted' : ''}></edited>` : '';
79-
const htmlWithDeletedTag = styleAsDeleted ? `<del>${html}</del>` : html;
79+
// We need to replace the space at the beginning of each line with &nbsp;
80+
const escapedHtml = html.replace(/(^|<br \/>)[ ]+/gm, (match: string, p1: string) => p1 + '&nbsp;'.repeat(match.length - p1.length));
81+
const htmlWithDeletedTag = styleAsDeleted ? `<del>${escapedHtml}</del>` : escapedHtml;
8082

8183
let htmlContent = htmlWithDeletedTag;
8284
if (containsOnlyEmojis) {

0 commit comments

Comments
 (0)