API / @aionbuilders/nabu/ui

SlashCommand

Type Stability: stable

An entry of the slash menu: a title, optional subtitle, icon and aliases to filter on, a group and order for sorting, an optional when to limit where it is offered, and the action to run. Extensions contribute theirs with slashCommands.

Definition

TypeScript
import type { SlashCommand } from '@aionbuilders/nabu/ui';
TypeScript
interface SlashCommand {
  aliases?: string[];
  group?: 'text' | 'lists' | 'blocks' | 'media' | 'structure' | string & {};
  icon?: string;
  order?: number;
  run: (engine: Nabu) => void;
  subtitle?: string;
  title: string;
  when?: (engine: Nabu, block: any) => boolean;
}

Properties

Properties of SlashCommand
PropertyTypeDescription
aliasesoptionalstring[]n/a
groupoptional'text' | 'lists' | 'blocks' | 'media' | 'structure' | string & {}

Where the entry is listed. Known groups, in display order: text, lists, blocks, media, structure; any other string is a group of its own listed after them; no group = last.

iconoptionalstring

A short text glyph (no emoji in the library's own entries). A theme or an integrator overrides an entry's icon by providing its own entry (commands of SlashMenu, or slashCommands of an extension).

orderoptionalnumber

Position inside the group (ascending, default 0); ties keep the declaration order. The menu's order never depends on the load order of the extensions.

run(engine: Nabu) => voidn/a
subtitleoptionalstringn/a
titlestringn/a
whenoptional(engine: Nabu, block: any) => boolean

Where the entry applies; block is the block holding the caret. Without it the entry is always offered.

Source: src/lib/ui/slash-menu.svelte.js:9