Skip to content

Heading

The heading node is used to represent blocks of heading in the document.

Usage

ts
import { defineHeading } from 'prosekit/extensions/heading'

const extension = defineHeading()

Commands

setHeading

ts
editor.commands.setHeading({ level: 1 })

toggleHeading

ts
editor.commands.toggleHeading({ level: 1 })

insertHeading

ts
editor.commands.insertHeading({ level: 1 })

Keyboard Shortcuts

Non-AppleAppleDescription
Ctrl-1Command-1Set the current block to an H1 node
Ctrl-2Command-2Set the current block to an H2 node
Ctrl-3Command-3Set the current block to an H3 node
Ctrl-4Command-4Set the current block to an H4 node
Ctrl-5Command-5Set the current block to an H5 node
Ctrl-6Command-6Set the current block to an H6 node
BackspaceBackspaceWhen the text cursor is at the start of a heading node, set it to paragraph

Input Rules

Input # followed by a space, it will automatically convert to a heading node. One # corresponds to an H1 node, two # correspond to an H2 node, and so on.

API Reference