Fix editor custom html output (#1348)

* replace paragraph with line breaks

* stop sending plain msg as custom html

* removes console log

* fix false negative for sanitized customHtml

* fix customHtmlEqualsPlainText doc
This commit is contained in:
Ajay Bura 2023-07-23 18:12:09 +10:00 committed by GitHub
parent 1a37fd0ca4
commit 053b801262
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View file

@ -51,6 +51,8 @@ import {
createEmoticonElement,
moveCursor,
resetEditorHistory,
customHtmlEqualsPlainText,
trimCustomHtml,
} from '../../components/editor';
import { EmojiBoard, EmojiBoardTab } from '../../components/emoji-board';
import { UseStateProvider } from '../../components/UseStateProvider';
@ -251,7 +253,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
uploadBoardHandlers.current?.handleSend();
const plainText = toPlainText(editor.children).trim();
const customHtml = toMatrixCustomHTML(editor.children);
const customHtml = trimCustomHtml(toMatrixCustomHTML(editor.children));
if (plainText === '') return;
@ -271,9 +273,11 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
const content: IContent = {
msgtype: MsgType.Text,
body,
format: 'org.matrix.custom.html',
formatted_body: formattedBody,
};
if (replyDraft || !customHtmlEqualsPlainText(formattedBody, body)) {
content.format = 'org.matrix.custom.html';
content.formatted_body = formattedBody;
}
if (replyDraft) {
content['m.relates_to'] = {
'm.in_reply_to': {