You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Fix Markdown conversion to not add extra \n
Fixes vector-im/vector-web#2094
This commit is contained in:
@@ -404,11 +404,13 @@ export default class MessageComposerInput extends React.Component {
|
||||
|
||||
enableRichtext(enabled: boolean) {
|
||||
if (enabled) {
|
||||
let html = mdownToHtml(this.state.editorState.getCurrentContent().getPlainText());
|
||||
this.setEditorState(this.createEditorState(enabled, RichText.HTMLtoContentState(html)));
|
||||
const html = mdownToHtml(this.state.editorState.getCurrentContent().getPlainText());
|
||||
const contentState = RichText.HTMLtoContentState(html);
|
||||
this.setEditorState(this.createEditorState(enabled, contentState));
|
||||
} else {
|
||||
let markdown = stateToMarkdown(this.state.editorState.getCurrentContent()),
|
||||
contentState = ContentState.createFromText(markdown);
|
||||
let markdown = stateToMarkdown(this.state.editorState.getCurrentContent());
|
||||
markdown = markdown.substring(0, markdown.length - 1); // stateToMarkdown tacks on an extra newline (?!?)
|
||||
const contentState = ContentState.createFromText(markdown);
|
||||
this.setEditorState(this.createEditorState(enabled, contentState));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user