mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Render pills in RTE (#1874)
* for now this can only work locally * works * added a test * updated RTE * revert package * pr suggestion * reverting package versions * better naming
This commit is contained in:
@@ -31,13 +31,15 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
AppSettings.reset()
|
||||
appSettings = AppSettings()
|
||||
appSettings.richTextEditorEnabled = true
|
||||
appSettings.mentionsEnabled = true
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
wysiwygViewModel = WysiwygComposerViewModel()
|
||||
completionSuggestionServiceMock = CompletionSuggestionServiceMock(configuration: .init())
|
||||
viewModel = ComposerToolbarViewModel(wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: completionSuggestionServiceMock,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings,
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock)
|
||||
}
|
||||
|
||||
func testComposerFocus() {
|
||||
@@ -107,7 +109,8 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
viewModel = ComposerToolbarViewModel(wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock)
|
||||
|
||||
XCTAssertEqual(viewModel.state.suggestions, suggestions)
|
||||
}
|
||||
@@ -126,4 +129,13 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
|
||||
XCTAssertEqual(wysiwygViewModel.content.html, "<a data-mention-type=\"user\" href=\"https://matrix.to/#/@test:matrix.org\" contenteditable=\"false\">Test</a> ")
|
||||
}
|
||||
|
||||
func testUserMentionInRTE() {
|
||||
let userID = "@test:matrix.org"
|
||||
let suggestion = SuggestionItem.user(item: .init(id: userID, displayName: "Test", avatarURL: nil))
|
||||
viewModel.context.send(viewAction: .selectedSuggestion(suggestion))
|
||||
|
||||
let attachment = wysiwygViewModel.textView.attributedText.attribute(.attachment, at: 0, effectiveRange: nil) as? PillTextAttachment
|
||||
XCTAssertEqual(attachment?.pillData?.type, .user(userID: userID))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user