Quick start
AddSlashCommand with the default command set:
/ in the editor to open the command menu. Use arrow keys to navigate and Enter to select.
Default commands
ThedefaultSlashCommands array includes these built-in commands:
Each command is also exported individually, so you can cherry-pick:
Adding custom commands
Create aSlashCommandItem and include it in the items array. Its icon is an element, created with h(), or a component:
SlashCommandItem interface:
string
required
Display name shown in the command list.
string
required
Help text shown below the title.
VNodeChild | Component
required
Icon displayed next to the command, like
h(Star, { size: 20 }), or a component.string
required
Category for grouping commands in the list.
string[]
Additional terms for fuzzy search matching.
(props: { editor, range }) => void
required
Function called when the command is selected. Receives the editor instance and the range to replace.
Using individual commands
You can cherry-pick from the default commands to show only specific options:Controlling visibility
string
default:"/"
Character that triggers the command menu.
(props: { editor }) => boolean
Function to control when the command menu can appear. Return
false to prevent it.Examples
See slash commands in action with a runnable example:Slash Commands
Default commands plus a custom Greeting command.