Slash commands are organized into groups. Each group contains a title and a commands array of BlockItem objects. You can define simple commands or grouped commands with subcommands using an id and a commands array. Subcommands are triggered by typing the id followed by a dot (e.g., /headers.).
// Example of grouped commands with subcommands
<Editor
blocks={[
{
title: 'Formatting',
commands: [
{
title: 'Headers',
id: 'headers',
searchTerms: ['header', 'title'],
commands: [
{
title: 'Heading 1',
searchTerms: ['h1', 'heading1'],
command: ({ editor, range }) => {
// Convert the current block to Heading 1.
},
},
{
title: 'Heading 2',
searchTerms: ['h2', 'heading2'],
command: ({ editor, range }) => {
// Convert the current block to Heading 2.
},
},
],
},
],
},
]}
/>