Skip to main content
The Heading extension allows you to create headings with different levels. It supports headings from level 1 to 6.

Installation

Usage

The Heading extension is included in the StarterKit by default:
To use it standalone:

Configuration

levels

Specifies which heading levels are available in the editor.
Level[]
default:"[1, 2, 3, 4, 5, 6]"
An array of heading levels to enable. Each level corresponds to an HTML heading tag (h1-h6).

HTMLAttributes

Custom HTML attributes to add to the rendered heading elements.
Record<string, any>
default:"{}"
Custom HTML attributes that should be added to the rendered HTML tag.

Commands

setHeading

Converts the current node to a heading with the specified level.

toggleHeading

Toggles a heading node with the specified level. If the current node is already a heading with that level, it converts it to a paragraph.

Keyboard Shortcuts

  • Mod-Alt-1: Toggle heading level 1
  • Mod-Alt-2: Toggle heading level 2
  • Mod-Alt-3: Toggle heading level 3
  • Mod-Alt-4: Toggle heading level 4
  • Mod-Alt-5: Toggle heading level 5
  • Mod-Alt-6: Toggle heading level 6

Input Rules

The Heading extension supports Markdown-style input rules:
  • Type # followed by a space to create an h1
  • Type ## followed by a space to create an h2
  • Type ### followed by a space to create an h3
  • And so on, up to ###### for h6

Source Code

View the source code on GitHub: packages/extension-heading/src/heading.ts