feat(compose): add strikethrough to the formatting toolbar #184

Merged
JMR-dev merged 7 commits from feat-71-strikethrough into main 2026-07-03 01:32:21 +00:00
2 changed files with 14 additions and 1 deletions
@@ -190,6 +190,13 @@ private fun FormattingToolbar(
underline = true,
onClick = { onToggleStyle(RichStyle.Underline) },
)
FormatButton(
label = "S",
description = stringResource(R.string.format_strikethrough),
active = RichTextEditing.isStyled(content, start, end, RichStyle.Strikethrough),
strikethrough = true,
onClick = { onToggleStyle(RichStyle.Strikethrough) },
)
FormatButton(
label = "•",
description = stringResource(R.string.format_bullet_list),
@@ -226,6 +233,7 @@ private fun FormatButton(
fontWeight: FontWeight? = null,
fontStyle: FontStyle? = null,
underline: Boolean = false,
strikethrough: Boolean = false,
) {
val colors = MaterialTheme.colorScheme
val background = if (active) colors.secondaryContainer else Color.Transparent
@@ -244,7 +252,11 @@ private fun FormatButton(
style = LocalTextStyle.current.copy(
fontWeight = fontWeight,
fontStyle = fontStyle,
textDecoration = if (underline) TextDecoration.Underline else null,
textDecoration = when {
underline -> TextDecoration.Underline
strikethrough -> TextDecoration.LineThrough
else -> null
},
),
)
}
+1
View File
@@ -97,6 +97,7 @@
<string name="format_bold">Bold</string>
<string name="format_italic">Italic</string>
<string name="format_underline">Underline</string>
<string name="format_strikethrough">Strikethrough</string>
<string name="format_bullet_list">Bulleted list</string>
<string name="format_numbered_list">Numbered list</string>
<string name="format_quote">Block quote</string>