feat(compose): add strikethrough to the formatting toolbar
The rich-text engine already fully supported RichStyle.Strikethrough (HTML serialization, parsing, and rendering); only the toolbar control was missing. Adds an "S" FormatButton next to Bold/Italic/Underline, wired the same way (onToggleStyle + isStyled toggle state), plus the format_strikethrough string resource for its onClickLabel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user