RTE Update (#2446)

This commit is contained in:
Mauro
2024-02-09 17:00:32 +01:00
committed by GitHub
parent d7a190ba23
commit 6a7ad6ccac
5 changed files with 11 additions and 18 deletions
+1 -1
View File
@@ -6791,7 +6791,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-wysiwyg-composer-swift"; repositoryURL = "https://github.com/matrix-org/matrix-wysiwyg-composer-swift";
requirement = { requirement = {
kind = exactVersion; kind = exactVersion;
version = 2.28.0; version = 2.29.0;
}; };
}; };
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { 96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {
@@ -138,8 +138,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-wysiwyg-composer-swift", "location" : "https://github.com/matrix-org/matrix-wysiwyg-composer-swift",
"state" : { "state" : {
"revision" : "7b341602195b6527eb34c61cc6bd479f7631409d", "revision" : "f788fe2482c0b89019f679a1f43dccf9c25a0782",
"version" : "2.28.0" "version" : "2.29.0"
} }
}, },
{ {
@@ -26,7 +26,6 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
private let wysiwygViewModel: WysiwygComposerViewModel private let wysiwygViewModel: WysiwygComposerViewModel
private let completionSuggestionService: CompletionSuggestionServiceProtocol private let completionSuggestionService: CompletionSuggestionServiceProtocol
private let appSettings: AppSettings private let appSettings: AppSettings
private let mentionDisplayHelper: MentionDisplayHelper
private var hasAppeard = false private var hasAppeard = false
private let actionsSubject: PassthroughSubject<ComposerToolbarViewModelAction, Never> = .init() private let actionsSubject: PassthroughSubject<ComposerToolbarViewModelAction, Never> = .init()
@@ -47,7 +46,6 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
self.wysiwygViewModel = wysiwygViewModel self.wysiwygViewModel = wysiwygViewModel
self.completionSuggestionService = completionSuggestionService self.completionSuggestionService = completionSuggestionService
self.appSettings = appSettings self.appSettings = appSettings
self.mentionDisplayHelper = mentionDisplayHelper
super.init(initialViewState: ComposerToolbarViewState(audioPlayerState: .init(id: .recorderPreview, duration: 0), super.init(initialViewState: ComposerToolbarViewState(audioPlayerState: .init(id: .recorderPreview, duration: 0),
audioRecorderState: .init(), audioRecorderState: .init(),
@@ -102,7 +100,8 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
} }
.weakAssign(to: \.state.suggestions, on: self) .weakAssign(to: \.state.suggestions, on: self)
.store(in: &cancellables) .store(in: &cancellables)
setupMentionsHandling(mentionDisplayHelper: mentionDisplayHelper)
focusComposerIfHardwareKeyboardConnected() focusComposerIfHardwareKeyboardConnected()
} }
@@ -111,7 +110,6 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
override func process(viewAction: ComposerToolbarViewAction) { override func process(viewAction: ComposerToolbarViewAction) {
switch viewAction { switch viewAction {
case .composerAppeared: case .composerAppeared:
setupMentionsHandlingIfNecessary()
if !hasAppeard { if !hasAppeard {
hasAppeard = true hasAppeard = true
wysiwygViewModel.setup() wysiwygViewModel.setup()
@@ -205,12 +203,8 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
} }
} }
private func setupMentionsHandlingIfNecessary() { private func setupMentionsHandling(mentionDisplayHelper: MentionDisplayHelper) {
guard let textView = wysiwygViewModel.textView, wysiwygViewModel.mentionDisplayHelper = mentionDisplayHelper
textView.mentionDisplayHelper == nil else {
return
}
textView.mentionDisplayHelper = mentionDisplayHelper
let attributedStringBuilder = AttributedStringBuilder(cacheKey: "Composer", permalinkBaseURL: appSettings.permalinkBaseURL, mentionBuilder: MentionBuilder()) let attributedStringBuilder = AttributedStringBuilder(cacheKey: "Composer", permalinkBaseURL: appSettings.permalinkBaseURL, mentionBuilder: MentionBuilder())
@@ -261,7 +255,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
} }
private func set(text: String) { private func set(text: String) {
wysiwygViewModel.textView?.flushPills() wysiwygViewModel.textView.flushPills()
if appSettings.richTextEditorEnabled { if appSettings.richTextEditorEnabled {
wysiwygViewModel.setHtmlContent(text) wysiwygViewModel.setHtmlContent(text)
@@ -33,7 +33,6 @@ class ComposerToolbarViewModelTests: XCTestCase {
appSettings.richTextEditorEnabled = true appSettings.richTextEditorEnabled = true
ServiceLocator.shared.register(appSettings: appSettings) ServiceLocator.shared.register(appSettings: appSettings)
wysiwygViewModel = WysiwygComposerViewModel() wysiwygViewModel = WysiwygComposerViewModel()
wysiwygViewModel.textView = WysiwygTextView()
completionSuggestionServiceMock = CompletionSuggestionServiceMock(configuration: .init()) completionSuggestionServiceMock = CompletionSuggestionServiceMock(configuration: .init())
viewModel = ComposerToolbarViewModel(wysiwygViewModel: wysiwygViewModel, viewModel = ComposerToolbarViewModel(wysiwygViewModel: wysiwygViewModel,
completionSuggestionService: completionSuggestionServiceMock, completionSuggestionService: completionSuggestionServiceMock,
@@ -150,7 +149,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
let suggestion = SuggestionItem.user(item: .init(id: userID, displayName: "Test", avatarURL: nil)) let suggestion = SuggestionItem.user(item: .init(id: userID, displayName: "Test", avatarURL: nil))
viewModel.context.send(viewAction: .selectedSuggestion(suggestion)) viewModel.context.send(viewAction: .selectedSuggestion(suggestion))
let attachment = wysiwygViewModel.textView?.attributedText.attribute(.attachment, at: 0, effectiveRange: nil) as? PillTextAttachment let attachment = wysiwygViewModel.textView.attributedText.attribute(.attachment, at: 0, effectiveRange: nil) as? PillTextAttachment
XCTAssertEqual(attachment?.pillData?.type, .user(userID: userID)) XCTAssertEqual(attachment?.pillData?.type, .user(userID: userID))
} }
@@ -160,7 +159,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
let suggestion = SuggestionItem.allUsers(item: .allUsersMention(roomAvatar: nil)) let suggestion = SuggestionItem.allUsers(item: .allUsersMention(roomAvatar: nil))
viewModel.context.send(viewAction: .selectedSuggestion(suggestion)) viewModel.context.send(viewAction: .selectedSuggestion(suggestion))
let attachment = wysiwygViewModel.textView?.attributedText.attribute(.attachment, at: 0, effectiveRange: nil) as? PillTextAttachment let attachment = wysiwygViewModel.textView.attributedText.attribute(.attachment, at: 0, effectiveRange: nil) as? PillTextAttachment
XCTAssertEqual(attachment?.pillData?.type, .allUsers) XCTAssertEqual(attachment?.pillData?.type, .allUsers)
} }
+1 -1
View File
@@ -66,7 +66,7 @@ packages:
# path: ../swift-ogg # path: ../swift-ogg
WysiwygComposer: WysiwygComposer:
url: https://github.com/matrix-org/matrix-wysiwyg-composer-swift url: https://github.com/matrix-org/matrix-wysiwyg-composer-swift
exactVersion: 2.28.0 exactVersion: 2.29.0
# path: ../matrix-wysiwyg/platforms/ios/lib/WysiwygComposer # path: ../matrix-wysiwyg/platforms/ios/lib/WysiwygComposer
# External dependencies # External dependencies