@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.padding
1313import androidx.compose.foundation.lazy.LazyColumn
1414import androidx.compose.foundation.rememberScrollState
1515import androidx.compose.foundation.text.BasicTextField
16+ import androidx.compose.foundation.text.input.rememberTextFieldState
1617import androidx.compose.foundation.text.selection.DisableSelection
1718import androidx.compose.foundation.text.selection.SelectionContainer
1819import androidx.compose.foundation.verticalScroll
@@ -70,7 +71,7 @@ fun main(): Unit = singleWindowApplication(
7071 )
7172 ) {
7273 SelectionContainer {
73- var text by remember { mutableStateOf (sampleMarkdown) }
74+ val state = rememberTextFieldState (sampleMarkdown)
7475 Row (
7576 modifier = Modifier
7677 .padding(32 .dp)
@@ -80,9 +81,7 @@ fun main(): Unit = singleWindowApplication(
8081 Column (modifier = Modifier .weight(1f )) {
8182 RichTextStyleConfig (richTextStyle = richTextStyle, onChanged = { richTextStyle = it })
8283 BasicTextField (
83- value = text,
84- onValueChange = { text = it },
85- maxLines = Int .MAX_VALUE ,
84+ state = state,
8685 modifier = Modifier
8786 .fillMaxHeight()
8887 .background(Color .LightGray )
@@ -111,7 +110,7 @@ fun main(): Unit = singleWindowApplication(
111110 modifier = Modifier .verticalScroll(rememberScrollState()),
112111 style = richTextStyle,
113112 ) {
114- Markdown (content = text)
113+ Markdown (content = state. text.toString() )
115114 }
116115 } else {
117116 val parser = remember { CommonmarkAstNodeParser () }
0 commit comments