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,
originalTimelineEvent,
newBodyText,
newBodyFormattedText,
true,
MessageType.MSGTYPE_TEXT,
compatibilityBodyText

View File

@ -312,7 +312,8 @@ internal class LocalEchoEventFactory @Inject constructor(
roomId: String,
eventReplaced: TimelineEvent,
originalEvent: TimelineEvent,
newBodyText: CharSequence,
replyText: CharSequence,
replyTextFormatted: String?,
autoMarkdown: Boolean,
msgType: String,
compatibilityText: String,
@ -321,22 +322,22 @@ internal class LocalEchoEventFactory @Inject constructor(
val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", 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.
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.
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(
permalink,
userLink,
originalEvent.senderInfo.disambiguatedDisplayName,
bodyFormatted,
formattedBodyOfRepliedEvent,
newBodyFormatted
)
//
// > <@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(
roomId,