Add new tests for WysiwygComposer

This commit is contained in:
Florian Duros 2022-10-21 19:26:33 +02:00
parent c9bf7da629
commit 50c29502e4
No known key found for this signature in database
GPG key ID: 9700AA5870258A0B
11 changed files with 774 additions and 357 deletions

View file

@ -38,7 +38,7 @@ export function useWysiwygEditActionHandler(
const context = payload.context ?? TimelineRenderingType.Room;
switch (payload.action) {
case Action.FocusSendMessageComposer:
case Action.FocusEditMessageComposer:
focusComposer(composerElement, context, roomContext, timeoutId);
break;
}

View file

@ -54,8 +54,8 @@ export function createMessageContent(
): IContent {
// TODO emote ?
const isReply = Boolean(replyToEvent?.replyEventId);
const isEditing = Boolean(editedEvent);
const isReply = isEditing ? Boolean(editedEvent?.replyEventId) : Boolean(replyToEvent);
/*const isEmote = containsEmote(model);
if (isEmote) {
@ -87,7 +87,7 @@ export function createMessageContent(
if (formattedBody) {
content.format = "org.matrix.custom.html";
const htmlPrefix = isReply ? getHtmlReplyFallback(editedEvent) : '';
const htmlPrefix = isReply && isEditing ? getHtmlReplyFallback(editedEvent) : '';
content.formatted_body = isEditing ? `${htmlPrefix} * ${formattedBody}` : formattedBody;
}

View file

@ -16,7 +16,7 @@ limitations under the License.
import { Composer as ComposerEvent } from "@matrix-org/analytics-events/types/typescript/Composer";
import { IContent, IEventRelation, MatrixEvent } from 'matrix-js-sdk/src/models/event';
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { ISendEventResponse, MatrixClient } from "matrix-js-sdk/src/matrix";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { PosthogAnalytics } from "../../../../../PosthogAnalytics";
@ -160,6 +160,7 @@ export function editMessage(
isReply: Boolean(editedEvent.replyEventId),
});
// TODO emoji
// Replace emoticon at the end of the message
/* if (SettingsStore.getValue('MessageComposerInput.autoReplaceEmoji')) {
const caret = this.editorRef.current?.getCaret();
@ -182,6 +183,8 @@ export function editMessage(
return;
}
let response: Promise<ISendEventResponse> | undefined;
// If content is modified then send an updated event into the room
if (isContentModified(newContent, editorStateTransfer)) {
const roomId = editedEvent.getRoomId();
@ -194,11 +197,11 @@ export function editMessage(
const event = editorStateTransfer.getEvent();
const threadId = event.threadRootId || null;
console.log('editContent', editContent);
mxClient.sendMessage(roomId, threadId, editContent);
response = mxClient.sendMessage(roomId, threadId, editContent);
dis.dispatch({ action: "message_sent" });
}
}
endEditing(roomContext);
return response;
}