MohamedRejeb / compose-rich-editor

A Rich text editor library for both Jetpack Compose and Compose Multiplatform, fully customizable, supports HTML and Markdown.
https://mohamedrejeb.github.io/compose-rich-editor/
Apache License 2.0
1.18k stars 78 forks source link

BasicRichTextEditor doesn't scroll down when the text reaches the end. #434

Open easy-apps-2018 opened 4 days ago

easy-apps-2018 commented 4 days ago

This is my implementation of BasicRichTextEditor:

BasicRichTextEditor(
                state = textState,
                readOnly = readOnly,
                decorationBox = { innerTextField ->
                    RichTextEditorDefaults.RichTextEditorDecorationBox(
                        enabled = true,
                        singleLine = false,
                        placeholder = {
                            Text(
                                text = rememberString(id = R.string.note),
                                style = MaterialTheme.typography.bodyLarge
                            )
                        },
                        value = textState.toText(),
                        innerTextField = innerTextField,
                        interactionSource = interactionSource,
                        colors = RichTextEditorDefaults.richTextEditorColors(
                            placeholderColor = Color.LightGray,
                            containerColor = Color.Transparent,
                            focusedIndicatorColor = Color.Transparent,
                            unfocusedIndicatorColor = Color.Transparent,
                            cursorColor = MaterialTheme.colorScheme.secondary
                        ),
                        visualTransformation = VisualTransformation.None,
                        contentPadding = RichTextEditorDefaults.richTextEditorWithoutLabelPadding(
                            end = 6.dp,
                            top = 10.dp,
                            start = 6.dp,
                            bottom = 10.dp
                        )
                    )

                },
                interactionSource = interactionSource,
                textStyle = MaterialTheme.typography.bodyLarge,
                modifier = Modifier.weight(weight = 1f).fillMaxSize(),
                cursorBrush = SolidColor(value = MaterialTheme.colorScheme.secondary)
            )

and the problem is when the text reaches the end it goes behind the keyboard instead of scrolling down. Also, when you move cursor, the scrolling doesn't work.

I added this line to the MainActivity WindowCompat.setDecorFitsSystemWindows(window, false)

and modified manifest by adding android:windowSoftInputMode="adjustResize"

I tried to add them one by one and replaced by by each other. No effect.

Screen_recording_20241122_102939.webm

Any thoughts? Thanks

easy-apps-2018 commented 4 days ago

If I add imePadding() to the Modifier of BasicRichTextEditor, it works, but adds huge padding between keyboard and the BasicRichTextEditor. Any other solution to make it scrollable once cursor reaches end?