Skip to content

Commit

Permalink
Merge pull request #519 from MohamedRejeb/1.x
Browse files Browse the repository at this point in the history
Change rich text font family in sample
  • Loading branch information
MohamedRejeb authored Feb 17, 2025
2 parents b708dc4 + 7039dc9 commit 2c4fda0
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1310,8 +1310,6 @@ public class RichTextState internal constructor(
break
}

val firstRichSpan = paragraph.getFirstNonEmptyChild()

val newType = OrderedList(
number = orderedListNumber,
config = config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,6 @@ fun RichTextStyleRow(
)
}

item {
RichTextStyleButton(
onClick = {
state.addRichSpan(SpellCheck)
},
isSelected = false,
icon = Icons.Outlined.Spellcheck,
)
}

item {
Box(
Modifier
Expand All @@ -248,6 +238,16 @@ fun RichTextStyleRow(
)
}

item {
RichTextStyleButton(
onClick = {
state.addRichSpan(SpellCheck)
},
isSelected = state.currentRichSpanStyle is SpellCheck,
icon = Icons.Outlined.Spellcheck,
)
}

item {
RichTextStyleButton(
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ 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
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
Expand Down Expand Up @@ -67,6 +69,7 @@ fun HtmlToRichText(
onValueChange = {
onHtmlChange(it)
},
textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down Expand Up @@ -105,6 +108,7 @@ fun HtmlToRichText(
RichText(
state = richTextState,
imageLoader = Coil3ImageLoader,
style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
modifier = Modifier
.fillMaxWidth()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,6 +51,7 @@ fun RichTextToHtml(
.fillMaxWidth()
.weight(1f),
state = richTextState,
textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down Expand Up @@ -86,6 +88,7 @@ fun RichTextToHtml(
item {
Text(
text = html,
style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
modifier = Modifier
.fillMaxWidth()
.weight(1f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,6 +65,7 @@ fun MarkdownToRichText(
onValueChange = {
onMarkdownChange(it)
},
textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down Expand Up @@ -101,6 +103,7 @@ fun MarkdownToRichText(
RichText(
state = richTextState,
imageLoader = Coil3ImageLoader,
style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
modifier = Modifier
.fillMaxWidth()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +52,7 @@ fun RichTextToMarkdown(
.fillMaxWidth()
.weight(1f),
state = richTextState,
textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down Expand Up @@ -92,6 +94,7 @@ fun RichTextToMarkdown(
) {
Text(
text = markdown,
style = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
modifier = Modifier
.fillMaxWidth()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -84,6 +86,7 @@ fun RichEditorContent() {
BasicRichTextEditor(
modifier = Modifier.fillMaxWidth(),
state = basicRichTextState,
textStyle = TextStyle.Default.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down Expand Up @@ -115,6 +118,7 @@ fun RichEditorContent() {
modifier = Modifier.fillMaxWidth(),
state = richTextState,
readOnly = true,
textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down Expand Up @@ -145,6 +149,7 @@ fun RichEditorContent() {
OutlinedRichTextEditor(
modifier = Modifier.fillMaxWidth(),
state = outlinedRichTextState,
textStyle = LocalTextStyle.current.copy(fontFamily = FontFamily.Monospace),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2c4fda0

Please sign in to comment.