From 83fa26bc25a5d8d215de5e31e75903e6e5087b19 Mon Sep 17 00:00:00 2001 From: audric Date: Tue, 10 Aug 2021 14:04:20 +1000 Subject: [PATCH] do not replace new lines with br in messages this is to allow copy pasting of content by just selecting it Relates #1758 --- ts/components/conversation/AddNewLines.tsx | 29 +--------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/ts/components/conversation/AddNewLines.tsx b/ts/components/conversation/AddNewLines.tsx index c1b5d092c..c864e1cf1 100644 --- a/ts/components/conversation/AddNewLines.tsx +++ b/ts/components/conversation/AddNewLines.tsx @@ -16,8 +16,6 @@ export class AddNewLines extends React.Component { public render() { const { text, renderNonNewLine, convoId } = this.props; - const results: Array = []; - const FIND_NEWLINES = /\n/g; // We have to do this, because renderNonNewLine is not required in our Props object, // but it is always provided via defaultProps. @@ -25,31 +23,6 @@ export class AddNewLines extends React.Component { return; } - let match = FIND_NEWLINES.exec(text); - let last = 0; - let count = 1; - - if (!match) { - return renderNonNewLine({ text, key: 0, convoId }); - } - - while (match) { - if (last < match.index) { - const textWithNoNewline = text.slice(last, match.index); - results.push(renderNonNewLine({ text: textWithNoNewline, key: count++, convoId })); - } - - results.push(
); - - // @ts-ignore - last = FIND_NEWLINES.lastIndex; - match = FIND_NEWLINES.exec(text); - } - - if (last < text.length) { - results.push(renderNonNewLine({ text: text.slice(last), key: count++, convoId })); - } - - return results; + return renderNonNewLine({ text, key: 0, convoId }); } }