Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #150 #151

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -70,7 +71,7 @@ fun main(): Unit = singleWindowApplication(
)
) {
SelectionContainer {
var text by remember { mutableStateOf(sampleMarkdown) }
val state = rememberTextFieldState(sampleMarkdown)
Row(
modifier = Modifier
.padding(32.dp)
Expand All @@ -80,9 +81,7 @@ fun main(): Unit = singleWindowApplication(
Column(modifier = Modifier.weight(1f)) {
RichTextStyleConfig(richTextStyle = richTextStyle, onChanged = { richTextStyle = it })
BasicTextField(
value = text,
onValueChange = { text = it },
maxLines = Int.MAX_VALUE,
state = state,
modifier = Modifier
.fillMaxHeight()
.background(Color.LightGray)
Expand Down Expand Up @@ -111,7 +110,7 @@ fun main(): Unit = singleWindowApplication(
modifier = Modifier.verticalScroll(rememberScrollState()),
style = richTextStyle,
) {
Markdown(content = text)
Markdown(content = state.text.toString())
}
} else {
val parser = remember { CommonmarkAstNodeParser() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,12 @@ private val LocalListLevel = compositionLocalOf { 0 }
val widestItem = itemPlaceables.maxByOrNull { it.width }!!

val listWidth = widestPrefix.width + widestItem.width
val listHeight = itemPlaceables.sumOf { it.height } +
val itemsHeight = itemPlaceables.sumOf { it.height } +
(itemPlaceables.size - 1) * itemSpacing.roundToPx()
val prefixesHeight = prefixPlaceables.sumOf { it.height } +
(prefixPlaceables.size - 1) * itemSpacing.roundToPx()

val listHeight = maxOf(itemsHeight, prefixesHeight)
layout(listWidth, listHeight) {
var y = 0

Expand Down
Loading