Strike
The Strike mark applies strikethrough formatting to text. It renders as <s> and parses <s>, <del>, <strike>, and CSS text-decoration: line-through. Included in StarterKit by default.
Live Playground
Section titled “Live Playground”Select text and apply strikethrough with buttons, keyboard shortcut (Cmd+Shift+S / Ctrl+Shift+S), or type ~~text~~ to trigger the input rule.
With the default theme enabled. Click the S toolbar button or use Cmd+Shift+S / Ctrl+Shift+S.
Vanilla JS preview - Angular components produce the same output
Vanilla JS preview - React components produce the same output
Plain editor without the theme. The buttons above call toggleStrike(), setStrike(), and unsetStrike() directly.
Strike is included in StarterKit, so it works out of the box. To use it standalone:
import { Editor, Document, Paragraph, Text, Strike, defaultIcons } from '@domternal/core';import '@domternal/theme';
const editorEl = document.getElementById('editor')!;
// Toolbarconst toolbar = document.createElement('div');toolbar.className = 'dm-toolbar';toolbar.innerHTML = `<div class="dm-toolbar-group"> <button class="dm-toolbar-button" data-mark="strike">${defaultIcons.textStrikethrough}</button></div>`;editorEl.before(toolbar);
// Editorconst editor = new Editor({ element: editorEl, extensions: [Document, Paragraph, Text, Strike], content: '<p>This is <s>struck-through</s> text.</p>',});
// Toggle strike on clicktoolbar.addEventListener('click', (e) => { const btn = (e.target as Element).closest<HTMLButtonElement>('[data-mark]'); if (btn) editor.chain().focus().toggleStrike().run();});import { Component, signal } from '@angular/core';import { DomternalEditorComponent, DomternalToolbarComponent } from '@domternal/angular';import { Editor, Document, Paragraph, Text, Strike } from '@domternal/core';
@Component({ selector: 'app-editor', imports: [DomternalEditorComponent, DomternalToolbarComponent], templateUrl: './editor.html',})export class EditorComponent { editor = signal<Editor | null>(null); extensions = [Document, Paragraph, Text, Strike]; content = '<p>This is <s>struck-through</s> text.</p>';}@if (editor(); as ed) { <domternal-toolbar [editor]="ed" />}<domternal-editor [extensions]="extensions" [content]="content" (editorCreated)="editor.set($event)"/>import { Domternal } from '@domternal/react';import { Document, Paragraph, Text, Strike } from '@domternal/core';
export default function Editor() { return ( <Domternal extensions={[Document, Paragraph, Text, Strike]} content="<p>This is <s>struck-through</s> text.</p>" > <Domternal.Toolbar /> <Domternal.Content /> </Domternal> );}import { Editor, Document, Paragraph, Text, Strike } from '@domternal/core';
const editor = new Editor({ element: document.getElementById('editor')!, extensions: [Document, Paragraph, Text, Strike], content: '<p>This is <s>struck-through</s> text.</p>',});
// Toggle strike programmaticallyeditor.chain().focus().toggleStrike().run();To disable Strike in StarterKit:
StarterKit.configure({ strike: false })Schema
Section titled “Schema”| Property | Value |
|---|---|
| ProseMirror name | strike |
| Type | Mark |
| HTML tag | <s> |
Parsing rules
Section titled “Parsing rules”Strike parses from multiple HTML sources for maximum compatibility:
| Source | Condition |
|---|---|
<s> | Always |
<del> | Always |
<strike> | Always |
CSS text-decoration | Value includes line-through |
The <strike> tag is deprecated HTML but still supported for backwards compatibility. The text-decoration style check uses includes('line-through'), so compound values like line-through dotted are also matched.
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
HTMLAttributes | Record<string, unknown> | {} | Custom HTML attributes added to the rendered <s> element |
import { Strike } from '@domternal/core';
const CustomStrike = Strike.configure({ HTMLAttributes: { class: 'my-strike' },});Commands
Section titled “Commands”setStrike
Section titled “setStrike”Applies strikethrough formatting to the current selection.
editor.commands.setStrike();unsetStrike
Section titled “unsetStrike”Removes strikethrough formatting from the current selection.
editor.commands.unsetStrike();toggleStrike
Section titled “toggleStrike”Toggles strikethrough formatting on the current selection. Applies strikethrough if not active, removes it if active.
editor.commands.toggleStrike();
// With chainingeditor.chain().focus().toggleStrike().run();Keyboard shortcuts
Section titled “Keyboard shortcuts”| Key | Action |
|---|---|
Mod-Shift-S | Toggle strikethrough (toggleStrike) |
Mod is Cmd on macOS and Ctrl on Windows/Linux.
Input rules
Section titled “Input rules”| Input | Result |
|---|---|
~~text~~ | Wraps text in strikethrough |
Type the closing ~~ to trigger the conversion. The markers are removed and the text between them gets strikethrough formatting.
Toolbar items
Section titled “Toolbar items”Strike registers a button in the toolbar with the name strike in group format at priority 170.
| Item | Type | Command | Icon | Shortcut | Active when |
|---|---|---|---|---|---|
| Strikethrough | button | toggleStrike | textStrikethrough | Mod-Shift-S | Strike mark is active on selection |
Exports
Section titled “Exports”import { Strike } from '@domternal/core';import type { StrikeOptions } from '@domternal/core';| Export | Type | Description |
|---|---|---|
Strike | Mark extension | The strikethrough mark extension |
StrikeOptions | TypeScript type | Options for Strike.configure() |
Source
Section titled “Source”@domternal/core - Strike.ts