mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-03 20:36:57 +03:00
Move processing into renamed function processHtmlforSending
And explain why this fix is necessary
This commit is contained in:
parent
69589c19e7
commit
f73fa4b49b
2 changed files with 9 additions and 3 deletions
|
@ -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');
|
const contentDiv = document.createElement('div');
|
||||||
contentDiv.innerHTML = html;
|
contentDiv.innerHTML = html;
|
||||||
|
|
||||||
|
|
|
@ -507,9 +507,9 @@ export default class MessageComposerInput extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.isRichtextEnabled) {
|
if (this.state.isRichtextEnabled) {
|
||||||
contentHTML = HtmlUtils.stripParagraphs(
|
contentHTML = HtmlUtils.processHtmlForSending(
|
||||||
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()) {
|
||||||
|
|
Loading…
Reference in a new issue