diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index ab9d2eec..a9b10ea2 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -1310,8 +1310,6 @@ public class RichTextState internal constructor( break } - val firstRichSpan = paragraph.getFirstNonEmptyChild() - val newType = OrderedList( number = orderedListNumber, config = config, diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/components/RichTextStyleRow.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/components/RichTextStyleRow.kt index c3d6331c..c76844b0 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/components/RichTextStyleRow.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/components/RichTextStyleRow.kt @@ -229,16 +229,6 @@ fun RichTextStyleRow( ) } - item { - RichTextStyleButton( - onClick = { - state.addRichSpan(SpellCheck) - }, - isSelected = false, - icon = Icons.Outlined.Spellcheck, - ) - } - item { Box( Modifier @@ -248,6 +238,16 @@ fun RichTextStyleRow( ) } + item { + RichTextStyleButton( + onClick = { + state.addRichSpan(SpellCheck) + }, + isSelected = state.currentRichSpanStyle is SpellCheck, + icon = Icons.Outlined.Spellcheck, + ) + } + item { RichTextStyleButton( onClick = { diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/HtmlToRichText.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/HtmlToRichText.kt index 79cbb458..d77f44c8 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/HtmlToRichText.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/HtmlToRichText.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Text @@ -12,6 +13,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp @@ -67,6 +69,7 @@ fun HtmlToRichText( onValueChange = { onHtmlChange(it) }, + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), ) } @@ -105,6 +108,7 @@ fun HtmlToRichText( RichText( state = richTextState, imageLoader = Coil3ImageLoader, + style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), modifier = Modifier .fillMaxWidth() ) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/RichTextToHtml.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/RichTextToHtml.kt index 42bdb490..01111b48 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/RichTextToHtml.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/RichTextToHtml.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp import com.mohamedrejeb.richeditor.model.RichTextState import com.mohamedrejeb.richeditor.sample.common.components.RichTextStyleRow @@ -50,6 +51,7 @@ fun RichTextToHtml( .fillMaxWidth() .weight(1f), state = richTextState, + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), ) } @@ -86,6 +88,7 @@ fun RichTextToHtml( item { Text( text = html, + style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), modifier = Modifier .fillMaxWidth() .weight(1f) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/MarkdownToRichText.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/MarkdownToRichText.kt index c6540a2e..392892b9 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/MarkdownToRichText.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/MarkdownToRichText.kt @@ -7,6 +7,7 @@ import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp @@ -64,6 +65,7 @@ fun MarkdownToRichText( onValueChange = { onMarkdownChange(it) }, + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), ) } @@ -101,6 +103,7 @@ fun MarkdownToRichText( RichText( state = richTextState, imageLoader = Coil3ImageLoader, + style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), modifier = Modifier .fillMaxWidth() ) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/RichTextToMarkdown.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/RichTextToMarkdown.kt index 51faaf32..773edc78 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/RichTextToMarkdown.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/RichTextToMarkdown.kt @@ -7,6 +7,7 @@ import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp import com.mohamedrejeb.richeditor.model.RichTextState import com.mohamedrejeb.richeditor.sample.common.components.RichTextStyleRow @@ -51,6 +52,7 @@ fun RichTextToMarkdown( .fillMaxWidth() .weight(1f), state = richTextState, + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), ) } @@ -92,6 +94,7 @@ fun RichTextToMarkdown( ) { Text( text = markdown, + style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), modifier = Modifier .fillMaxWidth() ) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index 4bf028eb..1ec8f7be 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -8,6 +8,8 @@ import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow @@ -84,6 +86,7 @@ fun RichEditorContent() { BasicRichTextEditor( modifier = Modifier.fillMaxWidth(), state = basicRichTextState, + textStyle = TextStyle.Default.copy(fontFamily = FontFamily.Monospace), ) } @@ -115,6 +118,7 @@ fun RichEditorContent() { modifier = Modifier.fillMaxWidth(), state = richTextState, readOnly = true, + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), ) } @@ -145,6 +149,7 @@ fun RichEditorContent() { OutlinedRichTextEditor( modifier = Modifier.fillMaxWidth(), state = outlinedRichTextState, + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), ) } diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/slack/SlackDemoContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/slack/SlackDemoContent.kt index 7c2aacb4..2f558a2c 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/slack/SlackDemoContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/slack/SlackDemoContent.kt @@ -18,6 +18,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp @@ -179,6 +181,7 @@ fun SlackDemoContent() { unfocusedIndicatorColor = Color.Transparent, placeholderColor = Color.White.copy(alpha = .6f), ), + textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace), modifier = Modifier .fillMaxWidth() .padding(8.dp)