Enable WYSIWYG plain text support

This commit is contained in:
aringenbach
2022-10-25 16:40:52 +02:00
committed by aringenbach
parent 94d9dc6366
commit ac77fb97da
26 changed files with 284 additions and 83 deletions

View File

@@ -66,6 +66,7 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
viewModel.callback = { [weak self] result in
self?.handleViewModelResult(result)
}
wysiwygViewModel.plainTextMode = !RiotSettings.shared.enableWysiwygTextFormatting
inputAccessoryViewForKeyboard = UIView(frame: .zero)
@@ -130,7 +131,8 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
}
private func sendWysiwygMessage(content: WysiwygComposerContent) {
delegate?.roomInputToolbarView?(self, sendFormattedTextMessage: content.html, withRawText: content.plainText)
let html = content.html.isEmpty ? content.plainText : content.html
delegate?.roomInputToolbarView?(self, sendFormattedTextMessage: html, withRawText: content.plainText)
}
private func showSendMediaActions() {
@@ -207,6 +209,20 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
updatePlaceholderText()
}
}
/// Whether text formatting is currently enabled in the composer.
var textFormattingEnabled: Bool {
get {
self.viewModel.textFormattingEnabled
}
set {
self.viewModel.textFormattingEnabled = newValue
self.wysiwygViewModel.plainTextMode = !newValue
if !newValue {
self.wysiwygViewModel.maximised = false
}
}
}
/// Add the voice message toolbar to the composer
/// - Parameter voiceMessageToolbarView: the voice message toolbar UIView