Skip to main content
The Strike extension adds support for strikethrough text formatting with keyboard shortcuts, input rules, and commands.

Installation

npm install @prosekit/extensions

Usage

Add the strike extension to your editor:
import { defineStrike } from '@prosekit/extensions/strike'
import { createEditor } from '@prosekit/core'

const editor = createEditor({
  extensions: [
    // ... other extensions
    defineStrike(),
  ],
})

API Reference

defineStrike()

Defines the complete strike extension including:
  • Mark specification for <s>, <strike>, and <del> HTML tags
  • Commands for toggling strikethrough
  • Keyboard shortcuts
  • Input rules for Markdown-style syntax
Returns: StrikeExtension

Commands

toggleStrike

Toggles strikethrough formatting on the current selection or at the cursor position.
editor.commands.toggleStrike()

Keyboard Shortcuts

ShortcutAction
Mod-SToggle strikethrough formatting
Mod-XToggle strikethrough formatting
Mod is Cmd on macOS and Ctrl on Windows/Linux.

Input Rules

The extension supports Markdown-style input rules:
  • Type ~~text~~ to create strikethrough text
  • The tildes will be automatically removed and the text will be formatted with strikethrough

HTML Output

Strikethrough text is rendered as <s> elements:
<s>Strikethrough text</s>

Parsing

The extension recognizes the following HTML elements and styles when parsing content:
  • <s> tag
  • <strike> tag
  • <del> tag
  • Elements with text-decoration: line-through
  • Elements with text-decoration-line: line-through

Advanced Configuration

If you need more control, you can use the individual components:
import { 
  defineStrikeSpec,
  defineStrikeCommands,
  defineStrikeKeymap,
  defineStrikeInputRule 
} from '@prosekit/extensions/strike'

const editor = createEditor({
  extensions: [
    defineStrikeSpec(),      // Just the mark definition
    defineStrikeCommands(),  // Just the commands
    defineStrikeKeymap(),    // Just the keyboard shortcuts
    defineStrikeInputRule(), // Just the input rules
  ],
})
These functions are marked as @internal in the source code and may change in future versions.
  • Bold - Bold text formatting
  • Italic - Italic text formatting
  • Underline - Underline text formatting
  • Code - Inline code formatting