-
Notifications
You must be signed in to change notification settings - Fork 782
Integrate WYSIWYG editor #7288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate WYSIWYG editor #7288
Changes from all commits
2521b83
5badbda
00fc854
cbdb197
e14bea8
ded508d
994aee4
3f8fb10
945018e
6cc187b
820bf8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add WYSIWYG editor. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Add `formattedText` or similar optional parameters in several methods: | ||
|
||
* RelationService: | ||
* editTextMessage | ||
* editReply | ||
* replyToMessage | ||
* SendService: | ||
* sendQuotedTextMessage | ||
|
||
This allows us to send any HTML formatted text message without needing to rely on automatic Markdown > HTML translation. All these new parameters have a `null` value by default, so previous calls to these API methods remain compatible. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,19 +124,23 @@ internal class LocalEchoEventFactory @Inject constructor( | |
roomId: String, | ||
targetEventId: String, | ||
newBodyText: CharSequence, | ||
newBodyFormattedText: CharSequence?, | ||
newBodyAutoMarkdown: Boolean, | ||
msgType: String, | ||
compatibilityText: String | ||
): Event { | ||
val content = if (newBodyFormattedText != null) { | ||
TextContent(newBodyText.toString(), newBodyFormattedText.toString()).toMessageTextContent(msgType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should consider changing TextContent to have 2 CharSequence members. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it probably makes sense to keep using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right. Thanks |
||
} else { | ||
createTextContent(newBodyText, newBodyAutoMarkdown).toMessageTextContent(msgType) | ||
}.toContent() | ||
return createMessageEvent( | ||
roomId, | ||
MessageTextContent( | ||
msgType = msgType, | ||
body = compatibilityText, | ||
relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId), | ||
newContent = createTextContent(newBodyText, newBodyAutoMarkdown) | ||
.toMessageTextContent(msgType) | ||
.toContent() | ||
newContent = content, | ||
) | ||
) | ||
} | ||
|
@@ -581,6 +585,7 @@ internal class LocalEchoEventFactory @Inject constructor( | |
roomId: String, | ||
eventReplied: TimelineEvent, | ||
replyText: CharSequence, | ||
replyTextFormatted: CharSequence?, | ||
autoMarkdown: Boolean, | ||
rootThreadEventId: String? = null, | ||
showInThread: Boolean | ||
|
@@ -594,15 +599,15 @@ internal class LocalEchoEventFactory @Inject constructor( | |
val body = bodyForReply(eventReplied.getLastMessageContent(), eventReplied.isReply()) | ||
|
||
// As we always supply formatted body for replies we should force the MarkdownParser to produce html. | ||
val replyTextFormatted = markdownParser.parse(replyText, force = true, advanced = autoMarkdown).takeFormatted() | ||
val finalReplyTextFormatted = replyTextFormatted?.toString() ?: 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 replyFormatted = buildFormattedReply( | ||
permalink, | ||
userLink, | ||
userId, | ||
bodyFormatted, | ||
replyTextFormatted | ||
finalReplyTextFormatted | ||
) | ||
// | ||
// > <@alice:example.org> This is the original body | ||
|
@@ -765,18 +770,20 @@ internal class LocalEchoEventFactory @Inject constructor( | |
roomId: String, | ||
quotedEvent: TimelineEvent, | ||
text: String, | ||
formattedText: String?, | ||
autoMarkdown: Boolean, | ||
rootThreadEventId: String? | ||
): Event { | ||
val messageContent = quotedEvent.getLastMessageContent() | ||
val textMsg = messageContent?.body | ||
val textMsg = if (messageContent is MessageContentWithFormattedBody) { messageContent.formattedBody } else { messageContent?.body } | ||
val quoteText = legacyRiotQuoteText(textMsg, text) | ||
val quoteFormattedText = "<blockquote>$textMsg</blockquote>$formattedText" | ||
|
||
return if (rootThreadEventId != null) { | ||
createMessageEvent( | ||
roomId, | ||
markdownParser | ||
.parse(quoteText, force = true, advanced = autoMarkdown) | ||
.parse(quoteText, force = true, advanced = autoMarkdown).copy(formattedText = quoteFormattedText) | ||
.toThreadTextContent( | ||
rootThreadEventId = rootThreadEventId, | ||
latestThreadEventId = localEchoRepository.getLatestThreadEvent(rootThreadEventId), | ||
|
@@ -786,7 +793,7 @@ internal class LocalEchoEventFactory @Inject constructor( | |
} else { | ||
createFormattedTextEvent( | ||
roomId, | ||
markdownParser.parse(quoteText, force = true, advanced = autoMarkdown), | ||
markdownParser.parse(quoteText, force = true, advanced = autoMarkdown).copy(formattedText = quoteFormattedText), | ||
MessageType.MSGTYPE_TEXT | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a
7288.sdk
file to describe the changes in the SDK API? Thanks.