Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace double newlines with a single newline #13739

Merged
merged 8 commits into from
Jan 10, 2023
4 changes: 3 additions & 1 deletion src/components/Composer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ class Composer extends React.Component {
return;
}

const plainText = event.clipboardData.getData('text/plain');
// The regex replace is there because when doing a "paste without formatting", there are extra line breaks added to the content (I do not know why). To fix the problem, anytime
// there is a double set of new lines, they are replaced with a single new line. This preserves the same number of new lines between pasting with and without formatting.
const plainText = event.clipboardData.getData('text/plain').replace(/\n\n/g, '\n');
this.paste(Str.htmlDecode(plainText));
}

Expand Down