A Discourse theme component that adds a strikethrough button to the composer toolbar. Works in both the rich text (ProseMirror) editor and the plain markdown editor.
It exists because Discourse core ships a strikethrough mark (~~text~~) but no
toolbar button for it. This component adds one that toggles the mark cleanly in
the rich editor and falls back to ~~…~~ markdown in the plain-text editor.
Confirmed working on Discourse 2026.6.0.
- Rich editor: registers a small rich editor extension that adds a
toggleStrikethroughcommand toggling core's built-instrikethroughmark via ProseMirror'stoggleMark. Clean toggle, no stray blocks. - Markdown editor: falls back to wrapping the selection in
~~…~~(the rich-editorcommandsobject is absent there, so the button detects it and routes toapplySurround). This mirrors how core's own List button supports both editors. - The button uses a text label (
S, styled with a line-through) rather than an icon, so it needs no changes to the SVG icon subset. - Strings are localized via
locales/*.yml. Because theme locale files load underjs.theme_translations.<id>(reachable viathemePrefix) rather than thecomposer.*namespace that core reads, the button title points at athemePrefixkey directly, and the one hardcoded key that core'sapplySurroundneeds (composer.strikethrough_text, its empty-selection placeholder) is bridged into that namespace at runtime. Locales fall back toen.
Add a language by dropping a locales/<code>.yml alongside en.yml, e.g.
locales/es.yml:
es:
strikethrough_title: "Tachado"
strikethrough_text: "texto tachado"strikethrough_title is the button tooltip; strikethrough_text is the
placeholder inserted when you click with nothing selected. Any locale without a
file falls back to English.
- Admin → Customize → Themes → Components → Install → From a git repository and paste this repo's URL (or From your device with a zip).
- Add the component to your active theme.
- Hard-refresh and open a composer — you'll see the S̶ button next to Bold / Italic.
The default is a text label so it works with zero extra setup. If you'd rather use the real strikethrough glyph:
- Add
strikethroughto thesvg_iconssite setting. - In
javascripts/discourse/api-initializers/strikethrough-button.js, replacetranslatedLabel: "S"withicon: "strikethrough"and removecommon/common.scss.
about.json
common/common.scss # strike-through the "S" label
javascripts/discourse/api-initializers/strikethrough-button.js