Initial integration of RTE (#1464)

* Initial integration of RTE

* Fix `clipped`, `focused` and composer view type

* Remove horizontal padding

* Add `ComposerToolbar` mock

* Restore `composerFocusedSubject`

* Allow using HTML from RTE on message sent

* Fix new message content API

* Add feature flag for Rich Text Editor
This commit is contained in:
aringenbach
2023-08-29 14:37:13 +02:00
committed by GitHub
parent 08ca969526
commit d1573ae40d
26 changed files with 334 additions and 214 deletions
+14 -5
View File
@@ -262,15 +262,19 @@ class RoomProxy: RoomProxyProtocol {
}
}
func sendMessage(_ message: String, inReplyTo eventID: String? = nil) async -> Result<Void, RoomProxyError> {
func sendMessage(_ message: String, html: String?, inReplyTo eventID: String? = nil) async -> Result<Void, RoomProxyError> {
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer {
sendMessageBackgroundTask?.stop()
}
let transactionId = genTransactionId()
let messageContent = messageEventContentFromMarkdown(md: message)
let messageContent: RoomMessageEventContentWithoutRelation
if let html {
messageContent = messageEventContentFromHtml(body: message, htmlBody: html)
} else {
messageContent = messageEventContentFromMarkdown(md: message)
}
return await Task.dispatch(on: messageSendingDispatchQueue) {
do {
if let eventID {
@@ -443,17 +447,22 @@ class RoomProxy: RoomProxyProtocol {
}
}
func editMessage(_ newMessage: String, original eventID: String) async -> Result<Void, RoomProxyError> {
func editMessage(_ newMessage: String, html: String?, original eventID: String) async -> Result<Void, RoomProxyError> {
sendMessageBackgroundTask = await backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer {
sendMessageBackgroundTask?.stop()
}
let transactionId = genTransactionId()
let newMessageContent: RoomMessageEventContentWithoutRelation
if let html {
newMessageContent = messageEventContentFromHtml(body: newMessage, htmlBody: html)
} else {
newMessageContent = messageEventContentFromMarkdown(md: newMessage)
}
return await Task.dispatch(on: messageSendingDispatchQueue) {
do {
let newMessageContent = messageEventContentFromMarkdown(md: newMessage)
try self.room.edit(newMsg: newMessageContent, originalEventId: eventID, txnId: transactionId)
return .success(())
} catch {
@@ -92,7 +92,7 @@ protocol RoomProxyProtocol {
func sendMessageEventContent(_ messageContent: RoomMessageEventContentWithoutRelation) async -> Result<Void, RoomProxyError>
func sendMessage(_ message: String, inReplyTo eventID: String?) async -> Result<Void, RoomProxyError>
func sendMessage(_ message: String, html: String?, inReplyTo eventID: String?) async -> Result<Void, RoomProxyError>
func toggleReaction(_ reaction: String, to eventID: String) async -> Result<Void, RoomProxyError>
@@ -130,7 +130,7 @@ protocol RoomProxyProtocol {
/// Cancels a failed message given its transaction ID from the timeline
func cancelSend(transactionID: String) async
func editMessage(_ newMessage: String, original eventID: String) async -> Result<Void, RoomProxyError>
func editMessage(_ newMessage: String, html: String?, original eventID: String) async -> Result<Void, RoomProxyError>
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
@@ -181,8 +181,8 @@ extension RoomProxyProtocol {
}
}
func sendMessage(_ message: String) async -> Result<Void, RoomProxyError> {
await sendMessage(message, inReplyTo: nil)
func sendMessage(_ message: String, html: String?) async -> Result<Void, RoomProxyError> {
await sendMessage(message, html: html, inReplyTo: nil)
}
// Avoids to duplicate the same logic around in the app