diff --git a/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorView.kt b/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorView.kt index e77763fd2..d93c12be9 100644 --- a/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorView.kt +++ b/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorView.kt @@ -8,6 +8,7 @@ import android.graphics.BlendModeColorFilter import android.graphics.Color import android.graphics.Rect import android.os.Build +import android.text.InputType import android.text.Spannable import android.util.AttributeSet import android.util.Log @@ -306,6 +307,22 @@ class ReactNativeRichTextEditorView : AppCompatEditText { } } + fun setAutoCapitalize(flagName: String?) { + val flag = when (flagName) { + "none" -> InputType.TYPE_NULL + "sentences" -> InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + "words" -> InputType.TYPE_TEXT_FLAG_CAP_WORDS + "characters" -> InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS + else -> InputType.TYPE_NULL + } + + inputType = (inputType and + InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS.inv() and + InputType.TYPE_TEXT_FLAG_CAP_WORDS.inv() and + InputType.TYPE_TEXT_FLAG_CAP_SENTENCES.inv() + ) or if (flag == InputType.TYPE_NULL) 0 else flag + } + // https://github.com/facebook/react-native/blob/36df97f500aa0aa8031098caf7526db358b6ddc1/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.kt#L283C2-L284C1 // After the text changes inside an EditText, TextView checks if a layout() has been requested. // If it has, it will not scroll the text to the end of the new text inserted, but wait for the diff --git a/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorViewManager.kt b/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorViewManager.kt index 3ba1ef6a1..311eb4627 100644 --- a/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorViewManager.kt +++ b/android/src/main/java/com/swmansion/reactnativerichtexteditor/ReactNativeRichTextEditorViewManager.kt @@ -178,6 +178,10 @@ class ReactNativeRichTextEditorViewManager : SimpleViewManager { placeholderTextColor?: ColorValue; cursorColor?: ColorValue; selectionColor?: ColorValue; + autocapitalize?: 'none' | 'sentences' | 'words' | 'characters'; richTextStyle?: RichTextStyle; style?: ViewStyle | TextStyle; onFocus?: () => void; @@ -163,6 +164,7 @@ export const RichTextInput = ({ cursorColor, selectionColor, style, + autocapitalize = 'sentences', richTextStyle = {}, onFocus, onBlur, @@ -320,6 +322,7 @@ export const RichTextInput = ({ cursorColor={cursorColor} selectionColor={selectionColor} style={style} + autoCapitalize={autocapitalize} richTextStyle={normalizedRichTextStyle} onInputFocus={onFocus} onInputBlur={onBlur}