API / @aionbuilders/nabu/ui

SlashMenuController

Class Stability: stable

The state of the "/" menu for one editor: whether it is open, the query typed after the slash, the filtered and sorted entries and the selected one. SlashMenu is its default rendering; use it directly to build your own menu.

Import

TypeScript
import { SlashMenuController } from '@aionbuilders/nabu/ui';

Constructor

TypeScript
new SlashMenuController(engine: Nabu, commands?: SlashCommand[])
Parameters of the constructor
ParameterTypeDescription
engineNabun/a
commandsoptionalSlashCommand[]

EXTRA entries of the integrator, added to the ones the loaded extensions contribute (Extension#slashCommands, collected in engine.slashCommands) and sorted with them. The menu has no entry of its own.

Properties

available

TypeScript
available: SlashCommand[]

The entries of the loaded extensions plus the integrator's extras that apply at the caret (when), in the documented order (group, order, declaration order).

commands

TypeScript
commands: SlashCommand[]

filteredItems

TypeScript
filteredItems: SlashCommand[]

The available entries matching the query: titles by substring, aliases by prefix.

match

TypeScript
match: {
    block: any;
    cursor: number;
    query: string;
    slashStart: number;
  } | null

The pending slash trigger at the caret: its block, where the slash starts, the caret and the query typed after it; null when there is none.

open

TypeScript
open: boolean

Whether the menu should be shown: a trigger at the caret, at least one match, not dismissed, not read-only.

query

TypeScript
query: string

The text typed after the slash (empty when no trigger).

selectedIndex

TypeScript
selectedIndex: number

Index of the highlighted entry in filteredItems.

Methods

close()

TypeScript
close(): void

Dismiss the menu for the current trigger position (Escape).

moveSelection()

TypeScript
moveSelection(delta: number): void

Move the highlight by delta entries, wrapping around.

Parameters of moveSelection
ParameterTypeDescription
deltanumbern/a

select()

TypeScript
select(index?: number): Promise<void>

Run the command at the given index (default: the selected one).

Parameters of select
ParameterTypeDescription
indexoptionalnumbern/a

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