@cometchat/chat-uikit-react-native 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  3. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
  6. package/ios/CometChatKeyboardModule.m +9 -0
  7. package/ios/CometChatKeyboardModule.swift +71 -0
  8. package/ios/KeyboardLanguageDirection.swift +24 -0
  9. package/ios/RichTextEditorView.swift +253 -51
  10. package/ios/RichTextEditorViewManager.m +1 -0
  11. package/package.json +1 -1
  12. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
  13. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
  14. package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +21 -8
  16. package/src/CometChatCompactMessageComposer/styles.ts +7 -7
  17. package/src/CometChatConversations/CometChatConversations.tsx +36 -30
  18. package/src/CometChatConversations/Skeleton.tsx +4 -1
  19. package/src/CometChatConversations/style.ts +1 -1
  20. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +35 -18
  21. package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
  22. package/src/CometChatGroupMembers/style.ts +6 -4
  23. package/src/CometChatGroups/CometChatGroups.tsx +13 -6
  24. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  25. package/src/CometChatGroups/Skeleton.tsx +4 -1
  26. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +44 -30
  27. package/src/CometChatMessageComposer/styles.tsx +1 -1
  28. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +22 -13
  29. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
  30. package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
  31. package/src/CometChatMessageList/CometChatMessageList.tsx +97 -128
  32. package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
  33. package/src/CometChatMessageList/style.ts +32 -32
  34. package/src/CometChatMessageList/swipeToReply.ts +25 -0
  35. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +10 -3
  36. package/src/CometChatNotificationFeed/style.ts +1 -1
  37. package/src/CometChatNotificationFeed/utils.ts +17 -18
  38. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +8 -1
  39. package/src/CometChatPinnedMessages/style.ts +5 -5
  40. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
  41. package/src/CometChatRichTextEditor/index.tsx +3 -0
  42. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +14 -11
  43. package/src/CometChatSavedMessages/style.ts +3 -3
  44. package/src/CometChatSearch/CometChatSearch.tsx +38 -35
  45. package/src/CometChatSearch/Skeleton.tsx +4 -1
  46. package/src/CometChatSearch/searchLabels.ts +26 -0
  47. package/src/CometChatSearch/style.ts +7 -7
  48. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +11 -7
  49. package/src/CometChatThreadHeader/Header.tsx +2 -2
  50. package/src/CometChatUsers/CometChatUsers.tsx +8 -1
  51. package/src/CometChatUsers/Skeleton.tsx +4 -1
  52. package/src/CometChatUsers/style.ts +1 -1
  53. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +8 -1
  54. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
  55. package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
  56. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
  57. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
  58. package/src/extensions/CollaborativeBubble/style.ts +4 -4
  59. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  60. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  61. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
  62. package/src/extensions/LinkPreview/style.ts +6 -6
  63. package/src/extensions/Polls/Header.tsx +1 -1
  64. package/src/extensions/Polls/Polls.tsx +25 -12
  65. package/src/extensions/Polls/PollsBubble.tsx +10 -6
  66. package/src/extensions/Polls/style.ts +4 -4
  67. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
  68. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
  69. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
  70. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
  71. package/src/index.ts +5 -1
  72. package/src/shared/CometChatUiKit/CometChatUIKit.ts +17 -0
  73. package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
  74. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +13 -10
  75. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
  76. package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
  77. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
  78. package/src/shared/framework/MessageDataSource.tsx +17 -94
  79. package/src/shared/helper/LocalizedDateHelper.ts +64 -4
  80. package/src/shared/helper/helperFunctions.ts +71 -4
  81. package/src/shared/helper/keyboardDirection.ts +54 -0
  82. package/src/shared/helper/layoutDirection.ts +205 -0
  83. package/src/shared/helper/pluralRules.ts +67 -0
  84. package/src/shared/helper/textDirection.ts +118 -0
  85. package/src/shared/icons/Icon.tsx +37 -2
  86. package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
  87. package/src/shared/offline/OfflineViews.tsx +5 -1
  88. package/src/shared/offline/notices.ts +15 -21
  89. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
  90. package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
  91. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +50 -2
  92. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +51 -3
  93. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +50 -2
  94. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +51 -3
  95. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +50 -2
  96. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +50 -2
  97. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +50 -2
  98. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +50 -2
  99. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +50 -2
  100. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +58 -2
  101. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +50 -2
  102. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +50 -2
  103. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +50 -2
  104. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +66 -2
  105. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +50 -2
  106. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +50 -2
  107. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +50 -2
  108. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +50 -2
  109. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
  110. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
  111. package/src/shared/utils/MessageUtils.tsx +14 -14
  112. package/src/shared/utils/PermissionUtil.ts +16 -5
  113. package/src/shared/utils/attachmentLimits.ts +3 -2
  114. package/src/shared/utils/conversationUtils.ts +3 -5
  115. package/src/shared/utils/fileIconFontSize.ts +10 -0
  116. package/src/shared/utils/fileSizeLabel.ts +16 -0
  117. package/src/shared/utils/groupActionText.ts +75 -0
  118. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
  119. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
  120. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
  121. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
  122. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +13 -9
  123. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
  124. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +10 -6
  125. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
  126. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
  127. package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
  128. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
  129. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
  130. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
  131. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
  132. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  133. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -4
  134. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
  135. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +29 -23
  136. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
  137. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
  138. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
  139. package/src/shared/views/CometChatList/CometChatList.tsx +10 -14
  140. package/src/shared/views/CometChatList/Header.tsx +5 -2
  141. package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
  142. package/src/shared/views/CometChatList/styles.ts +7 -7
  143. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
  144. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
  145. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
  146. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +16 -11
  147. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
  148. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +18 -2
  149. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
  150. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -2
  151. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
  152. package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
  153. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
  154. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
  155. package/src/shared/views/CometChatReportDialog/style.ts +1 -1
  156. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
  157. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
  158. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
  159. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
  160. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
  161. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
  162. package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
  163. package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
  164. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
  165. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +22 -22
  166. package/src/shared/views/SenderLabel.tsx +41 -0
  167. package/src/theme/default/default.ts +1 -1
@@ -0,0 +1,9 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(CometChatKeyboardModule, RCTEventEmitter)
5
+
6
+ RCT_EXTERN_METHOD(getKeyboardDirection:(RCTPromiseResolveBlock)resolve
7
+ reject:(RCTPromiseRejectBlock)reject)
8
+
9
+ @end
@@ -0,0 +1,71 @@
1
+ import Foundation
2
+ import React
3
+ import UIKit
4
+
5
+ /// The responder found by `sendAction(_:to: nil, …)`: UIKit delivers an untargeted action to the
6
+ /// first responder, which is the only responder whose `textInputMode` is the keyboard on screen.
7
+ private weak var cometChatFoundFirstResponder: UIResponder?
8
+
9
+ extension UIResponder {
10
+ @objc fileprivate func cometChatReportFirstResponder(_ sender: Any?) {
11
+ cometChatFoundFirstResponder = self
12
+ }
13
+ }
14
+
15
+ /// ENG-57281: the direction of the current keyboard's language, for the standard composer (a React
16
+ /// Native TextInput), which cannot see the keyboard from JS. The compact composer reads its own
17
+ /// keyboard (RichTextEditorView). Events go out only while JS listens (startObserving).
18
+ @objc(CometChatKeyboardModule)
19
+ class CometChatKeyboardModule: RCTEventEmitter {
20
+
21
+ static let directionChangeEvent = "keyboardDirectionChange"
22
+ /// Set in start/stopObserving, so nothing is sent with no JS listener (as SoundPlayer.m does).
23
+ private var hasListeners = false
24
+
25
+ override class func requiresMainQueueSetup() -> Bool { return false }
26
+
27
+ override func supportedEvents() -> [String]! { return [Self.directionChangeEvent] }
28
+
29
+ override func startObserving() {
30
+ hasListeners = true
31
+ NotificationCenter.default.addObserver(
32
+ self, selector: #selector(inputModeDidChange),
33
+ name: UITextInputMode.currentInputModeDidChangeNotification, object: nil)
34
+ }
35
+
36
+ override func stopObserving() {
37
+ hasListeners = false
38
+ NotificationCenter.default.removeObserver(
39
+ self, name: UITextInputMode.currentInputModeDidChangeNotification, object: nil)
40
+ }
41
+
42
+ @objc func getKeyboardDirection(
43
+ _ resolve: @escaping RCTPromiseResolveBlock,
44
+ reject: @escaping RCTPromiseRejectBlock
45
+ ) {
46
+ DispatchQueue.main.async { resolve(Self.currentDirection()) }
47
+ }
48
+
49
+ @objc private func inputModeDidChange() {
50
+ // The first responder may report the new mode a moment after the notification. A keyboard
51
+ // with no language (emoji panel, dictation) sends nothing, so the composer keeps its side.
52
+ DispatchQueue.main.async { [weak self] in
53
+ guard let self = self, self.hasListeners, let direction = Self.currentDirection() else { return }
54
+ self.sendEvent(withName: Self.directionChangeEvent, body: ["direction": direction])
55
+ }
56
+ }
57
+
58
+ /// "ltr" / "rtl" for the focused input's keyboard; nil with nothing focused or no language.
59
+ private static func currentDirection() -> String? {
60
+ cometChatFoundFirstResponder = nil
61
+ UIApplication.shared.sendAction(
62
+ #selector(UIResponder.cometChatReportFirstResponder(_:)), to: nil, from: nil, for: nil)
63
+ let language = cometChatFoundFirstResponder?.textInputMode?.primaryLanguage
64
+ cometChatFoundFirstResponder = nil
65
+ switch KeyboardLanguageDirection.of(language) {
66
+ case .rightToLeft?: return "rtl"
67
+ case .leftToRight?: return "ltr"
68
+ default: return nil
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,24 @@
1
+ import Foundation
2
+ import UIKit
3
+
4
+ /// ENG-57281: the writing direction of a keyboard's language (`UITextInputMode.primaryLanguage`), for
5
+ /// putting an empty composer paragraph's caret on that side. nil when the keyboard gives no language:
6
+ /// the emoji keyboard ("emoji", or no input mode at all), dictation ("dictation"), an empty code, or
7
+ /// one Locale has no direction for. Used by the editor and by CometChatKeyboardModule.
8
+ enum KeyboardLanguageDirection {
9
+ static func of(_ language: String?) -> NSWritingDirection? {
10
+ guard let language = language, !language.isEmpty,
11
+ language != "emoji", language != "dictation" else { return nil }
12
+ let direction: Locale.LanguageDirection
13
+ if #available(iOS 16, *) {
14
+ direction = Locale.Language(identifier: language).characterDirection
15
+ } else {
16
+ direction = Locale.characterDirection(forLanguage: language)
17
+ }
18
+ switch direction {
19
+ case .rightToLeft: return .rightToLeft
20
+ case .leftToRight: return .leftToRight
21
+ default: return nil
22
+ }
23
+ }
24
+ }
@@ -750,38 +750,42 @@ class RichTextView: UITextView {
750
750
  super.draw(rect)
751
751
 
752
752
  // Draw blockquote bars on top of text (decorative side bars)
753
- guard textStore.length > 0 else { return }
754
-
755
- let plainText = text ?? ""
756
- guard !plainText.isEmpty else { return }
757
-
758
- let lines = plainText.components(separatedBy: "\n")
759
-
760
- var quoteRegions: [(Int, Int)] = []
761
- var offset = 0
762
- for line in lines {
763
- let lineEnd = offset + (line as NSString).length
764
- if line.hasPrefix("▎") {
765
- if !quoteRegions.isEmpty && offset <= quoteRegions.last!.1 + 1 {
766
- quoteRegions[quoteRegions.count - 1] = (quoteRegions.last!.0, lineEnd)
767
- } else {
768
- quoteRegions.append((offset, lineEnd))
769
- }
770
- }
771
- offset = lineEnd + 1
753
+ let barRects = quoteBarRects()
754
+ guard !barRects.isEmpty else { return }
755
+ let barColor = UIColor(red: 220/255.0, green: 220/255.0, blue: 220/255.0, alpha: 1.0)
756
+ for barRect in barRects {
757
+ let barPath = UIBezierPath(roundedRect: barRect, cornerRadius: Self.quoteBarWidth / 2.0)
758
+ barColor.setFill()
759
+ barPath.fill()
772
760
  }
761
+ }
773
762
 
774
- guard !quoteRegions.isEmpty else { return }
763
+ static let quoteBarWidth: CGFloat = 3.0
775
764
 
776
- let barColor = UIColor(red: 220/255.0, green: 220/255.0, blue: 220/255.0, alpha: 1.0)
777
- let barWidth: CGFloat = 3.0
778
- let barRadius = barWidth / 2.0
765
+ /// A run of adjacent "▎" lines: [start, end] offsets (end = the last line's end, before its \n).
766
+ struct QuoteBarRegion: Equatable {
767
+ let start: Int
768
+ let end: Int
769
+ let rtl: Bool
770
+ }
771
+
772
+ /// The blockquote bars draw(_:) paints, in view coordinates: one per run of adjacent quote lines
773
+ /// of the same direction, each at its paragraph's start edge (right for RTL), where the hidden
774
+ /// "▎ " and the headIndent sit.
775
+ func quoteBarRects() -> [CGRect] {
776
+ let textStore = self.textStorage
777
+ let layoutMgr = self.layoutManager
778
+ guard textStore.length > 0 else { return [] }
779
+ let plainText = text ?? ""
780
+ guard !plainText.isEmpty else { return [] }
779
781
 
780
- for (regionStart, regionEnd) in quoteRegions {
781
- let clampedEnd = min(regionEnd, textStore.length - 1)
782
- let safeEnd = max(clampedEnd, regionStart)
782
+ var rects: [CGRect] = []
783
+ let ns = plainText as NSString
784
+ for region in Self.quoteBarRegions(in: plainText, isRTLAt: { paragraphIsRTL(at: $0, in: ns) }) {
785
+ let clampedEnd = min(region.end, textStore.length - 1)
786
+ let safeEnd = max(clampedEnd, region.start)
783
787
 
784
- let glyphRange = layoutMgr.glyphRange(forCharacterRange: NSRange(location: regionStart, length: safeEnd - regionStart + 1), actualCharacterRange: nil)
788
+ let glyphRange = layoutMgr.glyphRange(forCharacterRange: NSRange(location: region.start, length: safeEnd - region.start + 1), actualCharacterRange: nil)
785
789
 
786
790
  var firstLineRect = CGRect.zero
787
791
  var lastLineRect = CGRect.zero
@@ -797,15 +801,53 @@ class RichTextView: UITextView {
797
801
 
798
802
  let topY = firstLineRect.origin.y + textContainerInset.top
799
803
  let bottomY = lastLineRect.origin.y + lastLineRect.height + textContainerInset.top
800
- let barX = textContainerInset.left + 1.0
804
+ let barX = Self.quoteBarX(rtl: region.rtl, width: bounds.width, insetLeft: textContainerInset.left,
805
+ insetRight: textContainerInset.right, barWidth: Self.quoteBarWidth)
801
806
 
802
807
  guard bottomY > topY else { continue }
803
808
 
804
- let barRect = CGRect(x: barX, y: topY, width: barWidth, height: bottomY - topY)
805
- let barPath = UIBezierPath(roundedRect: barRect, cornerRadius: barRadius)
806
- barColor.setFill()
807
- barPath.fill()
809
+ rects.append(CGRect(x: barX, y: topY, width: Self.quoteBarWidth, height: bottomY - topY))
808
810
  }
811
+ return rects
812
+ }
813
+
814
+ /// The paragraph's resolved writing direction, as TextKit lays it out: the direction the
815
+ /// ENG-57281 pass (applyContentDirection) set, else for `.natural` its first strong letter,
816
+ /// else the default direction.
817
+ private func paragraphIsRTL(at offset: Int, in text: NSString) -> Bool {
818
+ let style = textStorage.attribute(.paragraphStyle, at: offset, effectiveRange: nil) as? NSParagraphStyle
819
+ var direction = style?.baseWritingDirection ?? .natural
820
+ if direction == .natural {
821
+ let paragraph = text.substring(with: text.paragraphRange(for: NSRange(location: offset, length: 0)))
822
+ direction = RichTextEditorView.firstStrongDirection(paragraph)
823
+ ?? NSParagraphStyle.defaultWritingDirection(forLanguage: nil)
824
+ }
825
+ return direction == .rightToLeft
826
+ }
827
+
828
+ /// Runs of adjacent "▎" lines in `text` (NSString offsets). Adjacent lines merge into one bar
829
+ /// only when `isRTLAt` gives them the same direction.
830
+ static func quoteBarRegions(in text: String, isRTLAt: (Int) -> Bool) -> [QuoteBarRegion] {
831
+ var regions: [QuoteBarRegion] = []
832
+ var offset = 0
833
+ for line in text.components(separatedBy: "\n") {
834
+ let lineEnd = offset + (line as NSString).length
835
+ if line.hasPrefix("▎") {
836
+ let rtl = isRTLAt(offset)
837
+ if let last = regions.last, offset <= last.end + 1, last.rtl == rtl {
838
+ regions[regions.count - 1] = QuoteBarRegion(start: last.start, end: lineEnd, rtl: last.rtl)
839
+ } else {
840
+ regions.append(QuoteBarRegion(start: offset, end: lineEnd, rtl: rtl))
841
+ }
842
+ }
843
+ offset = lineEnd + 1
844
+ }
845
+ return regions
846
+ }
847
+
848
+ /// The bar's left x: just inside the paragraph's start edge (the right one for RTL).
849
+ static func quoteBarX(rtl: Bool, width: CGFloat, insetLeft: CGFloat, insetRight: CGFloat, barWidth: CGFloat) -> CGFloat {
850
+ rtl ? width - insetRight - barWidth - 1.0 : insetLeft + 1.0
809
851
  }
810
852
 
811
853
  override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
@@ -926,6 +968,9 @@ extension UIColor {
926
968
  // .foregroundColor / .backgroundColor so those colors can be told apart from the ones the
927
969
  // editor itself owns (mention purple, link blue, inline code) and survive mention re-styling.
928
970
  private let ExternalForegroundKey = NSAttributedString.Key("cometchat.externalForeground")
971
+ /// ENG-57281: marks a paragraph whose alignment the user picked from the toolbar; the automatic
972
+ /// direction (applyContentDirection) leaves it alone.
973
+ private let UserAlignmentKey = NSAttributedString.Key("cometchat.userAlignment")
929
974
 
930
975
  // Sentinel placed in `pendingStyles` while a caret-armed consumer colour is active. The colour
931
976
  // itself lives in `pendingExternalForeground`; the sentinel exists because three lifecycle sites
@@ -1007,6 +1052,141 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
1007
1052
  private var currentKeyboardHeight: CGFloat = 0
1008
1053
  private var savedSelectionRange: NSRange = NSRange(location: 0, length: 0)
1009
1054
 
1055
+ /// ENG-41384: the kit's direction. iOS views don't get the Yoga direction, so the composer
1056
+ /// is told: placeholder and new paragraphs start at the right edge in RTL.
1057
+ @objc var isRTL: Bool = false {
1058
+ didSet { applyDirection() }
1059
+ }
1060
+ private var startAlignment: NSTextAlignment { isRTL ? .right : .left }
1061
+
1062
+ /// ENG-57281: the keyboard's language; read only while editing. A seam so tests can stand in a
1063
+ /// keyboard: UIKit reports an input mode only for a first responder in a window.
1064
+ @nonobjc lazy var keyboardLanguage: () -> String? = { [weak self] in
1065
+ self?.textView.textInputMode?.primaryLanguage
1066
+ }
1067
+ /// The last keyboard direction seen while editing; kept after the editor loses focus, and while
1068
+ /// a keyboard with no language (emoji, dictation) is up, so nothing moves. nil = no language seen yet.
1069
+ private var keyboardDirection: NSWritingDirection?
1070
+ /// ENG-57281: a paragraph with no letter yet (the empty editor, a new empty line) starts on the
1071
+ /// side of the keyboard's language: English at the left of an RTL screen, Arabic at the right of
1072
+ /// an LTR one. No keyboard language seen yet, the kit's start edge (ENG-41384). The placeholder
1073
+ /// keeps the start edge (applyDirection).
1074
+ private var emptyDirection: NSWritingDirection { keyboardDirection ?? (isRTL ? .rightToLeft : .leftToRight) }
1075
+ private var emptyAlignment: NSTextAlignment { emptyDirection == .rightToLeft ? .right : .left }
1076
+
1077
+ /// Re-reads the keyboard while editing (focus, keyboard switch) and re-aligns when it moved. A
1078
+ /// keyboard with no language (emoji panel, dictation) keeps the last side.
1079
+ private func refreshKeyboardDirection() {
1080
+ guard let now = KeyboardLanguageDirection.of(keyboardLanguage()), now != keyboardDirection else { return }
1081
+ keyboardDirection = now
1082
+ applyContentDirection()
1083
+ }
1084
+
1085
+ @objc private func keyboardLanguageDidChange(_ notification: Notification) {
1086
+ // Posted for any text field in the app; only the editor being typed in follows it. The text
1087
+ // view may report the new mode a moment after the notification, so read it on the next turn.
1088
+ DispatchQueue.main.async { [weak self] in
1089
+ guard let self = self, self.textView.isFirstResponder else { return }
1090
+ self.refreshKeyboardDirection()
1091
+ }
1092
+ }
1093
+
1094
+ /// ENG-57281: the alignment the toolbar shows for the paragraph at `index`: the user's toolbar
1095
+ /// choice, else the start edge (as before), never the automatic language alignment.
1096
+ private func toolbarAlignment(in text: NSAttributedString, at index: Int) -> NSTextAlignment {
1097
+ guard index >= 0, index < text.length,
1098
+ let raw = text.attribute(UserAlignmentKey, at: index, effectiveRange: nil) as? NSNumber,
1099
+ let choice = NSTextAlignment(rawValue: raw.intValue) else { return startAlignment }
1100
+ return choice
1101
+ }
1102
+
1103
+ /// ENG-57281: the direction of a paragraph by its first strong letter (Unicode bidi rule P2),
1104
+ /// the same ranges as the JS firstStrongDirection: Hebrew/Arabic/Syriac/Thaana/NKo… and the
1105
+ /// presentation forms are RTL, any other letter LTR. nil = no letter yet (digits, bullets, emoji).
1106
+ static func firstStrongDirection(_ text: String) -> NSWritingDirection? {
1107
+ for scalar in text.unicodeScalars {
1108
+ let v = scalar.value
1109
+ if (0x0590...0x08FF).contains(v) || (0xFB1D...0xFDFF).contains(v) || (0xFE70...0xFEFF).contains(v) {
1110
+ return .rightToLeft
1111
+ }
1112
+ if scalar.properties.isAlphabetic { return .leftToRight }
1113
+ }
1114
+ return nil
1115
+ }
1116
+
1117
+ /// ENG-57281: each paragraph aligns by its own language, like a message bubble: Arabic starts on
1118
+ /// the right and English on the left in either screen direction. A paragraph without letters yet
1119
+ /// starts on the keyboard language's side, else the kit's start edge (ENG-41384); one the user
1120
+ /// aligned from the toolbar keeps that.
1121
+ /// Mutates textStorage in place, so marked text (CJK composition) and the caret are untouched;
1122
+ /// typingAttributes follow the caret's paragraph so the next character continues it.
1123
+ private func applyContentDirection() {
1124
+ let storage = textView.textStorage
1125
+ let ns = storage.string as NSString
1126
+ let wasInternal = isInternalChange
1127
+ isInternalChange = true
1128
+ defer { isInternalChange = wasInternal }
1129
+
1130
+ var caretStyle: NSParagraphStyle?
1131
+ var caretUserChoice: NSTextAlignment?
1132
+ let caret = textView.selectedRange.location
1133
+ let emptyAlignment = self.emptyAlignment
1134
+ let emptyDirection = self.emptyDirection
1135
+ storage.beginEditing()
1136
+ ns.enumerateSubstrings(in: NSRange(location: 0, length: ns.length), options: [.byParagraphs, .substringNotRequired]) { _, range, enclosing, _ in
1137
+ guard enclosing.length > 0 else { return }
1138
+ // The toolbar choice is stored on the marker: applyListIndentation rebuilds every
1139
+ // paragraph style with the start alignment, so it is put back here.
1140
+ let userChoice = (storage.attribute(UserAlignmentKey, at: enclosing.location, effectiveRange: nil) as? NSNumber)
1141
+ .flatMap { NSTextAlignment(rawValue: $0.intValue) }
1142
+ do {
1143
+ let dir = Self.firstStrongDirection(ns.substring(with: range))
1144
+ let alignment: NSTextAlignment = userChoice
1145
+ ?? (dir == .rightToLeft ? .right : dir == .leftToRight ? .left : emptyAlignment)
1146
+ let base: NSWritingDirection = dir ?? emptyDirection
1147
+ let current = storage.attribute(.paragraphStyle, at: enclosing.location, effectiveRange: nil) as? NSParagraphStyle
1148
+ if current?.alignment != alignment || current?.baseWritingDirection != base {
1149
+ let style = (current?.mutableCopy() as? NSMutableParagraphStyle) ?? NSMutableParagraphStyle()
1150
+ style.alignment = alignment
1151
+ style.baseWritingDirection = base
1152
+ storage.addAttribute(.paragraphStyle, value: style, range: enclosing)
1153
+ }
1154
+ }
1155
+ if caret >= range.location && caret <= range.location + range.length {
1156
+ caretStyle = storage.attribute(.paragraphStyle, at: enclosing.location, effectiveRange: nil) as? NSParagraphStyle
1157
+ caretUserChoice = userChoice
1158
+ }
1159
+ }
1160
+ storage.endEditing()
1161
+
1162
+ // An empty paragraph at the caret (empty editor, or a new line at the end) has no characters
1163
+ // to carry a style: start it on the keyboard language's side (else the kit's start edge).
1164
+ var attrs = textView.typingAttributes
1165
+ let style = ((caretStyle ?? attrs[.paragraphStyle] as? NSParagraphStyle)?.mutableCopy() as? NSMutableParagraphStyle)
1166
+ ?? NSMutableParagraphStyle()
1167
+ if caretStyle == nil {
1168
+ style.alignment = emptyAlignment
1169
+ style.baseWritingDirection = emptyDirection
1170
+ }
1171
+ attrs[.paragraphStyle] = style
1172
+ // New characters in a toolbar-aligned paragraph carry the marker, so the choice holds.
1173
+ attrs[UserAlignmentKey] = caretUserChoice.map { NSNumber(value: $0.rawValue) }
1174
+ textView.typingAttributes = attrs
1175
+ if ns.length == 0 { textView.textAlignment = emptyAlignment }
1176
+ }
1177
+
1178
+ private func applyDirection() {
1179
+ placeholderLabel.textAlignment = startAlignment
1180
+ let empty = textView.attributedText.length == 0
1181
+ if empty { textView.textAlignment = emptyAlignment }
1182
+ var attrs = textView.typingAttributes
1183
+ let style = (attrs[.paragraphStyle] as? NSParagraphStyle)?.mutableCopy() as? NSMutableParagraphStyle
1184
+ ?? NSMutableParagraphStyle()
1185
+ style.alignment = empty ? emptyAlignment : startAlignment
1186
+ attrs[.paragraphStyle] = style
1187
+ textView.typingAttributes = attrs
1188
+ }
1189
+
1010
1190
  @objc var placeholder: String = "" {
1011
1191
  didSet { placeholderLabel.text = placeholder }
1012
1192
  }
@@ -1325,7 +1505,9 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
1325
1505
  textView.trailingAnchor.constraint(equalTo: trailingAnchor),
1326
1506
  textView.bottomAnchor.constraint(equalTo: bottomAnchor),
1327
1507
 
1328
- placeholderLabel.leadingAnchor.constraint(equalTo: textView.leadingAnchor, constant: 9)
1508
+ placeholderLabel.leadingAnchor.constraint(equalTo: textView.leadingAnchor, constant: 9),
1509
+ // Full width so textAlignment can put it at the right edge in RTL (ENG-41384).
1510
+ placeholderLabel.trailingAnchor.constraint(equalTo: textView.trailingAnchor, constant: -9)
1329
1511
  ])
1330
1512
 
1331
1513
  placeholderTopConstraint = placeholderLabel.topAnchor.constraint(equalTo: textView.topAnchor, constant: 4)
@@ -1353,6 +1535,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
1353
1535
  NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: UITextView.textDidChangeNotification, object: textView)
1354
1536
  NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
1355
1537
  NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
1538
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardLanguageDidChange(_:)), name: UITextInputMode.currentInputModeDidChangeNotification, object: nil)
1356
1539
  }
1357
1540
 
1358
1541
  @objc private func keyboardWillShow(_ notification: Notification) {
@@ -1451,6 +1634,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
1451
1634
  }
1452
1635
 
1453
1636
  func textViewDidBeginEditing(_ textView: UITextView) {
1637
+ refreshKeyboardDirection() // ENG-57281: an empty composer's caret on the keyboard's side
1454
1638
  onEditorFocus?([:])
1455
1639
  }
1456
1640
 
@@ -1926,15 +2110,14 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
1926
2110
  blockType = "heading"
1927
2111
  }
1928
2112
 
1929
- if let paragraphStyle = attributedText.attribute(.paragraphStyle, at: checkRange.location, effectiveRange: nil) as? NSParagraphStyle {
1930
- switch paragraphStyle.alignment {
1931
- case .center:
1932
- alignment = "center"
1933
- case .right:
1934
- alignment = "right"
1935
- default:
1936
- alignment = "left"
1937
- }
2113
+ // ENG-57281: the user's choice (or the start edge), not the automatic language alignment.
2114
+ switch toolbarAlignment(in: attributedText, at: checkRange.location) {
2115
+ case .center:
2116
+ alignment = "center"
2117
+ case .right:
2118
+ alignment = "right"
2119
+ default:
2120
+ alignment = "left"
1938
2121
  }
1939
2122
 
1940
2123
  // Detect code block state from CodeBlockAttributeKey
@@ -2607,12 +2790,10 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
2607
2790
  let hasNumbered = contentAfterQuote.range(of: "^\\d+\\.\\s", options: .regularExpression) != nil
2608
2791
  let hasChecklist = lineContent.hasPrefix("☐ ") || lineContent.hasPrefix("☑ ")
2609
2792
 
2610
- var currentAlignment: NSTextAlignment = .left
2793
+ var currentAlignment: NSTextAlignment = startAlignment
2611
2794
  if let attrText = textView.attributedText, attrText.length > 0 {
2612
2795
  let checkIndex = min(max(0, range.location - 1), attrText.length - 1)
2613
- if let paragraphStyle = attrText.attribute(.paragraphStyle, at: checkIndex, effectiveRange: nil) as? NSParagraphStyle {
2614
- currentAlignment = paragraphStyle.alignment
2615
- }
2796
+ currentAlignment = toolbarAlignment(in: attrText, at: checkIndex) // ENG-57281
2616
2797
  }
2617
2798
 
2618
2799
  guard range.length > 0 else {
@@ -2771,6 +2952,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
2771
2952
  // Skip applyListIndentation/renumberNumberedLists during internal changes
2772
2953
  // to avoid resetting typingAttributes set by autoContinueListOnEnter.
2773
2954
  guard !isInternalChange else {
2955
+ applyContentDirection()
2774
2956
  updateContentSize()
2775
2957
  sendContentChange()
2776
2958
  return
@@ -2795,6 +2977,9 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
2795
2977
 
2796
2978
  // Restore typingAttributes that were wiped by attributedText assignment
2797
2979
  textView.typingAttributes = savedTypingAttrs
2980
+ // ENG-57281: the two passes above rebuild every paragraph style (and the restore above the
2981
+ // typing attributes), so the language-based direction goes on last.
2982
+ applyContentDirection()
2798
2983
 
2799
2984
  // Strip mention styling from typingAttributes after text change.
2800
2985
  // Use whitelist approach: remove any bg that isn't inline code or code block.
@@ -3288,7 +3473,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
3288
3473
  let lineText = nsText.substring(with: lineRange)
3289
3474
 
3290
3475
  let paragraphStyle = NSMutableParagraphStyle()
3291
- paragraphStyle.alignment = .left
3476
+ paragraphStyle.alignment = startAlignment
3292
3477
  paragraphStyle.lineHeightMultiple = RichTextEditorView.defaultLineHeightMultiple
3293
3478
 
3294
3479
  if lineText.hasPrefix("▎ • ") {
@@ -4352,6 +4537,10 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
4352
4537
 
4353
4538
  applyListIndentation()
4354
4539
  renumberNumberedLists()
4540
+ // ENG-57281: applyListIndentation rebuilt the paragraph styles with the start alignment and
4541
+ // a natural direction; put each line's own direction back so the quoted line (and its bar)
4542
+ // stays on its language's side.
4543
+ applyContentDirection()
4355
4544
  saveToUndoStack()
4356
4545
  sendContentChange()
4357
4546
  emitActiveStyles()
@@ -4394,6 +4583,8 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
4394
4583
  textView.text = mutableText as String
4395
4584
  textView.selectedRange = NSRange(location: lineStart + newText.count, length: 0)
4396
4585
  isInternalChange = false
4586
+ // ENG-57281: the plain-text reset above paints the caret paragraph's style over every line.
4587
+ applyContentDirection()
4397
4588
 
4398
4589
  saveToUndoStack()
4399
4590
  sendContentChange()
@@ -4438,6 +4629,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
4438
4629
  textView.text = mutableText as String
4439
4630
  textView.selectedRange = range
4440
4631
  isInternalChange = false
4632
+ applyContentDirection() // ENG-57281: as in setChecklist()
4441
4633
 
4442
4634
  saveToUndoStack()
4443
4635
  sendContentChange()
@@ -4584,6 +4776,8 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
4584
4776
  paragraphStyle.lineHeightMultiple = RichTextEditorView.defaultLineHeightMultiple
4585
4777
 
4586
4778
  mutableAttrString.addAttribute(.paragraphStyle, value: paragraphStyle, range: lineRange)
4779
+ // ENG-57281: the user's choice wins over the automatic direction.
4780
+ mutableAttrString.addAttribute(UserAlignmentKey, value: NSNumber(value: alignment.rawValue), range: lineRange)
4587
4781
 
4588
4782
  isInternalChange = true
4589
4783
  textView.attributedText = mutableAttrString
@@ -5104,6 +5298,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5104
5298
 
5105
5299
  applyListIndentation()
5106
5300
  renumberNumberedLists()
5301
+ applyContentDirection() // ENG-57281: put each line's own direction back (see setQuote).
5107
5302
 
5108
5303
  // Restore again after applyListIndentation/renumberNumberedLists which also
5109
5304
  // set textView.attributedText and wipe typingAttributes.
@@ -5141,7 +5336,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5141
5336
  var displayText = text
5142
5337
  var prefixLength = 0
5143
5338
  let paragraphStyle = NSMutableParagraphStyle()
5144
- paragraphStyle.alignment = .left
5339
+ paragraphStyle.alignment = startAlignment
5145
5340
  paragraphStyle.lineHeightMultiple = RichTextEditorView.defaultLineHeightMultiple
5146
5341
 
5147
5342
  switch blockType {
@@ -5312,6 +5507,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5312
5507
  placeholderLabel.isHidden = !textView.text.isEmpty
5313
5508
  isInternalChange = false
5314
5509
  applyListIndentation()
5510
+ applyContentDirection() // ENG-57281: put each line's own direction back (see setQuote).
5315
5511
 
5316
5512
  let endPosition = textView.text?.count ?? 0
5317
5513
 
@@ -5567,7 +5763,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5567
5763
  // Reset typing attributes to default so text typed after the link
5568
5764
  // is not underlined / styled as a link
5569
5765
  let paragraphStyle = NSMutableParagraphStyle()
5570
- paragraphStyle.alignment = .left
5766
+ paragraphStyle.alignment = startAlignment
5571
5767
  paragraphStyle.lineHeightMultiple = RichTextEditorView.defaultLineHeightMultiple
5572
5768
  textView.typingAttributes = [
5573
5769
  .font: UIFont.systemFont(ofSize: 16),
@@ -5626,6 +5822,8 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5626
5822
  textView.attributedText = previous
5627
5823
  placeholderLabel.isHidden = !textView.text.isEmpty
5628
5824
  isInternalChange = false
5825
+ // ENG-57281: snapshots are taken before the direction pass; re-run it on what came back.
5826
+ applyContentDirection()
5629
5827
  sendContentChange()
5630
5828
  }
5631
5829
  }
@@ -5638,6 +5836,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5638
5836
  textView.attributedText = next
5639
5837
  placeholderLabel.isHidden = !textView.text.isEmpty
5640
5838
  isInternalChange = false
5839
+ applyContentDirection() // ENG-57281: as in undo()
5641
5840
  sendContentChange()
5642
5841
  }
5643
5842
 
@@ -5958,6 +6157,9 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
5958
6157
  if (textView.text ?? "").isEmpty {
5959
6158
  resetInlineStateForEmptyComposer()
5960
6159
  }
6160
+ // ENG-57281: text set from JS (an edit, a cleared composer) gets no change notification;
6161
+ // after the reset above, so an empty composer's caret goes back to the kit's start edge.
6162
+ applyContentDirection()
5961
6163
 
5962
6164
  updateContentSize()
5963
6165
  if force {
@@ -6732,7 +6934,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
6732
6934
  textView.selectedRange = NSRange(location: bracketOpen + linkText.count, length: 0)
6733
6935
 
6734
6936
  let paragraphStyle = NSMutableParagraphStyle()
6735
- paragraphStyle.alignment = .left
6937
+ paragraphStyle.alignment = startAlignment
6736
6938
  paragraphStyle.lineHeightMultiple = RichTextEditorView.defaultLineHeightMultiple
6737
6939
  textView.typingAttributes = [
6738
6940
  .font: UIFont.systemFont(ofSize: 16),
@@ -6761,7 +6963,7 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
6761
6963
  textView.selectedRange = NSRange(location: newCursorPos, length: 0)
6762
6964
 
6763
6965
  let paragraphStyle = NSMutableParagraphStyle()
6764
- paragraphStyle.alignment = .left
6966
+ paragraphStyle.alignment = startAlignment
6765
6967
  paragraphStyle.lineHeightMultiple = RichTextEditorView.defaultLineHeightMultiple
6766
6968
  textView.typingAttributes = [
6767
6969
  .font: UIFont.systemFont(ofSize: 16),
@@ -3,6 +3,7 @@
3
3
  @interface RCT_EXTERN_MODULE(RichTextEditorViewManager, RCTViewManager)
4
4
 
5
5
  RCT_EXPORT_VIEW_PROPERTY(placeholder, NSString)
6
+ RCT_EXPORT_VIEW_PROPERTY(isRTL, BOOL)
6
7
  RCT_EXPORT_VIEW_PROPERTY(editable, BOOL)
7
8
  RCT_EXPORT_VIEW_PROPERTY(maxHeight, CGFloat)
8
9
  RCT_EXPORT_VIEW_PROPERTY(numberOfLines, NSInteger)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.6.0",
3
+ "version": "5.7.0",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",