Work around draft-js-export-html#62 by post-processing <br>\n

Fixes https://github.com/vector-im/riot-web/issues/4446 by post-processing the output HTML from draft-js-export-html by replacing `<br>\n` with `<br>`. This works for content within or outside of `<pre>`. If we replace with `\n` instead, the newlines only apply in `<pre>` tags so we use `<br>`.
This commit is contained in:
Luke Barnard 2017-06-27 18:33:45 +01:00
parent be60dfdc3a
commit 69589c19e7

View file

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