Also fix pills with rich text editor

This commit is contained in:
ganfra 2023-12-20 20:46:19 +01:00 committed by Jorge Martín
parent b72039e735
commit 320aae1430
2 changed files with 8 additions and 6 deletions

View File

@ -131,6 +131,7 @@ internal class EventEditor @Inject constructor(
replyToEdit, replyToEdit,
originalTimelineEvent, originalTimelineEvent,
newBodyText, newBodyText,
newBodyFormattedText,
true, true,
MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_TEXT,
compatibilityBodyText compatibilityBodyText

View File

@ -312,7 +312,8 @@ internal class LocalEchoEventFactory @Inject constructor(
roomId: String, roomId: String,
eventReplaced: TimelineEvent, eventReplaced: TimelineEvent,
originalEvent: TimelineEvent, originalEvent: TimelineEvent,
newBodyText: CharSequence, replyText: CharSequence,
replyTextFormatted: String?,
autoMarkdown: Boolean, autoMarkdown: Boolean,
msgType: String, msgType: String,
compatibilityText: String, compatibilityText: String,
@ -321,22 +322,22 @@ internal class LocalEchoEventFactory @Inject constructor(
val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false) val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false)
val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: "" val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: ""
val body = bodyForReply(timelineEvent = originalEvent) val bodyOfRepliedEvent = bodyForReply(timelineEvent = originalEvent)
// As we always supply formatted body for replies we should force the MarkdownParser to produce html. // As we always supply formatted body for replies we should force the MarkdownParser to produce html.
val newBodyFormatted = markdownParser.parse(newBodyText, force = true, advanced = autoMarkdown).takeFormatted() val newBodyFormatted = replyTextFormatted ?: markdownParser.parse(replyText, force = true, advanced = autoMarkdown).takeFormatted()
// Body of the original message may not have formatted version, so may also have to convert to html. // Body of the original message may not have formatted version, so may also have to convert to html.
val bodyFormatted = body.formattedText ?: markdownParser.parse(body.text, force = true, advanced = autoMarkdown).takeFormatted() val formattedBodyOfRepliedEvent = bodyOfRepliedEvent.formattedText ?: markdownParser.parse(bodyOfRepliedEvent.text, force = true, advanced = autoMarkdown).takeFormatted()
val replyFormatted = buildFormattedReply( val replyFormatted = buildFormattedReply(
permalink, permalink,
userLink, userLink,
originalEvent.senderInfo.disambiguatedDisplayName, originalEvent.senderInfo.disambiguatedDisplayName,
bodyFormatted, formattedBodyOfRepliedEvent,
newBodyFormatted newBodyFormatted
) )
// //
// > <@alice:example.org> This is the original body // > <@alice:example.org> This is the original body
// //
val replyFallback = buildReplyFallback(body, originalEvent.root.senderId ?: "", newBodyText.toString()) val replyFallback = buildReplyFallback(bodyOfRepliedEvent, originalEvent.root.senderId ?: "", replyText.toString())
return createMessageEvent( return createMessageEvent(
roomId, roomId,