Move processing into renamed function processHtmlforSending

And explain why this fix is necessary
This commit is contained in:
Luke Barnard 2017-06-28 11:49:50 +01:00
parent 69589c19e7
commit f73fa4b49b
2 changed files with 9 additions and 3 deletions

View file

@ -84,7 +84,13 @@ export function charactersToImageNode(alt, useSvg, ...unicode) {
}
export function stripParagraphs(html: string): string {
export function processHtmlForSending(html: string): string {
// Replace "<br>\n" with "<br>" because the \n is redundant and causes an
// extra newline per line within `<pre>` tags.
// This is a workaround for a bug in draft-js-export-html:
// https://github.com/sstur/draft-js-export-html/issues/62
html = html.replace(/\<br\>\n/g, '<br>');
const contentDiv = document.createElement('div');
contentDiv.innerHTML = html;

View file

@ -507,9 +507,9 @@ export default class MessageComposerInput extends React.Component {
}
if (this.state.isRichtextEnabled) {
contentHTML = HtmlUtils.stripParagraphs(
contentHTML = HtmlUtils.processHtmlForSending(
RichText.contentStateToHTML(contentState),
).replace(/\<br\>\n/g, '<br>');
);
} else {
const md = new Markdown(contentText);
if (md.isPlainText()) {