Strikethrough
Cross out text while keeping it visible.
Try it
Select “Yurich” and click Strikethrough. The crossed-out word appears as <s>Yurich</s> in HTML. The text stays in the document.
Live example
Example result
Add it to your editor
Enable Strikethrough when a user needs to mark selected text as crossed out. Use toggleStrikethrough for the button.
import { EditorContent, EditorProvider, Strikethrough, useEditor, useIsActive } from 'yurich';
export function StrikethroughEditor() {
const editor = useEditor({
extensions: [Strikethrough],
initialValue: "<p>Strike Yurich from this sentence and see what survives.</p>",
});
const active = useIsActive(editor, 'toggleStrikethrough');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleStrikethrough')}
>
Strikethrough
</button>
<EditorContent ariaLabel="Editor" />
</EditorProvider>
);
}
Behavior to account for
The shortcut is Mod+Shift+S. HTML loaded with <del> is normalized to <s>.